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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    vector<map<ll, ll>> mat(N, map<ll, ll>());
    vector<ll> A(N-1);
    vector<ll> B(N-1);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
        mat[a][b] = -1;
        mat[b][a] = -1;
    }

    vector<bool> visited(N, false);

    queue<P> que;
    que.push(P(0, -1));
    visited[0] = true;
    ll ma = 0;
    while(!que.empty()) {
        P tmp = que.front();
        que.pop();

        ll color = 0;
        for(P node : mat[tmp.first]) {
            if (!visited[node.first]) {
                if (color == tmp.second) {
                    color++;
                }
                mat[tmp.first][node.first] = color;
                que.push(P(node.first, color));
                ma = max(ma, color);
                visited[node.first] = true;
                color++;
            }
        }
    }
    print(ma+1);
    rep(i, N-1) {
        print(mat[A[i]][B[i]]+1);
    }
    return 0;
}

Measured memory_bytes: 19456
#include<cstdio>
#define ls p<<1
#define rs p<<1|1
#define mid (l+r)/2
#define lson p<<1,l,(l+r)/2
#define rson p<<1|1,(l+r)/2+1,r
using namespace std;
const int maxn=100005;
int n,q;
char s[maxn];
int a[maxn],tree[maxn<<2],mark[maxn<<2];
void build(int p,int l,int r){
    mark[p]=0;
    if(l==r){
        tree[p]=a[l];
        return;
    }
    build(lson);
    build(rson);
    tree[p]=tree[ls]+tree[rs];
}
inline void push_up(int p){
    tree[p]=tree[ls]+tree[rs];
}
inline void push_down(int p,int l,int r){
    mark[ls]+=mark[p];
    mark[rs]+=mark[p];
    tree[ls]+=mark[p]*(mid-l+1);
    tree[rs]+=mark[p]*(r-mid);
    mark[p]=0;
}
int query(int qx,int qy,int p,int l,int r){
    int res=0;
    if(qx<=l&&r<=qy){
        return tree[p];
    }
    push_down(p,l,r);
    if(qx<=mid) res+=query(qx,qy,ls,l,mid);
    if(qy>mid) res+=query(qx,qy,rs,mid+1,r);
    return res;
}
int main(){
	int l,r; 
    scanf("%d %d",&n,&q);
    scanf("%s",s+1);
    for(int i=1;i<=n-1;i++) if(s[i]=='A'&&s[i+1]=='C') a[i]++;
    build(1,1,n-1);
    while(q--){
    	scanf("%d %d",&l,&r);
    	printf("%d\n",query(l,r-1,1,1,n-1));
	}
    return 0;
}

Measured memory_bytes: 3328
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    #define see(x) cout<<#x<<" = "<<x<<endl
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    struct tt
    {
      vector<ll> x;
      vector<ll> y;
    };
    int main()
    {   
         IOS;
         ll n,m,k,i,j;
         cin>>n;
         vector<tt> v(n);
         for(i=0;i<n;i++)
         {
           int sz;
           cin>>sz;
           for(j=0;j<sz;j++)
           {
             ll xi,yi;
             cin>>xi>>yi;
             v[i].x.pb(xi);
             v[i].y.pb(yi);
           }
         }
         ll ans=0;
         for(ll num =0;num<(1<<n);num++)
         {
            bool check =true;
            for(i=0;i<n;i++)
            {
              ll bit = (num&(1<<i));
              if(bit)
              {
                 for(j=0;j<v[i].x.size();j++)
                 {
                   ll pl =v[i].x[j]-1;
                   ll ver =v[i].y[j];
                   // cout<<num<<" "<<i<<" "<<pl<<" "<<ver<<endl;
                   if((ver==1 && ((1<<pl)&num)==0)||(ver==0&&((1<<pl)&num)!=0))
                    check=false;
                 }
              }
            }
            ll see = __builtin_popcountll(num);
            if(check)
              {
                ans=max(ans,see);
                // cout<<num<<" "<<see<<endl;
              }
         }
         cout<<ans;
         
         cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
    }

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
#define max 100000
#define sentinel 100000000

struct card {
	char c;
	int num;
};

card l[max / 2 + 2], r[max / 2 + 2];

