akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#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(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x)print("Yes");
	else print("No");
	
}

Measured memory_bytes: 256
let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let sc = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun s c -> (s - 1, c)

let ans = Array.make n (-1)

let () =
  Array.iter (fun (s, c) ->
    if ans.(s) = -1 || ans.(s) = c then ans.(s) <- c
    else begin
      print_endline "-1";
      exit 0
    end
  ) sc;
  if n = 1 then
    Printf.printf "%d\n" @@ if ans.(0) = -1 then 0 else ans.(0)
  else begin
    if ans.(0) = 0 then begin
      print_endline "-1";
      exit 0
    end;
    for i = 0 to n - 1 do
      if ans.(i) = -1 then ans.(i) <- if i = 0 then 1 else 0
    done;
    Array.iter print_int ans;
    print_newline ()
  end


Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include <string>
using namespace std;

#define FLG  INT_MIN
#define GOAL 0

#define N 3

map<string, int> mp;
queue<pair<string, int> > Q;

vector<int> neighbor(int pos)
{
    vector<int> rt;
    if (pos % N != 0)
        rt.push_back(pos - 1);
    if (pos % N != N - 1)
        rt.push_back(pos + 1);
    if (pos - N >= 0)
        rt.push_back(pos - N);
    if (pos + N < N * N)
        rt.push_back(pos + N);
    return rt;
}

int bfs()
{
    string st, tmp;
    int cnt, pos;
    while (!Q.empty()) {
        st = Q.front().first;
        cnt = Q.front().second;
        pos = st.find("0");
        Q.pop();
        if (mp.count(st)) {
            if (mp[st] == FLG) {
                continue;
            } else if (mp[st] == GOAL) {
                return cnt;
            } else
                printf("ERROR: %d\n", __LINE__);
        }
        mp[st] = FLG;
        vector<int> nb(neighbor(pos));
        for (int i = 0; i < nb.size(); i++) {
            tmp = st;
            tmp[pos] = st[nb[i]]; tmp[nb[i]] = st[pos];
            Q.push(make_pair(tmp, cnt + 1));
        }
    }
    return INT_MIN;
}

int main()
{
    string st, gl = "123456780";
    for (int i = 0; i < 9; i++) {
        int  j;
        cin >> j;
        st += to_string(j);
    }
    mp[gl] = GOAL;
    Q.push(make_pair(st, 0));
    cout << bfs() << endl;
    return 0;
}

Measured memory_bytes: 24572
# https://atcoder.jp/contests/abc133/tasks/abc133_c

l, r = map(int, input().split())

if r - l >= 2019:
    ans = 0
else:
    ans = float('inf')
    for i in range(l, r + 1):
        for j in range(l, r + 1):
            if i == j:
                continue
            ans = min(ans, i * j % 2019)
print(ans)

Measured memory_bytes: 41692
s = int(input())
mod = 1000000007
ans = 0
n = 2000
def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[k]%mod*finv[n-k]%mod

fac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

for i in range(1,s//3+1):
    r = s - i*3
    ans += comb(r+i-1,r)
    ans %= mod
print(ans)



Measured memory_bytes: 65332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll n;
char c[200005];
ll w[200005];
ll r[200005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> c[i];
	}
	REP(i, 0, n + 1){
		if (i == 0){
			r[i] = 0;
			w[i] = 0;
		} else {
			r[i] = r[i - 1] + (c[i - 1] == 'R');
			w[i] = w[i - 1] + (c[i - 1] == 'W');
		}
	}
	ll ans = 200005;
	REP(i, 0, n + 1){
		ll yy = w[i];
		ll zz = r[n] - r[i];
		ans = min(ans, max(yy, zz));
	}
	cout << ans << endl;
}

//cout.flush()

Measured memory_bytes: 6960
#include <iostream>

using namespace std;

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) cout << (0 < i && i < h - 1 && 0 < j && j < w - 1 ? '.' : '#');
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAX_N 200000
vector<ll>g[MAX_N];

vector<int> group[2];
void dfs(ll pre, ll now, ll d){
  group[d].push_back(now);
  for(auto to: g[now]){
    if(pre!=to) dfs(now, to, d^1);
  }
}

