akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};


int N,M;
string s[110],t[110];
int p[110];


int main() {
	cin>>N;
	Rep(i,N) cin>>s[i];
	cin>>M;
	Rep(i,M) cin>>t[i];
	Rep(i,N){
		p[i]=0;
		Rep(j,N){
			if(i>j && s[i]==s[j]) break;
			else if(s[i]==s[j]) p[i]++;
		}
		Rep(j,M){
			if(s[i]==t[j]) p[i]--;
		}
		if(p[i]<=0) p[i]=0;
	}
	sort(p,p+110);
	reverse(p,p+110);
	cout<<p[0]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
 
    int a,b,c,x,y,sum=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if(a+b<2*c)
    {
        printf("%d\n",a*x+b*y);
    }
    else
    {
        if(x<=y)
        {
            sum=2*x*c;
            if(2*c<b)
                sum=sum+2*abs(y-x)*c;
            else
                sum=sum+(y-x)*b;
        }
        else
        {
            sum=2*y*c;
            if(2*abs(y-x)*c<(x-y)*a)
                sum=sum+2*abs(x-y)*c;
            else
                sum=sum+(x-y)*a;
        }
 
     printf("%d",sum);
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define vi              vector< int >
#define vll             vector< ll >
#define vc              vector< char >
#define vs              vector< string >
#define pb              push_back
#define all(v)          v.begin(), v.end()
#define PI              acos(-1.0)  // 3.1415926535897932
#define yes             cout << "yes" << endl
#define no              cout << "no" << endl
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl

int main()
{
    string a;
    cin >> a;
    if(a=="ARC")
        cout << "ABC" << endl;
    else if(a=="ABC")
        cout << "ARC" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll fast(ll a, ll n)
{
  ll ret=1;
  while (n>0)
  {
    if (n & 1)
    {
      ret = ret * a % MOD;
    }
    a = a*a % MOD;
    n = (n>>1);
  }
  return (ret);
}

ll fac(ll n)
{
  ll ret = 1;
  while (n>0)
  {
    ret = ret * n %MOD;
    n--;
  }
  return (ret);
}

ll comb(ll n,ll r)
{
  ll top=1;
  ll bot=1;
  ll ret;
  while (r>0)
  {
    top *= n; top %= MOD;
    bot *= r; bot %= MOD;
    n--;r--;
  }
  ret = top * fast(bot,MOD-2) %MOD;
  return (ret);
}

int main()
{
  ll n,a,b;cin>>n>>a>>b;
  //2^n-1-nCa-nCbを求めたい
  ll ans = fast(2,n) -1;
  ans %=MOD;
  ans = ans - comb(n,a) +MOD;
  ans %=MOD;
  ans = ans - comb(n,b) +MOD;
  ans %= MOD;
  cout<<ans <<endl;
}

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

int main ()
{
    string a, b, c;
cin>>a>>b>>c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) {cout<<"YES"<<endl; return 0; }
cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN];
int ans[MAXN];
void work(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] == fa) continue;
		else {
			work(a[pos][i], pos);
			ans[pos] ^= ans[a[pos][i]] + 1;
		}
}
int main() {
	int n; read(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	work(1, 0);
	if (ans[1]) printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

Measured memory_bytes: 13952
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
H,W = LI()
S = [S() for _ in range(H)]
dp = [[-1]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        judge = 1 if S[i][j]=='#' else 0
        if i==0: #0行目
            if j==0:
                dp[0][0] = judge
            else:
                dp[0][j] = dp[0][j-1]+judge*(0 if S[0][j-1]=='#' else 1)
        else: #0行目以外
            if j==0:
                dp[i][0] = dp[i-1][0]+judge*(0 if S[i-1][j]=='#' else 1)
            else:
                temp1 = dp[i][j-1]+judge*(0 if S[i][j-1]=='#' else 1)
                temp2 = dp[i-1][j]+judge*(0 if S[i-1][j]=='#' else 1)
                dp[i][j] = min(temp1,temp2)
print(dp[-1][-1])


Measured memory_bytes: 3952
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();
    vector<vector<int>> c(26);
    rep(i, n) c[s[i]-'a'].push_back(i);
    rep(i, n) c[s[i]-'a'].push_back(i+n);
    int p = 0;
    ll ans = 0;
    rep(i, m) {
        int now = t[i] - 'a';
        int l = c[now].size();
        if (l == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(c[now].begin(), c[now].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    cout << ans + p << endl;
    return 0;
}


Measured memory_bytes: 4612
a = gets.chomp.split(" ").map(&:to_i)
a.sort!
sa1 = a[-1] - a[0]
sa2 = a[-1] - a[1]
iti = [sa1, sa2].min
ni = ([sa1, sa2].max - iti)/2
result = ([sa1, sa2].max - iti)%2 == 0? iti+ni : iti+ni+2
puts result


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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int n, k; cin>>n>>k;
	vl a(n); for(int i = 0; i<n; i++) cin>>a[i];
	for(int i = k; i<n; i++)
		if(a[i]>a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 4776
//package beg_173;
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int ac=0;
        int tle=0;
        int wa=0;
        int re=0;
        int num = s.nextInt();
        String tvguybhi = s.nextLine();
        for (int i=0;i<num;i++){
            String a = s.nextLine();
            if (a.equals("AC")){
                ac++;
            }
            if (a.equals("TLE")){
                tle++;
            }
            if (a.equals("WA")){
                wa++;
            }
            if (a.equals("RE")){
                re++;
            }
        }
        System.out.println("AC x " + Integer.toString(ac));
        System.out.println("WA x " + Integer.toString(wa));
        System.out.println("TLE x " + Integer.toString(tle));
        System.out.println("RE x " + Integer.toString(re));

    }
}


Measured memory_bytes: 60080
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx*dx + dy*dy, 0.5);
}

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

	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	
	double ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			ans += dist(i, j) * (2.0/n);
		}
	}

	printf("%8lf\n", ans);

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  	LL a[5],ans;
  	for(int i=0;i<5;i++){
      	cin>>a[i];
      if(a[i]==0)
        ans=i;
    }
  cout<<ans+1;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct edge {
  int t, d, c;
  edge() {}
  edge(int t, int d, int c) : t(t), d(d), c(c) {}
};

