akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int INF2 = 1e15;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int ans = 0;
        for(int j = 1; j*j <= i; j++) {
            for(int k = 1; k*k+j*j <= i; k++) {
                if(i-j*j-k*k-j*k > 0) {
                    int X = i-j*j-k*k-j*k;
                    for(int l = 1; l*l+l*j+l*k <= X; l++) {
                        if(l*j+l*k+l*l == X) {
                            ans++;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


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

int N, len, ans=0;
int A[200100], temp;
vector<pair<int,int> > V; 
bool ada[1000010];

int main () {
	cin >> N;
	for(int i=1; i<=N; i++) {
		cin >> A[i];
	}
	sort(A+1, A+N+1);
	len = 0;
	for(int i=1; i<=N; i++) {
		if (i==1 || A[i]!=A[i-1]) {
			V.push_back(make_pair(A[i], 1));
			len++;
		} else {
			V[len-1].second++;
		}
	}
	for(int i=0; i<len; i++) {
		int bil = V[i].first;
		int num = V[i].second;
		if (num>1) {
			ada[bil] = true;
			continue;
		} else {
			bool valid = true;
			for(int i=1; i*i<=bil; i++) {
				if (bil%i==0)
					if (ada[i] || ada[bil/i])
						valid = false;
			}
			if (valid) ans++;
			ada[bil] = true;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6516
#include <stdio.h>
int main(void)
{
  int n,i,j,c,f;
  while(scanf("%d",&n),n){
    c=0;
    for(i=n+1;i<=2*n;i++){
      f=1;
      for(j=2;j*j<=i;j++){
	if(!(i%j)){
	  f=0;
	  break;
	}
      }
      if(f) c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }

int32_t main(){
	IOS;
	int n, k;
	cin >> n >> k;
	int mx = n * (n - 1) / 2 - (n - 1);
	if(k > mx)
		cout << -1 << endl;
	else{
		vector<pii> e;
		for(int i=1; i<n; i++)
			e.push_back({0, i});
		int rem = mx - k;
		for(int i=1; i<n; i++){
			for(int j=i+1; j<n; j++){
				if(rem){
					rem--;
					e.push_back({i, j});

				}
			}
		}
		cout << e.size() << endl;
		for(auto t : e)
			cout << t.X+1 << " " << t.Y + 1 << endl;
	}
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  string ans = "No";

  string top;
  string bottom;

  for (ll i = 0; i < N; i++) {
    if (i < (N / 2)) {
      top += S[i];
    } else {
      bottom += S[i];
    }
  }
  if (top == bottom) {
    ans = "Yes";
  }

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;
struct edge{ int from,to,cost; };
edge es[90];
int d[10][10];//h:ツ始ツ点 w:ツ姪堋的ツ地
int e;

int main()
{
    while(1)
    {
        cin>>e;
        if(e==0) break;
        for(int i=0;i<2*e;i+=2)
        {
            cin>>es[i].from>>es[i].to>>es[i].cost;
            es[i+1]=es[i];
            swap(es[i+1].from,es[i+1].to);//ツ逆ツづ個陛督づーツ暗クツつュ
        }
        for(int i=0;i<10;i++)
        {
            for(int j=0;j<10;j++) d[i][j]=10000;
        }
        for(int i=0;i<10;i++)
        {
            d[i][i]=0;
            while(true)
            {
                bool up=false;
                for(int j=0;j<2*e;j++)
                {
                    edge ed=es[j];
                    if(d[i][ed.from]!=10000&&d[i][ed.to]>d[i][ed.from]+ed.cost)
                    {
                        d[i][ed.to]=d[i][ed.from]+ed.cost;
                        up=true;
                    }
                }
                if(!up) break;
            }
        }
        pair<int,int> res;
        res.first=-1;res.second=300000;
        for(int i=0;i<10;i++)
        {
            int sum=0;
            for(int j=0;j<10;j++)
            {
                if(d[i][j]!=10000)
                    sum+=d[i][j];
            }
            if(sum!=0&&sum<res.second)
            {
                res.first=i;
                res.second=sum;
            }
        }
        cout<<res.first<<" "<<res.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
    //Aは与えられる三桁の数字
  int B;
  B = A / 100;
  //Bはs1
  int C, D;
  C = A % 100;
  D = C / 10;
  //Dはs2
  int E;
  E = C % 10;
  //Eはs3
  cout << B + D + E << 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;
using P = pair<int, int>;

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

    int tmp = n;
    int s = 0;

    while(n > 0) {
        s += n % 10;
        n /= 10;
    }
    if (tmp % s == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	vi p,r,s;
	Union_Find_Tree(int n){
		p=r=vi(n);
		s=vi(n,1);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	int Size(int x){return s[Par(x)];}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]){
			p[x]=y;
			s[y]+=s[x];
		}
		else{
			p[y]=x;
			s[x]+=s[y];
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){return Par(x)==Par(y);}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vi a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	sort(a.begin(),a.end());
	ll res=1,I=n;
	for(int i=n-1;i>=0;i--){
		while(I>i&&a[I-1]>a[i]+m) I--;
		(res*=I-i)%=mod;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3368
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int N, T; cin >> N >> T;
  vector<int> c(N), t(N);
  for (int i = 0; i <N; ++i){
    cin >> c[i] >> t[i];
  }
  vector<int> filtered_c;
  for(int i = 0;i < N; ++i){
    if (t[i] <=T){
      filtered_c.push_back(c[i]);
    }
  }
  if(filtered_c.size() == 0){
    cout << "TLE" << endl;
  }
  else {
    cout << *min_element(filtered_c.begin(), filtered_c.end()) << endl;
  }
}

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

#define INF 1e18
#define int long long

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

    if(s[k - 1] == 'A') s[k - 1] = 'a';
    if(s[k - 1] == 'B') s[k - 1] = 'b';
    if(s[k - 1] == 'C') s[k - 1] = 'c';

    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  vector<P> x(n);
  rep(i,n) cin >> x[i].second >> x[i].first;
  sort(x.begin(),x.end());
  int t = 0;
  rep(i,n){
    if(t+x[i].second > x[i].first){
      cout << "No" << endl;
      return 0;
    }
    t += x[i].second;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	int n;
	cin >> n;
	vector<ll> x(n);
	vector<ll> y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	
	int ans = n;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int p = (x[i] - x[j]);
			int q = (y[i] - y[j]);

			int cnt = 0;
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					if (k == l) {
						continue;
					}
					if ((x[k] - x[l] == p) && (y[k] - y[l] == q)) {
						cnt++;
					}
				}
			}

			ans = min(ans, n - cnt);
			
		}
	}
	
	
	
	cout << ans << endl;
}

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


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

  int A[N][N];
  int B[M][M];

  for(int i = 0; i < N ; i++){
    string str;
    cin >> str;
    for(int j = 0; j < N; j++){
      if(str[j]=='#'){
        A[i][j] = 0;
      }else{
        A[i][j] = 1;
      }
    }
  }
  for(int i = 0; i < M ; i++){
    string str;
    cin >> str;
    for(int j = 0; j < M; j++){
      if(str[j]=='#'){
        B[i][j] = 0;
      }else{
        B[i][j] = 1;
      }
    }
  }


  bool result = false;
  for(int i=0;i<=(N-M);i++){


    for(int j=0;j<=(N-M);j++){
      bool flag = true;

      for(int k=i;k<(i+M);k++){
        for(int l=j;l<(j+M);l++){
            //cout << endl;
            //cout << i << endl << j << endl << k << endl << l <<endl;
          if(A[k][l]!=B[k-i][l-j]){
            flag = false;
          }
        }
      }

      if(flag == true){
        result = true;
      }
    }


  }

  if(result == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	map<ll,ll> mp;
	int N; cin>>N;
	rep(i,0,N){
		int a; cin>>a;
		mp[a]++;
	}
	ll ans=0;
	for(auto elm:mp){
		if(elm.second%2==1){
			ans++;
		}
	}
	cout<<ans;
	
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a<=8 && b<=8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }

    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    string S = In<string>();
    int ans = 1;
    char p = S[0];
    for(int i = 1; i < N; i++) {
        if(p!=S[i]){
            p = S[i];
            ans++;
        }
    }
    cout << ans << endl;
}

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000005);

int main(){
  int k;
  string s;
  cin >> k >> s;
  int n = k + s.length();
  mint ans1;
  mint ans2;
  mint ans3;
  mint ans=0;

  for(int i=1;i<=n;i++){
    if(i<s.length())continue;
    ans1 = comb(i-1, s.length()-1);
    ans2 = mint(25).pow(i-s.length());
    ans3 = mint(26).pow(n-i);
    ans += ans1*ans2*ans3;
  }
  cout << ans.x;
  return 0;
}

Measured memory_bytes: 36576
N=int(input())
A=list(map(int,input().split()))
if all(map(lambda x:x==0,A)) or (sum(map(lambda x:x==0,A))==(N/3) and (len(set(A))==2) or (len(set(A))==3) and list(set(A))[0]^list(set(A))[1]^list(set(A))[2]==0 and A.count(list(set(A))[0])==A.count(list(set(A))[1]) and A.count(list(set(A))[1])==A.count(list(set(A))[2]) and A.count(list(set(A))[2])==A.count(list(set(A))[0])):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14116
s=list(input())

od = ["R","U","D"]
ev = ["L","U","D"]
flag = False
for i in range(len(s)):
    if i%2 ==0:
        if s[i] not in od:
            flag = False#print("No")
            break
        else:
            flag = True
    elif i%2 == 1:
        if s[i] not in ev:
            flag = False#print("No")
            break
        else:
            flag = True
if flag:      
    print("Yes")
else:
    print("No")

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

int main() {
  vector<int> n(3,0);
  scanf("%d %d %d", &n[0], &n[1], &n[2]);
  sort(n.begin(), n.end());
  printf("%d %d %d\n", n[0], n[1], n[2]);
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    string s, t, ans = "", tmp;
    cin >> n >> s >> t;
    rep(i, n) {
        ans += s[i];
        ans += t[i];

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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
}

signed main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  // solve();
  return 0;
}


Measured memory_bytes: 764
from collections import deque

def edge_key(node1, node2):
    return '-'.join([str(min(node1, node2)), str(max(node1, node2))])

def bfs(si):
    q = deque()
    q.append([si, -1])
    used.add(si)

    while len(q) > 0:
        prv_node, prv_col = q.popleft()
        col = 1
        for node in g[prv_node]:
            if node in used:
                continue
            else:
                if col == prv_col:
                    col += 1

                cols[eds[edge_key(prv_node, node)]] = col
                q.append([node, col])
                used.add(node)
                col += 1

N = int(input())
g = {i: [] for i in range(N)}
eds = {}
for i in range(N-1):
    a, b = map(int, input().split())
    eds[edge_key(a-1, b-1)] = i
    g[a-1].append(b-1)
    g[b-1].append(a-1)

used = set()
cols = [-1 for _ in range(N-1)]
bfs(0)
print(max(cols))
[print(col) for col in cols]


Measured memory_bytes: 55700
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);

    var max = Math.max(a,b,c);

    if (a == max) {
        console.log('%d',((a * 10) + b + c));
        return;
    }
    if (b == max) {
        console.log('%d',((b * 10) + a + c));
        return;
    }
    if (c == max) {
        console.log('%d',((c * 10) + a + b));
        return;
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n = int(input())
a = [300]
a += list(map(int,input().split()))
a += [0]
#print(a)

d = []
for i in range(1,len(a)-1):
  if a[i-1] >= a[i] < a[i+1]:
    d.append((a[i],-1))
  elif a[i-1] <= a[i] > a[i+1]:
    d.append((a[i],1))

m = 1000
k = 0
for x,y in d:
  c = m//x
  if y == -1:
    k += c
    m -= x*c
  else:
    m += k*x
    k = 0
  #print(x,y,m,k)
print(max(m,1000))


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

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

inline void Main() {
  // code
  int N, A;
  double R = 0;
  cin >> N;
  rep(i, N) {
    cin >> A;
    R += 1.0 / A;
  }

  cout << 1.0 / R << endl;
}

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


Measured memory_bytes: 892
#include <iostream>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define vvl vector<vector<ll>>
#define in(a) insert(a)
#define M 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,k-n%k);
	return 0;
}



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

string ticket(vector<int> abcd, string a, int b) {
  if (b == 3) {
    int d = abcd.at(0);
    rep(i, 3) {
      if (a.at(i) == '+')
        d += abcd.at(i + 1);
      else if (a.at(i) == '-')
        d -= abcd.at(i + 1);
    }
    if (d == 7) {
      string e;
      e = abcd.at(0) + '0';
      rep(i, 3) {
        e += a.at(i);
        e += abcd.at(i + 1) + '0';
      }
      return e + "=7";
    }
    else
      return "-1";
  }
  string c = ticket(abcd, a + "+", b + 1);
  if (c == "-1")
    return ticket(abcd, a + "-", b + 1);
  else
    return c;
}

int main() {
  vector<int> abcd;
  int a;
  cin >> a;
  rep(i, 4) {
    abcd.push_back(a % 10);
    a /= 10;
  }
  reverse(abcd.begin(), abcd.end());
  cout << ticket(abcd, "", 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
const ll M = 1000000007;
typedef int item;
ll p(ll a,int n)
{
	ll res=1;
	while(n)
	{
		if(n&1)res=res*a%M;
		n>>=1;
		a=a*a%M;
	}
	return res;
}
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	ll ans=p(10,n);
	ans-=p(9,n)*(ll)2%M;
	ans+=p(8,n);
  ans+=M;
	ans%=M;
	cout<<ans;
}


Measured memory_bytes: 3608
n = int(input())
int_list = list(map(int,(input().split())))
count = 0
for i in range(30):
    for i in range(len(int_list)):
        
        if int_list[i] % 2 == 0 :
            int_list[i] = int_list[i]/2
        else:
            int_list = []
            break      
    if len(int_list) == n :
        count += 1
    else: 
        break
print(count)


Measured memory_bytes: 9236
n = int(input())
d = list(map(int, input().split()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    s = d[t]
    m = s
    i = t
    while (d[t+1] > s):
        s += 1
    print(s-m)
else:
    print(0)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n), b(n); rep(i, n) cin >> a[n - i - 1] >> b[n - i - 1];
  ll flag = 0;
  rep(i, n)
  {
    a[i] += flag;
    if(a[i] % b[i] == 0) continue;
    else
    {
      flag += b[i] - a[i] % b[i];
    }
  }
  fin(flag);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    REP(i, S.length()){
        if(i%2 == 0) cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

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

bool debug=false;
/*---------------------------------------------------*/

int main(){
    int a,b,sum,keta;
    while(cin>>a>>b){
        sum=a+b;
        for(keta=1;;keta++){
            sum=sum/10;
            if(sum==0)break;
        }
        cout<<keta<<endl;
    }
    return 0;
}

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

int main()
{
	char K[4];
	char S[4];
	int 	count = 0;
	for (int i = 0; i < 3; i++)
	{

		cin >> K[i];

	}

	for (int j = 0; j < 3; j++)
	{
		cin >> S[j];
		
	}

	for (int k = 0; k < 3; k++)
	{
		if (K[k] == S[k])
		{
			count++;
		}
	}

	cout << count;


}

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

int main(void) {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) ans += (S[i] == '+') ? 1 : -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll temp1, temp2, qtos_objs, capacidade, valor=0;
ll dp[200][200000], objetos[200], valores[200];
ll pega_ou_nao(ll objeto, ll sobrando){
    //cout<<"br"<<endl;
    if(dp[objeto][sobrando]>=0) return dp[objeto][sobrando];
    if(sobrando==0 or objeto==qtos_objs+1) return dp[objeto][sobrando]=0;
    ll n_pega = pega_ou_nao(objeto+1, sobrando);
    //cout<<"br2"<<endl;
    if(objetos[objeto]<=sobrando){
        ll pega = pega_ou_nao(objeto+1, sobrando-objetos[objeto])+valores[objeto];
        valor = max(valor, pega);
        //cout<<"pega"<<pega<<endl;
        return dp[objeto][sobrando] = max(n_pega, pega);
    }
    return dp[objeto][sobrando] = n_pega; 
}
int main(){
    memset(dp, -1, sizeof dp);
    cin>>qtos_objs>>capacidade;
    for(ll i=1;i<=qtos_objs;i++){
        cin>>temp1>>temp2;
        objetos[i]=temp1;
        valores[i]=temp2;
    }
    pega_ou_nao(1,capacidade);
    cout<<dp[1][capacidade]<<endl;
}

Measured memory_bytes: 312704
using System;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            codefes17q_b(args);
        }

        static void codefes17q_b(string[] args)
        {
            long n = int.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long ans = (int)Math.Pow(3, n);
            long odd = 1;
            for (int i=0; i<n; i++)
            {
                if (A[i] % 2 == 0) odd *= 2;
                else odd *= 1;
            }
            ans -= odd;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	string edit,s;
	cin >> s;
	for(int i=0;i<(int)s.length();i++){
		if(s[i]=='0'){
			edit += '0';
		}
		if(s[i]=='1'){
			edit += '1';
		}
		if(s[i]=='B'){
			if(!edit.empty())
						edit.pop_back();
		}
	}
	cout << edit << "\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

import itertools as it
mylist = []
a = 0
for i in it.permutations(range(1,n+1)):
  a+=1
  mylist.append(i)

ans1 = mylist.index(p)
ans2 = mylist.index(q)
print(abs(ans1-ans2))

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define oo
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n,K;
int mod=1e9+7;
struct Matran
{
    int c[55][55];
}A;
void ReadInPut()
{
    cin>>n>>K;
    F(i,1,n)F(j,1,n)cin>>A.c[i][j];
}
Matran operator * (Matran a,Matran b)
{
    Matran res;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int r=0;
            for(int h=1;h<=n;h++)
            {
                r=(r+(a.c[i][h]*b.c[h][j])%mod)%mod;
            }
            res.c[i][j]=r;
        }
    }
    return res;
}
Matran powmod(Matran a,int n)
{
    if(n==1)return a;
    if(n%2)return a*powmod(a,n-1);
    Matran tmp=powmod(a,n/2);
    return tmp*tmp;
}
void Solve()
{
    A=powmod(A,K);
    int ans=0;
    F(i,1,n)F(j,1,n)ans=(ans+A.c[i][j])%mod;
    cout<<ans;
}
main()
{
//    freopen("CPATH.INP","r",stdin);
  //  freopen("CPATH.OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 11776
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    D, G = il()
    PC = iml(D)
    ans = 999999999

    for i in range(1 << D):
        count = 0
        score = 0
        for j in range(D):
            if i >> j & 1:
                score += PC[j][1]
                score += PC[j][0] * (j + 1) * 100
                count += PC[j][0]

        for j in range(D - 1, -1, -1):
            if i >> j & 1:
                continue
            if score >= G:
                break
            g = (j + 1) * 100
            gg = (G - score + g - 1) // g
            score += min(gg, PC[j][0]) * g
            count += min(gg, PC[j][0])
        ans = min(ans, count)
    return ans


if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3064
N,K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
gen = []
gen[0] = 1
cnt = [0] * (N + 1)
count = 0

while count < K
  p = A[gen[count]-1]
  gen[count+1] = p
  count += 1
  cnt[p] += 1
  break if cnt[p] == 2
  if count == K
    puts gen[K]
    exit
  end
end

q = gen.find_index(p)
s = (K - q) % (count - q) + q
puts gen[s]

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> ans(n,0);
  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    ans[a-1]++;
    ans[b-1]++;
  }
  for(int i=0;i < n;i++)
    cout << ans.at(i) << endl;
}


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

int main(){

	int apart[4][3][10] = {};

	int n, b, f, r, v;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		apart[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4; i++){
		if(i) cout << "####################" << endl;
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << apart[i][j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

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

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

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

    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct Node{
	int parent,l,r;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setdepth(int u,int d);
int setheight(int u);
int getsibling(int u);

void print(int u);

int main(void){
	int v,l,r,root = 0;
	
	scanf("%d",&n);
	
	for(int i = 0;i<n;i++){
		T[i].parent = NIL;
	}
	
	for(int i = 0;i < n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l = l;
		T[v].r = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(int i = 0;i < n; i++){
		if(T[i].parent == NIL)root =i;
	}
	
	setdepth(root,0);
	setheight(root);
	
	for(int i = 0;i < n;i++){
		print(i);
	}
	
	return 0;
	
}

void setdepth(int u,int d){
	if(u == NIL)return;
	D[u] = d;
	setdepth(T[u].l,d+1);
	setdepth(T[u].r,d+1);
}

int setheight(int u){
	int h1 = 0;
	int h2 = 0;
	if(T[u].l != NIL)h1 = setheight(T[u].l)+1;
	if(T[u].r != NIL)h2 = setheight(T[u].r)+1;
	H[u] = (h1 > h2 ? h1 : h2);
	return H[u];
}

int getsibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].l != u && T[T[u].parent].l != NIL)return T[T[u].parent].l;
	if(T[T[u].parent].r != u && T[T[u].parent].r != NIL)return T[T[u].parent].r;
	return NIL;
}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getsibling(u));
	int deg = 0;
	if(T[u].l != NIL)deg++;
	if(T[u].r != NIL)deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) printf("root\n");
	else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
	else printf("internal node\n");
}


Measured memory_bytes: 2144
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/	
   int a,b;
   cin>>a>>b;
   if(a<=8&&b<=8)
   	cout<<"Yay!"<<endl;
   else
   	cout<<":("<<endl;
} 	

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

#define ll long long
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}

int main(){
  ll N, W; //ものの数と重さの限界
  cin >> N >> W;
  vector<ll>v[4]; // 4種類なので
  ll  first_w, first_v, target_w, target_v;
  cin >> first_w >> first_v; //初期値を持っておく
  v[0].push_back(first_v);

  //入力を4種類に分ける
  rep(i, N-1){
    cin >> target_w >> target_v;
    v[target_w - first_w].push_back(target_v); //重さごとに振り分ける
  }

  //ソートして、それぞれの項までの和を求める
  rep(i, 4){
    sort(v[i].rbegin(), v[i].rend()); //ソート
  }
  //和の計算
  ll sum[4][101] = {0};
  rep(i, 4){
    rep(j, v[i].size()){
      sum[i][j+1] = sum[i][j] + v[i][j];
    }
  }
  //sumのsizeで4重for文回して全パターン試してみる(25**4くらい)
    //resultをmaxで更新する
  ll result = 0, now_v, now_w;
  rep(a, v[0].size()+1){
    rep(b, v[1].size()+1){
      rep(c, v[2].size()+1){
        rep(d, v[3].size()+1){
          now_v = sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
          now_w = first_w*a + (first_w+1)*b + (first_w+2)*c + (first_w+3)*d;
          if (W >= now_w) {
            result = max(result, now_v);
          }
        }
      }
    }
  }
  puts(result)
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func culculate(s string) int {
	rs := []rune(s)
	cnt := 0
	for i := 1; i < len(rs); i++ {
		if rs[i] == rs[i-1] {
			rs[i] = '*'
			cnt++
		}
	}
	return cnt
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	s, k := nextStr(), nextInt()

	switch {
	case k%2 == 0:
		s2 := strings.Join([]string{s, s}, "")
		s4 := strings.Join([]string{s2, s2}, "")
		ans2, ans4 := culculate(s2), culculate(s4)
		diff := ans4 - ans2
		fmt.Println(ans2 + (diff * ((k / 2) - 1)))
	case k%2 == 1:
		s3 := strings.Join([]string{s, s, s}, "")
		ans1, ans3 := culculate(s), culculate(s3)
		diff := ans3 - ans1
		fmt.Println(ans1 + (diff * (((k + 1) / 2) - 1)))
	}
}


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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int x; cin >> x;
    if(x == 0)cout << 1 ;
    else cout << 0;
}

Measured memory_bytes: 3608
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

ll n,m,ans=0;
vector<bool> reached(8,false);
vector<vector<ll>> G(8,vector<ll>());

void dfs(ll v,vector<bool> &reached,ll &ans){
  bool isEnd=true;
  rep(i,n) if(!(reached[i]) && i!=v) isEnd=false;
  if(isEnd){
    ans++;
    return;
  }
  reached[v]=true;
  for(auto nv:G[v]){
    if(reached[nv]) continue;
    dfs(nv,reached,ans);
  }
  reached[v]=false;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  cin>>n>>m;
  rep(i,m){
    ll a,b;cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  dfs(0,reached,ans);
  cout<<ans<<endl;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)

/***** MAIN *****/
signed main() {
  int n, ans = 0;
  string lucky;
  scanf("%d", &n);
  cin >> lucky;

  int luckyNum[n];
  REP(i, n) {
    luckyNum[i] = lucky[i] - '0';
  }

  bool dpf[10] = {};
  REP(first, n) {
    if(dpf[luckyNum[first]]) continue;

    dpf[luckyNum[first]] = true;
    bool dps[10] = {};
    REPS(second, first+1, n) {
      if(dps[luckyNum[second]]) continue;

      dps[luckyNum[second]] = true;
      bool dpt[10] = {};
      REPS(third, second+1, n) {
        if(dpt[luckyNum[third]]) continue;
        
        ans++;
        dpt[luckyNum[third]] = true;
      }
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
  
}
/***** MAIN *****/

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int a,b,i,c,d;
    while(sc.hasNext()){
      a = sc.nextInt();
      b = sc.nextInt();
      d = 1;
      for(i = 1;i <= Math.min(a,b);i++){
        if(a % i == 0 && b % i == 0)d = i;
      }
      c = a / d * b ;
      System.out.println(d + " " + c);
    }
  }
}

Measured memory_bytes: 19280
using System;
 
class Program{
	public static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			int[] n = Array.ConvertAll(s.Split(' '), int.Parse);

			float a = n[2] * n[4] - n[1] * n[5];
			float b = n[0] * n[5] - n[2] * n[3];
			float c = n[0] * n[4] - n[1] * n[3];

			Console.WriteLine("{0:f3} {1:f3}", a/c, b/c);
		}
	}
}

Measured memory_bytes: 9000
import time
startTimeProblem=time.time()

import fileinput, sys, itertools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
A = In.ints()

ct = Counter(A)
    
ans = [0]*(N)

for i in range(N):
    ans[i] = ct[i+1]

Out.intsNL(ans)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<vector<int>>f(n,vector<int>(10)); for(auto&i:f)for(auto&j:i)cin>>j;
	vector<vector<int>>p(n,vector<int>(11)); for(auto&i:p)for(auto&j:i)cin>>j;
	int64_t ans=0x8000000000000000;
	for(int i=1;i<(1<<10);++i){
		vector<int>cnt(n,0);
		for(int j=0;j<10;++j){
			if(i&(1<<j)){
				for(int k=0;k<n;++k){
					if(f.at(k).at(j))++cnt.at(k);
				}
			}
		}
		int64_t tans=0;
		for(int j=0;j<n;++j){
			tans+=p.at(j).at(cnt.at(j));
		}
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vector<vector<pair<int,double>>> g;
	public:
	vd DIJ(int s){
		priority_queue<pair<double,int>> q;
		vd d(n,inf);
		d[s]=0;
		q.push(make_pair(0,s));
		while(!q.empty()){
			auto p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first;
				double D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vector<vector<pair<int,double>>>(v);
	}
	void add_edge(int s,int t,double c){
//		cout<<s<<' '<<t<<' '<<syosu(9)<<c<<endl;
		g[s].push_back(make_pair(t,c));
	}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int k,n,m,s,t;
		cin>>k>>n>>m>>s>>t;
		s--;t--;
		if(k==0) break;
		int N=1<<k;
		Graph g(N*n);
		vi a(k);
		for(int i=0;i<k;i++) cin>>a[i];
		for(int i=0;i<m;i++){
			int u,v;
			double w;
			cin>>u>>v>>w;
			u--;v--;
			for(int j=0;j<N;j++) for(int l=0;l<k;l++) if(!(j&1<<l)){
				g.add_edge(u*N+j,v*N+j+(1<<l),w/a[l]);
				g.add_edge(v*N+j,u*N+j+(1<<l),w/a[l]);
			}
			u--;v--;
		}
		vd d=g.DIJ(s*N);
		double res=inf;
		for(int i=0;i<N;i++) res=min(res,d[t*N+i]);
		if(res>inf/2) cout<<"Impossible"<<endl;
		else cout<<syosu(9)<<res<<endl;
//		for(int i=0;i<N*n;i++) cout<<i<<' '<<syosu(9)<<d[i]<<endl;
	}
}


Measured memory_bytes: 25640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll D, T, S;
    cin >> D >> T >> S;
    if(D <= S * T){
        Yes();
    }
    else{
        No();
    }
}

Measured memory_bytes: 3564