int main(){
  ll n;cin>>n;
  rep(i, n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(-1, 0, 0);

  vector<int> num[3];
  rep1(i, n)num[i%3].push_back(i);

  vector<int> result(n);

  if(group[0].size() > group[1].size())swap(group[0], group[1]);

  if(group[0].size() <= n/3){
    for(auto tmp: group[0]){
      result[tmp] = num[0].back();
      num[0].pop_back();
    }
    for(auto tmp: group[1]){
      rep(i, 3){
        if(num[i].empty())continue;
        result[tmp] = num[i].back();
        num[i].pop_back();
        break;
      }
    }
    rep(i, n)cout<<result[i]<<' ';
    return 0;
  }

  rep(i, 2){
    for(auto tmp:group[i]){
      if( !num[i+1].empty() ){
        result[tmp] = num[i+1].back();
        num[i+1].pop_back();
      }else{
        result[tmp] = num[0].back();
        num[0].pop_back();
      }
    }
  }
  rep(i, n)cout<<result[i]<<' ';

  return 0;
}


Measured memory_bytes: 24692
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}

vector<string> split(string s, char remove) {
    istringstream stream(s);
    string field;
    vector<string> ans;
    while (getline(stream, field, remove)) {
        ans.emplace_back(field);
    }
    return ans;
}

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

    string s;
    getline(cin, s);

    string many, lng;
    int mxcnt = 0, lngcnt = 0;
    auto st = split(s, ' ');
    SORT(st);
    for (auto &&i : st) {
        if (chmax(mxcnt,
                  (int)(upper_bound(ALL(st), i) - lower_bound(ALL(st), i))))
            many = i;
        if (chmax(lngcnt, (int)i.size()))
            lng = i;
    }
    std::cout << many << " " << lng << '\n';

    return 0;
}


Measured memory_bytes: 3220
n = int(input())


x = n / 2
result = 0

if n <= 10:
    result = n
elif (n <= 100 and not n % 10) or not x % 10:
    result = 0

    while(x > 0):
        result += int(x % 10)
        x = x // 10
    result = result* 2
else:
    if n % 10:
        x = n % 10
    elif n % 10: 
        x = n % 100
    elif n % 1000: 
        x = n % 1000
    elif n % 10000: 
        x = n % 10000
    n = n - x
    while(x > 0):
        result += x % 10
        x = x // 10

    while(n > 0):
        result += n % 10
        n = n // 10
print(result)


#
#else:
#    resulty, resultx = 0, 0
#
#    while(x > 0):
#        resultx += x % 10
#        x = x // 10
#
#    while(y > 0):
#        resulty += y % 10
#        y = y // 10
#
#    #print(resulty+resultx)
#    z = n//2
#
#    result = 0
#    while(z > 0):
#        result += z % 10
#        z = z // 10
#
#    if result*2 < resulty+resultx:
#        print(result*2)
#    else:
#        print(resulty+resultx)
#


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

long long A, V, B, W, T;
int factor = 1;

