akhauriyash/Code-Regression huggingface dataset:
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;
using namespace __gnu_pbds;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
  	ll n;
  	cin>>n;
  	cout<<((n-2)*180);
  
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

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)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

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

    set <string> st;

    REP(i,n){
        string s;
        cin >> s;

        st.insert(s);
    }

    cout << st.size() <<endl;
}





Measured memory_bytes: 19172
#include<stdio.h>
#define N 100000
#define M 50000

int binarySearch(int*, int, int);

int main(){
    int A[N];
    int B[M];
    int i, j, x, y;
    int judge = 0;
    int cont = 0;
    int flag = 0;
    
    scanf("%d", &x);
    for(i=0 ; i<x ; i++){
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &y);
    for(j=0 ; j<y ; j++){
        scanf("%d", &B[j]);
        judge = binarySearch(A, B[j], x);
        if(judge != 0){
            cont++;
            flag = 1;
        }
    }
    
    if(flag==0){
        printf("0\n");
    }else{
        printf("%d\n", cont);
    }
    
    return 0;
}

int binarySearch(int* aa, int key, int n){
    int i;
    int mi;
    int left = 0,right;
    
    right = n;
    
    while(left<right){
        mi = (left + right) / 2;
        if(aa[mi]==key){
            return 1;
        }else if(key<aa[mi]){
            right = mi;
        }else{
            left = mi + 1;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2316
import itertools

N,M,X=map(int,input().split(' '))

book=[]
skil=[0]*M
for i in range(N):
    line=list(map(int,input().split(' ')))
    book.append(line)
    skil=list(map(lambda x,y:x+y,skil,line[1:]))

min_p=12000000
for n in range(1,N+1):
    for conbo in itertools.combinations(book,n):
        conbo_book=[0]*(1+M)
        for b in list(conbo):
            conbo_book=list(map(lambda x,y:x+y,conbo_book,b))
        if len([m for m in conbo_book[1:] if m>=X])==M:
            if min_p>conbo_book[0]:
                min_p=conbo_book[0]

print(min_p) if min_p<12000000 else print("-1")

Measured memory_bytes: 9248
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 m=sc.nextInt();
			int s=sc.nextInt();
			if(h==-1&&m==-1&&s==-1){
				break;
			}
			int remainder=2*3600-h*3600-m*60-s;
			int remainderH=remainder/3600;
			int remainderM=(remainder-remainderH*3600)/60;
			int remainderS=remainder-remainderH*3600-remainderM*60;
			System.out.println("0"+remainderH+":"+(remainderM>=10?remainderM:"0"+remainderM)+":"+(remainderS>=10?remainderS:"0"+remainderS));
			remainder=(2*3600-h*3600-m*60-s)*3;
			remainderH=remainder/3600;
			remainderM=(remainder-remainderH*3600)/60;
			remainderS=remainder-remainderH*3600-remainderM*60;
			System.out.println("0"+remainderH+":"+(remainderM>=10?remainderM:"0"+remainderM)+":"+(remainderS>=10?remainderS:"0"+remainderS));
		}
	}
}

Measured memory_bytes: 17236
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#define ll long long
using namespace std;
int main(){
	ll n;
	cin>>n;
	int cnt[4]={0};
	while(n--){
		string temp;
		cin>>temp;
		if(temp=="AC") cnt[0]++;
		else if(temp=="WA") cnt[1]++;
		else if(temp == "TLE") cnt[2]++;
		else cnt[3]++;
	}
	cout<<"AC x "<<cnt[0]<<endl;
	cout<<"WA x "<<cnt[1]<<endl;
	cout<<"TLE x "<<cnt[2]<<endl;
	cout<<"RE x "<<cnt[3]<<endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	int N;
	cin >> N;
	pi arr;
	int v;
	for(int i = 1; i <= N; i++){
		cin >> v;
		arr.PB(v);
	}
	auto max = max_element(arr.begin(), arr.end());
	auto min = min_element(arr.begin(), arr.end());
	
	int best_score = -1;
	for(int P = *min; P <= *max; P++){
		int moment_score = 0;
		for(int i= 0; i < N; i++){
			moment_score += (arr[i]-P)*(arr[i]-P);
		}
		if(best_score == -1 || best_score > moment_score){
			best_score = moment_score;
		}
	}
	cout << best_score;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
}

