akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  string sl = s.substr(0,2), sr = s.substr(2);
  bool yymm = "01" <= sr && sr <= "12";
  bool mmyy = "01" <= sl && sl <= "12";
  if (yymm && mmyy) puts("AMBIGUOUS");
  else if (yymm) puts("YYMM");
  else if (mmyy) puts("MMYY");
  else puts("NA");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,m;
    int i;

    scanf("%d %d",&n,&m);
    int a[n+1];
    int s[m+1],c[m+1];

    for(i=0;i<m;i++){
        scanf("%d %d",&s[i],&c[i]);
    }
    for(i=0;i<n;i++){
        a[i]=-1;
    }

    for(i=0;i<m;i++){
        if(n!=1 && s[i]==1 && c[i]==0){
            printf("-1");
            return 0;
        }
        else if(a[s[i]-1]==-1){
            a[s[i]-1]=c[i];
        }
        else if(a[s[i]-1]!=c[i]){
            printf("-1");
            return 0;
        }
    }

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

    if(n!=1 && a[0]==0){
        a[0] = 1;
    }

    for(i=0;i<n;i++){
        printf("%d",a[i]);
    }




    return 0;
}










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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[20][20];
int val[1<<20],dp[1<<20];
void solve(){
    cin>>n;
    rep(i,0,n){
        rep(j,0,n){
            cin>>a[i][j];
        }
    }
    rep(i,0,1<<n){
        rep(j,0,n){
            rep(k,j+1,n){
                if((i>>j)&1 and (i>>k)&1){
                    val[i]+=a[j][k];
                }
            }
        }
    }
    rep(i,0,1<<n){
        for(int j=i;j>=0;j=i&(j-1)){
            int group=i^j;
            dp[i]=max(dp[i],dp[group]+val[j]);
            if(j==0) break;
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double

constexpr int K_MAX = 1000;

//(x,y)に各希望が何個あるか
int black[2 * K_MAX][2 * K_MAX], white[2 * K_MAX][2 * K_MAX];
// 希望の2次元累積和
int sb[2 * K_MAX + 1][2 * K_MAX + 1], sw[2 * K_MAX + 1][2 * K_MAX + 1];

// sbとswを構築する
void construct_sum() {
	for (int x = 1; x <= 2 * K_MAX; ++x) {
		for (int y = 1; y <= 2 * K_MAX; ++y) {
			sb[x][y] =
				sb[x - 1][y] + sb[x][y - 1] - sb[x - 1][y - 1] + black[x - 1][y - 1];
			sw[x][y] =
				sw[x - 1][y] + sw[x][y - 1] - sw[x - 1][y - 1] + white[x - 1][y - 1];
		}
	}
}

int getsum_b(int x1, int y1, int x2, int y2) {
	if (x2 < 0 || y2 < 0) return 0;
	x1 = max(x1, 0); y1 = max(y1, 0);
	x2 = max(x2, 0); y2 = max(y2, 0);
	x1 = min(x1, 2 * K_MAX - 1); y1 = min(y1, 2 * K_MAX - 1);
	x2 = min(x2, 2 * K_MAX - 1); y2 = min(y2, 2 * K_MAX - 1);
	if (x1 > x2 || y1 > y2)
		return 0;
	return (sb[x2 + 1][y2 + 1] - sb[x1][y2 + 1] - sb[x2 + 1][y1] + sb[x1][y1]);
}
int getsum_w(int x1, int y1, int x2, int y2) {
	if (x2 < 0 || y2 < 0) return 0;
	x1 = max(x1, 0); y1 = max(y1, 0);
	x2 = max(x2, 0); y2 = max(y2, 0);
	x1 = min(x1, 2 * K_MAX - 1); y1 = min(y1, 2 * K_MAX - 1);
	x2 = min(x2, 2 * K_MAX - 1); y2 = min(y2, 2 * K_MAX - 1);
	if (x1 > x2 || y1 > y2)
		return 0;
	return (sw[x2 + 1][y2 + 1] - sw[x1][y2 + 1] - sw[x2 + 1][y1] + sw[x1][y1]);
}

// 座標(x,y)を白の左上としたときに、何個の希望が叶うか
int cnt(int k, int x, int y) {
	int ok = getsum_w(x, y, x + k - 1, y + k - 1);
	ok += getsum_w(x + k, y + k, x + 2 * k - 1, y + 2 * k - 1);
	ok += getsum_w(x - k, y - k, x - 1, y - 1);
	ok += getsum_w(x + k, y - k, x + 2 * k - 1, y - 1);
	ok += getsum_w(x - k, y + k, x - 1, y + 2 * k - 1);
	ok += getsum_b(x - k, y, x - 1, y + k - 1);
	ok += getsum_b(x + k, y, x + 2 * k - 1, y + k - 1);
	ok += getsum_b(x, y - k, x + k - 1, y - 1);
	ok += getsum_b(x, y + k, x + k - 1, y + 2 * k - 1);
	return ok;
}

signed main() {
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; ++i) {
		int x, y; char c;
		cin >> x >> y >> c;
		x %= 2 * k;
		y %= 2 * k;
		if (c == 'B') {
			++black[x][y];
		}
		else {
			++white[x][y];
		}
	}

	construct_sum();

	int ans = 0;
	for (int i = 0; i < k; ++i) {
		for (int j = 0; j < k; ++j) {
			int tmp = cnt(k, i, j);
			ans = max({ ans,tmp,n - tmp });
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int dfs(vector<vector<int>>&ans,int l,int r,int x=1){
    //[l,r)を塗る
    if(r-l==1){
        return 0;
    }
    int nx=0;
    chmax(nx,dfs(ans,l,(l+r+1)/2,x));
    chmax(nx,dfs(ans,(l+r+1)/2,r,x));
    x=nx+1;
    FOR(i,l,(l+r+1)/2){
        FOR(j,(l+r+1)/2,r){
            ans[i][j]=ans[j][i]=x;
        }
    }
    return x;
}
int main(){
    int n;
    cin>>n;
    vvi ans(n,vi(n));
    dfs(ans,0,n);
    REP(i,n){
        bool f=false;
        REP(j,n){
            if(i<j){
                if(f)cout<<" ";
                cout<<ans[i][j];
                f=true;
            }
        }cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

string s, ans;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i += 2) {
        ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 592
#include<stdio.h>

#define MAX 100000

int a[MAX];
int n;

int partition(int,int);

int main()
{
  int i,q;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&a[i]);
    }

  q = partition(0,n - 1);

  for(i = 0 ; i < n ; i++)
    {
      if(i)printf(" ");

      if(i == q)printf("[");
      printf("%d",a[i]);
      if(i == q)printf("]");
    }
  printf("\n");

  return 0;
  
}

int partition(int p,int r)
{
  int x,i,j,t;

  x = a[r];
  i = p - 1;
  for(j = p ; j < r ; j++)
    {
      if(a[j] <= x)
	{
	  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;
}



Measured memory_bytes: 2072
from sys import exit, setrecursionlimit
setrecursionlimit(1000000)

N = int(input())
A = [[int(e) - 1 for e in input().split()] for _ in range(N)]

node_id_db = [[0] * (N+1) for _ in range(N + 1)]
v = 0
for i in range(N):
    for j in range(i + 1, N):
        node_id_db[i][j] = v
        v += 1


def get_node_id(i, j, node_id_db):
    if i < j:
        return node_id_db[i][j]
    else:
        return node_id_db[j][i]


start_nodes = []
edges = [[] for _ in range(N * (N - 1) // 2)]
for i in range(N):
    Ai = A[i]
    from_id = get_node_id(i, Ai[0], node_id_db)
    if i < Ai[0]:
        start_nodes.append(from_id)
    for j in range(1, N - 1):
        to_id = get_node_id(i, Ai[j], node_id_db)
        edges[from_id].append(to_id)
        from_id = to_id

dp = [-1 for _ in range(N * (N - 1) // 2)]


def dfs(node_id, edges):
    t = dp[node_id]
    if t >= 0:
        return t
    dp[node_id] = 0
    result = 0
    for n in edges[node_id]:
        t = dfs(n, edges)
        if t == 0:  # looped
            print(-1)
            exit()
        if t > result:
            result = t
    result += 1
    dp[node_id] = result
    return result


print(max(dfs(n, edges) for n in start_nodes))


Measured memory_bytes: 139020
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[80];

LL ans = 0;

void solve(){
	//i-1日目に
	//株を全部売却した時の
	//所持金の最大値をdp[i]とする
	vector<LL> dp(N+1,0);
	dp[0] = 1000;
	//ばらまくイメージ
	//i+1日目になった時点での所持金の最大値を求める
	for(int i=0;i<N;i++){
		//最後に売った日付がj日目の時を考える
		for(int j=0;j<=i;j++){
			//j~i日目のうち最も株価が安い日に所持金を目一杯使って買っておく
			LL stock_minimum = INF;
			for(int k=j;k<=i;k++) stock_minimum = min(stock_minimum,A[k]);
			dp[i+1] = max(dp[i+1],dp[j]/stock_minimum*A[i] + dp[j]%stock_minimum);
		}
	}
	ans = dp[N];
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3196
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
  if 2*x[i] <= 2*(k-x[i]):
    ans += 2*x[i]
  else:
    ans += 2*(k-x[i])
print(ans)

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    char b;
    cin >> b;
    switch(b){
        case 'A':
            cout << 'T';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
        case 'T':
            cout << 'A';
            break;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,data[100];
	int i,x;
    scanf("%d",&n);

	for (i = 0;i < n;i++){
        scanf(" %d",&data[i]);

	}



	for(i=n-1;i>=0;i--){
        printf("%d",data[i]);
        if(i!=0){
            printf(" ");
        }
    }

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), c(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<array<ll, 3>> dp(n + 1);
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for (int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    
	return 0;
}

/*
	Raise your standard.
*/


Measured memory_bytes: 3840
N = int(input())
ans = 0
if N > 10:
    ans = N - (int(N / 10) * 10)
else:
    ans = N

if ans == 3:
    print('bon')
elif ans == 0 or ans == 1 or ans == 6 or ans == 8:
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9096
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
l={}
r={}
N.times do|i|
    l_=A[i]+i+1
    l[l_]=0 if l[l_].nil?
    l[l_]+=1
    r_=i+1-A[i]
    r[r_]=0 if r[r_].nil?
    r[r_]+=1
end
ans=0
l.each do|k,v|
    if not r[k].nil?
        ans+=v*r[k]
    end
end
puts ans

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


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

    ll n, d, i=1;

    cin >> n >> d;

    int cnt = 0;


    while(i<=n)
    {
        ll a, b;

        cin >> a >> b;

        a = a*a;

        b   = b*b;

        long double v = sqrt(a + b);


        if(v <= d)
        {
            cnt++;

            //cout << v << " ";
        }

        i++;
    }

    cout << cnt;

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i,n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first;
#define sc second;

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

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

int64 n, m;
int64 res = 0;
vector<vector<int64>> table;
vector<int64> cnt;

void dfs(int64 p) {
  if (cnt[p] > (n-1)/2) return;
  if (p == n-1) {
    REP(i, n) {
      if (cnt[i] != (n-1)/2) return;
    }
    res++;
    return;
  }
  vector<int64> undec;
  FOR(i, p+1, n) {
    if (table[p][i] == 0) undec.push_back(i);
  }
  if (n/2-cnt[p] > undec.size()) return;
  vector<int64> comb(undec.size());
  REP(i, n/2-cnt[p]) comb[undec.size()-i-1] = 1;
  do {
    REP(i, undec.size()) {
      if (comb[i] == 0){
        table[p][undec[i]] = -1;
        cnt[undec[i]]++;
      } else {
        table[p][undec[i]] = 1;
        cnt[p]++;
      }
    }
    dfs(p+1);
    REP(i, undec.size()) {
      if (comb[i] == 0){
        table[p][undec[i]] = 0;
        cnt[undec[i]]--;
      } else {
        table[p][undec[i]] = 0;
        cnt[p]--;
      }
    }
  } while (next_permutation(all(comb)));
}

int main(void){
  cin.tie(0);

  while (cin >> n && n) {
    cin >> m;
    table = vector<vector<int64>>(n, vector<int64>(n, 0));
    cnt = vector<int64>(n, 0);
    REP(i, m) {
      int64 x, y;
      cin >> x >> y; x--; y--;
      table[x][y] = 1;
      table[y][x] = -1;
      cnt[x]++;
    }
    res = 0;
    dfs(0);
    cout << res << endl;
  }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define lli long long int  
int main() {
	// your code goes here
	lli x,i;
	cin>>x;
	i=360;
	while(1)
	{
		if(i%x==0)
		{
			cout<<i/x;
			break;
		}
		i=i+360;
	}
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
ll n,d,x,y;
ll cnt;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>d;
	d*=d;
	while(n--){
		cin>>x>>y;
		if(x*x+y*y<=d)cnt++;
	}
	cout<<cnt;
	return 0;
}



Measured memory_bytes: 3648
import heapq
n = int(input())
a = list(map(int,input().split()))
aka = a[:n]
heapq.heapify(aka)
akasum = [0] * (n+1)
akasum[0] = sum(aka)
ao = a[2*n:]
aosum = [0] * (n+1)
aosum[-1] = sum(ao)
for i in range(len(ao)):
  ao[i] = -ao[i]
heapq.heapify(ao)
for i in range(n,2*n):
  b = heapq.heappop(aka)
  if b >= a[i]:
    heapq.heappush(aka, b)
    akasum[i-n+1] = akasum[i-n] 
  else:
    heapq.heappush(aka, a[i])
    akasum[i-n+1] = akasum[i-n] + a[i] - b
  b = heapq.heappop(ao)
  if b >=  -a[-i-1]:
    heapq.heappush(ao, b)
    aosum[-i+n-2] = aosum[-i+n-1]
  else:
    heapq.heappush(ao, -a[-i-1])
    aosum[-i+n-2] = aosum[-i+n-1] + a[-i-1] + b
ans = - float("inf")
for i in range(n+1):
  kota = akasum[i] - aosum[i]
  ans = max(kota,ans)
print(ans)

Measured memory_bytes: 39132
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題167


            string[] line = Console.ReadLine().Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);

            int K = int.Parse(Console.ReadLine());

            for (int i = 0; i < K; i++)
            {
                if (A >= B)
                {
                    B *= 2;
                }
                else if (B >= C)
                {
                    C *= 2;
                }

            }

            if (A < B && B < C)
            {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
            
        }


    }
}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

   cout<<a+a*a+a*a*a;
  

return 0;
}


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

int main(){
    int ans=0,n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        if(i%2==0){
            ans+=a.at(i);
        }else{
            ans-=a.at(i);
        }
    }
    b.at(0)=ans;
    for(int i=1;i<n;i++){
        b.at(i)=2*a.at(i-1)-b.at(i-1);
    }

    for(int i=0;i<n;i++){
        cout << b.at(i) << " ";
    }
        cout << endl;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s1 = scanner.next();
        final String s2 = scanner.next();

        boolean isVertical = false;
        long count = 1;
        for (int i = 0; i < n; ) {
            final char c1 = s1.charAt(i);
            final char c2 = s2.charAt(i);

            if (i == 0) {
                isVertical = c1 == c2;
                count = isVertical ? 3 : 6;
            } else {
                if (c1 == c2) {
                    count *= isVertical ? 2 : 1;
                    isVertical = true;
                } else {
                    count *= isVertical ? 2 : 3;
                    isVertical = false;
                }
            }

            count %= MOD;
            i += isVertical ? 1 : 2;
        }

        System.out.println(count);
    }
}



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

public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		String[] a = new String[h];
		for (int i = 0; i < h; i++) {
			a[i] = in.next();
		}

		boolean[] row = new boolean[h];
		Arrays.fill(row, false);
		boolean[] col = new boolean[w];
		Arrays.fill(col, false);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i].charAt(j) == '#') {
					row[i] = true;
					col[j] = true;
				}
			}
		}

		for (int i = 0; i < h; i++) {
			if (row[i]) {
				for (int j = 0; j < w; j++) {
					if (col[j]) {
						System.out.print(a[i].charAt(j));
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 24128
#include<stdio.h>



int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if ((a == b) && (b == c))
	{
		printf("No");
	}
	else if((a!=b)&&(a!=c)&&(b!=c))
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}

	return 0;
}

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

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

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

void solve(long long H, long long W, vector<string> map) {
    int ans = 0;
    rep(si, H) rep(sj, W) {
        if (map[si][sj] == '#') {
            continue;
        }
        vector<vector<int>> dist(H, vector<int>(W, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j));
        };
        update(si, sj, 0);

        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            for (int dir = 0; dir < 4; dir++) {
                int ni = i + di[dir];
                int nj = j + dj[dir];
                if (ni < 0 || nj < 0 || ni >= H || nj >= W) {
                    continue;
                }
                if (map[ni][nj] == '#') {
                    continue;
                }
                update(ni, nj, dist[i][j] + 1);
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (dist[i][j] == INF) continue;
                ans = max(ans, dist[i][j]);
            }
        }
    }
    cout << ans << endl;
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    solve(h, w, s);
    return 0;
}


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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

class UnionFind{
private:
    ::std::vector<int_fast32_t> par, edge;
    size_t n;

public:
    UnionFind(){}
    UnionFind(size_t n):n(n){
        par.resize(n, -1);
        edge.resize(n, 0);
    }

    uint_fast32_t find(uint_fast32_t x){
        return par[x] < 0 ? x : par[x] = find(par[x]);
    }

    size_t size(uint_fast32_t x){
        return -par[find(x)];
    }

    bool unite(uint_fast32_t x, uint_fast32_t y){
        x = find(x);
        y = find(y);
        edge[x] += 1;
        if(x == y) return false;
        if(size(x) < size(y)) std::swap(x, y);
        par[x] += par[y];
        edge[x] += edge[y];
        par[y] = x;
        return true;
    }

    bool same(uint_fast32_t x, uint_fast32_t y){
        return find(x) == find(y);
    }

    size_t esize(uint_fast32_t x) {
        return edge[find(x)];
    }
};

int main(void) {
    int64 N, M;
    cin >> N >> M;
    UnionFind uf(N);
    REP(i, M) {
        int64 x, y, z;
        cin >> x >> y >> z; x--; y--;
        uf.unite(x, y);
    }
    int64 res = 0;
    REP(i, N) {
        if (uf.find(i) == i) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 62;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll c(n-1),s(n-1),f(n-1);
  rep(i,n-1){
    cin>>c[i]>>s[i]>>f[i];
  }
  rep(i,n){
    ll cu=0;
    for(int j=i;j<n-1;j++){
      if(cu<=s[j]){
        cu=s[j];
      }
      else{
        ll k=cu-s[j];
        cu=s[j]+(k+f[j]-1)/f[j]*f[j];
      }
      cu+=c[j];
    }
    COUT(cu);
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int min_v = a[0], max_v = a[0], min_i = 1, max_i = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] < min_v) {
			min_v = a[i];
			min_i = i + 1;
		}
		if (a[i] > max_v) {
			max_v = a[i];
			max_i = i + 1;
		}
	}
	cout << 2 * (n - 1) << endl;
	if (-min_v > max_v) {
		for (int i = 1; i <= n; i++) {
			if (i != min_i) {
				cout << min_i << " " << i << endl;
			}
		}
		for (int i = n; i >= 2; i--) {
			cout << i << " " << i - 1 << endl;
		}
	} else {
		for (int i = 1; i <= n; i++) {
			if (i != max_i) {
				cout << max_i << " " << i << endl;
			}
		}
		for (int i = 1; i <= n - 1; i++) {
			cout << i << " " << i + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/tasks/abc137_d
// 優先度付きキュー
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

// N件の日雇いバイト, M日後の報酬合計最大数
int N, M;
// i 件目の日雇いアルバイトを請けて働くと、その Ai 日後に報酬 Bi が得られます。

// i日で報酬をもらえる期限の仕事たち
vector<vector<int>> jobs;

int main() {
  cin >> N >> M;
  // 日にちごとの仕事を考えるのでMでリサイズ
  jobs.resize(M);

  rep(i, N) {
    // a日後に報酬bを得る
    int a, b;
    cin >> a >> b;
    if (a > M) {
      // そもそも間に合わない場合には追加しない
      continue;
    }
    // 期限: 報酬を得られる最終日 - 報酬の支払い差
    jobs[M - a].push_back(b);
  }

  priority_queue<int> q;
  long ans = 0;

  // i: 日にち. 前日からはじめて初日まで調べる
  for (int i = M - 1; i >= 0; i--) {
    // b: i日目が期限の仕事の報酬額をキューに追加
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      // 報酬額の高いものから行う
      ans += q.top();
      // 行った仕事は削除する
      q.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5504
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	ll m; cin>>m;
	if(n==m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    long long int a;
    const long long int INF=1LL<<60;
    while (cin>>n>>k) {
        if (n==0&&k==0) {
            break;
        } else {
            std::deque<long long int> deq;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            std::deque<long long int> s(n+1,0);
            long long int ans=-INF;
            for (int i=0;i<n;i++) {
                s[i+1]=s[i]+deq[i];
            }
            for (int i=0;i<=n-k;i++) {
                ans=max(ans,s[k+i]-s[i]);
            }
            cout<<ans<<endl;
        }
    }
}


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

int main(void)
{
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0; i < s.size(); i++) {
		if (i%2 == 0)
			ans.push_back(s[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
string S;
int A[234567];
int B[234567];


int main() {
	cin >> N;
	cin >> S;
	for (int i = N - 1; i >= 0; --i) {
		if (S[i] == '#') {
			A[i + 1] = 1;
		}
		else {
			B[i + 1] = 1;
		}
	}
	for (int i = 1; i <= N; ++i) {
		A[i] += A[i - 1];
		B[i] += B[i - 1];
	}
	int ans = 234567;
	for (int i = 0; i <= N; ++i) {
		int can = A[i] + (B[N] - B[i]);
		ans = min(ans, can);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2180
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll n, ans = INF;
vector<ll>a, b;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            a.emplace_back(i);
            b.emplace_back(n/i);
        }
    }
    for (int i = 0; i < a.size(); ++i)
        ans = min(ans , abs(a[i] - 1) + abs(b[i] - 1));
    cout << ans << '\n';
}

Measured memory_bytes: 384
K = int(input())
S = input()
N = len(S)
mod = int(1e9+7)

### 123
### a1bb2ccc3dddd 10文字インサート
# pow(25,6) * pow(26,4) * 8C2
# (3はfixで、それより前の8mojiから1/2を入れる場所を決める）
# これを3の位置でループする（1-indexで 3<=i<=N)

# 123dddddddddd
# pow(25,0) * pow(26,10) * 2C2(1)
# 12x3ddddddddd
# pow(25,1) * pow(26,9) * 3C2( = 2C2 * 3 / 1)
# 12xx3dddddddd
# pow(25,2) * pow(26,8) * 4C2( = 3C2 * 4 / 2)
# ...
# 12xxxxxxxxxx3
# pow(25,10) * pow(26,0) * 12C2( = 11C2 * 12 / 10)

# 5C5, 6C5, 7C5 1, 6, 21, 56

wk = pow(26,K,mod)
inv26 = pow(26,-1,mod)

ans = wk
for i in range(1,K+1):
  wk = (wk * 25 * inv26) % mod
  wk = (wk * (N-1+i) * pow(i,-1,mod) % mod)
  ans = (ans + wk)%mod
    
print(ans)


Measured memory_bytes: 11060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;						\
										 c>0?i<b:							\
										 i>b;								\
										 i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
     
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
     
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

class Mycin {
	bool flag = true;
public:
	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
	operator bool() {return flag;}
} mycin;

class Mycout {
public:
	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
	Mycout& operator << (const char c) {printf("%c", c); return *this;}
	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
} mycout;

#define cin mycin
#define cout mycout
#define endl '\n'

vector<set<int>> a = {
	{1, 3, 5, 7, 8, 10, 12},
	{4, 6, 9, 11},
	{2}
};

int find_id(int v) {
	rep(i, a.size()) {
		if (a[i].count(v) == 1) return i;
	}
	return -1;
}

int x, y;

void solve() {
	cin >> x >> y;
	if (find_id(x) == find_id(y)) cout << "Yes" << endl;
	else cout << "No" << endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int s;
    scanf("%d", &s);
    int a = s/100;
    int b = s%100;
    int c = 0;
    if(a > 0 && a < 13)c++;
    if(b > 0 && b < 13)c+=2;
    if(c == 0)printf("NA\n");
    if(c == 1)printf("MMYY\n");
    if(c == 2)printf("YYMM\n");
    if(c == 3)printf("AMBIGUOUS\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

queue<int> Q;
int n,u,k,v,tem;
int D[110];
vector<int> edges[110];
void solve() {
    D[1] = 0;
    while (! Q.empty()) {
        int cur = Q.front();
        Q.pop();
        while(edges[cur].size()){
            tem=edges[cur].back();
            edges[cur].pop_back();
            if(D[tem]==-1){
                Q.push(tem);
                D[tem]=D[cur]+1;
            }
        }
    }
        for (int i=1;i<=n;i++) {
            cout<<i<<' '<<D[i]<<endl;
        }
}


int main(){
    for(int i=0;i<110;i++){
        D[i]=-1;
    }
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
        cin>>v;
        edges[u].push_back(v);
    }
}
    Q.push(1);
    solve();
        return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> ans(2);
  rep(i, b) {
    ans[0] += to_string(a);
  }
  rep(i, a) {
    ans[1] += to_string(b);
  }
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    int n;
    scanf("%d", &n);
    int a, b, c, d;

    a = n % 10;
    n = n / 10;
    b = n % 10;
    n = n / 10;
    c = n % 10;
    n = n / 10;
    d = n % 10;

    if(a == b || b == c || c == d ) {
        printf("Bad\n");
    } else {
        printf("Good\n");
    }

    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

struct dsu
{
public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b)
    {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y)
            return x;
        if (-parent_or_size[x] < -parent_or_size[y])
            std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b)
    {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a)
    {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0)
            return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a)
    {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups()
    {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++)
        {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++)
        {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++)
        {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int> &v) { return v.empty(); }),
            result.end());
        return result;
    }

private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

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

    ll N,M;
    string S;
    cin >> N>>M;

    dsu d(N+1);

    REP(i,M){
        ll a, b;
        cin >> a >> b;
        d.merge(a, b);
    }

    set<ll> s;

    REPS(i,N){
        ll tmp = d.leader(i);
        s.insert(tmp);
    }
    cout << s.size()-1 << endl;
}


Measured memory_bytes: 7528
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int a, b;
	cin >> a >> b;
	for(int i=1; i<=1e4; ++i) {
		int a2=i*8/100, b2=i*10/100;
		if(a2==a&&b2==b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <tuple>

#define MAX_N 22

using namespace std;

int HV[][2]{
        {1,  0},
        {0,  1},
        {-1, 0},
        {0,  -1},
};

int solve(char maze_[][MAX_N], int H, int W, int sy, int sx) {

    int ret = 0;

    char maze[MAX_N][MAX_N];
    memcpy(maze, maze_, MAX_N * MAX_N);

    queue<tuple<int, int, int>> que;
    que.emplace(sy, sx, 0);
    maze[sy][sx] = '#';

    while (!que.empty()) {
        int y, x, c;
        y = get<0>(que.front());
        x = get<1>(que.front());
        c = get<2>(que.front());
        que.pop();
        ret = max(ret, c);
        for (int *hv : HV) {
            int ny, nx;
            ny = y + hv[0];
            nx = x + hv[1];
            if (maze[ny][nx] == '.') {
                que.emplace(ny, nx, c + 1);
                maze[ny][nx] = '#';
            }
        }
    }

    return ret;
}

int main() {
    int H, W;
    cin >> H >> W;

    char maze_[MAX_N][MAX_N];
    fill(maze_[0], maze_[MAX_N - 1] + MAX_N, '#');

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> maze_[i][j];
        }
    }

    int ans = 0;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (maze_[i][j] == '.') {
                ans = max(ans, solve(maze_, H + 2, W + 2, i, j));
            }
        }
    }

    cout << ans << endl;
}

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

#define ct cout
#define in cin
#define el endl
#define rep(i, N) for (int i = 0; i < N; i++)
#define ol(N) cout << N << endl

int main()
{
	int a, b, c, z = 1;

	in >> a >> b >> c;

	if (a != b) z++;
	if (a != c && b != c) z++;

	ol(z);

	return (0);
}


Measured memory_bytes: 256
use proconio::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
    }
    let a = N % 10;
    println!("{}",
        match a {
            2 | 4 | 5 | 7 | 9 => "hon",
            0 | 1 | 6 | 8 => "pon",
            3 => "bon",
            _ => "",
        }
    );
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && a + b >= c)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int n;

int main(){
  int ave;
  while(cin >> n && (n > 0)){
  int a[100];
  int sum = 0;
  for (int i = 0; i <= n-1; i++){
   cin >> a[i];
   }
   sort(a, a+n);
   for (int j=1; j <= n-2; j++){
     sum += a[j];
	 }
   ave = floor(sum / (n-2));
   cout << ave << endl;
	}
 }

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);

    for (int i = 0; i < N; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }

    int cx = 0;
    int cy = 0;

    for (int i = 0; i < N; ++i) {
        int d = abs(cx - x[i]) + abs(cy - y[i]);

        if (!(d <= t[i] && (d % 2 == t[i] % 2))) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a>>b >> c;
    if(a <= c && c <= b)    cout << "Yes\n";
    else{
        cout << "No\n";
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int time, fee_a, fee_b;
  scanf("%d %d %d", &time, &fee_a, &fee_b);
  if(time * fee_a < fee_b) {
    printf("%d\n", time * fee_a);
  } else {
    printf("%d\n", fee_b);
  }
  return 0;
}


Measured memory_bytes: 128