const int INF = 1 << 30;
int N, M;
int u[200010], v[200010], d[200010], c[200010];
vector<edge> g[100010];
int dis[100010][1010];

void init() {
  for (int i = 0; i < N; i++) {
    g[i].clear();
    for (int j = 0; j < 1010; j++) {
      dis[i][j] = INF;
    }
  }
}

void dijkstra() {
  dis[0][0] = 0;
  using P = tuple<int, int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.emplace(0, 0, 0);
  while (!que.empty()) {
    int dd, cur, pre;
    tie(dd, cur, pre) = que.top();
    que.pop();
    if (dd < dis[cur][pre]) continue;
    for (edge e : g[cur]) {
      if (dis[e.t][e.c] > dis[cur][pre] + e.d) {
        dis[e.t][e.c] = dis[cur][pre] + e.d;
        que.emplace(dis[e.t][e.c], e.t, e.c);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> N >> M, N) {
    init();
    for (int i = 0; i < M; i++) {
      cin >> u[i] >> v[i] >> d[i] >> c[i];
      u[i]--; v[i]--;
      g[u[i]].emplace_back(v[i], d[i], c[i]);
      g[v[i]].emplace_back(u[i], d[i], c[i]);
    }
    dijkstra();
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int mind = INF, add = -1;
      for (int j = 0; j < 1010; j++) {
        if (dis[i][j] < mind) {
          mind = dis[i][j];
          add = j;
        }
      }
      ans += add;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 44240
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const int N=50+5;
int main()
{
    int n,pos,mx,tmp,flag;
    while(~scanf("%d",&n))
    {
        pos=1,mx=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&tmp);
            if(abs(tmp)>mx) mx=abs(tmp),pos=i,flag=(tmp<0)?1:0;
        }
        printf("%d\n",2*n-2);
        for(int i=1;i<=n;i++)
            if(i!=pos) printf("%d %d\n",pos,i);
        if(flag)
            for(int i=n;i>1;i--)
            printf("%d %d\n",i,i-1);
        else
            for(int i=2;i<=n;i++)
            printf("%d %d\n",i-1,i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string str;
  int n;
  while(cin >> n && n){
    map<string,int> data;
    vector<pair<int,string> > v;
    char c;
    bool flg = false;
    getchar();
    while(n--){
      getline(cin,str);
      stringstream ss(str);
      while(ss >> str)data[str]++;
    }
    cin >> c;
    for(map<string,int>::iterator i=data.begin(),l=data.end();i!=l;i++){
      if(c==i->first[0]){
	v.push_back(make_pair(-i->second,i->first));
      }
    }
    sort(v.begin(),v.end());

    if(v.empty()) cout << "NA" << endl;
    else {
      for(int i=0,l=v.size();i<l&&i<5;i++){
	if(flg)cout << " ";
	else flg = true;
	cout << v[i].second;
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1252
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a;
    cin >> b;
    if ((b-a) % 2 == 0) {
        cout << (a + b) / 2 << "\n";
    } else {
        cout << "IMPOSSIBLE" << "\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int L, A, B, C, D, c, d, e, f;
  scanf("%d %d %d %d %d", &L, &A, &B, &C, &D);
  if(A % C != 0){
    c = A / C + 1;
  }else{
    c = A / C;
  }
  if(B % D != 0){
    d = B / D + 1;
  }else{
    d = B / D;
  }
  if(c > d){
    e = c;
  }else{
    e = d;
  }
  f = L - e;
  printf("%d\n", f);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()

ll lc = 0;
void dfs(vector<ll>adj[], ll s, vector<bool>&visited){
	visited[s] = true;
	lc++;
	for(auto e: adj[s]){
		if(!visited[e]){
			dfs(adj,e,visited);
		}
	}
}

int main()
{
	ll n,m;
	cin>>n>>m;
	vector<ll>adj[n];
	FOR(i,0,m){
		ll u,v;
		
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll best = 0;
	vector<bool>visited(n,false);
	FOR(i,0,n){
		lc = 0;
		if(!visited[i]){
			dfs(adj,i,visited);
		}
		best = max(lc,best);
	}
	cout<<best<<endl;
	return 0;
}


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

long long ans=0;
int H,W,K;

int solve(vector<int> on,vector<vector<char>>& c){
    int cnt=0;
    for(int i=0;i<H;i++){
        if(on[i]!=1){
            for(int j=0;j<W;j++){
                if(on[j+H]!=1){
                    if(c[i][j]=='#'){
                        cnt++;
                    }
                }
            }
        }
    }
    if(cnt==K){
        return 1;
    }else{
        return 0;
    }
}

void dfs(int size,vector<int> on,int cur,vector<vector<char>>& c){
    if(size==cur){
        ans+=solve(on,c);
        return;
    }else{
        dfs(size,on,cur+1,c);
        on[cur]=1;
        dfs(size,on,cur+1,c);
    }

}

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

    vector<vector<char>> c(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){

            cin>>c[i][j];
        }
    }

    ans=0;
    vector<int> on(H+W,0);
    dfs(H+W,on,0,c);

    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

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

    while (A.size() != 0) {
        vector<pair<int, int>> vec;
        rep(i, A.size()) {
            if (A[i] - (i + 1) == 0)
                vec.push_back({A[i], i});
        }
        sort(all(vec), greater<pair<int, int>>());
        if (vec.size() == 0) {
            cout << -1 << endl;
            return 0;
        }

        ans.push_back(vec[0].first);
        A.erase(A.begin() + vec[0].second);
    }

    reverse(all(ans));
    for (auto a : ans) {
        cout << a << endl;
    }
}

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

struct node{

  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left != NIL)
    x = x->left;

  return x;
}

Node treeMaximum(Node x){

  while(x->right != NIL)
    x = x->right;

  return x;
}

Node treeSearch(Node u, int k){

  if(u == NIL || k == u->key)
    return u;

  if(k < u->key)
    return treeSearch(u->left, k);

 else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){

  if(x->right != NIL)
    return treeMinimum(x->right);

  Node y = x->p;

  while(y != NIL && x == y->right){

    x = y;
    y = y->p;
  }

  return y;
}

void treeDelete(Node z){

  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;

  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;

  else
    x = y->right;

  if(x  != NIL)
    x->p = y->p;

  if(y->p == NIL)
    root = x;
    
  else if(y == y->p->left)
    y->p->left = x;

  else
    y->p->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }

  z->p = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
    
    
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}

void preorder(Node u){

  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){

  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);

      Node t = treeSearch(root, x);

      if ( t != NIL )
        printf("yes\n");
      else
        printf("no\n");
    }
    else if ( com[0] == 'i' ){

      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){

      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");

    } else if ( com[0] == 'd' ){

      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 25140
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  string S;
  while(cin >> S){
    int a = (S[0]-'0')*10 + S[1]-'0';
    int b = (S[2]-'0')*10 + S[3]-'0';

    bool x = (a>=1 and a<=12);
    bool y = (b>=1 and b<=12);
    

    if(x and y){
      cout << "AMBIGUOUS" << endl;
    }else if(x){
      cout << "MMYY" << endl;
    }else if(y){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }

  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		long a=input.nextLong();
		long b=input.nextLong();
		input.close();
		if((a+b)%2==0)
		{
			System.out.println((a+b)/2);
		}
		else
		{
			System.out.println("IMPOSSIBLE");
		}
		System.exit(0);
	

	}

}


Measured memory_bytes: 35824
import scala.io.StdIn

object Main {
  def main(args:Array[String]) {
    val input = StdIn.readLine()
    val rawS = input.toInt
    val s:Int = rawS % 60
    val m:Int = (rawS / 60) % 60
    val h:Int = (rawS / 60) / 60
    println(h + ":" + m + ":" + s)
  }
}

Measured memory_bytes: 43712
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; ++i) {
		cin >> D[i];
	}
	sort(D.begin(), D.end());
	int ans = D[N / 2] - D[N / 2 - 1];

	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int hantei(int n){int a,b,c,d,e;
                  a=n/10000;
                  b=(n-a*10000)/1000;
                  c=(n-a*10000-b*1000)/100;
                  d=(n-a*10000-b*1000-c*100)/10;
                  e=n-a*10000-b*1000-c*100-d*10;
                 if(a==e&&b==d){return 1;}
                 else{return 0;}}
int main(){
int A,B,sum;
  bool N;
cin>>A>>B;
  sum=0;
  for(int i=A;i<=B;i++){sum+=hantei(i);}
  cout<<sum<<endl;
}

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


int main() {
	int n, t, a;
	cin >> n >> t >> a;
	int ans = 0;
	int diff = 1e9;
	
	rep(i, n) {
		int tmp;
		int h;
		cin >> h;
		tmp = t*1000 - h * 6;
		if (diff > abs(tmp - a*1000)) {
			ans = i;
			diff = abs(tmp - a*1000);
		}
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
h = []
for i in range(N):
    hi = int(input())
    h.append(hi)


h.sort()
result = 10 ** 10
for i in range(N - K + 1):
    result = min(result, h[i + K - 1] - h[i])

print(result)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n);
    rep(0,i,n)cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==1){
        cout<<b[(n-1)/2]-a[(n-1)/2]+1;
    }else{
        cout<<b[(n-1)/2]+b[(n-1)/2+1]-(a[(n-1)/2]+a[(n-1)/2+1])+1;
    }
    
}


Measured memory_bytes: 6420
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
	
	vector<int> dd;
	vector<int> a;
	vector<int> h;
	int tmp;
	int f,g;
	int ans;
	
	for(int i=0; i<5; i++){
		scanf("%d\n", &tmp);
		dd.push_back(tmp);
		f = (tmp%10==0) ? 0 : 10-(tmp%10);
		g = (tmp%10==0) ? 10 : tmp%10;
		a.push_back(tmp+f);
		h.push_back(g);
	}
	
	ans = accumulate(a.begin(), a.end(), 0) + *min_element(h.begin(), h.end()) - 10;
	printf("%d\n", ans);
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
//#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n,k;
vector<int> vec;
vector<vector<int> > dp;
vector<int> pref;
void init()
{
    cin>>n;
    vec.resize(n);
    pref.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    pref[0]=vec[0];
    for(int i=1;i<n;i++)
        pref[i]=pref[i-1]+vec[i];
    dp.resize(n,vector<int>(n,inf));
    for(int i=0;i<n;i++)
        dp[i][i]=0;
}

int go(int l,int r)
{
    if(l<0||r<0||l>=n||r>=n)
        return 0;
    if(dp[l][r]!=inf)
        return dp[l][r];
    int ans=inf;
    for(int i=l;i<r;i++)
    {
        int sd;
        if(l==0)
            sd=0;
        else
            sd=pref[l-1];
        ans=min(ans,go(l,i)+go(i+1,r)+pref[r]-sd);
    }
    return dp[l][r]=ans;
}

signed main()
{
    init();
    go(0,n-1);
//    for(int i=0;i<n;i++)
//    {
//        for(int j=0;j<n;j++)
//            cout<<dp[i][j]<<" ";
//        cout<<"\n";
//    }
    cout<<dp[0][n-1];
    return 0;
}














Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, k, s;
vector<int> v;

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

    if (s == 1) {
        if (k == 0) {
            rep(i, n) v.push_back(2);
        } else if (k == 1) {
            v.push_back(1);
            rep(i, n-1) v.push_back(2);
        } else {
            rep(i, k) v.push_back(1);
            rep(i, n-k) v.push_back(2);
        }
    } else if (s == 1e9) {
        rep(i, k) v.push_back(s);
        rep(i, n-k) v.push_back(s-1);
    } else {
        rep(i, k) v.push_back(s);
        rep(i, n-k) {
            if (i % 2 == 0) v.push_back(1);
            else v.push_back(s+1);
        }
    }

    rep(i, n) {
        if (i < n-1) cout << v[i] << " ";
        else cout << v[i] << endl;
    }
}



Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  
  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x);
      i += i & -i;
    }
  }

  ll sum(int l,int r){ //[l, r) 0オリジン
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};


