akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

const int step[4][2] = {
	{ 1, 0 },
	{ -1, 0 },
	{ 0, 1 },
	{ 0, -1 },
};

int H, W;
char HW[1000 + 1][1000 + 1];
char magicAll[1000 + 1][1000 + 1];
ll DH, DW;

// bfs
int bfs(int sx, int sy)
{
	vector<vector<ll>> dist(H, vector<ll>(W, INF));
	deque<P> que;
	
	dist[sx][sy] = 0;
	que.emplace_front(sx, sy);
	while (que.size()) {
		ll xNow = que.front().first;
		ll yNow = que.front().second;
		que.pop_front();
		for (int i = 0; i < 4; i++) {
			int xNext = xNow + step[i][0];
			int yNext = yNow + step[i][1];
			if (!((0 <= xNext && xNext < H) && (0 <= yNext && yNext < W))) {
				continue;
			}
			if ((dist[xNow][yNow] < dist[xNext][yNext] && HW[xNext][yNext] == '.')) {
				dist[xNext][yNext] = dist[xNow][yNow];
				que.emplace_front(xNext, yNext);
			}
		}

		for (int h = -2; h <= 2; h++) {
			for (int w = -2; w <= 2; w++) {
				int xNext = xNow + h;
				int yNext = yNow + w;
				if (!((0 <= xNext && xNext < H) && (0 <= yNext && yNext < W))) {
					continue;
				}
				if ((dist[xNow][yNow] + 1 < dist[xNext][yNext] && HW[xNext][yNext] == '.')) {
					dist[xNext][yNext] = dist[xNow][yNow] + 1;
					que.emplace_back(xNext, yNext);
				}
			}
		}
	}
	
	if (dist[DH][DW] != INF) {
		return dist[DH][DW];
	} else {
		return -1;
	}
}

// メイン
void Solve()
{
	// 入力
	ll CH, CW;
	cin >> H >> W;
	cin >> CH >> CW;
	cin >> DH >> DW;
	CH--; CW--; DH--; DW--;
	REP(i, H) {
		REP(j, W) {
			cin >> HW[i][j];
			magicAll[i][j] = 'W';
		}
	}

	// 結果
	cout << bfs(CH, CW) << endl;

}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 13532
N,M=map(int,input().split())

city=[]
for i in range(M):
  city.append(list(map(int,input().split())))
  city[i].append(int(i))
city.sort(key=lambda x:x[1])
city.sort(key=lambda x:x[0])

start=city[0][0]
count=0
for i in range(M):
  if city[i][0]!=start:
    start=city[i][0]
    count=1
  else:
    count=count+1
  city[i].append(count)
  
city.sort(key=lambda x:x[2])

for i in range(M):
  print('%06d' % city[i][0],end='')
  print('%06d' % city[i][3])
#print(city)