Measured memory_bytes: 26412
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size();
    set<char> st;
    rep(i,n) st.insert(s[i]);
    if(n==st.size()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int[] count = new int[26];
		for (int i = 0; i < H; i++) {
			String str = in.next();
			for (int j = 0; j < W; j++) {
				count[str.charAt(j)-'a'] ++;
			}
		}
		
		boolean ans = true;
		int safe2 = 0;
		int safe1 = 0;
		if(H%2 == 1) {
			if(W%2 == 1) {
				safe1 = 1;
				safe2 = H + W -2;
			}else {
				safe2 = W;
			}
		}else{
			if(W%2 == 1) {
				safe2 = H;
			}
		}
		
		for (int i = 0; i < 26; i++) {
			count[i] = count[i] % 4;
			if(count[i] == 0) continue;
			if(count[i] == 1) safe1 --;
			if(count[i] == 2) safe2 -= 2;
			if(count[i] == 3 || safe1<0 || safe2<0) {
				ans = false;
				break;
			}
		}
		System.out.println(ans? "Yes":"No");
		
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
int main(void){
    int i,j,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0) break;
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i==1||i==H||j==1||j==W){
                    putchar('#');
                }
                else{
                    putchar('.');
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



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

//最大公約数
long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b){
            a = a%b;
        }else{
            b = b%a;
        }
    }
    return a+b;
}


//最小公倍数 : gcdを含める必要がある
long long lcm(long long a,long long b){
    return a / gcd(a,b) * b;
}

int main()
{
    int n;
    std::cin>>n;
    long long l;
    std::cin>>l;
    for(int i=1;i<n;i++){
        long long tmp;
        std::cin>>tmp;
        l = lcm(l,tmp);
    }
    std::cout<<l<<std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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(){
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    vector<int> c(26);  
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,26) cin >> c[i];    
    rep(d,D) rep(i, 26) cin >> s[d][i];

    vector<int> t(D);
    vector<int> last(26,-1);
    const int INF = INT32_MAX;
    int ans = 0;
    rep(d,D) {
        int max_ans = -INF;
        int t;
        rep(i,26) {
            int tmp = s[d][i] + c[i] * (d-last[i]);
            if(tmp > max_ans) {
                max_ans = tmp;
                t = i;
            }
        }
        cout << t+1 << endl;
        last[t] = d;
    }
}


Measured memory_bytes: 3708
n = int(input())
a = []
for i in range(n):
  x, y = map(int, input().split())
  if x == y:
    a.append(1)
  else:
    a.append(0)
  if len(a) > 2:
    if a[-1] + a[-2] + a[-3] == 3:
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 9176
/*                                                                              
座標から面積                                                                    
a=(x1,y1) b=(x2,y2)　とすると                                                   
S= a*b*sin&#8710;AOB = a*b*√(1-cos^2 &#8710;AOB) = √( (ab)^2 - (a,b)^2 ) =...= √((x1*y2-x2*\
y1)^2)                                                                          
*/
#include<iostream>
#include<iomanip>
#include<cmath>
#define rep(i,j) for(i=0;i<j;i++)
using namespace std;