int main() {
	scanf("%lld%lld%lld%lld%lld", &A, &V, &B, &W, &T);
	if (A > B) factor = -1;
	if (A == B) {
        printf("YES\n");
        return 0;
	}
	A += V * T * factor;
	B += W * T * factor;
	if ((A > B && factor == 1) || (A < B && factor == -1) || A == B) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

 int h,w,k;
int mp[10][1000];

deque<int> make(deque<int> v,int num){
  if(h==1){v.push_back(0);return v;}
  if(num%2==1) v.push_front(1);
  else v.push_front(0);
  if(v.size() == h-1){v.push_back(0);return v;}
  else return make(v,num/2);
}

int cut(deque<int> ct){
  vector<int> v;
  bool flag=false;
  v.push_back(0);
  int ans=0;
  rep(i,h){
    // v[v.size()-1]+=mp[i][0];
    if(ct[i]==1) v.push_back(0);
    ans+=ct[i];
  }
  /* rep(i,v.size() ){
    cout<<v[i]<<" ";
  }
  cout<<endl;*/
  
  repi(i,0,w){
    int nex=0;
    flag=false;
    rep(j,h){
      v[nex]+=mp[j][i];
      if(v[nex]>k){
	flag=true;
      }
      if(ct[j]==1) nex++;
    }
    if(flag){
      ans++;
      rep(j,v.size() ){
	v[j]=0;
      }
      nex=0;
      rep(j,h){
	v[nex]+=mp[j][i];
	if(v[nex]>k){
	  return INF;
	}
	if(ct[j]==1) nex++;
      }
    }
    
    
    /* rep(z,v.size() ){
      cout<<v[z]<<" ";
    }
    cout<<ans<<endl;*/
  }
  return ans;
}

int cut2(deque<int> ct){
  vector<int> v;
  bool flag=false;
  v.push_back(0);
  int ans=0;
  rep(i,h){
    // v[v.size()-1]+=mp[i][0];
    if(ct[i]==1) v.push_back(0);
    ans+=ct[i];
  }
  /* rep(i,v.size() ){
    cout<<v[i]<<" ";
  }
  cout<<endl;*/
  
  repn(i,w-1){
    int nex=0;
    flag=false;
    rep(j,h){
      v[nex]+=mp[j][i];
      if(v[nex]>k){
	flag=true;
      }
      if(ct[j]==1) nex++;
    }
    if(flag){
      ans++;
      rep(j,v.size() ){
	v[j]=0;
      }
      nex=0;
      rep(j,h){
      v[nex]+=mp[j][i];
      if(v[nex]>k){
	return INF;
      }
      if(ct[j]==1) nex++;
      }
    }
    
    
    /* rep(z,v.size() ){
      cout<<v[z]<<" ";
    }
    cout<<ans<<endl;*/
  }
  return ans;
}



signed main(){
  cin.tie(0);	
  // ios::sync_with_stdio(false);
 
  cin>>h>>w>>k;
  //cout<<'x'<<endl;
  rep(i,h){
    rep(j,w){
      char c;
      cin>>c;
      
      mp[i][j]=c-'0';
    }
  }
  // cout<<'a'<<endl;
  deque<int> x;
  deque<int> p;
  int ans=INF;
  rep(i,1<<(h-1) ){
    // cout<<"make"<<endl;
    x=make(p,i);
    /*rep(i,x.size() ){
      cout<<x[i]<<" ";
      }*/
    
    // cout<<"ans"<<endl;
    ans=min(ans,cut(x));
    ans=min(ans,cut2(x));
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum[999999], a[999999];

ll comb2(ll a){
  if(a==0 || a==1) return 0;
  ll ret=a*(a-1)/2;
  return ret;
}

int main(){
  int n; scanf("%d", &n);
  sum[0]=0;
  for(int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i-1]+a[i];
    //cout << sum[i] << endl;
  }
  n++;
  sort(sum, sum+n);
  n--;
    ll ans=0;
  //printf("%d %d\n\n", sum[n], sum[n+1]);
  //sum[n+1] = sum[n]-1;
  for(int i = 0; i <= n; i++){
    
    ll tmp=0;
    for(int j = i; j <= n; j++){
      //printf("%d %d %d %d\n", i, sum[i], j, sum[j]);
      if(sum[i] == sum[j]) tmp++;
      else {
        
        i=j-1;
        break;
      }
      if(j==n) {
        i=j;
        break;
      }
    }
    //printf("tmp %d\t", tmp);
    ans += comb2(tmp);
    //printf("%d\n", ans);
  }
  printf("%lld\n", ans);
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int A[3];
    rep(i,3)cin>>A[i];
    sort(A,A+3);

    cout<<min(A[2]-A[0],A[2]+A[1]-2*A[0])<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
a = str(input())
lis_a = []
for i in a:
    lis_a.append(int(i))
    
sum = 0
for i in range(1,len(lis_a)):
    if lis_a[i-1] == lis_a[i]:
        sum += 1
        if lis_a[i] == 0:
            lis_a[i] = 1
        else:
            lis_a[i] = 0

print(sum)

Measured memory_bytes: 3956
import java.util.Scanner;
    
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String aa = scan.next();
    String bb = scan.next();
    String cc = scan.next();
    int a = Integer.parseInt(aa);
    int b = Integer.parseInt(bb);
    int c = Integer.parseInt(cc);
    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26084
#include <iostream>
#include <array>
#include <algorithm>

int main(void) {
    std::array<u_int, 4> a;
    std::array<u_int, 4> b;

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]
                    >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        for (u_int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) ++hit;
        }

        int blow = -hit;  // ヒットを除く
        std::sort(a.begin(), a.end());
        for (auto& v : b) {
            if ( std::binary_search(a.begin(), a.end(), v) ) ++blow;
        }

        std::cout << hit << " " << blow << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
ll dis2[N];
bool vis[N];
vector <pii> vec[N];
void dij(int st,int n)
{
    //for(int i=1;i<=4;i++) deb(dis[i])
    for(int j=0;j<=n;j++)
    {
        vis[j]=false;
        dis2[j]=INT_MAX;
    }
    dis2[st]=0;
    multiset <pair <int,int>> s;
    s.insert(mp(0,st));
    while(!s.empty())
    {
        pair <int,int> p=*s.begin();
        s.erase((s.begin()));
        int x,w;
        x=p.ss;
        //cout<<x<<'\n';
        if(vis[x])
        {
            continue;
        }
        vis[x]=true;
        int size=vec[x].sz;
        //deb(size)
        for(int i=0;i<size;i++)
        {
            int y=vec[x][i].ss;
            w=vec[x][i].ff;
            //cout<<x<<" "<<w<<" "<<y<<'\n';
            if(dis2[x]+w<dis2[y])
            {
                dis2[y]=dis2[x]+w;
                s.insert(mp(dis2[y],y));
            }
        }
    }
}
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    int n,x,y;
    cin>>n>>x>>y;
    vec[x].pb(mp(1,y));
    vec[y].pb(mp(1,x));
    fpr(i,1,n)
    {
        vec[i].pb(mp(1,i+1));
        vec[i+1].pb(mp(1,i));
    }
    int res[n];
    mset(res,0)
    fpr(i,1,n+1)
    {
        dij(i,n);
        //deb(i)
        //print_arr(dis2,n)
        fpr(j,1,n+1)
        {
            res[dis2[j]]++;
        }
    }
    fpr(i,1,n)
    {
        cout<<res[i]/2<<'\n';
    }
    return 0;
}





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

int main(){
  int N;
  cin >> N;
  int a[100];
  for(int i=0;i<N;i++)cin >> a[i];
  sort(a, a+N, greater<int>());
  int A=0;
  int B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a[i];
    }else{
      B+=a[i];
    }
  }
  cout << A-B << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)

