akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  int a, b, c;
  for(int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> h.at(i);
    if (h.at(i) != 0) a = x.at(i), b = y.at(i), c = h.at(i);
  }
  int ans , sub, count = 0;
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <= 100; j++) {
      count = 0;
      ans = abs(i - a) + abs(j - b) + c;
      for(int k = 0; k < N; k++) {
        sub = ans - abs(i - x.at(k)) - abs(j - y.at(k));
        sub = max(sub, 0);
        if (h.at(k) == sub) count++;
        if(count == N) {
          cout << i << ' ' << j << ' ' << ans;
          return 0;
        }
      }
    }
  }
}


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

using namespace std;

void solve(long long X)
{
	long long M = 5000;

	vector<long long> p5;
	for (long long i = -M; i <= M; ++i) {
		p5.push_back(i * i * i * i * i);
	}
	const int N = p5.size();

	for (int i = 0; i < N; ++i) {
		auto j = lower_bound(p5.begin(), p5.end(), p5[i] - X) - p5.begin();
		if (j != N && p5[i] - p5[j] == X) {
			cout << i - M << " " << j - M << endl;
			return;
		}
	}
}

int main()
{
	long long X;
	cin >> X;
	solve(X);
}


Measured memory_bytes: 3724
#include <iostream>
#include <list>
#include <string>
#include <iomanip>
using namespace std;