void merge(card a[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) l[i] = a[left + i];
	for (int i = 0; i < n2; i++) r[i] = a[mid + i];
	l[n1].num = sentinel;
	r[n2].num = sentinel;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		if (l[i].num <= r[j].num) {
			a[k] = l[i++];
		}
		else {
			a[k] = r[j++];
		}
	}
}

void mergesort(card a[], int n, int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergesort(a, n, left, mid);
		mergesort(a, n, mid, right);
		merge(a, n, left, mid, right);
	}
}

int partition(card a[], int n, int p, int r) {
	card t, x;
	x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j].num <= x.num) {
			i++;
			t = a[i]; a[i] = a[j]; a[j] = t;
		}
	}
	t = a[i + 1]; a[i + 1] = a[r]; a[r] = t;
	return i + 1;
}

void quicksort(card a[], int n, int p, int r) {
	int q;
	if (p < r) {
		q = partition(a, n, p, r);
		quicksort(a, n, p, q - 1);
		quicksort(a, n, q + 1, r);
	}
}

int main()
{
	int n, i, v;
	card a[max], b[max];
	char s[10];
	int stable = 1;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> s >> v;
		a[i].c = b[i].c = s[0];
		a[i].num = b[i].num = v;
	}

	mergesort(a, n, 0, n);
	quicksort(b, n, 0, n - 1);

	for (i = 0; i < n; i++) {
		if (a[i].c != b[i].c) stable = 0;
	}

	if (stable == 0) cout << "Not stable\n";
	else cout << "Stable\n";
	for (i = 0; i < n; i++) {
		cout << b[i].c << " " << b[i].num << endl;
	}
	return 0;
}



Measured memory_bytes: 5356
#include<stdio.h>

int main(){
    int i,a,b,c;
    int j=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<b-a+1;i++){
        if(c%(a+i)==0) j++;
    }
        printf("%d\n",j);
        return 0;
}


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


int main(){
    int N,Y;
    

    cin >> N >> Y;

    int man = -1,go = -1,sen = -1;

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i; j++){
            int k = N - i - j;
            int total = 10000*i + 5000*j + 1000*k;
            if(total == Y){
                man = i;
                go = j;
                sen = k;
            }

        }
    }

    cout << man <<" "<<go<<" "<<sen<<"\n";

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc083/tasks/arc083_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