Measured memory_bytes: 35296
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ar[n][3];
	for(int i=0;i<n;i++)
		cin>>ar[i][0]>>ar[i][1]>>ar[i][2];

	int dp[n][3];
	for(int i=0;i<3;i++)dp[0][i]=ar[0][i];

	for(int i=1;i<n;i++)
	{
		dp[i][0]=ar[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=ar[i][1]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=ar[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	int ans=max(dp[n-1][0],dp[n-1][1]);
	ans=max(ans,dp[n-1][2]);
	cout<<ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

int n, m[2], b[2][28], in, T = 0;
char d[2][5][5][5];

main(){
  while(cin >> n && n){
    if(T) cout << endl;
    for(int k=0;k<5;k++) for(int j=0;j<5;j++) for(int i=0;i<5;i++) cin >> d[0][i][j][k];
    fill(b[0], b[2], 0);
    for(int i=0;i<2;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++){
        cin >> in;
        b[i][in]++;
      }
    }
    for(int t=0;t<n;t++){
      for(int x=0;x<5;x++){
        for(int y=0;y<5;y++){
          for(int z=0;z<5;z++){
            int cnt = 0;
            for(int dx=-1;dx<2;dx++){
              for(int dy=-1;dy<2;dy++){
                for(int dz=-1;dz<2;dz++){
                  if(dx == dy && dz == dx && dz == 0) continue;
                  int nx = x + dx;
                  int ny = y + dy;
                  int nz = z + dz;
                  if(min(nx, min(ny, nz)) < 0 || max(nx, max(ny, nz)) > 4) continue;
                  if(d[t%2][nx][ny][nz] == '1') cnt++;
                }
              }
            }
            d[(t+1)%2][x][y][z] = d[t%2][x][y][z];
            if(d[t%2][x][y][z] == '1' && !b[1][cnt]) d[(t+1)%2][x][y][z] = '0';
            if(d[t%2][x][y][z] == '0' && b[0][cnt]) d[(t+1)%2][x][y][z] = '1';
          }
        }
      }
    }
    cout << "Case " << ++T << ":" << endl;
    for(int k=0;k<5;k++){
      if(k) cout << endl;
      for(int j=0;j<5;j++){
        for(int i=0;i<5;i++) cout << d[n%2][i][j][k];
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

map<pii, int> mp;
set<int> st[100010];
queue<pii> q;
int n, f[100010];

int find(int x)
{
    if (f[x] == x)
        return x;
    return f[x] = find(f[x]);
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n * 2 - 2; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        st[x].insert(y);
        st[y].insert(x);
        mp[pii(x, y)]++;
        mp[pii(y, x)]++;
        if (mp[pii(x, y)] == 2)
            q.push(pii(x, y));
    }
    for (int i = 1; i <= n; ++i)
        f[i] = i;
    set<int>::iterator it;
    while (!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        x = find(x);
        y = find(y);
        st[x].erase(y);
        st[y].erase(x);
        if (st[x].size() < st[y].size())
            swap(x, y);
        for (it = st[y].begin(); it != st[y].end(); ++it)
        {
            int z = *it;
            mp[pii(y, z)] = mp[pii(z, y)] = 0;
            st[z].erase(y);
            st[z].insert(x);
            mp[pii(x, z)]++;
            mp[pii(z, x)]++;
            st[x].insert(z);
            if (mp[pii(x, z)] == 2)
                q.push(pii(x, z));
        }
        f[y] = x;
        st[y].clear();
    }
    int s = 0;
    for (int i = 1; i <= n; ++i)
        s += (f[i] == i);
    if (s == 1)
        puts("YES");
    else
        puts("NO");
    return 0;
}

Measured memory_bytes: 56320
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			if(n+w==0)break;
			int[] cnt = new int[100];
			for (int i = 0; i < n; i++) {
				cnt[sc.nextInt()/w]++;
			}
			double high=0;
			double max = 0;
			for (int i = 0; i < cnt.length; i++) {
				high=Math.max(high, cnt[i]);
				if(cnt[i]>0){
					max=i;
				}
			}
			double ans = 0.01;
			for (int i = 0; i < cnt.length; i++) {
				if(cnt[i]==0)continue;
				ans += (cnt[i]/high) * ((int)max-i)/(max);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 23624
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, K;

    cin >> N >> K;

    int64_t wholeCount = 0;
    for (int b = 1; b <= N; b++)
    {
        if (b - K <= 0)
        {
            continue;
        }
        int cnt = 0;

        int n0 = N / b;
        cnt += n0 * (b - K);
        cnt += max(0, N + 1 - (n0 * b + K));
        cnt -= K == 0 ? 1 : 0;

        //cout << "b: " << b << " cnt: " << cnt << endl;

        wholeCount += (int64_t)cnt;
    }

    cout << wholeCount << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> A >> B >> C;
  Out((A-B+1)*(A-C+1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::base_sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}

int main(){
	int N;
	cin >> N;
	int ganjil = 0 , genap = 0;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		if(a % 2 == 0) genap++;
		else ganjil++;
	}
	genap = 1;
	while (ganjil >= 2){
		ganjil -= 2;
		genap++;
	}
	if(ganjil !=0 ) cout << "NO\n";
	else cout << "YES\n";
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n;
    cin >> n;
    int k;
    cin >> k;
    int h[n];
    for(int i = 0; i < n; ++i){
    	cin >> h[i];
    }
    sort(h, h + n);
    ll sum  = 0;
    for(int i = 0; i < (n - k); ++i)
    	sum += h[i];

    cout << sum;

    return 0;
}

/*

*/

Measured memory_bytes: 4404
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int cnt[300010];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	for(int i=1;i<=n;i++)cnt[read()]++;
	sort(cnt+1,cnt+n+1);
	int now=n,sum=n,p=1;
	for(int i=n;i>=0;i--)
	{
		while(now>cnt[i])
		{
			int uf=sum+(n-i)*now;
			while(p<=uf/now && p<=n)pr2(now),p++;
			now--;
		}sum-=cnt[i];
	}while(p<=n)pr2(0),p++;
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
signed main(){
  int a;
  cin>>a;
  string taro[a],hanako[a];
  int t=0,h=0;
  rep(0,a){
    cin>>taro[i]>>hanako[i];
    if(taro[i]>hanako[i])t+=3;
    else if(hanako[i]>taro[i])h+=3;
    else{
      t++;
      h++;
    }
  }
  cout<<t<<' '<<h<<endl;
}



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

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

using namespace std;

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

    ll a,b,x;

    cin>>a>>b;

    x = a * b;
    do
    {
        if(a > b) {
           a = a - b;
        } else {
            b = b - a;
        }
    }
    while(a != b);

    cout<<x/a<<'\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int dp[5050][5050];
int dp2[5050][5050];

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i)cin >> a[i];
  sort(a.begin(),a.end());
  dp[0][0]= 1;
  dp2[0][0]= 1;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= k; ++j){
      if(j-a[i]>= 0){
        dp[i+1][j]|= dp[i][j-a[i]];
      }
      dp[i+1][j]|= dp[i][j];
      if(j-a[n-1-i]>=0){
        dp2[i+1][j]|= dp2[i][j-a[n-1-i]];
      }
      dp2[i+1][j]|= dp2[i][j];
    }
  }
  int ans = 0;
  
  for(int i = 0; i < n; ++i){
    if(a[i]>=k){
      ++ans;
      continue;
    }
    vector<int> sum(5050);
    for(int j = 0; j <= k; ++j){
      sum[j+1] = sum[j] + dp2[n-1-i][j];
    }
    
    for(int j = 0; j < k; ++j){
      if(dp[i][j]==1 && sum[k-j]-sum[k-a[i]-j]>0){
        ++ans;
        break;
      }
    }
  }
  cout << n-ans << endl;
  for(int i = 0; i <= n; ++i){
    for(int j = 0; j <= k; ++j){
      //cout << dp2[i][j]<< ' ';
    }
    //cout << endl;
  }
  
}


Measured memory_bytes: 198912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main()
{
   char s;
   cin >> s;

   if (islower(s))
   {
       cout << "a" << endl;
   }
   else
   {
       cout << "A" << endl;
   }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
bool ispalindrome(char s[])
{
    int flag=0;
    int l=strlen(s)-1;
    int h=0;
 
    while(l>h)
    {
        if(s[h++] != s[l--])
        {
            return false;
        }
    }
 
    return true;
}
 
bool firsthalfpalindrome(char s[])
{
    int h=0;
    int l= ((strlen(s)-1)/2)-1;
  //  cout<<l<<endl;
 
    while(l>=h)
    {
        if(s[l--] != s[h++])
            return false;
 
            return true;
    }
}
 
bool lasthalfpalindrome(char s[])
{
    int h= ((strlen(s)+3)/2)-1;
   // cout<< h<<endl;
    int l=strlen(s)-1;
    while(l>=h)
    {
        if(s[l--]!= s[h++])
            return false;
 
            return true;
    }
}
 
 
int main()
{
    char s[100];
    scanf("%s",s);
 
    if(ispalindrome(s) && firsthalfpalindrome(s) &&  lasthalfpalindrome(s) )
        cout<< "Yes"<<endl;
    else
        cout<< "No"<<endl;
 
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	if(N == 1) {
		writeln(1);
		return;
	}
	auto arr = generate_prime_list(N);
	ulong[ulong] m;
	foreach(i; 1..N+1) {
		foreach(j; arr) {
			while(i % j == 0) {
				m[j]++;
				i /= j;
			}
		}
		if(arr.canFind(i)) m[i]++;
	}
	ulong mod = 1000000007;
	m.values.map!(i => i + 1).reduce!((i, j) => (i * j) % mod).writeln;
}

ulong fact(ulong n) {
	if(n == 1) return 1;
	else return n * fact(n-1);
}

ulong[] generate_prime_list(T)(T N) if(isIntegral!T) {
	ulong[] prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N.to!ulong+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
	return prime_list;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  if(s[0]==s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 105
int as1=1e8,n,head[N],cnt,in[N],dep[N],a,b,s[N][2];
long long as2;
struct edge{int t,next;}ed[N*2];
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;in[f]++,in[t]++;}
void dfs(int u,int fa){dep[u]=dep[fa]+1;for(int i=head[u];i;i=ed[i].next)if(ed[i].t!=fa)dfs(ed[i].t,u);}
void solve1(int x)
{
	dfs(x,0);
	int mxdep=0;long long as=1;
	for(int i=1;i<=n;i++)if(dep[i]>mxdep)mxdep=dep[i];
	for(int i=1;i<mxdep;i++)
	{
		int mx=1;
		for(int j=1;j<=n;j++)
		if(dep[j]==i&&mx<in[j]-1)mx=in[j]-1;
		if(i==1)mx++;
		as*=mx;
	}
	if(as1>mxdep||(as1==mxdep&&as2>as))as1=mxdep,as2=as;
}
void solve2(int x,int y)
{
	dep[y]=0;dfs(x,y);dep[x]=0;dfs(y,x);dep[x]=1;
	int mxdep=0;long long as=2;
	for(int i=1;i<=n;i++)if(dep[i]>mxdep)mxdep=dep[i];
	for(int i=1;i<mxdep;i++)
	{
		int mx=1;
		for(int j=1;j<=n;j++)
		if(dep[j]==i&&mx<in[j]-1)mx=in[j]-1;
		as*=mx;
	}
	if(as1>mxdep||(as1==mxdep&&as2>as))as1=mxdep,as2=as;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&s[i][0],&s[i][1]),adde(s[i][0],s[i][1]);
	for(int i=1;i<=n;i++)solve1(i);
	for(int i=1;i<n;i++)solve2(s[i][0],s[i][1]);
	printf("%d %lld\n",as1,as2);
}//

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

int main(){
    string N;
    cin >> N;
    int size = N.length();
    if (N.at(size - 1) == '2' || N.at(size - 1) == '4' || N.at(size - 1) == '5' || N.at(size - 1) == '7' || N.at(size - 1) == '9') cout << "hon" << endl;
    else if (N.at(size - 1) == '3') cout << "bon" << endl;
    else cout << "pon" << endl;
        return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main() {
    int x , y;
   cin >> x >> y;
   if (x > y)
    cout << "a > b" << endl;
   else if (x < y)
    cout << "a < b" << endl;
   else if (x == y)
    cout << "a == b" << endl;
    
return 0;
} 


Measured memory_bytes: 3100
#include<stdio.h>
#define ll long long
ll x,i,j;
ll mu5(ll val)
{
	return val*val*val*val*val;
}
int main()
{
	scanf("%lld",&x);
	for (i=-4000;i<=4000;++i)
	for (j=-4000;j<=4000;++j)
	if (x==mu5(i)-mu5(j))
	{
		printf("%lld %lld",i,j);
		return 0;
	}
}

Measured memory_bytes: 1728
fun main(arr: Array<String>) {
    val (x1,y1,x2,y2) = readLine()!!.split(" ").map { it.toInt() }
    val x3 = x2 - (y2-y1)
    val y3 = y2 + (x2-x1)
    val x4 = x1 - (y2-y1)
    val y4 = y1 + (x2-x1)
    println(listOf(x3,y3,x4,y4).joinToString(" "))
}

Measured memory_bytes: 38996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	vector<string> ss;
	string s;
	while(getline(cin, s))
	{
		ss.push_back(s);
	}
	map<char,int> mp;
	for(char c ='a'; c <= 'z'; c++)mp[c] = 0;
	rep(k,sz(ss))rep(i,sz(ss[k]))
	{
		ss[k][i] = tolower(ss[k][i]);
		if('a'<=ss[k][i] && ss[k][i] <= 'z')mp[ss[k][i]]++;
	}
	for(char c ='a'; c <= 'z'; c++)cout<< c <<" : "<< mp[c] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <set>
#include <queue>

using namespace std;

vector<vector<int>> graph;

int ans = 0;

vector<int> countOfWins;

int findMaxGamesCount(int root) {
	if (countOfWins[root] == 0) return 0;
	vector<int> tmp((int) graph[root].size());
	for (int i = 0; i < (int) graph[root].size(); ++i) {
		tmp[i] = findMaxGamesCount(graph[root][i]) + 1;
	}
	int max_d = 0;
	sort(tmp.begin(), tmp.end());
	for (int i = 1; i < (int) tmp.size(); ++i) {
		if (tmp[i] <= tmp[i - 1]) tmp[i] = tmp[i - 1] + 1;
	}

	/*cout <<"root: " << root <<  endl;
	if (root == 0) {
		for (int i = 0; i < (int) tmp.size(); ++i) {
			cout << tmp[i] << " ";
		} cout << endl;
	}
	*/
	return tmp[(int) graph[root].size() - 1];
}

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

	int n;
	cin >> n;
	graph.resize(n);

	countOfWins.resize(n, 0);

	for (int i = 0; i < n - 1; ++i) {
		int tmp;
		cin >> tmp;
		--tmp;
		graph[tmp].push_back(i + 1);
		++countOfWins[tmp];
	}

	cout << findMaxGamesCount(0) << endl;
	
	return 0;
}

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

int main()
{
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> divs;
  for (int64_t i = 1; i * i <= M; i++)
  {
    if (M % i != 0)
      continue;
    divs.push_back(i);
    if (M / i != i)
      divs.push_back(M / i);
  }
  sort(divs.begin(), divs.end());
  reverse(divs.begin(), divs.end());
  for (auto d : divs)
  {
    if (M / d >= N)
    {
      cout << d << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    string s0, s1, s2;
    cin >> s0;
    cin >> s1;
    cin >> s2;

    cout << s0[0] << s1[1] << s2[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
using namespace std;
int main()
{
	ll s,w;
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe"<<endl;
	else
	cout<<"safe"<<endl;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if(S[i] == T[i]) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

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

    ll N;
    cin>>N;
    vector<ll> a(N+1),b(N+1);
    a[0]=0;
    ll B=0;
    FOR(i,1,N+1) cin>>a[i];
    FOR(i,0,N){
        if((N-i)>N/2) b[N-i]=a[N-i];
        else{
            //cout<<N-i<<' '<<N/i+1<<endl;
            B=0;
            FOR(j,2,N/(N-i)+1){
                //cout<<'a'<<(N-i)*j<<endl;
                B+=b[(N-i)*j];
            }
            //cout<<B<<endl;
            b[N-i]=abs(a[N-i]-B%2);
        }
    }

    ll c=0;
    FOR(i,1,N+1){
        if(b[i]==1) c++;
    }
    cout<<c<<endl;

    FOR(i,1,N+1){
        if(b[i]==1) cout<<i<<' ';
    }
    
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  vector<int> n(4);
  for (auto &e : n)
    cin >> e;
  sort(n.begin(), n.end());
  if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

int main() {
    int N,L;
    string S[100],work;
    cin>>N>>L;
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(S[i]>S[j]){
                work=S[i];
                S[i]=S[j];
                S[j]=work;
            }
        }
    }
    
    for(int i=0;i<N;i++)cout<<S[i];
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
for _ in range(3):
	a = list(map(int, input().split()))
	wt = 3600*(a[3]-a[0])+60*(a[4]-a[1])+a[5]-a[2]
	print('{0} {1} {2}'.format(wt//3600, wt%3600//60, wt%3600%60))



Measured memory_bytes: 5592
n, m = map(int, input().split())
graph = {}
for i in range(m):
    am, bm = map(int, input().split())
    if am not in graph:
        graph[am] = [bm]
    else:
        graph[am].append(bm)
    if bm not in graph:
        graph[bm] = [am]
    else:
        graph[bm].append(am)
guide = {1: 0}
visited = [1]
i = 0
while True:
    # flag = False
    for j in graph[visited[i]]:
        if j not in guide.keys():
            guide[j] = visited[i]
            visited.append(j)
            # flag = True
    i += 1
    # if flag and i == len(visited):
    #     break
    if i == len(visited):
        break

if i == n:
    print("Yes")
    for x in range(2, n+1):
        print(guide[x])
else:
    print("No")


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


int cnt[100001];
bitset<100001> bs;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cnt[i]=1;
	bs.set(1);
	for(int i=1,x,y;i<=m;i++){
		cin>>x>>y;
		if(bs[x])	bs.set(y);
		cnt[x]--;cnt[y]++;
		if(!cnt[x])	bs.reset(x);
	}
	cout<<bs.count()<<endl;	
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>

using namespace std;

#define MAX_V 100

struct edge { int to,cap,rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,G[to].size()});
    G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();que.pop();
        for(int i = 0;i < G[v].size();i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v,int t,int f){
    if(v == t) return f;
    for(int &i = iter[v];i < G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    while(1){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f = dfs(s,t,INT_MAX)) > 0) {
            flow += f;
        }
    }
}

int main(){
    int v,e;
    cin >> v >> e;
    int i,j;
    int a,b,c;
    for(i = 0;i < e;i++){
        cin >> a >> b >> c;
        add_edge(a,b,c);
    }
    cout << max_flow(0,v-1) << endl;
}

Measured memory_bytes: 1276
function F1(x,y){
xy[x][y-1]+=1;
xy[x-1][y]+=1;
xy[x][y]+=1;
xy[x+1][y]+=1;
xy[x][y+1]+=1;
}
function F2(x,y){
F1(x,y);
xy[x-1][y-1]+=1;
xy[x+1][y-1]+=1;
xy[x-1][y+1]+=1;
xy[x+1][y+1]+=1;
}
function F3(x,y){
F2(x,y);
xy[x][y-2]+=1;
xy[x-2][y]+=1;
xy[x+2][y]+=1;
xy[x][y+2]+=1;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");

var xy=[];
for(var i=0;i<10+4;i++){
   xy[i]=[];
   for(var j=0;j<10+4;j++){
      xy[i][j]=0;
   }
}

for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(",").map(Number);
   var x=arr[0]+2;
   var y=arr[1]+2;
   if(arr[2]==1)F1(x,y);
   if(arr[2]==2)F2(x,y);
   if(arr[2]==3)F3(x,y);
}

var sum=0;
var max=0;
for(var i=2;i<10+2;i++){
   for(var j=2;j<10+2;j++){
      if(xy[i][j]==0)sum++;
      max=Math.max(max,xy[i][j]);
   }
}
console.log(sum);
console.log(max);

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

int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	if(n % 2 == 1) cout << (double)(n + 1) / (2 * n) << "\n";
	else cout << (double)1/2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll x;
    cin >> x;
    ll ans=0;
    ll now=100;
    while(now<x){
        now=now*1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}











Measured memory_bytes: 3596
#include <iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	string s ;
	cin >> s;
	int a = 0;
	for (int i = 0; i <= 3; i++) {
		if (s[i] == '+')a = a + 1;
		else a = a - 1;
	}

	cout << a << endl;
	return 0;
}

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

int main(void){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
// #include "../00_Library/template.hpp"
#include <vector>
#include <iostream>
#include <string>

using namespace std;
int main(){
  size_t h,w; cin >> h >> w;
  vector<string> s;
  string row(w,'.'); 
  for (int i = 0; i < h; i++)
  {
    string t; cin >> t;
    if(t==row) continue;
    s.push_back(t);
  }
  h = s.size();
  for (int j = 0; j < w; j++)
  {
    bool isEmpty = true;
    for (int i = 0; i < h; i++) {if(s[i][j]=='#') isEmpty=false;}
    if(isEmpty) {
      if(j==0) for (int i = 0; i < h; i++) s[i] = s[i].substr(1);
      else for (int i = 0; i < h; i++) s[i] = s[i].substr(0,j)+s[i].substr(j+1);
      w--;
      j--;
      }
  }
  
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << s[i][j];
    }
    cout << "\n";
  }
  // string te="123456789";
  // cout << te.substr(0,3) << te.substr(4) << endl;
  // cout << te.substr(2) << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0/*,-1,0*/ }, dy[4] = { 0,1/*,0,-1*/ };
/**************/
int X, K, A[100];
bool win[int(1e5)+1];

int main()
{
	cin >> K>>X;
	for (int i = 0; i < K; i++)cin >> A[i];
	for (int j = 1; j <= X; j++) {
		win[j] = false;
		for (int i = 0; i < K; i++) {
			win[j] |= A[i] <= j && !win[j - A[i]];

		}
	}

	if (win[X])cout << "First" << endl;
	else cout << "Second"<<endl;

	
}

Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <stdint.h>
#include <vector>
using namespace std;

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

int main(){
    int x,y;
    scanf("%d %d",&x,&y);

    printf("%d\n",x+y/2);

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long a = scan.nextLong();
        long b = scan.nextLong();
        long x = scan.nextLong();
        long answer = b / x + 1;
        if (a != 0) {
            answer -= (a - 1) / x + 1;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
long long dp[100200];
int main(){
	int n, K;
	cin >> n >> K;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
  
for(int i = 0; i < 100200;i++) dp[i] = 10000000000;
  	dp[0] = 0;
  	for(int i = 0; i < n; i++) {
      for(int j = 1; j <= K; j++) {
        dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]) , dp[i+j]);
      }
    }
	cout << dp[n-1] << endl;
	
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, K, ans = 0;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    FOR(i, K + 1, N + 1) {
        ans += (N / i) * (i - K);
        ans += max(0LL, (N % i) - K + 1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int a[100002], f[100002], mx, n;


int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    f[a[i]]++;
    mx = max(mx, a[i]);
  }
  for (int i = 1; i <= n; i++)
    if (a[i] < (mx + 1) / 2) {
      cout << "Impossible";
      return 0;
	}
  if (f[(mx + 1) / 2] != 1 + (mx % 2)) {
    cout << "Impossible";
    return 0;
  }
  for(int i = (mx + 1) / 2 + 1; i <= mx; i++) {
	if (f[i] < 2) {
      cout << "Impossible";
      return 0;
	}
  }
  cout << "Possible";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// combination mod prime
// comnputing order k
ll comb(int n, int k){
	ll res = 1;
	for(int i=n; i>n-k; i--) res = res * i;
	for(int i=k; i>0; i--) res = res / i;
	return res;
}
int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	vll s(n+1);
	s[0] = 0;
	rep(i,n) s[i+1] = s[i]+a[i];
	map<ll,int> mp;
	rep(i,n+1)mp[s[i]]++;
	ll ans = 0;
	for(auto p: mp)ans += comb(p.se,2);
	cout << ans << endl;
}




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

int main() {
    ll n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << endl;
    return 0;
}


Measured memory_bytes: 3576
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 5010;

int main()
{
	
	int n, d;
	cin >> n >> d;
	d = 2*d+1;
	cout << (n-1)/d+1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return exp(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int n;cin >> n;
    map<char,ll> ans;
    rep(i,n){
        string s;cin >> s;
        ans[s[0]]++;
    }
    ll cnt=0;
    cnt+=ans['M']*(ans['A']*(ans['R']+ans['C']+ans['H'])
        +ans['R']*(ans['C']+ans['H'])+ans['C']*ans['H']);
    cnt+=ans['A']*(ans['R']*(ans['C']+ans['H'])+ans['C']*ans['H']);
    cnt+=ans['R']*ans['C']*ans['H'];
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

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

  int minusCount = 0;
  i64 sum = 0;
  i64 minAbs = INF;

  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    sum += abs(a);
    if (a < 0) ++minusCount;
    chmin(minAbs, abs(a));
  }

  if (minusCount % 2 == 0)
    cout << sum << endl;
  else {
    cout << sum - 2 * minAbs << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MX = 1e18;

int main() {
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }

return 0;
}


Measured memory_bytes: 3620
N,a,b = map(int,input().split())

mod = 10**9+7

MAX = max(a,b)+10
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()
cmb1 = 1
for i in range(a):
    cmb1 *= (N-i)
    cmb1 %= mod
cmb1 *= finv[a]

cmb2 = 1
for i in range(b):
    cmb2 *= (N-i)
    cmb2 %= mod
cmb2 *= finv[b]


ans = pow(2,N,mod) - 1 - cmb1 - cmb2
ans %= mod
print(ans)

Measured memory_bytes: 26740