akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
 
double dot(P a,P b){
  return real(b*conj(a));
}
 
double cross(P a,P b){
  return imag(b*conj(a));
}
 
double eps = 1e-8;
 
P crossPoint(L l,L m){
  double A = cross(l.second-l.first,m.second-m.first);
  double B = cross(l.second-l.first,l.second-m.first);
  if( fabs(A) < eps && fabs(B) < eps ) return m.first;
  else if(fabs(A) >= eps ) return m.first+B/A*(m.second-m.first);
  else P(0,0);
}
 
bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}
 
bool eq(P a,P b){
  return eq( abs(b-a) , 0 );
}
 
bool onSegment(L a,P p){
  return eq( abs(a.first-a.second) , abs(a.first-p)+abs(a.second-p) );
}
 
 
bool isParallel(L a,L b){
  if( abs(cross(a.first-a.second,b.first-b.second)) < eps ) return true;
  return false;
}
 
int n,m;
vector<P> G[100];
vector<P> t;
vector<L> u;
 
int check(P a,bool debug=false){
 
 
 
  int cnt=0;
  for(int i=0;i<m;i++){
    L v=L(a,t[i]);
    bool flg=true;
    for(int j=0;j<n;j++){
      int size=G[j].size();
      for(int k=0;k<size;k++){
        L w=L(G[j][k],G[j][(k+1)%size]);
        if(isParallel(v,w))continue;
        P p=crossPoint(v,w);
 
        if(eq(w.first,p))continue;
        if(eq(w.second,p))continue;
        if(eq(v.first,p))continue;
        if(eq(v.second,p))continue;
        if(!onSegment(w,p))continue;
	
        if(onSegment(v,p)){
          flg=false;
        }
      }
    }
    if(flg)cnt++;
  }
  return cnt;
}
 
int solve(){
 
  if(n==0)return m;
  int res=0;
  for(int i=0;i<(int)u.size();i++){
    for(int j=0;j<i;j++){
      L a=u[i];
      L b=u[j];
 
      P target=crossPoint(a,b);
 
      if( isParallel(a,b) ) continue;
      res=max(res,check(target));
    }
  }
  return res;
}
 
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    double x,y;
    int L;
    cin>>L;
    G[i].resize(L);
    for(int j=0;j<L;j++){
      cin>>x>>y;
      G[i][j]=P(x,y);
    }
  }
  for(int i=0;i<m;i++){
    double x,y;
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<(int)G[j].size();k++){
        u.push_back(L(t[i],G[j][k]));
      }
    }
  }
 
  cout<<solve()<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

ll cnt(ll bit)
{
    ll res = 0;
    while (bit)
    {
        if (bit % 2)
            res++;
        bit /= 2;
    }
    return res;
}

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

    ll n;
    while (cin >> n, n)
    {
        std::vector<int> sche[31];
        int memo[31][n];
        for (int i = 0; i <= 30; i++)
            for (int j = 0; j < n; j++)
                memo[i][j] = 0;
        for (int i = 0; i < n; i++)
        {
            int f;
            cin >> f;
            for (int j = 0; j < f; j++)
            {
                int d;
                cin >> d;
                sche[d].push_back(i);
                memo[d][i] = 1;
            }
        }
        VVI dp(31, vector<ll>(n, 0));
        ll tmp = 1;
        for (int i = 0; i < n; i++)
        {
            dp[0][i] = tmp;
            tmp *= 2;
        }
        for (int day = 1; day <= 30; day++)
        {
            for (int j = 0; j < n; j++)
            {
                if (memo[day][j])
                {
                    for (int k = 0; k < (int)sche[day].size(); k++)
                    {
                        if (memo[day][j])
                            dp[day][j] |= dp[day - 1][sche[day][k]];
                    }
                }
                else
                {
                    dp[day][j] = dp[day - 1][j];
                }
            }
        }
        int res = INF;
        for (int day = 1; day <= 30; day++)
        {
            for (int j = 0; j < n; j++)
            {
                if (cnt(dp[day][j]) == n)
                    res = min(res, day);
            }
        }
        if (res == INF)
            cout << -1 << endl;
        else
            cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, a, b) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << '\n';

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s[i] == 'U' || s[i] == 'D') continue;
    if (s[i] == 'L' && (~i & 1)) return puts("No"), 0;
    if (s[i] == 'R' && (i & 1)) return puts("No"), 0;
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