h, n = map(int, input().split())
m_list = []
max_a = 0
for i in range(n):
  a, b = map(int, input().split())
  m_list.append((a, b))
  if a > max_a:
    max_a = a
  
class Attack_Memo():
  def __init__(self):
    self.attack_memo = {}
  
  def attack(self, h):
    res_list = []
    if h <= 0:
      return 0
    if h in self.attack_memo:
      return self.attack_memo[h]
    for a, b in m_list:
      base_b = self.attack(h-a)
      res_list.append(base_b+b)
    self.attack_memo[h] = min(res_list)
    return min(res_list)

res = 100000000000
ins = Attack_Memo()
for i in range(h+a+1):
  tmp = ins.attack(i)
  if i >= h and tmp <= res:
    res = tmp
print(res)

Measured memory_bytes: 46428
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,x,y,i;cin>>n>>x>>y;map<ll,ll>mp;
	vvi g(n+1);for(i=2;i<=n;i++) g[i].pb(i-1),g[i-1].pb(i);
	g[x].pb(y);g[y].pb(x);queue<ll>q;
	for(i=1;i<=n;i++){
		q.push(i);vi vis(n+1,0),l(n+1,0);
		vis[i]=1;while(q.size()){
			ll x=q.front();q.pop();
			for(auto j:g[x]){
				if(!vis[j]) l[j]=l[x]+1,vis[j]=1,q.push(j);
			}
		}for(ll j=1;j<=n;j++) mp[l[j]]++;
	}for(i=1;i<n;i++) cout<<mp[i]/2<<endl;
}