signed main(){
  int n,k,a[200000];
  cin>>n>>k;
  BIT bit(n);
  for(int i=0;i<n;i++)cin>>a[i],a[i]-=k,bit.add(i,1);
  for(int i=1;i<n;i++)a[i]+=a[i-1];
  vector<P> v;
  for(int i=0;i<n;i++)v.push_back(P(a[i],i));
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<n;i++){
    int p=(i==0?0:a[i-1]);
    int l=lower_bound(v.begin(), v.end(), P(p,i))-v.begin();
    int pp=lower_bound(v.begin(), v.end(), P(a[i],i))-v.begin();
    ans+=bit.sum(l,n);
    bit.add(pp,-1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

void solve() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    // N個の島に対して、N-1個の橋で全て連結できる
    int ans = N - 1;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ans -= uf.unite(a, b);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n%2==0) {
    for(int i=0; i<n/2; i++) {
      if(s[i] != s[n/2+i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
  else cout << "No" << endl;
  return 0;
}

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


int main(){
  string s;
  cin >> s;
  int n=s.size();
  int i;
  bool ha1=true;
  for(i=0;i<n/2;++i){
    if(s[i]==s[n-1-i]){
      continue;
    }else{
      ha1=false;
      cout << "No" << endl;
      return 0;
    }
  }
  int j=((n-1)/2)/2;
  for(i=0;i<j;++i){
    if(s[i]==s[((n-1)/2)-1-i]){
      continue;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  int k=(n+3)/2;
  int l=(k-1+n-1)/2;
  for(i=k-1;i<l;++i){
    if(s[i]==s[n-1-i]){
      continue;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

constexpr int MAX = 1000;
char str[MAX+1];

int main(void){
    while(true){
        int res = 0;
        scanf("%s", str);
        if(str[0] == '0' and str[1] == '\0') break;
        int i = 0; while(str[i] != '\0') res += str[i++] - '0';
        printf("%d\n", res);
    }

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n,l;
	cin >> n >> l;

	bool pernah_nol=false;

	int x=0;
	int total=0;
	int test=1000;

	for(int i=n;i>=1;i--){
		x=((l+i)-1);
		total+=x;
		if(abs(x)<test){
			test=x;
			if(test==0){
				pernah_nol=true;
			}
		}
	}

	if(pernah_nol==true){
		cout << total << endl;
	}
	else{
		cout << total-test << endl;
	}
}


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

static const int NMAX = 60;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1<<20);

struct edge {
  int x, y;
};

struct XYD {
  int x, y, d;
};

bool operator< (const XYD &XYD1, const XYD &XYD2) {
  return XYD1.d < XYD2.d;
};

vector<edge> G[NMAX][NMAX];
char s[NMAX][NMAX];
int h, w;


void dijkstra() {
  priority_queue<XYD> PQ;
  int color[NMAX][NMAX];
  int d[NMAX][NMAX];

  for (int i = 0; i < NMAX; i++) {
    for (int j = 0; j < NMAX; j++) {
      color[i][j] = WHITE;
      d[i][j] = INFTY;
    }
  }

  d[1][1] = 0;
  PQ.push({1,1,0});
  color[1][1] = GRAY;

  while (!PQ.empty()) {
    XYD f = PQ.top();
    PQ.pop();
    color[f.y][f.x] = BLACK;

    if (d[f.y][f.x] < f.d * (-1)) continue;

    for (int k = 0; k < G[f.y][f.x].size(); k++) {
      int nx = G[f.y][f.x][k].x;
      int ny = G[f.y][f.x][k].y;
      if (color[ny][nx] == BLACK) continue;
      if (d[ny][nx] > d[f.y][f.x] + 1) {
        d[ny][nx] = d[f.y][f.x] + 1;
        PQ.push({nx, ny, d[ny][nx]*(-1)});
        color[ny][nx] = GRAY;
      }
    }

  }

  int cnt_black = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (s[i][j] == '#') cnt_black++;
    }
  }

  if (d[h][w] == INFTY) {
    cout << -1 << endl;
  } else {
    int ans = (h * w) - cnt_black - (d[h][w] + 1);
    cout << ans << endl;
  }

}



int main() {
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> s[i][j];
    }
  }

  for (int j = 0; j < NMAX; j++) {
    s[0][j] = '#';
    for (int i = h + 1; i < NMAX; i++) {
      s[i][j] = '#';
    }
  }
  for (int i = 0; i < NMAX; i++) {
    s[i][0] = '#';
    for (int j = w + 1; j < NMAX; j++) {
      s[i][j] = '#';
    }
  }

  int nx[] = {1, 0, -1, 0};
  int ny[] = {0, 1, 0, -1};
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (s[i][j] == '#') continue;

      for (int k = 0; k < 4; k++) {
        int xx, yy;
        yy = i + ny[k];
        xx = j + nx[k];
        if (s[yy][xx] == '#') continue;

        G[i][j].push_back({xx, yy});
      }
    }
  }

  dijkstra();

  return 0;

}

Measured memory_bytes: 512
n = int(input())
e = [[int(_) for _ in input().split()] for _ in range(n)]

def recursiveOdd(x, y, str):
    p = 31 - len(str)
    if x == 0 and y == 0:
        return str
    elif abs(x) > abs(y):
        if x > 0:
            return recursiveOdd(x - 2**p, y, str + 'R')
        else:
            return recursiveOdd(x + 2**p, y, str + 'L')
    else:
        if y > 0:
            return recursiveOdd(x, y - 2**p, str + 'U')
        else:
            return recursiveOdd(x, y + 2**p, str + 'D')

mod = (e[0][0] + e[0][1]) % 2
for i in e:
    if (i[0] + i[1]) % 2 != mod:
        print(-1)
        exit()

d = [2 ** (31 - _) for _ in range(0, 32)]
if mod == 0:
    d.append(1)
print(len(d))
print(' '.join([str(_) for _ in d]))

if mod == 1:
    for xy in e:
        print(recursiveOdd(xy[0], xy[1], ''))
else:
    for xy in e:
        print(recursiveOdd(xy[0] - 1, xy[1], '') + 'R')

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		String ans = "NO";

		int i = a;
		int j=1;

		for (i = a; i <= 10000000; i = i * j) {
			if (i % b == c) {
				ans = "YES";
				break;
			}

			j++;
			i=a;
		}

		System.out.println(ans);

	}

}

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