pll rec(int n,ll& N,vector<vector<int>>& G,vector<ll>& X){
    pll ret = {0,0};
    int sz = (int)G[n].size();
    vector<pll> scores(sz);
    for(int i = 0; i < sz;i++){
        scores[i] = rec(G[n][i],N,G,X);
        if(scores[i].first == LINF) return {LINF,LINF};
    }
    vector<vector<ll>> dp(2,vector<ll>(X[n]+1,LINF));
    int cur = 0,next = 1;
    dp[cur][0] = 0;
    for(int i = 0; i < sz;i++){
        for(int j = 0;j <= X[n];j++){
            if(j+scores[i].first <= X[n]){
                dp[next][j+scores[i].first] = min(dp[next][j+scores[i].first],dp[cur][j]+scores[i].second);
            }
            if(j+scores[i].second <= X[n]){
                dp[next][j+scores[i].second] = min(dp[next][j+scores[i].second],dp[cur][j]+scores[i].first);
            }
            
            dp[cur][j] = LINF;
        }
        swap(cur,next);
    }
    auto minV = *min_element(dp[cur].begin(),dp[cur].end());
    if(minV == LINF) return {LINF,LINF};
    ret = {X[n],minV};
    return ret;
}
string solve(){
    string res;
    ll N; cin >> N;
    vector<vector<int>> G(N);
    for(int i = 1; i < N;i++){
        int P; cin >> P; P--;
        G[P].push_back(i);
    }
    vector<ll> X(N); for(auto& in:X) cin >> in;
    return res=(rec(0,N,G,X).first==LINF?"IMPOSSIBLE":"POSSIBLE");
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 512
import itertools

N = input()
if len(N)==1:
    print(N)
    exit()


gen = (1,2,3,4,5,6,7,8,9)
A = list(itertools.product(gen,gen))
count =0

mem = [[0 for i in range(0,10,1)]for j in range(0,10,1)]

for a,b in A:
    tmp = 0
    if a < int(N[0]):
        for i in range(0,len(N)-1,1):
            tmp+= pow(10,i)
    elif a > int(N[0]):
        for i in range(0,len(N)-2,1):
            tmp+= pow(10,i)
    else:
        tmp +=1
        for i in range(1,len(N)-2,1):
            tmp+= pow(10,i)
        if len(N) > 2:
            tmp+=int(N[1:len(N)-1])+1
            if int(N[len(N)-1]) < b:
                tmp-=1
    if a==b:
        tmp+=1
    mem[a][b]=tmp

for a,b in A:
    count+=mem[a][b]*mem[b][a]

print(count)



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll H, W;
vector<vector<char> > grid(100, vector<char>(100, '.'));

ll check(ll row, ll col)
{
        ll res = 0;
        rep(i, row-1, row+2) {
                rep(j, col-1, col+2) {
                        if (i == row and j == col) continue;
                        if (grid[i][j] == '#') ++res;
                }
        }
        return res;
}

int main()
{
        cin >> H >> W;
        rep(i, 1, H+1) rep(j, 1, W+1) cin >> grid[i][j];
        rep(i, 1, H+1) {
                rep(j, 1, W+1) {
                        if (grid[i][j] == '.') {
                                string tmp = to_string(check(i, j));
                                grid[i][j] = tmp[0];
                        }
                }
        } 
        rep(i, 1, H+1) {
                rep(j, 1, W+1) {
                        cout << grid[i][j];
                }
                cout << endl;
        }
}

Measured memory_bytes: 256
from collections import deque
N,Q=map(int,input().split())
tree=[[] for i in range(N+1)]
counter=[0]*(N+1)
for i in range(N-1):
  a,b=map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
for i in range(Q):
  p,x=map(int,input().split())
  counter[p]+=x
d=deque([1])
parent=[0]*(N+1)
while d:
  a=d.popleft()
  for b in tree[a]:
    if b!=parent[a]:
      counter[b]+=counter[a]
      parent[b]=a
      d.append(b)
print(*counter[1:])

Measured memory_bytes: 58104
fn read_as_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim()
        .split_whitespace()
        .map(|e| e.trim().parse().ok().unwrap())
        .collect()
}

fn main() {
    let (n, m) = {
        let nm: Vec<usize> = read_as_vec();
        (nm[0], nm[1])
    };

    let a: Vec<usize> = read_as_vec();

    let mut sum: usize = 0;
    for i in 0..m {
        sum += a[i];
        if sum > n {
            println!("{}", -1);
            return;
        }
    }

    println!("{}", n - sum);
}


Measured memory_bytes: 2204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const int mod=1e9+7;


int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n);
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int[] ans = new int[s.length()];
		int a = 0;
		int b = 0;
		char now_c = 'R';
		int idx_r_to_l = 0;
		int i = 0;
		while(i<s.length()) {
			if(now_c=='R') {
				if(s.charAt(i)=='L') {
					idx_r_to_l = i-1;
					now_c = 'L';
				}
				if(i%2==0) a++;
				else b++;
			}else {
				if(s.charAt(i)=='R') {
					ans[idx_r_to_l] = idx_r_to_l%2==0?a:b;
					ans[idx_r_to_l+1] = (idx_r_to_l+1)%2==0?a:b;
					now_c = 'R';
					a = 0;
					b = 0;
				}
				if(i%2==0) a++;
				else b++;
			}
			i++;
		}
		ans[idx_r_to_l] = idx_r_to_l%2==0?a:b;
		ans[idx_r_to_l+1] = (idx_r_to_l+1)%2==0?a:b;
		
		for(int j=0;j<s.length();j++) {
			System.out.print(ans[j] + " ");
		}
		in.close();

	}

}


Measured memory_bytes: 47348
N = int(input())

O=[]
for i in range(1,N+1):
  if i%2 == 1:
    O.append(i)
  else:
    continue

c = 0
for i in O:
  a = 1
  b = 0
  while a <= i:
    if i%a == 0:
      b += 1
      a += 1
    else:
      a += 1
  if b == 8:
    c += 1
  else:
    continue
    