int main(){
  int n,i,cnt=1;
  while(true){
    cin >> n;
    if(!n)break;
    int vertices_x[n];
    int vertices_y[n];
    double area=0;
    rep(i,n){
      cin >> vertices_x[i] >> vertices_y[i];
    }
    rep(i,n-1){
      area+=vertices_x[i]*vertices_y[i+1]-vertices_x[i+1]*vertices_y[i];
    }
    area+=vertices_x[n-1]*vertices_y[0]-vertices_x[0]*vertices_y[n-1];
    cout << cnt++<<" "<<fixed<<setprecision(1)<<abs(area/2)<<endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
	int answer = 0;
	string S, T;
	cin >> S >> T;
	for (int count = 0; count < 3; count++)
	{
		if (S.at(count) == T.at(count))
		{
			answer++;
		}
	}
	cout << answer << endl;
}

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

int main() {
	bool flag=false;
	int l,b=0;
	char moji[] = { 'K','I','H','B','R' };
	string akiba;

	cin >> akiba;
	l = akiba.size();
	if (l > 9) {
		cout << "NO" << endl;
		b = 5;
		return 0;
	}
	for (int i = 0; i < l; i++) {
		if (akiba[i] == 'A') {
			if (b == 1 || b == 2) {
				cout << "NO" << endl; 
				b = 5;
				flag = true;
				break;
			}
			if (akiba[i + 1] == 'A') {
				cout << "NO" << endl;
				b = 5;
				flag = true;
				break;
			}
		}
		else if (akiba[i] == moji[b]) {
			if (b == 4 ) {
				b++;
				if (l - i == 1) {//文末
					cout << "YES" << endl;
					flag = true;
					break;
				}
				else if (l - i == 2 && akiba[i+1]=='A') {//一文字ある
					cout << "YES" << endl;
					flag = true;
					break;
				}
				else {
					cout << "NO" << endl;
					flag = true;
					break;
				}
			}
			b++;
		}
		else {
			cout << "NO" << endl;
			b = 5;
			break;
		}
	}
	if (b<5)cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
#define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end())
template<typename A,typename B> inline bool chmax(A &a,const B &b){if(a<b){a=b;return 1;}return 0;}
template<typename A,typename B> inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;}

const int MOD = (int)1e9 + 7;
const int INF = 1 << 30;
const ll INFF = 1LL << 62;

/*
zzzzzzzzzzzzza azzzzzzzzzzzzz
zzzzzzzzzzzzaa aazzzzzzzzzzzz
zzzzzzzzzzaaaa aaaazzzzzzzzzz
aの数は指数的に増えていく
*/

/*
・groupby
[備考] stringについて用いる場合は, vector<char>に以下のようにして一旦移し替える.
      string str;
      vector<char> vec(str.begin(), str.end());
[使用例]
vector<int> vec = {1, 2, 2, 3, 3, 3, 3};
auto gb = groupby(vec);                       // {{1, 1}, {2, 2}, {3, 4}}
*/

template<typename T> vector< pair< T, int > > groupby(const vector< T > &vec) {
  vector< pair< T,int > > ret;
  int piv = -1;
  for (auto& e: vec) {
    if (piv == -1 || ret[piv].first != e) ++piv, ret.emplace_back(make_pair(e, 1));
    else ++(ret[piv].second);
  }
  return ret;
}

int N, K;
string S;

signed main() {

    cin >> N >> K >> S;

    char mn = 'z';
    EACH(e, S) chmin(mn, e);

    // 2 ** 13 == 8192
    if (K >= 13) {
        cout << string(N, mn) << endl;
        return 0;
    }

    K = min(K, 13);

    reverse(ALL(S));
    REP(i, K) {
        string S_rev = S;   reverse(ALL(S_rev));
        string T = S_rev + S;
        vector<char> vec(ALL(T));
        auto gb = groupby(vec);
        vector<pair<int, int>> cand;
        int piv = 0;
        EACH(g, gb) {
            if (g.first == mn) {
                cand.emplace_back(make_pair(g.second, piv));
            }
            piv += g.second;
        }
        RSORT(cand);
        int mx = cand[0].first;
        piv = 0;
        int sz = cand.size();
        string best = "{";
        while (piv < sz and cand[piv].first == mx) {
            if (cand[piv].second + N <= 2 * N) {
                chmin(best, T.substr(cand[piv].second, N));
            }
            piv++;
        }
        S = best;
    }

    cout << S << endl;

}

Measured memory_bytes: 520
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int a[100050];
int main()
{
    int n,x,nn=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        a[x]++;
        a[x-1]++;
        a[x+1]++;
    }
    for(int i=0;i<=100000;i++)
    nn=max(nn,a[i]);
    printf("%d\n",nn);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    string s;
    cin >> n >> s;
    vector<vector<ll>> idx(10);
    rep(i, n) {
        idx[s[i] - '0'].push_back(i);
    }
    ll ans = 0;
    rep(i, 1000) {
        string sub = to_string(i);
        rep(j, 3 - len(sub)) sub = "0" + sub;
        ll pos = 0;
        bool f = true;
        rep(j, 3) {
            ll v = sub[j] - '0';
            auto it = lower_bound(all(idx[v]), pos);
            if (it == idx[v].end()) {
                f = false;
                break;
            }
            pos = *it + 1;
        }
        if (f) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y;
    cin>>x>>y;
    if(y & 1){
        cout<<"No"<<endl;
        return 0;
    }
    y/=2;
    if(y>=x && y-x<=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3564
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

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

  ll n;
  cin >> n;
  vector<ll> p(n), v(n);
  rep(i, n) {
    cin >> p.at(i);
    --p.at(i);
    v.at(i) = p.at(i)==i ? 1:0;
  }
  vector<ll> vv;
  ll cnt=0;
  rep(i, n) {
    if (v.at(i)==0) {
      vv.push_back(cnt);
      cnt=0;
    }else ++cnt;
  }
  vv.push_back(cnt);
  vv.erase(remove(all(vv), 0), vv.end());
  ll ans=0;
  for (const auto& i: vv){
    ans += i/2 + i%2;
  }

  cout << ans << endl;


  return 0;
}

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;
using Si = set<int>;
using vSi = vector<Si>;
using vvSi = vector<vSi>;

#define fi first
#define se second
#define INF 1e9 + 5
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n;
	while(cin >> n) {
		cout << n*n*n << '\n';
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const  int maxn=1e5+10;
int depth[maxn];
int out_put[maxn];
struct Node
{
    int x,y;
};
vector<int>s[maxn];
void dfs(int now,int pre)
{
    for(int i=0; i<s[now].size(); i++)
    {
        int x=s[now][i];
        if(x==pre)
        continue;
        if(depth[x]==0)
        {
            depth[x]=depth[now]+1;
            dfs(x,now);
        }
        else
        {
            if(depth[x]>depth[now])
            {
                printf("%d %d\n",now,x);
                out_put[now]++;
            }
        }
    }
    if(pre==0)
        return ;
    if(out_put[now]%2)
    {
        printf("%d %d\n",now,pre);
        out_put[now]++;
    }
    else
    {
        printf("%d %d\n",pre,now);
        out_put[pre]++;
    }


}
int main()
{
    int m,n;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;
        s[x].push_back(y);
        s[y].push_back(x);
    }
    if(m%2)
    {
        puts("-1");
        return 0;
    }
    depth[1]=1;
    dfs(1,0);
    return 0;
}


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

int n;
inline int lowbit(int x){
	return x & (-x);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int t = log(lowbit(i^j)) / log(2) + 1;
			printf("%d ",t);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 512
# coding: utf-8

def main():
    N = int(input())
    v = list(map(int, input().split()))
    v.sort()
    ans = v[0] / 2 ** (N - 1)
    for i in range(1, N):
        ans += v[i] / 2 ** (N - i)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9148
#include <stdio.h>

int main(void){
	int i,n,g[10]={1,2,4,8,16,32,64,128,256,512};
	while(scanf("%d",&n),n){
		i=0;
		while(1){
			if(n%2==1){
				printf("%d",g[i]);
				if(n/2!=0)printf(" ");
			}
			n/=2;
			if(n==0)break;
			i++;
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

pr num[100005];

int main() {
  int n;
  scanf("%d",&n);
  int sz=0;
  for(int i=1;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	bool ok=0;
  	for(int j=1;j<=sz;j++)
  	  if (num[j].FR==x) {
  	  	  ok=1;
  	  	  num[j].SE++;
  	  	  break;
		}
	if (!ok) {
		num[++sz]=pr(x,1);
		if (sz>3) {
			puts("No");
			return 0;
		}
	}
  }
  sort(num+1,num+sz+1);
  if (n%3==0) {
  	if (sz==1) puts((!num[1].FR)?"Yes":"No");
  	else if (sz==2) puts((!num[1].FR&&num[2].SE==num[1].SE*2)?"Yes":"No");
  	else puts(((num[1].FR^num[2].FR)==num[3].FR&&num[1].SE==num[2].SE&&num[2].SE==num[3].SE)?"Yes":"No");
  }
  else if (n%3==1) puts((sz==1&&!num[1].FR)?"Yes":"No");
  else {
  	if (sz==1) puts((!num[1].FR)?"Yes":"No");
  	else if (sz==2) puts((!num[1].FR&&num[2].SE==num[1].SE+1)?"Yes":"No");
  	else puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define a first
#define b second
#define all(x) x.begin(), x.end()

int main(){
    
    // 1. 入力情報.
    int N, K;
    map<char, int> m;
    scanf("%d %d", &N, &K);
    rep(i, N){
        char c[22];
        scanf("%s", c);
        m[c[0]]++;
    }
    
    // 2. データを保存.
    vector<pair<int, char>> v;
    for(auto &i : m) v.push_back({i.b, i.a});
    
    // 3. 最大で何回のKUPCを開催できるか？
    int ans = 0;
    while(1){
        int k = K;
        sort(all(v));
        reverse(all(v));
        for(auto &p : v){
            if(p.a > 0){
                p.a--;
                k--;
            }
            if(!k) break;
        }
        if(k) break;
        else  ans++;
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
    freopen ("E.in", "r", stdin);
    freopen ("E.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n;

pair<int, int> a[N];

multiset<int> R, B;

#define Max(S) *S.rbegin()
#define Min(S) *S.begin()

int main() {

	File();

	n = read();
	For (i, 1, n) {
		int x = read(), y = read(); if (x > y) swap(x, y);
		B.insert(x); R.insert(y); a[i] = make_pair(x, y);
	}
	long long ans = 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B));

	sort(a + 1, a + n + 1);
	For (i, 1, n) {
		B.erase(B.find(a[i].first)); R.insert(a[i].first);
		R.erase(R.find(a[i].second)); B.insert(a[i].second);
		chkmin(ans, 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B)));
	}
	printf ("%lld\n", ans);

	return 0;

}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  rep(i, N) {
    if (p[i] == i) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
// たぶんDP
#include <bits/stdc++.h>
using namespace std;

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int H, W, D;
vector<pair<int, int>> A;
int Q;

int main(void) {
    cin >> H >> W >> D;
    A.resize(H * W + 1);
    REP(y, 0, H) {
        REP(x, 0, W) {
            int a;
            cin >> a;
            A[a] = pair<int, int>(x, y);
        }
    }

    int d[90001] = {};
    for(int i = D + 1; i <= H * W; ++i) {
        d[i] = d[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second);
    }

    cin >> Q;
    rep(i, Q) {
        int L, R;
        cin >> L >> R;
        cout << (d[R] - d[L]) << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        double exp = num+Math.pow(num,2)+Math.pow(num,3);
        int result = (int)exp;
        System.out.println(result);
        scan.close();
    }
}

Measured memory_bytes: 27056
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextInt();
			B[i] = A[i];
		}
		Arrays.sort(B);
		for( int i=0; i<N; i++ ){
			if( A[i]==B[N-1] ){
				System.out.println(B[N-2]);
			}else{
				System.out.println(B[N-1]);
			}
		}
	}
}


Measured memory_bytes: 101028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  int arr[4] = {4, 6, 9, 11};
  for (int i = 0; i < 4; i++) {
	if (a == arr[i]) {
	  a = 14;
	}
	if (b == arr[i]) {
	  b = 14;
	}
  }
  if (a == 2 || b == 2) {
	cout << "No" << endl;
	return (0);
  }
  if (a == b) {
	cout << "Yes" << endl;
  }
  else if (a == 14 || b == 14) {
	cout << "No" << endl;
  }
  else {
	cout << "Yes" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x,y;
	cin>>x>>y;
	if(2*x<=y && y<=4*x && y%2==0) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int rd(){
    int a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}
ll rdll(){
    ll a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}

const int N=304;
const ll p=998244353;
int n,m,x;
bitset<N>a[N],d[N];
ll expo(ll a,ll b){
    ll c=1;
    while(b){
        if(b&1)c=c*a%p;
        b>>=1,a=a*a%p;
    }
    return c;
}
void dbg(const bitset<N> &a){
	for(int i=1;i<=m;i++)printf(" %d",a[i]);printf("\n");
}
int main(){
	n=rd(),m=rd();
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)a[i][j]=rd();
	for(int i=1;i<=n;i++)for(int j=m;j;j--)if(a[i][j]){//printf("a[%d]:",i);dbg(a[i]);printf("d[%d]:",j);dbg(d[j]);
	    if(d[j][j])a[i]^=d[j];
	    else{d[j]=a[i];break;}
	}
	for(int i=1;i<=m;i++)x+=d[i][i];//printf("x=%d\n",x);
	printf("%lld",((expo(2,m)-expo(2,m-x)+p)%p)*expo(2,n-1)%p);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int ans[200000];
int now[200000];
int aaa[200000];
int main()
{
	int num,len,query;
	scanf("%d%d%d",&num,&len,&query);
	vector<int>v;
	for(int i=0;i<query;i++)
	{
		int z;
		scanf("%d",&z);
		z--;
		v.push_back(z);
	}
	reverse(v.begin(),v.end());
	set<int>se;
	vector<int>dd;
	for(int i=0;i<v.size();i++)
	{
		if(se.find(v[i])==se.end())
		{
			ans[v[i]]=se.size()+1;
			se.insert(v[i]);
			dd.push_back(v[i]);
		}
		int x=ans[v[i]];
		int beg=0,end=num;
		for(;;)
		{
			if(beg==end)break;
			int med=(beg+end)/2;
			if(now[med]<x)end=med;
			else beg=med+1;
		}
		//printf("  %d %d  %d\n",beg,v[i]+1,x);
		if(beg!=num&&now[beg]==x-1)
		{
			now[beg]++;
		}
	}
	for(int i=0;i<len;i++)if(ans[i]==0)dd.push_back(i);
	vector<int>z;
	for(int i=0;i<now[num-1];i++)
	{
		z.push_back(dd[i]);
		aaa[dd[i]]=1;
	}
	for(int i=0;i<len;i++)if(aaa[i]==0)z.push_back(i);
	//for(int i=0;i<len;i++)printf("%d %d\n",dd[i]+1,z[i]+1);
	if(dd==z)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 7032
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
  	int A, B, C;
  	cin >> A >> B >> C;
  	
  	int temp1 = (10 * A) + B + C;
 	int temp2 = A + (10 * B) + C;
  	int temp3 = A + B + (10 * C);
  
  	int max1 = max(temp1, temp2);
  	int fin = max(max1, temp3);
 	cout << fin << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H+1);
    vector<vector<int>> ans(H+1,vector<int>(W+1));
    vector<bool> flg(H+1,false);
    rep(i,H){
        cin >> S[i];
        if(S[i].find("#")==-1){
            flg[i] = true;
        }
    }
    int num = 0;
    for(int h=0;h<H;h++){
        int ichigo = 0;
        num++;
        for(int w=0;w<W;w++){
            if(flg[h]){
                num--;
                break;
            }
            if(S[h][w]=='.'){
                ans[h][w]=num;
            }else{
                if(ichigo == 0){
                    ichigo = 1;
                    ans[h][w] = num;
                }else{
                    num++;
                    ans[h][w] = num;
                }
            }
        }
    }

    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(flg[h]){
                if(h!=0){
                    ans[h][w] = ans[h-1][w];
                }
            }
        }
    }

    for(int h=H-1;h>=0;h--){
        for(int w=0;w<W;w++){
            if(flg[h]){
                if(ans[h][w]==0){
                    ans[h][w] = ans[h+1][w];
                }
            }
        }
    }

    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<char,char>> spell(q);
    REP(i,q){
        char t, d;
        cin >> t >> d;
        spell[i] = pair<char,char>(t,d);
    }
    int32 l = 0, r = n;
    while(r - l > 1){
        int32 m = (l + r) / 2;
        int32 idx = m;
        REP(i,q){
            if(spell[i].first == s[idx]){
                if(spell[i].second == 'L'){
                    idx--;
                }else{
                    idx++;
                }
            }
            if(idx < 0 || n <= idx)break;
        }
        if(idx < 0){
            l = m;
        }else{
            r = m;
        }
    }
    int32 l2 = 0,r2 = n;
    while(r2 - l2 > 1){
        int32 m = (l2 + r2) / 2;
        int32 idx = m;
        REP(i,q){
            if(spell[i].first == s[idx]){
                if(spell[i].second == 'L'){
                    idx--;
                }else{
                    idx++;
                }
            }
            if(idx < 0 || n <= idx)break;
        }
        if(n <= idx){
            r2 = m;
        }else{
            l2 = m;
        }
    }
    ANS(r2 - r);
    return 0;
}

Measured memory_bytes: 976
import sys
input = sys.stdin.readline
 
M = int(1e18)
n = int(input())
s = list(map(int, input().split()))
res = 1
flag = False
if 0 in s: print('0')
else:
    for i in range(len(s)):
        res *= s[i]
        if res > M: flag = True; break
    print(-1 if flag else res)

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

int main(){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
        return 0;
    }
    if(r<2800){
        cout << "ARC"<<endl;
        return 0;
    }
    cout << "AGC"<<endl;
    return 0;
}

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

int N, a, b, c, ans;
int X[30];

int main(){
  cin >> N;
  // とりあえずXに入れる
  rep(i, N){
    cin >> X[i];
  }
  // 左から貪欲に調べていく
  // 繰り返し回数はN-3+1回
  rep(i, N-3+1){
    // 調べる3つの数字を格納する配列
    int Y[3];
    // 格納していく
    rep(j, 3){
      Y[j] = X[i+j];
    }
    // ソートする
    sort(Y, Y+3);
    // 2番目が変わらなければ条件に一致する
    if (Y[1]==X[i+1]) ans++;
  }
  // 出力
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
int main(){
  ll x;
  cin >> x;
  cin.ignore();

  ll x_1000 = x / 500;
  ll xp1000 = x % 500;
  ll xp1000_5 = xp1000 / 5;

  ll ans = 1000 * x_1000 + 5 * xp1000_5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int A, B, C, X;
  scanf("%d%d%d%d",&A,&B,&C,&X);
  int ans = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int t = 500 * a + 100 * b + 50 * c;
        if (t == X) ++ans;
      }
    }
  }
  printf("%d",ans);
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a[0];
	for (int i = 1; i < a.size(); ++i) cout << ' ' << a[i];
	cout << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int x,a,b; cin>>x>>a>>b;
    if(b-a<=0) cout<<"delicious"<<endl;
    else if(b-a<=x) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
let main: () = {
    let N = nextInt()
    let C = listOfInt(-1)
    var G = Array(N) { _ in [Int]() }
    repeate(N - 1) { _ in
        let (a, b) = *listOfInt(-1)
        G[a].append(b)
        G[b].append(a)
    }
    var all = 0
    var cnt = Array<Int>(N), sub = Array<Int>(N)
    var ans = Array(N) { _ in N * (N - 1) / 2 }
    func dfs(_ v: Int, _ p: Int) -> Int {
        sub[v] = 1
        let bfr = cnt[C[v]]
        for u in G[v] {
            if (u == p) {continue}
            let pre = all - cnt[C[v]]
            sub[v] += dfs(u, v)
            let nxt = all - cnt[C[v]]
            ans[C[v]] -= (nxt - pre) * (nxt - pre - 1) / 2
        }
        cnt[C[v]] = bfr + sub[v]
        all += 1
        return sub[v]
    }
    _ = dfs(0, -1)
    repeate(N) { c in
        let pre = 0, nxt = N - cnt[c]
        ans[c] -= (nxt - pre) * (nxt - pre - 1) / 2
    }
    for c in C { ans[c] += 1}
    print(ans.joinToString("\n"))
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
@inlinable func listOfInt(_ offset: Int = 0) -> [Int] { listOfString().map { Int($0)! + offset } }
extension Array {
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
}
extension Array where Element == Int {
    init(_ size: Int) {
        self = [Element]()
        for _ in 0 ..< size {
            self.append(0)
        }
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }

@inlinable func repeate(_ times1: Int, _ action: (Int) -> Void) {
    for index1 in 0 ..< times1 {
        action(index1)
    }
}


Measured memory_bytes: 70116
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[128], stack[128];
    while (fgets(s, 128, stdin)) {
        int n=strlen(s)-1;
        char* p=strchr(s, '\n');
        int i, ok=1, sp=0;
        if (p) *p=0;
        if (*s=='.' && n==1) break;

        for(i=0;i<n;++i) {
            switch (s[i]) {
                case '(': stack[sp++]=s[i]; break;
                case ')': if (!sp || stack[--sp]!='(') ok=0; break;
                case '[': stack[sp++]=s[i]; break;
                case ']': if (!sp || stack[--sp]!='[') ok=0; break;
            }
        }
        ok=ok&&sp==0;
        puts(ok ? "yes" : "no");
    }
    return 0;
}

Measured memory_bytes: 524
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k, q = list(map(int, input().rstrip('\n').split()))
    a = [int(input().rstrip('\n')) for _ in range(q)]
    ls = [0] * n
    for v in a:
        ls[v-1] += 1
    for i in range(n):
        if q - ls[i] < k:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49756
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

void move_keta(vector<int>& keta) {
  if (keta[2] == 9) {
    if (keta[1] == 9) {
      keta[0]++;
      keta[1] = 0;
      keta[2] = 0;
    } else {
      keta[1]++;
      keta[2] = 0;
    }
  } else {
    keta[2]++;
  }
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  vector<int> keta = {0, 0, 0};
  int hyaku, zyuu, iti;

  for (int pin = 0; pin < 1000; pin++) {
    hyaku = zyuu = iti = -1;
    for (int i = 0; i < N; i++) {
      if (S[i] - '0' == keta[0]) {
        hyaku = i;
        break;
      }
    }
    if (hyaku == -1) {
      move_keta(keta);
      continue;
    }
    for (int i = hyaku + 1; i < N; i++) {
      if (S[i] - '0' == keta[1]) {
        zyuu = i;
        break;
      }
    }
    if (zyuu == -1) {
      move_keta(keta);
      continue;
    }
    for (int i = zyuu + 1; i < N; i++) {
      if (S[i] - '0' == keta[2]) {
        iti = i;
        break;
      }
    }
    if (iti == -1) {
      move_keta(keta);
      continue;
    }
    ans++;
    move_keta(keta);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
ll dp[105][200000];
ll arr[100000];
const ll mod = 1e9+7;
int main()
{
    ll n, k; cin >> n >> k;
    ll sqrt_n = sqrt(n);
    for (ll i = 1, sum = 0; i <= 2 * sqrt_n; i++)
    {
        if (i <= sqrt_n){arr[i]++; sum++;}
        else {
            arr[i] += n / (2 * sqrt_n - i + 1) - sum;
            sum += arr[i];
        }
        dp[0][i] = sum;
    }
    for (ll i = 1; i <= k; i++)
        for (ll j = 0; j < 2 * sqrt_n; j++)
            dp[i][j+1] = (dp[i-1][sqrt_n * 2 - j] * arr[j+1] + dp[i][j])%mod;
    cout << dp[k-1][sqrt_n*2] << endl;
}

Measured memory_bytes: 156928
#include<bits/stdc++.h>
using namespace std;
int A, B;
int main(){
    cin>>A>>B;
    if(B == 1){
        puts("0");
    }
    else{
        printf("%d\n", (B - 2) / (A - 1) + 1);
    }
    return 0;
}

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

public class Main {
	class Team implements Comparable<Team>{
		int id, s;
		int[] p;
		int ac;

		Team(int id, int pro) {
			this.id = id;
			this.p = new int[pro];
			this.s = 0;
			this.ac = 0;
		}

		@Override
		public int compareTo(Team o) {
			if (this.ac != o.ac)
				return o.ac - this.ac;
			return this.s - o.s;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int r = sc.nextInt();
			if ((n | m | r) == 0) {
				break;
			}

			Team[] t = new Team[n];
			for (int i = 0; i < n; i++) {
				t[i] = new Team(i, m);
			}

			for (int i = 0; i < r; i++) {
				int tid = sc.nextInt() - 1;
				int pid = sc.nextInt() - 1;
				int tim = sc.nextInt();
				String mes = sc.next();

				if (mes.equals("CORRECT")) {
					t[tid].ac++;
					t[tid].s += t[tid].p[pid]*1200 + tim;
				} else {
					t[tid].p[pid]++;
				}
			}

			Arrays.sort(t);
			for (int i = 0; i < n; i++) {
				int tid = t[i].id;
				int ac = t[i].ac;
				int pen = t[i].s;
				System.out.println(++tid + " " + ac + " " + pen);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int N;
  int64_t m=0,a=0,r=0,c=0,h=0;
  cin>>N;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if(s.at(0)=='M'){
      m++;
    }
    else if(s.at(0)=='A'){
      a++;
    }
    else if(s.at(0)=='R'){
      r++;
    }
    else if(s.at(0)=='C'){
      c++;
    }
    else if(s.at(0)=='H'){
      h++;
    }
  }
  cout<<m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h<<endl;
}

Measured memory_bytes: 256