int32_t main()
{
	ninja
	int n; cin>>n;
	map<int, int> mp;
	int x;
	int res=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		res += mp[i-x];
		mp[i+x]++;
	}
	cout<<res;
}



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

const int N=1e9;

int main(){

    int n, k, a;
    scanf("%d%d", &n, &k);
    int mn=N, idx=0;
    for(int i=1; i<=n; ++i){
        scanf("%d", &a);
        if(a<mn){
            mn=a;
            idx=i;
        }
    }

    int cnt=0, mn2=N;
    if(idx>n-k+1)
        idx=n-k+1;
    else if(idx<k)
        idx=k;

    for(int i=idx; i<n; i+=k-1)
        ++cnt;
    for(int i=idx; i>1; i-=k-1)
        ++cnt;

    mn2=min(mn2, cnt);
    cnt=0;

    for(int i=1; i<n; i+=k-1)
        ++cnt;
    mn2=min(mn2, cnt);

    printf("%d\n", mn2);



    return 0;
}


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

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





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int n;
int a[maxn];
int b[maxn];

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

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

    reverse(b,b+n);

    int val=-1;
    for (int i=0; i<n; i++) {
	if (a[i]==b[i]) {
	    val=a[i];
	    break;
	}
    }

    int l=n;
    int r=-1;

    for (int i=0; i<n; i++) {
	if (a[i]==val && b[i]==val) {
	    l=i;
	    break;
	}
    }
    
    for (int i=n-1; i>=0; i--) {
	if (a[i]==val && b[i]==val) {
	    r=i;
	    break;
	}
    }

    for (int i=0; i<n && l<=r; i++) {
	if (a[i]!=val && b[i]!=val) {
	    swap(b[l++],b[i]);
	}
    }

    if (l<=r) out("No");

    cout<<"Yes\n";
    for (int i=0; i<n; i++) {
	cout<<b[i]<<" ";
    }
    cout<<endl;
    
    
    return 0;
}


Measured memory_bytes: 5216
#include <stdio.h>

int main(void)
{
	int a, b, c, tmp;

	scanf("%d%d%d", &a, &b, &c);

	tmp = a;
	a = b;
	b = tmp;

	tmp = a;
	a = c;
	c = tmp;

	printf("%d %d %d", a, b, c);

	return 0;
}

Measured memory_bytes: 1700
#include<stdio.h>
int main() {
	int a[3];
	int temp;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	for (int j = 0; j < 2; j++) {
		for (int i = 0; i < 2; i++) {
			if (a[i] > a[i + 1]) {
				temp = a[i];
				a[i] = a[i + 1];
				a[i + 1] = temp;
			}
		}

	}
	for (int i = 0; i < 3; i++) {
		if (i == 2) 
			printf("%d\n", a[i]);
		else
			printf("%d ", a[i]);
		
	}

}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    long long N, T, ans = 0, t[200000];
    cin >> N >> T;
    rep(i, N){
        cin >> t[i];
        if(!i) ans += T;
        else if(t[i - 1] + T < t[i]) ans += T;
        else ans += t[i] - t[i - 1]; 
    }
        cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
typedef long long ll;
int w[105], v[105];
ll dp[105][100005] = {0};

int main() {
    int n, W;
    cin >> n >> W;
    for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];
    for (int j = 0; j <= W; ++j) dp[0][j] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j =    0; j < w[i]; ++j) dp[i + 1][j] =     dp[i][j];
        for (int j = w[i]; j <=   W; ++j) dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