void insertion_sort(int nums[100], int n){
    int p;
    for(int i=1; i<n; i++){
        p = nums[i];
        for(int j=0; j<i; j++){
            if(p<nums[j]){
                for(int k=i-1; k>=j; k--){
                    nums[k+1]=nums[k];
                }
                nums[j] = p;
                break;
            }
        }
        for(int i=0; i<n; i++){
            cout << nums[i];
            if(i<n-1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }
}

int gcd(int a, int b){
    int temp, k;
    if(a > b){
        temp = a;
        a=b;
        b=temp; 
    }
    k = a%b;
    while(k != 0){
        a = b;
        b = k;
        k = a%b;
    }
    return b;
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  string S;
  cin >> S;

  ll ans = 0;
  rep0(i, N) {
    ll temp = 0;
    rep(j, i, N) {
      // cout <<j<<SP<<i<<SP<<S[j] << SP << S[j-i] << BR;
      // if (j - i == i) break;
      if (S[j] == S[j - i]) temp++;
      else {
        temp = min(i, temp);
        ans = max(ans, temp);
        // cout << ans <<BR;
        temp = 0;
      }
    }
    temp = min(i, temp);
    ans = max(ans, temp);
    // cout << ans <<BR;
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int car[100],num=0,current; 
  //car:??\??£???????????????, num:??\??£???????????°??°, current:?????¨?????°???
  while(scanf("%d",&current)!=EOF){
    if(current==0){
      printf("%d\n",car[num]);
      car[num]=0;
      num--;
    }else{
      num++;
      car[num]=current;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <string>
#include <iostream>
using namespace std;
int a,b;
void rec(string s,int x,int y) {
	if(a==x&&b==y){cout<<s<<endl;return;}
	if((x<4||y<4)&&(x==5||y==5))return;
	if(x+y>9) return;
	rec(s+"A",x+1,y);
	rec(s+"B",x,y+1);
}
int main() {
	scanf("%d%d",&a,&b);
	rec("",0,0);
}

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

int main(){
  int N,M;cin>>N>>M;
  vector<int> F(M+1,0);
  for(int i=0;i<N;i++){
    int K;cin>>K;
    for(int j=0;j<K;j++){
      int A;cin>>A;
      F.at(A)++;
    }
  }
  int ans=0;
  for(int i=1;i<=M;i++){
    if(F.at(i)==N) ans++;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
 
using namespace std;
 
int main(){
    int n;
    scanf("%d\n", &n);

    int num_ab = 0;
    int x2a = 0;
    int b2a = 0;
    int b2x = 0;

    for(int i = 0; i < n; ++i){
        string s;
        getline(cin, s);

        if(s.at(0) == 'B' && s.back() == 'A'){
            b2a++;
        }else if(s.at(0) == 'B'){
            b2x++;
        }else if(s.back() == 'A'){
            x2a++;
        }
        for(int j = 0; j < s.size() - 1; ++j){
            if(s.at(j) == 'A' && s.at(j+1) == 'B'){
                num_ab++;
            }
        }
    }

    int ans = num_ab;
    if(b2x == 0 && x2a == 0){
        ans += max(b2a - 1, 0);
    }else{
        ans += b2a + min(b2x, x2a);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
#include <utility>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/

int main() {
	ll n,m;cin >> n>>m;
	cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];
    sort(all(a));
    REP(i, n-1) a[i+1] += a[i];
    int ans = n;
    REP(i, n-1){
        if(a[i+1]-a[i] > a[i]*2) ans = n-i-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
//typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
//#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int n,m;
long long dp[100][100];
static const long long INF=(1LL<<32);

void floyd()
{
	REP(k,n)
	{
		REP(i,n)
		{
			if(dp[i][k]==INF)continue;
			REP(j,n)
			{
				if(dp[k][j]==INF)continue;
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
			}
		}
	}
}

int main()
{
	cin>>n>>m;
	REP(i,n)
	{
		REP(j,n)
		{
			dp[i][j]=INF;
			if(i==j)dp[i][j]=0;
		}
	}
	REP(i,m)
	{
		int s,t,d;cin>>s>>t>>d;
		dp[s][t]=d;
	}
	floyd();
	
	bool negative=false;
	REP(i,n)if(dp[i][i]<0)negative=true;
	if(negative)cout<<"NEGATIVE CYCLE"<<endl;
	else
	{
		REP(i,n)
		{
			REP(j,n)
			{
				if(j)cout<<" ";
				if(dp[i][j]==INF)cout<<"INF";
				else cout<<dp[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
	
}

Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

int main() {
  int n, k; cin >> n >> k;
  vector<double> a(n), p(n);
  rep(i, n) {
    cin >> a[i];
    p[i] = (a[i]+1)/2.;
  }

  vector<double> s(n+1, 0);
  for(int i = 1; i <= n; i++) {
    s[i] = s[i-1] + p[i-1];
  }

  double ans = 0;
  for(int i = 0; i < n-k+1; i++) {
    ans = max(ans, s[i+k] - s[i]);
  }
  cout << setprecision(10);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

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

        System.out.println(((top + bottom) * height) / 2);
    }
}

Measured memory_bytes: 21844
inpl = lambda: list(map(int,input().split()))
H, W = inpl()
S = [input() for _ in range(H)]
A = [[0]*W for _ in range(H)]

for h in range(H):
    start = 0
    while start < W:
        while start < W and S[h][start] == '#':
            start += 1
        end = start
        while end < W and S[h][end] == '.':
            end += 1
        for i in range(start,end):
            A[h][i] += end - start
        start = end

for w in range(W):
    start = 0
    while start < H:
        while start < H and S[start][w] == '#':
            start += 1
        end = start
        while end < H and S[end][w] == '.':
            end += 1
        for i in range(start,end):
            A[i][w] += end - start
        start = end

ans = max(max(max(A[i]) for i in range(H)) - 1, 0)
print(ans)

Measured memory_bytes: 101080
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















template <typename T>
class bellmanford {
private:
    struct edge {
        int to;
        T cost;
    };
    int n;
    vector<vector<edge>> g;
    vector<T> dist;
    
public:
    bellmanford(int n) : n(n), g(n){}
    
    void add_edge(int v1, int v2, T cost){
        g[v1].push_back({ v2, cost });
    }
    
    // 負の閉路があるときfalseを返す
    bool run(int s){
        dist = vector<T>(n, INF);
        dist[s] = 0;    //開始点の距離は0
        
        for (int i = 0; i < n; i++) {
            for (int v = 0; v < n; v++) {
                for (auto& e : g[v]) {
                    if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        if (i == n - 1) {
                            // return false;
                            dist[e.to] = -INF;
                        }
                    }
                }
            }
        }
        return true;
    }
    
    T get_distance(int v){
        return dist[v];
    }
};





int main(){
    ll n, m;
    cin >> n >> m;
    bellmanford<ll> bell(n);
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bell.add_edge(a, b, -c);
    }
    bell.run(0);
    ll ans = -bell.get_distance(n - 1);
    if(ans != INF) cout << ans << endl;
    else cout << "inf" << endl;
}

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

int main() {
  int N, n, sum;
  
  cin >> N;
  
  n = N;
  while ( n%10 ) {
    sum += n%10;
    n /= 10;
  }
  
  if ( N%sum ) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}
int main() {
  int x;
  cin >> x;
  cout << (((x / 500) * 1000) + (((x % 500) / 5) * 5)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	V<int> b(a);
	fo(i,a)
	cin>>b[i];
	Sort(b);
	rev(b);
	int c=0,d=0;
	fo(i,a){
		if(i%2==0)
			c+=b[i];
		else
			d+=b[i];
	}
	cout<<c-d<<endl;
}

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

int main(){
  //入力
  int n;  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  ll ans=0;
  rep(i,n){
    if(a[i] <= b[i]){
      int rm = b[i] - a[i];
      ans += a[i];
      if(a[i+1] >= rm){
        a[i+1] -= rm;
        ans += rm;
      }else{
        ans += a[i+1];
        a[i+1] = 0;
      }
    }else{
      ans += b[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,input=0,output=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a==(input= max(input,a))){
      output++;
    }
       }
  cout<<output;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void)

{

int a,b,c;

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

if(a<b)

{

if(b<c)

{

printf("Yes\n");

}

else

{

printf("No\n");

}

}

else

{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 580
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

string s;
int ans = 0, n;

void add(string s){
  int k = s.size();
  int p = 1;
  reverse(all(s));
  for(auto t:s){
    ans += ( p*(t%48) );
    p*=10;
  }
}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> s;
  n = s.size();

  for(int i=0;i<(1<<(n-1));i++){
    string cur = "";
    cur+=s[0];
    for(int j = 0;j<n-1;j++){
      if( i&(1<<j) ){
        add(cur);
        cur = "";
        cur+=s[j+1];
      }
      else cur+=s[j+1];
    }
    //cur+=s[n-1];
    add(cur);
  }
  cout << ans << endl;

return 0;
}
///....


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

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

  int ans = 1;
  while(ans<=10000) {
    if((ans*8)/100==a && (ans*10)/100==b) {
      cout<<ans<<endl;
      return 0;
    }
    ans++;
  }

  cout<<-1<<endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(r,b,g,n):
  r_max = n // r
  b_max = n // b
  g_max = n // g
  ans = 0
  for i in range(r_max+1):
    for j in range(b_max+1):
      rest = n - (r*i + b*j)
      if rest >= 0 and rest % g == 0:
        ans += 1
  return ans



def main():
  R,G,B,N = map(int,input().split())
  print(solve(R,G,B,N))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9128
#include<stdio.h>
int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(W-r>=x &&  H-r>=y && x-r>=0 && y-r>=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  vi que;
  vvi cost(h, vi(w, inf));
  cost[0][0] = 1;
  int gx = w-1, gy = h-1;
  que.eb(0);
  rep(i, que.size()) {
    int x = que[i] % w, y = que[i] / w;
    srep(dx, -1, 2) srep(dy, -1, 2) {
      int nx = x+dx, ny = y+dy;
      if (dx*dx + dy*dy != 1 ||
          nx < 0 || nx >= w || ny < 0 || ny >= h ||
          grid[ny][nx] == '#' ||
          cost[ny][nx] != inf) continue;
      cost[ny][nx] = cost[y][x] + 1;
      que.pb(ny*w + nx);
    }
  }
  int ans = h * w;
  rep(i, h) rep(j, w) ans -= (grid[i][j] == '#');
  ans -= cost[gy][gx];
  if (cost[gy][gx] == inf) ans = -1;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
package main

import (
	"io"
	"os"

	"fmt"
	"sort"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}

	return x
}

func maxAbs(n int, a []int) int {
	sort.Ints(a)
	return abs(a[n-1] - a[0])
}

func Solve(in io.Reader, out io.Writer) {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}

	fmt.Fprintln(out, maxAbs(n, a))
}

func main() {
	Solve(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	int N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	sort(A.begin(), A.end());

	rep(i, N-1) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;


	return 0;
}


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


double Snuke(long long x) {
    long long tmp = 0, c = x;
    while(c) {
        tmp += c % 10;
        c /= 10;
    }
    return 1.0 * x / tmp;
}



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

    long long res = 0, x = 1;
    while(n--) {
        double t1, t2;
        while(true) {
            t1 = Snuke(res + x);
            t2 = Snuke(res + x * 10);
            if(t1 <= t2) break;
            x *= 10;
        }
        res += x;
        printf("%lld\n", res);
    }
}

Measured memory_bytes: 256
// ABC142_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

//CUT HERE BEGIN ysys13
template <typename T>
vector<T> divisor(T n) {
    // 約数列挙(n 自身は含まない，必要に応じて vec.push_back())
    vector<T> vec;
    for(T i = 1; i*i <= n ; ++i) {
        if (n%i == 0) {
            vec.push_back(i);
            if (i != 1 && i*i != n) {
                vec.push_back(n / i);
            }
        }
    }
    sort(vec.begin(), vec.end());
    vec.push_back(n);
    return vec;
}
//CUT HERE END

template <typename T>
T gcd(T a, T b) {
    if (a <= 0 || b <= 0) {
        // どちらかが 0 以下であれば -1 を返す
        return -1;
    } else if (a == 1 || b == 1) {
        // どちらかが 1 であれば，最大公約数は 1
        return 1;
    } else {
        if (a < b) swap(a, b);
        if (a%b == 0) return b;
        return gcd(b, a%b);
    }
}

//BEGIN CUT HERE
template <typename T>
T isPrime(T x){
    if(x <= 1) {
        // 0，1は素数じゃない
        return 0;
    } else if (x == 2) {
        // 2は素数
        return 1;
    } else if (x%2 == 0) {
        // 偶数は除く
        return 0;
    } else {
        // 偶数は２で割り切れるため除く
        for(T i = 3; i*i <= x; i+=2) {
            if(x%i == 0) return 0;
        }
        return 1;
    }
}
//END CUT HERE

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B;
    cin >> A >> B;
    
    // calculation
    vector<ll> fac_A = divisor(A);
    vector<ll> fac_B = divisor(B);
    set<ll> fac_AB;
    
    REP(i, fac_A.size()) {
        REP(j, fac_B.size()) {
            if (fac_A[i] == fac_B[j]) {
                fac_AB.insert(fac_A[i]);
            }
        }
    }
    
    ll res = 1;
    auto begin = fac_AB.begin(), end = fac_AB.end();
    for (auto iter = begin; iter != end; iter++) {
        if (isPrime(*iter)) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
  int H, N, A, sum = 0;
  scanf("%d %d", &H, &N);

  for(int i=0; i<N; i++){
    scanf("%d", &A);
    sum += A;
  }

  if(sum >= H)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
int main(){
	int Q;scanf("%d",&Q);
	while(Q--){
		int A,B,C,D;
		scanf("%d%d%d%d",&A,&B,&C,&D);--C;
		int d=(A+B)/(A<B?A+1:B+1);
		if(d==1){
			for(int i=C;i<D;i++)putchar("AB"[i+(B>A)&1]);
		}
		else{
			long long t=1ll*d*(A+1)-B-1;
			if(t<0)t=0;
			t/=1ll*d*d-1;
			long long lim=t+A+1-(B-t+d-1)/d;
			for(int i=C;i<D;i++)putchar(i<lim?"AB"[i%(d+1)==d]:"AB"[(A+B-i)%(d+1)>0]);
		}
		puts("");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	int total = (b - a) * (b - a + 1) / 2 - b;
	cout << total << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string.h>
using namespace std;
int main(){

    int n;
    string s;
    cin>>n;
    cin>>s;
    int i=0;
    int count=0;
    while(i<n){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            i=i+3;
            count++;
        }
        else{
            i++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,e) for(ll i = 0;i<e;i++)
#define foa(i,s,e) for(ll i=s;i<e;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    string s;
    cin>>s;
    if(s=="ARC")cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    
    
    

    

}

Measured memory_bytes: 3644
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n,k = MI()
a = LI()
d = [-1]*n
d[0] = 0
for i in range(n):
	for j in range(i,min(i+k+1,n)):
		if d[j] == -1:
			d[j] = d[i]+abs(a[i]-a[j])
		else:
			d[j] = min(d[j],d[i]+abs(a[i]-a[j]))
print(d[-1])

Measured memory_bytes: 84732
import string
LTRS = string.ascii_letters + string.digits
MAXL = 128

def query(s):
    print('?', s)
    r = int(input())
    if r==0:
        print('!', s)
        exit()
    return r

import heapq
hq = []
heapq.heapify(hq)
for c in LTRS:
    r = query(c * MAXL)
    l = MAXL - r
    if l:
        heapq.heappush(hq, (l, c*l))

def merge(s,t):
    cost = query(s)
    ret = ''
    i = j = 0
    while i < len(s) and j < len(t):
        r = query(ret + t[j] + s[i:])
        if r < cost:
            cost = r
            ret += t[j]
            j += 1
        else:
            ret += s[i]
            i += 1
    if i == len(s):
        ret += t[j:]
    elif j == len(t):
        ret += s[i:]
    else:
        assert False
    return ret

while len(hq) >= 2:
    _,s = heapq.heappop(hq)
    _,t = heapq.heappop(hq)
    u = merge(s,t)
    heapq.heappush(hq, (len(u), u))

_,ans = heapq.heappop(hq)
query(ans)

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll Q;
    cin >> Q;

    while(Q--){
        ll a;
        cin >> a;

        ll index = lower_bound(ALL(A), a) - A.begin();
        p(index);
    }

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

typedef long long LL;

LL f(LL b, LL n)
{
	if(n < b)
		return n;

	return f(b, n/b) + n%b;
}

int main(void)
{
	LL n, s;
	cin >> n >> s;

	if(s > n)
	{
		cout << -1 << endl;
		return 0;
	}

	if(n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}

	for(LL i=2; i<sqrt(n); i++)
	{
		if(f(i, n) == s)
		{
			cout << i << endl;
			return 0;
		}
	}

	for(LL i=sqrt(n); i>0; i--)
	{
		LL b = (n - s)/i + 1;
		if(b <= 1)
			continue;

		if(f(b, n) == s)
		{
			cout << b << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}




//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m ;
  cin >> n >> m ;
  
  vll kaizyo(100000+1) ;
  kaizyo[0] = 1 ;
  kaizyo[1] = 1 ; 
  for(ll i=2;i<=100000;i++){
    kaizyo[i] = kaizyo[i-1]*i%MOD ;
  }
    
  if(max(n,m)-min(n,m)>=2){
    cout << 0 <<endl ;
  }
  else{
    if(n==m){
      cout << 2*kaizyo[n]*kaizyo[m]%MOD <<endl ;
    }
    else{
      cout << kaizyo[n]*kaizyo[m]%MOD <<endl ;
    }
  }
      
  
  
  
  
  
  
  return 0 ;
}






Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;

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

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

    sort(v.begin(), v.end(), greater<int>());

    int count = 0;
    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (v[i] < v[j] + v[k] && v[i] != v[j] && v[j] != v[k] && v[i] != v[k]) {
                    count++;
                }
            }
        }
    }

    cout << count;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int l=0,r=s.size()-1;l<=r;l++,r--){
    if(s[l]==s[r])
      continue;
    if(s[l]=='x'){
      for(;s[l]=='x';l++){
        ans++;
        if(l>r){
          puts("-1");
          return 0;
        }
      }
      if(s[l]!=s[r]){
        puts("-1");
        return 0;
      }
    }else if(s[r]=='x'){
      for(;s[r]=='x';r--){
        ans++;
        if(l>r){
          puts("-1");
          return 0;
        }
      }
      if(s[l]!=s[r]){
        puts("-1");
        return 0;
      }
    }else{
      puts("-1");
      return 0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 

int main(void) {
  int n;
  cin >> n;
  ll a[n];
  rep (i, n) cin >> a[i];

  vector<ll> L(n, 0), R(n, 0);

  L[0] = a[0];
  R[n - 1] = a[n - 1];

  for (int i = 1; i < n; i++) {
    L[i] = L[i - 1] + a[i];
  }
  for (int i = n - 2; i >= 0; i--) {
    R[i] = R[i + 1] + a[i];
  }

  ll ans = 20020020022;

  for (int i = 0; i < n - 1; i++) {
    ll tmp = abs(L[i] - R[i + 1]);
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int,input().split()))
def solve(A):
  count = {}
  for x in A:
    if x not in count:
      count[x] = 0
    count[x] += 1
  if 0 in count and count[0] == N: return True
  if len(A) % 3 != 0: return False    
  xs = []
  for k, v in count.items():
    if v % (N//3) != 0: return False
    for _ in range(v // (N//3)):
      xs.append(k)
  return (xs[0] == xs[1] ^ xs[2]) or (xs[1] == xs[2] ^ xs[0]) or (xs[2] == xs[0] ^ xs[1])

print('Yes' if solve(A) else 'No')


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

using Pair = pair<int, int>;
#define X first
#define Y second

void solve()
{
	int n;
	cin >> n;

	vector< vector<Pair> > saying(n, vector<Pair>());

	int a, x, y;
	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		for(int j = 0; j < a; ++j)
		{
			cin >> x >> y;
			x--;
			saying[i].emplace_back(make_pair(x, y));
		}
	}

	int people = 1 << n; // bit 0で不親切, 1で正直者
	int ans = 0;
	while(people -= 1, people >= 0)
	{
		bitset<15> mask(people);
		if ((int)mask.count() <= ans) continue;

		//cout << "-----" << endl << people << " " << mask << endl;
		bool ok = true;
		for(int i = 0; i < n; ++i)
		{
			bool isHonest = mask[i];
			//cout << i << " " << isHonest << endl;
			for(const auto& s : saying[i])
			{
				if ( isHonest) ok &= ((int)mask[s.X] == s.Y);
			}

			if (!ok) break;
		}
		if (ok)
		{
			ans = (int)mask.count();
		}
	}
	//cout << endl;
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define xx first
#define yy second
#define ll long long
using namespace std;

const int N = 200000 + 5;
int n;
pair<int, int> info[N];

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf ("%d", &info[i].xx);
		info[i].yy = i;
	}
	sort (info + 1, info + n + 1);
	for (int i = 1; i <= n; ++i) {
		if (i == info[n].yy) {
			printf ("%d\n", info[n - 1].xx);
		}
		else printf ("%d\n", info[n].xx);
	}
	return 0;
}






















Measured memory_bytes: 3200
// dp[現在いくつの数を使ったか][現在使おうとしている数字][現在の合計] = 組み合わせ数
#include <iostream>
using namespace std;

typedef long long ll;

ll dp[102][12][1002];

int main(){
  dp[0][0][0] = 1;

  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 9; j++){
      for(int k = 0; k <= 1000; k++){
        if(dp[i][j][k] == 0) continue;

        dp[i + 1][j][k] += dp[i][j][k];

        if(j == 9) continue;
        if(1000 < k + i) continue;

        dp[i + 1][j + 1][k + i] += dp[i][j][k];
      }
    }
  }

  int n, s;

  while(cin >> n >> s, n || s){
    cout << dp[101][n][s] << endl;
  }
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k<0 || n<k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

int n,k,a[20];

mint f(int i,int x){
	return choose(n-x,a[i]-x)/fact(x);
}

int main(){
	cin>>n>>k;
	rep(i,k) cin>>a[i];

	mint dp[1001][21];
	dp[0][0]=1;
	rep(i,n+1) rep(j,k) rep(x,i+1) dp[i][j+1]+=f(j,x)*dp[i-x][j];

	cout<<fact(n)*dp[n][k]<<'\n';

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y;
  cin >> x >> y;
  if (abs(x - y) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

//木が完全マッチングを作れるかどうか判定する O(N)
bool is_perfect_matching_graph(const vector<vector<int>>& edge){
    int N = edge.size();
    vector<int> degree(N,0);
    vector<bool> visited(N,false);
    queue<int> q;
    REP(i,N){
        degree[i] = edge[i].size();
        if(degree[i] == 1) q.push(i);
    }
    while(not q.empty()){
        int v = q.front(); q.pop();
        if(visited[v]) continue;
        visited[v] = true;
        int pair_of_v = -1;
        for(auto to:edge[v]){
            if(visited[to]) continue;
            pair_of_v = to;
        }
        if(pair_of_v==-1) return false;
        visited[pair_of_v] = true;
        for(auto to:edge[pair_of_v]){
            if(visited[to]) continue;
            degree[to]--;
            if(degree[to] == 1){
                q.push(to);
            }
        }
    }
    return true;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a,b;
    vector<vector<int>> edge(N);
    REP(i,N-1){
        cin >> a >> b;
        edge[--a].emplace_back(--b);
        edge[b].emplace_back(a);
    }
    if(is_perfect_matching_graph(edge)) cout << "Second" << bn;
    else cout << "First" << bn;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int a,b,t;cin>>a>>b>>t;
  int time = a;
  int cnt =0;
  while(time<=t){
    cnt += b;
    time += a;
  }
  cout << cnt << endl;
  return 0;
}


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


long long gcd(long long a,long long b){
    while(b){
        int temp = a %b;
        a = b;
        b = temp;
    }
    return a;
}

int main(){
    long long a,b;
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
    int n, m; cin >> n >> m;
    vector<int> v(n, 0);
    set<int> flg;
    for(int i=0; i<m; i++){
        int s, c; cin >> s >> c;
        if(s==1 && c==0 && n!=1){
          cout << "-1" << endl; return 0;
        }         
        if(flg.count(s)==1 && v[s-1]!=c){
            cout << "-1" << endl; return 0;
        }
        v[s-1]=c;
        flg.insert(s);
    }
    if(v[0]==0 && n!=1) v[0]=1;
    for(int i=0; i<n; i++)  cout << v[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    sort(a, a + n);
    int x = 1;
    for (int i = 0 ; i < n - 1 ; i++) {
    	if (a[i + 1] > a[i]) x++; 
	}
	cout << x;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

def binary_search(num, start, end, l):
    if start == end:
        return start
    tmp = (start + end) // 2
    if l[tmp] <= num:
        return binary_search(num, tmp+1, end, l)
    else:
        return binary_search(num, start, tmp, l)

def main():
    MAX = int(1e9)
    check_list = [0]
    tmp = 0
    i = 1
    while True:
        tmp += i
        if tmp < MAX:
            check_list.append(tmp)
            i += 1
        else:
            break
    len_ = len(check_list)

    while True:
        b = int(input())
        if b == 0:
            break
        ans = 0
        start = binary_search(b, 0, len_-1, check_list)
        for i in range(start, 0, -1):
            if check_list[i] <= b:
                tmp = (b - check_list[i]) % i
                if tmp == 0:
                    print((b-check_list[i])//i+1, i)
                    break

if __name__ == "__main__":
    main()



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

int main(){
    long long N,K;
    cin >> N >> K;
    if(K%2 == 1) {
        cout << (N/K)*(N/K)*(N/K) << endl;
    } 
    else {
        cout << (N/K)*(N/K)*(N/K)+((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)<< endl;
    }
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s', $s);
$n = strlen($s);
$cnt = 0;
$max = 0;
for ($i = 0; $i < $n; $i++) {
    if (in_array($s[$i], ['A', 'C', 'G', 'T'])) $cnt++;
    else $cnt = 0;
    $max = max($max, $cnt);
}
echo $max . PHP_EOL;

Measured memory_bytes: 4728
from collections import defaultdict
N, Q = map(int, input().split())

neighbor = defaultdict(list)
counter = [0] * N

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

for i in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

def propagate():
    stack = [(0, None)]
    while stack:
        (node, parent) = stack.pop()
        for c in neighbor[node]:
            if c != parent:
                counter[c] += counter[node]
                stack.append((c, node))

propagate()
print(*counter)


Measured memory_bytes: 78472