Measured memory_bytes: 512
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N) {
    long ans = long.max;
    foreach (a; 1 .. (cast(double) N).sqrt.ceil.to!long + 1) {
        if (N % a != 0)
            continue;
        
        auto b = N / a;
        ans = ans.min(a + b - 2);
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N);
    else {
        auto ans = solve(N);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


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

int main(){
	int array[10];
	int num1=0,num2=0,num3=0;
	for(int i=0;i<10;i++){
		cin >> array[i];
		if(array[i]>num1){
			num3 = num2;
			num2 = num1;
			num1 = array[i];
			continue;
		}
		if(array[i]>num2){
			num3=num2;
			num2=array[i];
			continue;
		}
		if(array[i]>num3){
			num3=array[i];
			continue;
		}
	}

	cout << num1 << endl
		<< num2 << endl
		<< num3 << endl;
	return 0;
}

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

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

  vector<P> ps(n);
  rep(i, n) ps[i] = make_pair(a[i], b[i]);
  sort(ps.begin(), ps.end());
  ll ans = 0;
  rep(i, n) {
    if (m == 0) break;
    ans += (ll)ps[i].first * min(m, ps[i].second);
    m -= min(m, ps[i].second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4828
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    v = [int(x) for x in input().split()]

    v = sorted(v)

    ans = v[0]
    for i in range(1,N):
        ans = (ans + v[i])/2

    print(ans)


# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc138","c",main)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int a, b, t;
    cin >> a >> b >> t;

    cout << t / a * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  while(cin>>n>>w,n){
    int v[111],cnt[111]={};
    int mac=0,mak=0;
    for(int i=0;i<n;i++){
      cin>>v[i];
      int k=v[i]/w;
      cnt[k]++;
      mac=max(mac,cnt[k]);
      mak=max(mak,k);
    }
    mak;
    double ans=0.01;
    for(int i=0;i<=mak;i++){
      double t=(double)(mak-i)/mak;
      t*=(double)cnt[i]/mac;
      ans+=t;
    }
    printf("%.10lf\n",ans);
  }
  return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s, p;
    cin >> s >> p;
    s = s + s;
    bool f = false;
    int slen = s.length(), plen = p.length();
    for (int i = 0; i <= slen - plen; i++)
    {
        if (s.substr(i, plen) == p)
            f = true;
    }
    cout << (f ? "Yes" : "No") << endl;
}



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<pair<int, int>> Q(m);
    for (int i = 0; i < m; i++) cin >> Q[i].second >> Q[i].first;
    sort(Q.begin(), Q.end());
    int ind = m - 1;
    vector<int> d;
    for (int i = 0; i < n; i++) {
        Q[ind].second--;
        d.push_back(Q[ind].first);
        if (Q[ind].second == 0) ind--;
        if (ind == -1) break;
    }
    for (int i = 0; i < n && i < d.size(); i++) {
        if (a[i] >= d[i]) break;
        a[i] = d[i];
    }
    long long sum = 0;
    for (auto i: a) sum += i;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5112
#include<iostream>
#include<cstdio>
#include<vector>
#define int long long
using namespace std;
vector<int> inv;
const int p=1e9+7;
const int N=2e5+5;
inline int pw(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=ans*a%p;
		b>>=1;
		a=a*a%p;
	}
	return ans%p;
}
inline int c(int a,int b){
	int ans=1;
	for(int i=a;i>=a-b+1;--i)ans=(ans*i)%p;
	for(int i=b;i>=1;--i)ans=ans*inv[i]%p;
	return (ans%p+p)%p;
}
inline void init(){
    inv.push_back(0), inv.push_back(1);
	for (long long i = 2; i <= N; ++i) {
        int k = (p - p / i) * inv[p % i] % p;
        inv.push_back(k);
    }
}
signed main(){
	init();
	int n,a,b;
	cin>>n>>a>>b;
	int ans=pw(2,n)-1;ans%=p;
	ans-=(c(n,a)+c(n,b))%p;ans%=p;
	ans=(ans+p)%p;
	cout<<ans<<endl;
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  REP(i,n-2){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
[a,b,c]=[input() for i in range(3)]
a=a[::-1]
b=b[::-1]
c=c[::-1]
k="a"
for j in range(len(a)+len(b)+len(c)):
    if k=="a" and len(a)==0:
        print("A")
        break
    elif k=="b" and len(b)==0:
        print("B")
        break
    elif k=="c" and len(c)==0:
        print("C")
        break
    else:
        if k=="a":
            k=a[len(a)-1]
            a=a[0:len(a)-1]
        elif k=="b":
            k=b[len(b)-1]
            b=b[0:len(b)-1]
        else:
            k=c[len(c)-1]
            c=c[0:len(c)-1]


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


struct L {
  int a, b, c, d;
  L(int a=0, int b=0, int c=0, int d=0): a(a), b(b), c(c), d(d) {}
};

int main() {
  //input
  int s, w;
  cin >> s >> w;
  
  if(s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  
}

Measured memory_bytes: 3560
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef vector<int> VI;
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define INF 1000000000
#define PB push_back
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
PII arr[300010];
const int sz = (1 << 18);
int tree[sz];

void add_to_tree(int val, int ll, int rr)
{
	int l = ll + sz / 2;
	int r = rr + sz / 2;
	while (l <= r)
	{
		if (l % 2 == 1) tree[l] += val, l++;
		if (r % 2 == 0) tree[r] += val, r--;
		l /= 2;
		r /= 2;
	}
}

int getVal(int pos)
{
	int res = 0;
	pos += sz / 2;
	while (pos != 0)
	{
		res += tree[pos];
		pos /= 2;
	}
	return res;
}

bool comp(PII p1, PII p2)
{
	return p1.Y - p1.X < p2.Y - p2.X;
}

int main()
{
	///freopen("distance4.in", "r", stdin);
	///freopen("distance4", "w", stdout);
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(4);

	cin >> n >> m;
	For(i, 0, n)
	{
		cin >> arr[i].X >> arr[i].Y;
	}

	sort(arr, arr + n, comp);
	int ni = 0;
	vector<int> ans;
	For(d, 1, m + 1)
	{
		int res = 0;
		while (ni < n && arr[ni].Y - arr[ni].X + 1 < d)
		{
			add_to_tree(1, arr[ni].X, arr[ni].Y);
			ni++;
		}
		res += n - ni;
		int k = d;
		while (k <= m)
		{
			res += getVal(k);
			k += d;
		}
		ans.push_back(res);
	}

	For(i, 0, ans.size())
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 4600
s = input()
for i in range(len(s)):
    if s[i] == 'A':
        left = i
        break
for j in range(len(s) - 1, 0, -1):
    if s[j] == 'Z':
        right = j
        break
ans = len(s[left:right+1])
print(ans)


Measured memory_bytes: 3516
#include <stdio.h>
#include <string.h>
#define R register
#define MN 205
#define P 998244353
int n,x[MN],y[MN],p[MN],ans;
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
	return f?-x:x;
}
inline void del(int &x,int y){x-=y; if (x<0) x+=P;}
int main(){
	n=read();for (R int i=1; i<=n; ++i) x[i]=read(),y[i]=read();
	p[0]=1;for (R int i=1; i<=n; ++i) p[i]=p[i-1]<<1,p[i]>=P?p[i]-=P:0;
	ans=p[n];del(ans,n+1);	
	for (R int i=2; i<=n; ++i)
		for (R int j=1,cnt; j<i; ++j){
			cnt=0;
			for (R int k=1; k<j; ++k)
				if ((x[k]-x[i])*(y[j]-y[i])==(y[k]-y[i])*(x[j]-x[i])) ++cnt;
			del(ans,p[cnt]);	
		}printf("%d\n",ans);
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/agc032/tasks/agc032_b
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pii> v;
    if (n % 2 == 1) {
        for (int i = 1; i < n; i++) {
            v.push_back({i, n});
        }
    }
    for (int i = 1; i <= (n / 2 * 2); i++) {
        for (int j = i + 1; j <= (n / 2 * 2); j++) {
            if (i + j != n + (n + 1) % 2) {
                v.push_back({i, j});
            }
        }
    }
    cout << v.size() << "\n";
    for (auto &x : v) {
        cout << x.first << " " << x.second << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	string s;
  	cin >> s;
  	char pre = s[0];
  	int ans = 0;
  	for(int i = 0; i < s.size(); i++) {
      	if (s[i] != pre)
        	ans += 1;
    	pre = s[i];
    }
  	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(void){
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
    }
    ll cnt = 0;
    for(int i = 0; i < N-1; i++){
        if(A *(X.at(i+1)-X.at(i)) > B){
            cnt += B; 
        }
        else{
            cnt += A * (X.at(i+1)-X.at(i));
        }
    }
    printf("%lld",cnt);
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    atcoder::scc_graph g(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto v = g.scc();
    cout << v.size() << endl;
    for(auto a : v) {
        cout << a.size();
        for(auto tmp : a) {
            cout << " " << tmp;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 40100
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    const p = nextIntArray()
    const q = nextIntArray()
    let arr = []
    for(let i = 1; i<=N; i++){
        arr.push(i)
    }
    let pat = []
    const dfs = (sub, used)=>{
        if(sub.length === N){
            sub.join("")
            pat.push(Number(sub.join("")))
            return
        }
        for(let el of arr){
            if(used.includes(el)) continue
            used.push(el)
            dfs([...sub, el], used)
            used.pop()
        }
    }
    dfs([], [])
    pat.sort((a,b) => a-b)
    const pn = Number(p.join(""))
    const pi = pat.indexOf(pn)
    const qn = Number(q.join(""))
    const qi = pat.indexOf(qn)
    console.log(Math.abs(pi-qi))
}
Main()


Measured memory_bytes: 37280
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    string s; cin >> s;
    int n = s.size();
    if(n == 2){
        if(s[0] == s[1]){
        cout << 1 << " " << 2 << endl;
        return 0;
        }
    }
    else{
        rep(i, n-2)if(s[i] == s[i+1] || s[i+1] == s[i+2] || s[i+2] == s[i]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

//Autumnal Illumination
public class Main{

	int n;
	int[][][] p;
	
	int cross(int[] s, int[] t, int[] r){
		int x1 = t[0]-s[0], y1 = t[1]-s[1], x2 = r[0]-s[0], y2 = r[1]-s[1];
		return x1*y2-x2*y1;
	}
	boolean online(int[] s, int[] t, int[] r){
		if(cross(s, t, r)!=0)return false;
		int minx = Math.min(s[0], t[0]), maxx = Math.max(s[0], t[0]);
		int miny = Math.min(s[1], t[1]), maxy = Math.max(s[1], t[1]);
		return minx<=r[0]&&r[0]<=maxx&&miny<=r[1]&&r[1]<=maxy;
	}
	boolean isCross(int[] a, int[] b, int[] s, int[] t){
		if(cross(a, b, s)*cross(a, b, t)>=0)return false;
		if(cross(b, a, s)*cross(b, a, t)>=0)return false;
		if(cross(s, t, a)*cross(s, t, b)>=0)return false;
		return cross(t, s, a)*cross(t, s, b)<0;
	}
	
	boolean col(int a, int b){
		for(int i=0;i<4;i++)for(int j=0;j<4;j++){
			if(online(p[a][i], p[a][(i+1)%4], p[b][j]))return true;
			if(online(p[b][i], p[b][(i+1)%4], p[a][j]))return true;
			if(isCross(p[a][i], p[a][(i+1)%4], p[b][j], p[b][(j+1)%4]))return true;
		}
		for(int j=0;j<4;j++){
			boolean in = true;
			for(int i=0;i<4;i++)if(cross(p[a][i], p[a][(i+1)%4], p[b][j])>=0)in = false;
			if(in)return true;
		}
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
//		for(;;){
//			int[] p1 = new int[]{0, 0}, p2 = new int[]{10, 0};
//			int[][] t = new int[2][2];
//			for(int i=0;i<2;i++)for(int j=0;j<2;j++)t[i][j]=sc.nextInt();
//			System.out.println("Inter:"+isCross(p1, p2, t[0], t[1])+" Rev:"+isCross(t[0], t[1], p1, p2));
//			System.out.println("Online:"+online(p1, p2, t[0])+" :"+online(p1, p2, t[1]));
//			System.out.println("Rev:"+online(t[0], t[1], p1)+" :"+online(t[0], t[1], p2));
//			System.out.println("Line: ("+t[0][0]+","+t[0][1]+")-("+t[1][0]+","+t[1][1]+") P("+t[2][0]+","+t[2][1]+") is:" + online(t[0], t[1], t[2]));
			
//		}
		for(;;){
			int m = sc.nextInt();
			if(m==0)break;
			while(m--!=0){
				n = sc.nextInt();
				p = new int[n][4][2];
				for(int i=0;i<n;i++)for(int j=0;j<4;j++)for(int k=0;k<2;k++)p[i][j][k]=sc.nextInt();
				UnionFind u = new UnionFind(n);
				for(int i=0;i<n;i++)for(int j=0;j<n;j++){
					if(u.find(i, j))continue;
					if(col(i, j))u.union(i, j);
				}
				System.out.println(u.num);
			}
		}
	}
	
	class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		int size(int x) {
			return -tree[root(x)];
		}
		int getNum() {
			return num;
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int count=0;
    while(b<=a){
        b*=2;
        count++;
    }
    while(c<=b){
        c*=2;
        count++;
    }
    if(k>=count){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[2000020], invf[2000020];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int k; cin>>k;
    string s; cin>>s;
    int n=s.size();
    fac(n+k);
    ll ans=0;
    for(int i=0; i<=k; i++){
        (ans+=powmod(25, i)*comb(n-1+i, i)%MOD*powmod(26, k-i))%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35540
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int x=0,y=0,ans=0;
int main()
{
    scanf("%s",a);
    for (int i=0;i<sizeof(a);i++)
        if (x==y)
        {
            x++;
            if(a[i]=='p') ans--;
        }
        else
        {
            y++;
            if(a[i]=='g') ans++;
        }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/dp/tasks/dp_a
# include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define pri(n) printf("%d",n)
#define priln(n) printf("%d\n",n)
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 (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a; }

// もらうDP
int main()
{
  int n;
  scn(n);

  int a[n];
  rep(i, n) scn(a[i]);

  int dp[n];
  rep(i, n) dp[i] = INF;
  dp[0] = 0;

  rep(j, n - 1) {
    int i = j + 1;
    chmin(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
  }

  pri(dp[n - 1]);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long ll;

ll n, ans = 0;

void div(ll d) {
    ll cnt = 0;
    while (n % d == 0) ++cnt, n /= d;
    for (ll i = 0, j = 0; ; j += (++i)) if (cnt < j) {
        ans += i - 1;
        return;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    div(2);
    for (ll i = 3; i * i <= n; i += 2) div(i);
    if (n > 1) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
package main

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

func solve() {
	n, m := getInt(), getInt()
	isAC := make([]bool, n)
	pena := make([]int, n)
	cntAC, cntPena := 0, 0

	for i := 0; i < m; i++ {
		p := getInt() - 1
		s := getString()

		if !isAC[p] {
			if s == "AC" {
				isAC[p] = true
				cntAC++
				cntPena += pena[p]
			} else {
				pena[p]++
			}
		}
	}

	fmt.Fprintln(wr, cntAC, cntPena)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 2304
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto S = cast(char[])readln.chomp;
  auto N = readln.chomp.to!long;

  void solve() {
    bool inverted = false;
    char[200000] head;
    char[200000] tail;
    long num_head;
    long num_tail;

    foreach(_; 0..N) {
      int queryType; readf(" %d", &queryType);

      if (queryType == 1) {
        inverted ^= true;
        continue;
      }

      int forHead;
      char toAppend;
      readf(" %d %c\n", &forHead, &toAppend);

      auto addToHead = (forHead == 1) ^ inverted;
      if (addToHead) {
          tail[num_tail++] = toAppend;
      } else {
          head[num_head++] = toAppend;
      }
    }

    if (inverted) {
      auto reversed_head = head[0..num_head];
      reversed_head.reverse();
      S.reverse();
      writeln( reversed_head ~ S ~ tail[0..num_tail]);
    } else {
      auto reversed_tail = tail[0..num_tail];
      reversed_tail.reverse();
      writeln(reversed_tail ~ S ~ head[0..num_head]);
    }
  }

  solve();
}


Measured memory_bytes: 3224
(N,), *XL = [list(map(int, s.split())) for s in open(0)]
XL.sort(key=lambda x: x[0] + x[1])
curr = -float("inf")
ans = 0
for x, l in XL:
    if x - l >= curr:
        curr = x + l
        ans += 1
print(ans)


Measured memory_bytes: 32100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

int w, h;
char grid[10][20];
map<string, int> spell;

void dfs(int sy, int sx, int y, int x, int d, string str)
{
	spell[str]++;

	int ny = (y + dy[d] + h) % h;
	int nx = (x + dx[d] + w) % w;
	
	if (ny == sy&&nx == sx) {
		return;
	}
	
	dfs(sy, sx, ny, nx, d, str + grid[ny][nx]);
}

int main()
{
	while (true) {
		cin >> h >> w;

		if (h == 0 && w == 0) {
			break;
		}

		spell.clear();
		vector<vector<bool>> visited(h, vector<bool>(w, false));

		rep(y, h) {
			rep(x, w) {
				cin >> grid[y][x];
			}
		}

		rep(y, h) {
			rep(x, w) {
				rep(d, 8) {
					string str;
					dfs(y, x, y, x, d, str + grid[y][x]);
				}
			}
		}

		string ans;

		for (auto it = spell.begin(); it != spell.end(); it++) {
			if (it->second >= 2) {
				if (ans.size() < it->first.size()) {
					ans = it->first;
				}
				else if (ans.size() == it->first.size()) {
					if (it->first < ans) {
						ans = it->first;
					}
				}
			}
		}

		if (ans.size() != 1) {
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 38072