print(c)    


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  LL del = D - C;
  --N;
  B -= A;
  bool ok = false;
  for(LL n=0;n<=N;++n){
	LL p = N - n;
	LL T = B - C * (p - n);
	if(-n * del <= T && T <= p * del)
	  ok = true;
  }
  cout << (ok?"YES": "NO") << endl;

  return 0;
}


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


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    ll a = A[N / 2];
    ll b = B[N / 2];
    ll ans = B[N / 2] - A[N / 2] + 1;
    //cout<<B[N / 2]<<" "<<A[N / 2]<<endl;
    if(N % 2 == 0){
        //cout<<B[N / 2]<<" "<<A[N / 2 - 1]<<endl;
        ans = (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 6452
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stdio.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    string s,ans;
    cin >> s;
    for (int i = 0; i < s.size(); i+=2) {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int get_maxkey(map<int, int> m, bool check = false, int v = 0) {
  int max_val = 0, res = 0;
  for (auto o : m) {
    if (max_val < o.second) {
      if (check && v == o.first)
        continue;
      max_val = o.second;
      res = o.first;
    }
  }
  return res;
}

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

  int n, b = 0, diff = 0;
  cin >> n;
  vector<int> v(n);
  map<int, int> odds, eves;
  rep(i, 0, n) {
    cin >> v[i];
    if (i & 1)
      odds[v[i]]++;
    else
      eves[v[i]]++;
    if (b != v[i])
      diff++;
    b = v[i];
  }

  if (diff == 1) {
    cout << n / 2 << endl;
    return 0;
  }

  int key_odds = get_maxkey(odds), key_eves = get_maxkey(eves);
  if (key_odds == key_eves) {
    int e = get_maxkey(eves, true, key_eves);
    int o = get_maxkey(odds, true, key_odds);
    if (eves[e] >= odds[o])
      key_eves = e;
    else
      key_odds = o;
  }

  int ans = 0;
  rep(i, 0, n) {
    if (i & 1) {
      if (key_odds != v[i])
        ans++;
    } else {
      if (key_eves != v[i])
        ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7680
from math import gcd
a,b,c,d=map(int,input().split())
if a==c or b==d:
    print(0)
    exit()
p=abs(a-c)
q=abs(b-d)
g=gcd(p,q)
p//=g
q//=g
print((p+q-1)*g)

Measured memory_bytes: 62064
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M)]

fs = '{:0' + str(N) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*(M+1)
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)


Measured memory_bytes: 9352
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 1e6 + 10;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int mx = -1, agcd = -1;
	int n, k;
	cin >> n >> k;
	bool can = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (agcd == -1) agcd = a;
		else agcd = gcd(agcd, a);
		if (a == k) can = 1;
		mx = max(mx, a);
	}
	//can &= mx >= k;
	if (!can && mx >= k) {
		can = (mx - k) % agcd == 0;
	}
	if (can) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;

struct BIT
{
    int n;
    vector<int>bit;

    BIT(int N)
    {
        n=N;
        bit.resize(n, 0);
    }

    int sum(int r)
    {
        int ret=0;
        for(; r>=0; r=(r&(r+1))-1)
            ret+=bit[r];
        return ret;
    }

    int sum(int l, int r)
    {
        int ret=sum(r);
        if(l) ret-=sum(l-1);
        return ret;
    }

    void add(int p, int idx)
    {
        for(; idx<n; idx=(idx|(idx+1)))
        {
            bit[idx]+=p;
        }
    }
};

int powr(int a, int r)
{
    if(!r) return 1;
    int t=powr(a, r>>1);
    t=(t*t)%mod;
    if(r&1) t = (a*t)%mod;
    return t;
}

int32_t main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>xs, ys;
    for(int i=0; i<n; ++i)
    {
        int x, y;
        cin>>x>>y;
        xs.push_back({x, i});
        ys.push_back({y, i});
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    vector<pair<int,int>>a(n);
    for(int i=0; i<n; ++i)
    {
        a[xs[i].second].first = i;
        a[ys[i].second].second = i;
    }

    sort(a.begin(), a.end());
    int ans=0;
    vector<int>fwd(n, 0), bwd(n, 0);
    BIT *ft = new BIT(n);
    for(int i=n-1; i>=0; --i)
    {
        fwd[i] = ft->sum(a[i].second, n - 1);
        ft->add(1, a[i].second);
    }
    ft = new BIT(n);
    for(int i=0; i<n; ++i)
    {
        bwd[i] = ft->sum(0, a[i].second);
        ft->add(1, a[i].second);
    }
    for(int j=0; j<n; ++j)
    {
        int d[4]={};
        d[0]=powr(2, fwd[j])-1;
        d[1]=powr(2, j-bwd[j])-1;
        d[3]=powr(2, n-1-j-fwd[j])-1;
        d[2]=powr(2, bwd[j])-1;
        
        int t=powr(2, n-1);

        for(int i=0; i<2; ++i)
        {
            t=(t + (d[i]*d[i+2])%mod )%mod;
        }
        int p=1;
        for(auto x: d)
            p=(p*x)%mod;
        t=(t+p)%mod;
        for(int i=0; i<4; ++i)
        {
            t = (t + ((d[i] * d[(i+1)%4])%mod * d[(i+2)%4])%mod )%mod;
        }
        ans=(ans+t)%mod;
        // cout<<t<<"\n";
    }
    ans=(ans+mod)%mod;
    cout<<ans;
}

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

int main(void){
  long long n;
  while(cin>>n,n){
    vector<long long> bef(n,0);
    vector<long long> vec(n);
    for(long long i = 0 ; i < n ; i ++){
      cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    long long ans;
    ans=0;
    //cout<<vec[0]<<endl;
    for(long long i = 1 ; i < n ; i++){
      bef[i] += vec[i-1] + bef[i-1];
      //cout<<bef[i]<<" "<<vec[i]<<endl;
      ans+=bef[i];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1360
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int q, h, s, d;
    int n;

    cin >> q >> h >> s >> d >> n;
    int tiisai = min(min(q*4, h*2), s);
    bool flag = false;
    if(tiisai*2 < d) flag = true;
    
    LL ans = 0;
    while(1){
        if(n == 0) break;
        if(!flag && n-2 >= 0){
            ans += d;
            n -= 2;
        }else{
            ans += tiisai;
            n -= 1;
        }
    }

    cout << ans << endl;
}


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



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>




#include <ostream>
#include <sstream>


using namespace std;
class A {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    int a, b, c;
    in >> a >> b >> c;
    vector<int> tmp(3);
    for(int i = 0; i < 10000000; ++i){
      if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
        out << i << endl;
        return;
      }
      if(a == b && b == c){
        out << -1 << endl;
        return;
      }
      tmp[0] = a;
      tmp[1] = b;
      tmp[2] = c;
      a = (tmp[1] + tmp[2]) / 2;
      b = (tmp[0] + tmp[2]) / 2;
      c = (tmp[0] + tmp[1]) / 2;
    }
    out << -1 << endl;
	}
};


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


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
	io();
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	cout<<(n*(n-1))/2+ (m*(m-1))/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t x;
  int64_t result;
  cin >> x;
  result = x / (int64_t)11 * 2;
  x -= (int64_t)11 * result / 2;
  if (1 <= x) {
    if (x <= 6)
      result++;
    else
      result += 2;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    H,W=map(int,input().split())
    if H==1 or W==1:
        print(1)
    elif (H*W)%2==1:
        print((H*W)//2+1)
    else:
        print((H*W)//2)

resolve()

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


int main(){
    cout<<fixed<<setprecision(10);

    
    ll H,W;cin>>H>>W;
    
    while(H>0 || W>0){
        rep(i,H){
            rep(j,W)cout<<'#';
            cout<<endl;
        }    
        cout<<endl;
        cin>>H>>W;
    }
    

    

    return 0;
}




Measured memory_bytes: 3084
N, M, C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
A = []
for n in range(0, N):
  A.append([int(i) for i in input().split()])

num = 0
for n in range(0, N):
  acc = C
  for m in range(0, M):
    acc = acc + A[n][m] * B[m]
  if acc > 0:
    num = num + 1

print(num)

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

using namespace std;

vector <int> adj[105];
int level[105];
int visited[105];

void bfs()
{
    for(int i = 0; i < 105; i++)
        level[i] = -1;

    queue <int> q;
    q.push(1);
    visited[1] = 1;
    level[1] = 0;

    while(!q.empty())
    {
        int u = q.front();
        q.pop();

        for(int i = 0; i < adj[u].size(); i++)
        {
            int v = adj[u][i];

            if(!visited[v]) {
                visited[v] = 1;
                level[v] = level[u] + 1;
                q.push(v);
            }
        }
    }
}

int main()
{
    int node, vertice, edge, vertex, u, v, i, j;

    cin >> node;

    for(i = 0; i < node; i++)
    {
        cin >> vertice >> edge;
        for(j = 0; j < edge; j++) {
            cin >> vertex;
            adj[vertice].push_back(vertex);
        }
    }

    bfs();

    for(i = 1; i <= node; i++) {
        cout << i << " " << level[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int n=s.length(),i,j;
    long long int ans = 0, now;
    for(i=0;i< (1 << (n-1));i++){
        now=0;
        for(j=0;j<n;j++){
            now *= 10;
            now += s.at(j)-'0';
            if((i & (1<<j))==0){
                //前からj番目が0なら+を入れる
                ans += now;
                now = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n)cin >> a.at(i);
  int64_t ansv = 0;
  vector<int64_t> ans(2),s(2);//+,-
  //奇数番目と偶数番目どちらを正にするかで解が変わる。
  if(a.at(0)>0){
    s.at(0) = a.at(0);
    ans.at(1) = a.at(0)+1;
    s.at(1) = -1;
  }else if(a.at(0)<0){
    s.at(1) = a.at(0);
    ans.at(0) = 1-a.at(0);
    s.at(0) = 1;
  }else{
    s.at(0) = 1;
    s.at(1) = -1;
    ans.at(0) = 1;
    ans.at(1) = 1;
  }
  //cout<<s.at(0)<<ans.at(0)<<endl;
  //cout<<s.at(1)<<ans.at(1)<<endl;
  rep(k,2){
    rep(i,n){
      if(i==0)continue;
      if(s.at(k)>0){//和はマイナス
        if(s.at(k)+a.at(i)>=0){
          ans.at(k)+=(s.at(k)+a.at(i)-(-1));
          s.at(k)=-1;
          continue;
        }
      }else if(s.at(k)<0){
        if(s.at(k)+a.at(i)<=0){
          ans.at(k)+=(1-(s.at(k)+a.at(i)));
          s.at(k)=1;
          continue;
        }
      }
      s.at(k)+=a.at(i);
    
      
      if(s.at(k)==0){//１か−１にする。
        ans.at(k)++;
        if(i<n-1){
          for(int j = i+1; j < n; j++){
            if(a.at(j)>0){
              s.at(k) = -1;
              break;
            }else if(a.at(j)<0){
              s.at(k) = 1;
              break;
            }
          }
        }
      }
      
      if(s.at(k)==0){
        s.at(k) = 1;
      }
      //cout<<"ans is"<<ans.at(k)<<"  sum is"<<s.at(k)<<endl;
    }
  }
  //cout<<ans.at(0)<<"or"<<ans.at(1)<<endl;
  ansv = min(ans.at(0),ans.at(1));
  //cout<<"ans is"<<ans<<"  sum is"<<s<<en
  cout<<ansv<<endl;
  return 0;
}


Measured memory_bytes: 1024
# 構造化プログラミング

n = int(input())

i = 1
while i<=n:
    x = i
    if x%3==0:
        print(" %d"%(i), end="")
        i = i + 1
        continue
    while True:
        if x%10==3:
            print(" %d"%(i), end="")
            break
        x = x // 10
        if x==0:
            break
    i = i + 1
print()



Measured memory_bytes: 5868
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
const MOD: i64 = 1_000_000_007;

fn main() {
    let n: i64 = read();
    let k: i64 = read();

    let mut a: Vec<i64> = vec![];
    let mut ans: i64 = 0;

    for i in 1..n + 2 {
        a.push(i)
    }

    let mut minv: i64 = a[0..k as usize].iter().sum();
    let mut maxv: i64 = a[a.len() - k as usize..a.len()].iter().sum();
    ans += maxv - minv + 1;

    for i in k + 1..n + 2 {
        minv += a[i as usize - 1];
        maxv += a[a.len() - i as usize];

        ans += maxv - minv + 1;
        if ans > MOD {
            ans %= MOD
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i = 0; i < n; ++i)  cin >> a[i] >> b[i];
    for(int i = 0; i < m; ++i)  cin >> c[i] >> d[i];

    for(int i = 0; i < n; ++i){
        int ans = INF, mine = INF;
        for(int j = 0; j < m; ++j){
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(mine > dist){
                mine = dist;
                ans = j;
            }
        }
        cout << ans + 1 << '\n';
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int A;
    int max1 = 0;
    int max1_n = 0;
    int max2 = 0;
    int max2_n = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &A);
        if(A > max1_n)
        {    
            max1 = i;
            max1_n = A;
        }
        else if(A > max2_n)
        {    
            max2 = i;
            max2_n = A;
        
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(i == max1)
            printf("%d\n", max2_n);
        else
            printf("%d\n", max1_n);
    }
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    scanVecInt(A, N);
    cout << 1 + max((N - 2) / (K - 1), 0) << endl;
}


Measured memory_bytes: 640
import collections

n = int(input())
s = [input() for i in range(n)]
rlist=[]
i = 0

c = collections.Counter(s)
m=c.most_common()[0]
max=m[1]


while(i<n):
  if(c[s[i]] == max):
    rlist.append(s[i])
  i+=1

r2list=list(set(rlist))
r2list.sort()

len= len(r2list)
j=0

while(j<len):
  print(r2list[j])
  j+=1

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

int main()
{
  string s,t;
  ll n;
  cin >> n;
  cin >> s;
  cin >> t;
  string r;
  for (ll i = 0; i < n; i++)
  {
    r += s[i];
    r += t[i];
  }
  cout << r << endl;
  
  return 0;
}

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

using namespace std;

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll k,x;
  cin >> k >> x;

  if(500*k>=x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N,K;
  cin>>N>>K;
  
  vector<long long int>h(N);
  
  for(long long int i=0;i<N;i++){
    cin>>h[i];
  }
      sort(h.begin(),h.end());
      
      long long int min=1000000000;
      
      for(long long int i=0;i<N-K+1;i++){
        if(min>h[i+K-1]-h[i]){
min=h[i+K-1]-h[i];
        }
      }

      cout<<min<<endl;
      }

        
        

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

namespace ABC141A
{
    class Program
    {
        static void Main(string[] args)
        {
            String S, a, b, c;

            S = Console.ReadLine();

            a = "Sunny";
            b = "Cloudy";
            c = "Rainy";

            if (S == a)
                Console.WriteLine(b);

            else if (S == b)
                Console.WriteLine(c);

            else if (S == c)
                Console.WriteLine(a);

            Console.ReadKey();


        }
    }
}

Measured memory_bytes: 9044
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int maxA = 0, maxB = 0;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (maxA < a) {
                maxA = a;
                maxB = b;
            }
        }
        System.out.println(maxA + maxB);
    }
}

Measured memory_bytes: 63980
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> d(n);

    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int check = 0;
    for(int i = 0 ; i < 3 ; i++)
    {
        if(s.at(i)==s.at(i+1)){
            check=1;
            break;
        }
    }
    if(check){
        cout<<"Bad"<<endl;

    }
    else {
        cout<<"Good"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct point{
  double x, y;
  point(){
  }
  point(double x, double y): x(x), y(y){
  }
  point operator -(point P){
   return point(x - P.x, y - P.y);
  }
};
double abs(point P){
  return sqrt(pow(P.x, 2) + pow(P.y, 2));
}
double dist(point P, point Q){
  return abs(Q - P);
}
double dot(point P, point Q){
  return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
  return P.x * Q.y - P.y * Q.x;
}
struct line{
  point A, B;
  line(){
  }
  line(point A, point B): A(A), B(B){
  }
};
point vec(line L){
  return L.B - L.A;
}
double point_line_distance(point P, line L){
  return abs(cross(P - L.A, vec(L))) / abs(vec(L));
}
double point_segment_distance(point P, line L){
  if (dot(P - L.A, vec(L)) < 0){
    return dist(P, L.A);
  } else if (dot(P - L.B, vec(L)) > 0){
    return dist(P, L.B);
  } else {
    return point_line_distance(P, L);
  }
}
int main(){
  int N;
  cin >> N;
  vector<int> r(N);
  vector<line> L(N);
  for (int i = 0; i < N; i++){
    point s, t;
    cin >> r[i] >> s.x >> s.y >> t.x >> t.y;
    L[i] = line(s, t);
  }
  int ans = 0;
  vector<bool> used(1 << N, false);
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    ans = max(ans, __builtin_popcount(v));
    for (int i = 0; i < N; i++){
      if (!(v >> i & 1)){
        int w = v | (1 << i);
        if (!used[w]){
          bool ok = true;
          for (int j = 0; j < N; j++){
            if (i != j){
              if (!(v >> j & 1)){
                if (point_segment_distance(L[j].A, L[i]) <= r[i] + r[j]){
                  ok = false;
                }
              } else {
                if (point_segment_distance(L[j].B, L[i]) <= r[i] + r[j]){
                  ok = false;
                }
              }
            }
          }
          if (ok){
            used[w] = true;
            Q.push(w);
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n=0;
  char c,s[210];
  bool f=0;
  for(;cin>>c;) s[n++]=c;
  n/=2;
  for(;n--;){
    f=0;
    fr(i,n) if(s[i]!=s[i+n]) f=1;
    if(f) continue;
    cout<<2*n<<endl;
    return 0;
  }
}

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

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

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

    int num = a + b + c;
    if ((a + b == c) || (a + c == b) || (b + c == a)) {
            if(num % 2 == 0) {
                cout << "Yes" << endl;
            }  
        } else {
            cout << "No" << endl;
        }

    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c,d;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	//cin >> a >> b >> c;
	//cin >> a >> b >> c >> d;
	//cin >> str;
	//cin >> str >> str2 >> str3;
	//cin >> n;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	
	vs.resize(3);
	REP(i, 3){
		cin >> str;
		vs[i] = str;
	}

	REP(i, 2){
		if(vs[i][vs[i].size()-1] != vs[i+1][0]){
			Cout("NO");
			return 0;
		}
	}
	Cout("YES");

	//transform(ALL(str_toupper), str_toupper.begin(), ::toupper);

	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;
	//replace(ALL(str), ',', ' ');

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

const int Maxn = 100000;

int main(){ 
	int a[1000],ans;
	for(int i = 1; i <= 7; i++) a[i] = pow(2, i);
	int n;
	scanf("%d", &n);
	if(n == 1) {
		printf("1\n");
		return 0;
	}
	for(int i = 1; i <= 7; i++){
		if(a[i] > n){ 
			ans = a[i-1];
			break;
		}
		else if(a[i] == n){
			ans = a[i];
			break;
		}
		else if(i == 7 && a[i] < n) ans = a[7];
	}
	printf("%d\n", ans);
	return 0;
}

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

string rev(string s){
  string ans="";
  for(int i=s.size()-1; i>=0; i--)
    ans += s.substr(i,1);
  return ans;
}

int main(){

  int n;
  cin >> n;
  for(int k=0; k<n; k++){
    string s;
    cin >> s;
    vector<string> ans;
    for(int i=1; i<s.size(); i++){
      string pre  = s.substr(0,i);
      string late = s.substr(i,s.size()-i);
      //      cout << rev(pre) + " "+ late << endl;
      ans.push_back(pre+late);
      ans.push_back(late+pre);
      ans.push_back(rev(pre)+late);
      ans.push_back(late+rev(pre));
      ans.push_back(rev(late)+pre);
      ans.push_back(pre+rev(late));
      ans.push_back(rev(late)+rev(pre));
      ans.push_back(rev(pre)+rev(late));
    }
    sort(ans.begin(),ans.end());
    auto end = unique(ans.begin(),ans.end());
    int res=0;
    for(auto it = ans.begin(); it < end; it++,res++){}
    cout <<res <<endl;
  }
}

Measured memory_bytes: 3140