ll ans;
int n;
ll a[200005];
map <ll, ll> mp[2];

int main() {

	cin >> n;

	rrep(i, n) {
		cin >> a[i];
		mp[1][i - a[i]]++;
		mp[0][i + a[i]]++;
	}

	for (const auto& x : mp[0]) {
		ans += mp[0][x.fi] * mp[1][x.fi];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 39416
import sys
sys.setrecursionlimit(10**5 + 1)

n, m = map(int, input().split())
sus = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    sus[a - 1].append(b - 1)
    sus[b - 1].append(a - 1)

valid = [True for i in range(n)]

def dfs(x):
    ret = 1
    valid[x] = False
    for y in sus[x]:
        if valid[y]:
            valid[y] = False
            ret += dfs(y)
    return ret

color = [-1 for i in range(n)]
sol = 0
cnt = [0, 0]

def boji(x):
    global cnt
    cnt[color[x]] += 1
    for y in sus[x]:
        if color[y] == -1:
            color[y] = 1 - color[x]
            if boji(y):
                return True
        elif color[y] == color[x]:
            return True
    return 0

for i in range(n):
    if color[i] == -1 and valid[i]:
        cnt = [0, 0]
        color[i] = 0
        if boji(i) == 0:
            sol += cnt[0] * cnt[1]
        else:
            d = dfs(i)
            sol += d * (d - 1) // 2
print(sol - m)


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a+b)>(c+d)) {
    cout << "Left" << endl;
  } else if((a+b)==(c+d)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int f1 = (s.size() % 2), f2 = (s[0] == s[s.size()-1]);
    if(f1 ^ f2){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n;
  cin >> n;
  int a;
  char s;
  char mark[4] = {'S', 'H', 'C', 'D'};
  bool card[4][13] = {false};
  REP(i,n) {
    cin >> s >> a;
    REP(j,4) {
      if(s==mark[j]) {
        card[j][a-1] = true;
      }
    }
  }
  REP(i,4) {
    REP(j,13) {
      if(!card[i][j]) {
        cout << mark[i] << " " << j+1 << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
long long int dp[100040] = {};
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b)) {
		cout << "B";
	}
	else {
		cout << "A";
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()
def read(): return int(input())
def reads(): return [int(i) for i in input().split()]
	
from operator import itemgetter

N, H = reads()
ab = [None]*N
for i in range(N):
	ab[i] = tuple(reads())
	
ab.sort(key=itemgetter(1), reverse=True)

a_max = 0
b_of_a_max = 0
a_max_index = 0
for i in range(N):
	if ab[i][0] >= a_max:
		a_max = ab[i][0]
		b_of_a_max = ab[i][1]
		a_max_index = i
del ab[a_max_index]
	
ans = 0

for i in range(N-1):
	if b_of_a_max > H:
		H = 0
		ans += 1
		break
	if ab[i][1] >= a_max:
		H -= ab[i][1]
		ans += 1
		if H <= 0:
			break
	else:
		break
		
if H > 0 and b_of_a_max > a_max:
	H -= b_of_a_max
	ans += 1
	
if H > 0:
	ans += -(-H // a_max)
	
print(ans)


Measured memory_bytes: 17996
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    a, b = input_list()
    print(int(a*b))


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


def input_list():
    return list(map(Decimal, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 77332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {}
	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y);}
	int size(int x) { return -d[find(x)];}
};

template<typename T>
struct edge {
	int from, to;
	T cost;
};

template<typename T>
T kruskal(vector<edge<T>> &edges, int V) {
	sort(edges.begin(), edges.end(), [](const edge<T> &a, const edge<T> &b) {
		return a.cost < b.cost;
	});
	UnionFind unionFind(V);
	T res = 0;
	for (edge<T> &e: edges) {
		if (unionFind.unite(e.to, e.from)) {
			res += e.cost;
		}
	}
	return res;
}


int main() {
	int N;
	cin >> N;
	vector<tint> v, r;
	int a=0, b=0, c=0, x, y, z;
	rep(i, N) {
		cin >> x >> y;
		v.push_back(make_tuple(x, y, i));
		r.push_back(make_tuple(y, x, i));
	}
	sort(all(v));
	sort(all(r));
	vector<edge<lint>> e(N*2-2);
	rep(i, N-1) {
		x = get<0>(v.at(i+1)) - get<0>(v.at(i));
		e.at(i).from = get<2>(v.at(i));
		e.at(i).to   = get<2>(v.at(i+1));
		e.at(i).cost = x;
	}
	rep(i, N-1) {
		y = get<0>(r.at(i+1)) - get<0>(r.at(i));
		e.at(i+N-1).from = get<2>(r.at(i));
		e.at(i+N-1).to   = get<2>(r.at(i+1));
		e.at(i+N-1).cost = y;
	}
	cout << kruskal(e, N) << '\n';
}


Measured memory_bytes: 9020
#include <iostream>

using namespace std;
long long k, x, mn, mx;
int main()
{
    cin >> k >> x;
    mn = max(-1000000ll, x - k + 1);
    mx = min(1000000ll, x + k - 1);

    for(int i = mn; i <= mx; ++i)
        cout << i << ' ';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N, M;
int arr[110];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	int i;
	for (i = 0; i < M; i++)
	{
		int a;
		cin >> a;
		int j;
		for (j = 0; j < a; j++)
		{
			int x;
			cin >> x;
			arr[x]++;
		}
	}
	int ans = 0;
	for (i = 1; i <= N; i++)
	{
		ans += !arr[i];
	}
	cout << ans;
}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A !=C ){
        cout << "Yes" << endl;}
    else if(A ==C  && C!= B){
        cout << "Yes" << endl;
        } 
    else if(B == C && A!= C){
        cout << "Yes" << endl;
        } 
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[105],sum[105],len[105];
bool solve(){
	sort(a+1,a+n+1);
	if(a[n]!=a[n-1]) return 0;
	int mn=1e9;
	for(int i=1;i<=a[n]+1;i++){
		len[i]=max(i-1,a[n]-i+1);
		mn=min(mn,len[i]);
		sum[len[i]]--;
		if(sum[len[i]]<0) return 0;
	}
	for(int i=1;i<=mn;i++) if(sum[i]) return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[a[i]]++;
	if(solve()) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ll a,v,b,w; cin >> a >> v >> b >> w;
    ll t; cin >> t;
    if(a<b){
        if(a+v*t<b+w*t) cout << "NO" << endl;
        else cout << "YES" << endl;
    }else{
        if(b-t*w<a-v*t){
            cout << "NO" << endl;
        }
        else cout << "YES" << endl;
    }
}


Measured memory_bytes: 3632
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut indexes: Vec<usize> = vec![0; n];
    for i in 0..n {
        let pi: usize = iterator.next().unwrap().parse().unwrap();
        let pi = pi - 1;
        indexes[pi] = i;
    }

    let mut c_max = 0;
    let mut c = 1;
    let mut prev = indexes[0];
    for i in 1..n {
        if indexes[i] > prev {
            c += 1;
        } else {
            c_max = max(c_max, c);
            c = 1;
        }
        prev = indexes[i];
    }
    c_max = max(c_max, c);

    let ans = n - c_max;
    ans.to_string()
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    if (N % i == 0 && N / i < 10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N)
{
    int j, i, v;
    for (i = 1; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main()
{
    int N, i, j;
    int A[100];

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

    trace(A, N);
    insertionSort(A, N);
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

int getChar(char ch);
long long getKey(char[]);
int h1(int);
int h2(int);
int find(char[]);
int insert(char str[]);

char H[M][L];

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i = 0; i < M; i++){
    H[i][0] = '\0';
  }
  cin >> n;
  for( i = 0; i < n; i++){
    cin >> com;
    cin >> str;
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if( find(str) ){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
  }
  return 0;
}

int getChar(char ch){
  if( ch == 'A'){
    return 1;
  }
  else if(ch == 'C'){
    return 2;
  }
  else if(ch == 'G'){
    return 3;
  }
  else if(ch == 'T'){
    return 4;
  }
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1,i;
  for(i = 0; i < strlen(str); i++){
    sum += p*(getChar( str[i]) );
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1+( key%(M-1) );
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = ( h1(key)+i*h2(key) ) % M;
    if( strcmp( H[h],str) == 0){
      return 1;
    }
    else if( strlen(H[h]) == 0 ){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = ( h1(key)+i*h2(key) ) % M;
    if( strcmp(H[h],str) == 0 ){
      return 1;
    }
    else if( strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 17416
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	array<ll, 3> ls;
	cin >> ls[0] >> ls[1] >> ls[2];
	sort(ls.begin(), ls.end());

	ll min = ls[0], med = ls[1], max = ls[2];

	if ((med - min) % 2 == 0)
		return OUT((med - min) / 2 + (max - med));

	return OUT((med - min) / 2 + (max - med) + 2);
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from itertools import combinations_with_replacement
INF = float('inf')

def main():
    N, M, Q = map(int, readline().split())
    abcd = []

    for _ in range(Q):
        a,b,c,d = map(int, readline().split())
        abcd.append([a,b,c,d])

    As = combinations_with_replacement(range(1,M+1),N)
    ans = 0

    for A in As:
        score = 0
        for a,b,c,d in abcd:
            if A[b-1] - A[a-1] == c:
                score += d

        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
// Problem Code: abc158_c

#include <iostream>
#include <cmath>

using namespace std;

int tax_increase(int A, int B) {
	for (int i = ceil(A / 0.08); int(i * 0.08) == A; i++)
		if (int(i * 0.1) == B)
			return i;
	return -1;
}

int main() {
	int A, B;
	cin >> A >> B;
	cout << tax_increase(A, B);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, q;
    cin >> a >> b >> q;

    vl s(a+2);
    s[0] = -INF;
    exrep(i, 1, a) {
        cin >> s[i];
    }
    s[a+1] = INF;

    vl t(b+2);
    t[0] = -INF;
    exrep(i, 1, b) {
        cin >> t[i];
    }
    t[b+1] = INF;

    vl ans(q, INF);
    rep(i, q) {
        ll x;
        cin >> x;
        ll posRji = upper_bound(all(s), x) - s.begin();
        ll posRte = upper_bound(all(t), x) - t.begin();
        ll Rji = s[posRji] - x;
        ll Rte = t[posRte] - x;
        posRji--;  posRte--;
        ll Lji = x - s[posRji];
        ll Lte =  x - t[posRte];
        chmin(ans[i], max(Lji, Lte));
        chmin(ans[i], max(Rji, Rte));
        chmin(ans[i], 2*Lji + Rte);
        chmin(ans[i], 2*Rte + Lji);
        chmin(ans[i], 2*Lte + Rji);
        chmin(ans[i], 2*Rji + Lte);
    }
    
    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
using namespace std;

typedef struct
{
	int x;
	int y;
} POS;

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

POS sq[1000];
POS s, e;

int main()
{
	int N;
	
	while (scanf("%d", &N), N){
		s.x = 0;
		e.x = 0;
		s.y = 0;
		e.y = 0;
		
		sq[0].x = 0;
		sq[0].y = 0;
		
		for (int i = 1; i < N; i++){
			int n, d;
			
			scanf("%d %d", &n, &d);
			
			sq[i].x = sq[n].x + dx[d];
			sq[i].y = sq[n].y + dy[d];
			
			s.x = min(s.x, sq[i].x);
			e.x = max(e.x, sq[i].x);
			s.y = min(s.y, sq[i].y);
			e.y = max(e.y, sq[i].y);
		}
		
		printf("%d %d\n", e.x - s.x + 1, e.y - s.y + 1);
	}
	
	return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, k;
    cin >> n >> k;
    int excepts[k];
    repi(i, k, 0)
    {
        cin >> excepts[i];
    }
    int ans = n;
    while (true)
    {
        string s = to_string(ans);
        bool state = true;
        repi(j, s.size(), 0)
        {
            repi(i, k, 0)
            {
                if (s[j] - '0' == excepts[i])
                {
                    state = false;
                    break;
                }
            }
            if (!state)
                break;
        }
        if(state){
            cout << ans << endl;
            break;
        }
        ans++;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	static int[][] multi;
	static int[] matR;
	static int[] matC;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		multi = new int[n][n];
		matR = new int[n];
		matC = new int[n];

		for (int i = 0; i < n; i++) {
			matR[i] = scan.nextInt();
			matC[i] = scan.nextInt();
		}

		System.out.println(Mat(0, n - 1));

		scan.close();
		System.exit(0);
	}

	private static int Mat(int fr, int to) {
		if (fr == to)
			return 0;
		if (multi[fr][to] == 0) {
			int min = Integer.MAX_VALUE;
			for (int i = fr; i < to; i++) {
				int r = Mat(fr, i) + Mat(i + 1, to) + (matR[fr] * matC[i] * matC[to]);
				if (r < min)
					min = r;
			}
			multi[fr][to] = min;
		}
		return multi[fr][to];
	}
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int L = S.size();

    for (int i = L - 1; i >= 0; --i) {
        if (S[i] == 'B') {
            for (int j = i - 1; j >= 0; --j) {
                if (S[j] == '0' || S[j] == '1') {
                    S[j] = '2';
                    break;
                }
            }
        }
    }

    for (int i = 0; i < L; ++i) {
        if (S[i] == '0' || S[i] == '1') cout << S[i];
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from copy import deepcopy
from itertools import combinations


def main():
    h, w, k = map(int, input().split())
    base_table = []
    for i in range(h):
        s = input()
        tmp = []
        for j in s:
            if j == '.':
                tmp.append(0)
            else:
                tmp.append(1)
        base_table.append(tmp)

    tate = [[-1]]
    for n in range(1, h + 1):
        for item in combinations(range(h), n):
            tate.append(list(item))
    yoko = [[-1]]
    for n in range(1, w + 1):
        for item in combinations(range(w), n):
            yoko.append(list(item))

    ans = 0
    for i in tate:
        for j in yoko:
            table = deepcopy(base_table)

            if i[0] != -1:
                for i_idx in i:
                    for s in range(w):
                        table[i_idx][s] = 0
            if j[0] != -1:
                for j_idx in j:
                    for t in range(h):
                        table[t][j_idx] = 0

            cnt = np.array(table).sum()
            if cnt == k:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int M1,D1,M2,D2;
  cin>>M1>>D1>>M2>>D2;
  if(M1!=M2){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {
                return;
            }
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    if(i % 2 == 1) {
                        if(j % 2 == 1) {
                            System.out.print("#");
                        }
                        else {
                            System.out.print(".");
                        }
                    } else {
                        if(j % 2 == 1) {
                            System.out.print(".");
                        }
                        else {
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34516
#include<bits/stdc++.h>
using namespace std;
int n,memo[50][50];
int solve(int dp,int sum);

int main(){
    while(1){
    cin >> n;
    if(n==0)break;
    cout << (solve(0,0)/(365*10))+1 << endl;
    fill(memo[0],memo[49],0);
    }

return 0;
}

int solve(int dp,int sum){
    if(sum==n)return 1;
    else if(sum>n)return 0;
    if(memo[dp][sum]!=0)return memo[dp][sum];
    return memo[dp][sum]=solve(dp+1,sum+1)+solve(dp+1,sum+2)+solve(dp+1,sum+3);
}

Measured memory_bytes: 1168
package main

import (
	"fmt"
)

func main() {
	q := readInt64() // 1/4
	h := readInt64() // 1/2
	s := readInt64() // 1
	d := readInt64() // 2
	n := readInt64()

	e := s
	if s > q*4 {
		e = q * 4
	} else if s > h*2 {
		e = h * 2
	}

	f := d
	if d > e*2 {
		f = e * 2
	}

	needYen := int64(n/2) * f
	if n%2 == 1 {
		needYen += e
	}

	fmt.Println(needYen)
}

func readInt64() int64 {
	var a int64
	fmt.Scan(&a)
	return a
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n;
long a[100010], b, c, t;

int main() {
  cin >> n;
  for (int i = 0; i < n + 1; ++i) cin >> a[i];
  c = 0;
  for (int i = 0; i < n; ++i) {
    cin >> b;
    t = min(b, a[i] + a[i + 1]);
    c += t;
    a[i + 1] -= t - min(b, a[i]);
  }
  cout << c;
}


Measured memory_bytes: 1024
#![allow(unused_mut, non_snake_case, unused_imports, dead_code)]

use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::swap;
use std::collections::{HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

fn main() {
    input!(S:chars);
    let mut S : Vec<char> = S;
    S.remove(4);
    S.remove(6);

    let S = S.iter().fold(0,|sum,&v| sum*10+(v as i32 - '0' as i32));
    println!("{}",if S <= 20190430 {"Heisei"}else{"TBD"});
}

Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn gcd(x: i64, y: i64) -> i64 {
  if x == 0 {
    y
  } else {
    gcd(y % x, x)
  }
}

fn main() {
  input! {
    n: usize,
    a: [i64; n],
  }
  let mut scan_left = vec![0; n+1];
  let mut scan_right = vec![0; n+1];
  for i in 0 .. n {
    scan_left[i+1] = gcd(scan_left[i], a[i]);
  }
  for i in (0 .. n).rev() {
    scan_right[i] = gcd(scan_right[i+1], a[i]);
  }
  let mut max = 0;
  for i in 0 .. n {
    max = cmp::max(max, gcd(scan_left[i], scan_right[i+1]));
  }

  println!("{}", max);
}


Measured memory_bytes: 8444
Sd = list(input())
T = list(input())

find = False
for i in range(len(Sd) - len(T) + 1)[::-1]:
    flag = True
    for j in range(len(T)):
        if Sd[i + j] != '?' and Sd[i + j] != T[j]:
            flag = False
            break
    if flag:
        find = True
        for j in range(len(T)):
            Sd[i + j] = T[j]
        break

if find:
    for i in range(len(Sd)):
        if Sd[i] == '?':
            print('a', end='')
        else:
            print(Sd[i], end='')
    print()
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int count=0;
		if(b>=a*c){
			count=c;
		}else{
			for(int i=1;i<c;i++){
				if(b<i*a){
					break;
				}
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        scanner.nextLine();
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        if (n[0] != 0 || Arrays.stream(n).filter(x -> x == 0).count() > 1) {
            System.out.println(0);
            return;
        }
        Arrays.sort(n);

        int index = 1;
        int num = 1;
        int pcnt = 1;
        int cnt = 0;
        long ans = 1;
        while (index < n.length) {
            while (index < n.length && n[index] == num) {
                cnt++;
                index++;
            }
            if (cnt == 0) {
                System.out.println(0);
                return;
            }
            for (int i = 0; i < cnt; i++) {
                ans = (ans * (long) pcnt) % 998244353;
            }
            pcnt = cnt;
            cnt = 0;
            num++;
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 48780
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	int k, cnt = 0;
	lli x, ans;
	queue<lli> q;
	cin >> k;
	loop(i, 1, 10) q.push(i);

	while(!q.empty()){
		x = q.front();
		cnt++;
		if(cnt == k){
			ans = x;
			break;
		}
		if(x%10 != 0) q.push(x*10+x%10-1);
		q.push(x*10+x%10);
		if(x%10 != 9) q.push(x*10+x%10+1);
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
const int N = 200005;

int n, a[N];

ll ans = 0;
ll cnt[N];

int main() {

	scanf("%d", &n);

	for(int i = 0; i < n; i++) scanf("%d", a + i);

	for(int i = 0; i < n; i++) {
		ans -= cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;
		cnt[ a[i] ]++;
		ans += cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;
	}

	for(int i = 0; i < n; i++) {
		ans -= cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;
		cnt[ a[i] ]--;
		ans += cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;

		printf("%lld\n", ans);
		
		ans -= cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;
		cnt[ a[i] ]++;
		ans += cnt[ a[i] ] * (cnt[ a[i] ] - 1) / 2;
	}
}


Measured memory_bytes: 6148
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;
ll gcd(ll, ll);
ll numFact(ll a);

int main()
{
	ll A, B;
	cin >> A >> B;
	ll g = gcd(A, B);
	ll numF = numFact(g);
	co(numF + 1);
	return 0;
}

ll gcd(ll a, ll b)
{
	if (a < b)return gcd(b, a);
	while (b != 0)
	{
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}

ll numFact(ll a)
{
	ll res = 0;
	ll i = 2;
	ll a_o = a;
	while ((a > 1) && i * i <= a_o)
	{
		ll cnt = 0;
		while (a%i == 0)
		{
			cnt++;
			a /= i;
			if (cnt == 1)res++;
		}
		i++;
	}
	if (a > 1)res++;
	return res;
}


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

int cou;

void d(int a[],int start,int end,int key)
{
	if(start>end) return;
	int mid=start+((end-start)>>1);
	if(a[mid]==key)
	{
		cou++;
		return;
	}else
	{
		if(key<a[mid]) d(a,start,mid-1,key);
		else d(a,mid+1,end,key);
	}
}
int main()
{
	int a;
	cin>>a;
	int _a[a];
	for(int i=0;i<a;i++) cin>>_a[i];
	sort(_a,_a+a);
	int b,key;
	cin>>b;
	for(int i=0;i<b;i++)
	{
		scanf("%d",&key);
		d(_a,0,a-1,key);
	}
	printf("%d\n",cou);
	return 0;
}


Measured memory_bytes: 3580
/*氏名：保坂優介, 学籍番号：200441141
  概要：長方形の面積と周を求めるプログラム*/

#include<stdio.h>

int main(void)
{
    int Vertical, width, circumference, area;       //変数の宣言

    scanf("%d %d", &Vertical, &width);      //入力

    circumference = 2 * Vertical + 2 * width;       //計算
    area = Vertical * width;

    printf("%d %d\n", area, circumference);       //出力

    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	int t;
    do
    {
        t=a%b;
        a=b;
        b=t;
    }while(t!=0);
    return a;
}
int main()
{
    int n,a,b,c,sum=0;
	cin>>n;	
	for(a=1;a<=n;a++)
	{
		for(b=1;b<=n;b++)
		{
			for(c=1;c<=n;c++)
			{
				sum=sum+gcd(c,gcd(a,b));
			}
		}
	}
    cout<<sum;
}

Measured memory_bytes: 3624
import math


a, b, x = map(int, input().split())
t = x / a / a
maxim = b-t

if t < b/2:
    ans = 90 - math.degrees((math.atan(2 * x / a / b / b)))
else:
    ans = math.degrees(math.atan(2 * maxim / a))

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="abc"||s=="acb"||s=="bca"||s=="bac"||s=="cba"||s=="cab")
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}	
	return 0;
    		
}

Measured memory_bytes: 256