int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(!a) cout << "1\n";
	else if(!b) cout << "2\n";
	else if(!c) cout << "3\n";
	else if(!d) cout << "4\n";
	else cout << "5\n";
}

Measured memory_bytes: 3596
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def combdp():
    n = 50
    comb = [[0] * (n + 1) for _ in range(n + 1)]
    comb[0][0] = 1

    for i in range(1, n + 1):
        comb[i][0] = 1
        for j in range(1, i + 1):
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j])

    return comb


def main():
    n, a, b = map(int, readline().split())
    v = list(map(int, readline().split()))
    v.sort()
    v.reverse()

    comb = combdp()
    val = [0] * (n + 1)
    cnt = [0] * (n + 1)

    for i in range(a, b + 1):
        val[i] = sum(v[:i])
        mn = min(v[:i])
        c1 = v.count(mn)
        ct = 0
        for j in range(n):
            if v[j] > mn:
                ct += 1
        c2 = i - ct
        cnt[i] = comb[c1][c2]

    ans_val = 0
    ans_cnt = 0

    for i in range(a, b + 1):
        for j in range(a, b + 1):
            x = val[i] * j
            y = val[j] * i
            if x >= y:
                pass
            else:
                break
        else:
            ans_val = val[i] / i
            ans_cnt += cnt[i]

    print(ans_val)
    print(ans_cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67512
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
up=LI()
low=LI()
dp=[0 for i in range(n)]
dp[0]=up[0]+sum(low)
for i in range(1,n):
    dp[i]=dp[i-1]-low[i-1]+up[i]
print(max(dp))

Measured memory_bytes: 3444
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int total = 0;
        for (int i=1 ; i <= N; i=i+2){
            int count = 0;
            for (int j=1 ; j <= N ; j=j+2){
                if(i%j==0){
                    count = count + 1;
                }
            }
            if(count==8){
                total = total + 1;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int N,a,b,c,d;
	cin >> N;

	a=N/1000; N=N-a*1000;
	b=N/100;  N=N-b*100;
	c=N/10;   N=N-c*10;
	d=N;

	if(a+b+c+d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var A = Enumerable.Range(0, N - 1).Select(_ => GetInt() - 1).ToArray();
		var cnt = new int[N];
		for(int i = N - 2; i >= 0; i--)
			cnt[A[i]]++;

		WriteLine(String.Join("\n", cnt));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 45204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool cmp(int a,int b)
{
	return b>a;
}
int main()
{
	int n; cin>>n;
	ll a[n];
	map<ll,ll>mp;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	
	sort(a,a+n,cmp);
	ll x=-1,y=-1;
	for(int i=n-1;i>=0;i--)
	{
		if(mp[a[i]]>=2)
		{
			if(x==-1)
			{
				x=a[i];
				mp[a[i]]-=2;
			}
			else
			{
				y=a[i];
				break;
			}
		}
	}
	if(x==-1 || y==-1)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<x*y<<endl;
	}
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)	
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;
int main()
{
	int n ;
	cin >> n ;
	if(n >= 30)
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;
	return 0 ;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
using namespace std;
int h[100010], dp[100010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		dp[i+1] = 1001001001;
	}
	for (int i = 0; i < n; i++) {
		dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
		dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
	}
	printf("%d\n", dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
const int N = 3e5 + 9;
 
int W, H, n, tag[N << 2], ans, mx[N << 2], t1, t2;
struct Py { int x, y; }s1[N], s2[N];
 
#define L (x<<1)
#define R (x<<1|1)
 
void Modify (int x, int l, int r, int ql, int qr, int t) {
	if (l == ql && r == qr) return void((mx[x] += t, tag[x] += t));
	int mid = (l + r) >> 1;
	if (qr <= mid) Modify(L, l, mid, ql, qr, t);
	else if (ql > mid) Modify(R, mid + 1, r, ql, qr, t);
	else Modify(L, l, mid, ql, mid, t), Modify(R, mid + 1, r, mid + 1, qr, t);
	mx[x] = max(mx[L], mx[R]) + tag[x];
}
 
int Query (int x, int l, int r, int ql, int qr) {
	if (l == ql && r == qr) return tag[x];
	int mid = (l + r) >> 1;
	if (qr <= mid) return Query(L, l, mid, ql, qr) + tag[x];
	if (ql > mid) return Query(R, mid + 1, r, ql, qr) + tag[x];
	return max(Query(L, l, mid, ql, qr), Query(R, mid + 1, r, ql, qr)) + tag[x];
}
 
void Max (int &x, int y) { if (x < y) x = y; }
 
struct Point {
	int x, y;
	bool operator < (const Point &rhs) const { return y < rhs.y; }
}p[N];
 
void Solve () {
	sort(p + 1, p + n + 1); memset(tag, 0, sizeof tag); memset(mx, 0, sizeof mx); t1 = t2 = 0;
	int mid = W >> 1;
	Modify(1, 0, n, 0, 0, W); s1[++t1] = Py{0, 0}; s2[++t2] = Py{W, 0};
	for (int i = 1, j; i <= n; ++i) {
		Max(ans, (mx[1] + p[i].y) << 1);
		if (p[i].x <= mid) {
			for (j = 0; t1 && s1[t1].x <= p[i].x; --t1, j = 1) {
				Modify(1, 0, n, s1[t1 - 1].y + 1, s1[t1].y, s1[t1].x - p[i].x);
			}
			s1[++t1] = Py{p[i].x, i - 1};
		} else {
			for (j = 0; t2 && s2[t2].x >= p[i].x; --t2, j = 1) {
				Modify(1, 0, n, s2[t2 - 1].y + 1, s2[t2].y, p[i].x - s2[t2].x);
			}
			s2[++t2] = Py{p[i].x, i - 1};
		}
		s1[++t1] = Py{0, i};
		s2[++t2] = Py{W, i};
		Modify(1, 0, n, i, i, W - p[i].y);
	}
	Max(ans, (mx[1] + H) << 1);
}
 
int main () {
	scanf("%d%d%d", &W, &H, &n); s2[0].y = s1[0].y = -1;
	for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i].x, &p[i].y);
	Solve();
	for (int i = 1; i <= n; ++i) swap(p[i].x, p[i].y); swap(W, H);
	Solve();
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 5;

vector<int> prime;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (m == i * i)
                prime.push_back(i);
            else {
                prime.push_back(i);
                prime.push_back(m / i);
            }
        }
    }
    int ans = 1;
    for (int i = 0; i < prime.size(); i++)
        if (n <= m / prime[i]) 
            ans = max(ans, prime[i]);
    cout << ans << endl;
    return 0;
}


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

int main(){
	int a,b ;
	cin >> a >> b ;
	int k ; cin >> k ;
	int cnt = 0 ;
	for(int i=1000;i>0;i--){
		if(a%i==0&&b%i==0){
			cnt++ ;
			if(cnt==k){
				cout << i << endl ;
				return 0 ;
			}
		}
	}
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int F(int H, int W) {

    ll sa = 0, sb = 0, sc = 0;
    ll rsl = 1e9;
    rep(w, 1, W + 1) {
        ll wa = w;
        ll wb = W - wa;
        ll ha = H / 2;
        ll hb = (H % 2 == 0) ? (H / 2) : (H / 2 + 1);
        sa = wa * H;
        sb = wb * ha;
        sc = wb * hb;
        ll s_max = max(sa, max(sb, sc));
        ll s_min = min(sa, min(sb, sc));
        rsl = min(rsl, s_max - s_min);
        ll tmp = wa;
        wa = wb;
        wb = tmp;
        sa = wa * H;
        sb = wb * ha;
        sc = wb * hb;
        s_max = max(sa, max(sb, sc));
        s_min = min(sa, min(sb, sc));
        rsl = min(rsl, s_max - s_min);
    }

    if(W >= 3) {
        ll wa, wb;
        wa = wb = W / 3;
        ll wc = (W % 3 == 0) ? (W / 3) : (W / 3 + 1);
        sa = H * wa;
        sb = H * wb;
        sc = H * wc;
        ll s_min = min(sa, min(sb, sc));
        ll s_max = max(sa, max(sb, sc));
        rsl = min(rsl, s_max - s_min);
    }

    return rsl;

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

    int H, W;
    cin >> H >> W;
    int rsl = 0;
    rsl = F(H, W);
    rsl = min(rsl, F(W, H));
    cout << rsl << endl;
}


Measured memory_bytes: 256