akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

vector<ll> A;
vector<vector<int>> edge;

bool dfs(int now, int pre) {
    bool res = true;
    ll cstone = 0;
    ll child = 0;
    ll mx = 0;
    for (int nxt : edge[now]) {
        if (nxt == pre) continue;
        res &= dfs(nxt, now);
        child++;
        cstone += A[nxt];
        mx = max(A[nxt], mx);
    }
    if (child == 0) return true;
    if (child == 1) return (res && (A[now] == cstone));
    if (child >= 2) {
        if (cstone > A[now]*2) res = false;
        if (cstone < A[now]) res = false;
        if (cstone - A[now] > cstone-mx) res = false;
        A[now] -= min(A[now], (cstone - A[now]));
        return res;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    A.resize(N+1, 0);
    edge.resize(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    edge[0].push_back(1);
    edge[1].push_back(0);
    for (int i = 0; i < N-1; i++) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    
    bool ans = dfs(1, 0);
    if (edge[1].size() >= 3 && A[1] != 0) ans = false;
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 14464
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int total = x+y+z;
    
    if(total <= 21){
      System.out.println("win");
    }else{
      System.out.println("bust");
    }
    
  }
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
            x[0] += A[i];
        else
            x[0] -= A[i];
    }

    for (int i = 1; i < N; i++)
    {
        x[i] = (2 * A[i - 1] - x[i - 1]);
    }

    for (int i = 0; i < N; i++)
    {
        cout << x[i] << (i == N - 1 ? "\n" : " ");
    }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    ll n;cin>>n;
    vector<ll>a,b;
    for(ll i=1;i<=n;i++)
    {
    	int x;cin>>x;
    	a.pb(i-x);
    	b.pb(i+x);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    map<ll,ll>mp;
    for(ll i=0;i<n;i++)mp[b[i]]++;
    ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		if(mp[a[i]])cnt+=mp[a[i]];
	}
	cout<<cnt;
}


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

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int field[51][51];
int h, w;

void sol(int x, int y)
{
  field[x][y] = 0;
  for (int i = 0; i < 8; i++){
    if ((0 <= x + dx[i] && x + dx[i] < h) || (0 <= y + dy[i] && y + dy[i] < w))
    if (field[x + dx[i]][y + dy[i]] == 1) sol(x + dx[i], y + dy[i]);
  }
}

int main()
{

  while (cin >> w >> h, h || w){
    int res = 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> field[i][j];
      }
    }

    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (field[i][j] == 1){
          res++;
          sol(i, j);
        }
      }
    }
    cout << res << endl;
  }
}

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

int main() {
  int n,m,j = 0, ans = 0;
  cin >> n >> m;
  vector<int> a(m*2);
  for(int i = 0; i < m*2; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    int count = 0;
    for(int j = 0; j < m*2; j++) if(a[j] == i+1) count++;
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,tmp;
  scanf("%d %d %d", &a, &b, &c);
  
  tmp=a;
  a=c;
  c=b;
  b=tmp;
  
  printf("%d %d %d",a,b,c);
  
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;

    for (int i = 1; i <= 1000; ++ i){

        if(100 * i <= x && x <= 105 * i){
            cout << 1 << endl;
            return 0;
        }
    }

    cout << 0 << endl;

}

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

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

    int n;
    cin >> n;

    string array[n];

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

    bool flag = true;
    vector<string> done;
    for (int i = 0; i < n-1; ++i)
    {

    	bool anotherFlag = true;

    	int size = array[i].size();
    	done.push_back(array[i]);
    	char check = array[i][size-1];

    	for (int j = 0; j < done.size(); ++j)
    	{
    		if (done[j] == array[i+1]) anotherFlag = false;
    	}

    	if (array[i+1][0] != check || !anotherFlag)
    	{
    		flag = false;
    		break;
    	}
    }

    if (flag) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{

    
    class Program
    {
       
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            decimal[] p = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();         

            decimal[,] dp = new decimal[N + 1, N + 1];
            //初期化
            dp[0, 0] = 1;
            for (int i = 0; i < N; i++)
            {
                for(int j = 0; j <= i; j++)
                {
                    //i + 1枚目が表
                    dp[i + 1, j + 1] += dp[i, j] * p[i];
                    //i + 1枚目が裏
                    dp[i + 1, j] += dp[i, j] * (1 - p[i]);
                }
            }

            decimal sum = 0;
            for(int j = (N + 1) / 2; j <= N; j++)
            {
                sum += dp[N, j];
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 150752
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n][3];
	for (int i = 0;i < n;++i) {
		for (int j = 0;j < 3;++j) {
			cin >> arr[i][j];
		}
	}
	int dp[n][3];
	memset(dp,0,sizeof(dp));
	for (int i = 0;i < 3;++i) {
		dp[0][i] = arr[0][i];
	}
	for (int i = 1;i < n;++i) {
		for (int j = 0;j < 3;++j) {
			for (int k = 0;k < 3;++k) {
				if (k == j) {
					continue;
				} else {
					dp[i][j] = max(dp[i-1][k]+arr[i][j],dp[i][j]);
				}
			}
		}
	}
	// for (int i = 0;i < n;++i) {
	// 	for (int j = 0 ;j < 3;++j) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << '\n';
	// }
	int ans = 0;
	for (int i = 0;i < 3;++i) {
		ans = max(dp[n-1][i],ans);
	}
	cout << ans << '\n';
 	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000003,INF=1<<30;

int prime[MAX];//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(1000001);
    while(1){
        int A,B,C;cin>>A>>B>>C;
        if(A==0) break;
        
        int cnt=0;
        
        while(cnt<C){
            if(is_prime[A]) cnt++;
            A+=B;
        }
        
        cout<<A-B<<endl;
    }
}



Measured memory_bytes: 4500
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
const int N=5e3+10;
int stk[N],n,m,l[N][210],r[N][210],a[N][205],top=0;
ll dis[N],f[N][N],ans=0;
inline void add(int r1,int c1,int r2,int c2,ll v)
{
	f[r1][c1]+=v; f[r1][c2+1]-=v; f[r2+1][c1]-=v; f[r2+1][c2+1]+=v;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d%d",&n,&m);
  for(int i=2;i<=n;i++) scanf("%d",&dis[i]),dis[i]+=dis[i-1];//处理距离
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
  top=0; 
  for(int i=1;i<=m;i++)//第i张票 
  {
	 top=0;
	 for(int j=1;j<=n;j++)
	 {
	   while(top&&a[stk[top]][i]<a[j][i]) top--;
	   l[j][i]=(top?stk[top]:0);
	   stk[++top]=j; 
     }
     top=0;
     for(int j=n;j>=1;j--)
     {
     	while(top&&a[stk[top]][i]<a[j][i]) top--;
     	r[j][i]=(top?stk[top]:n+1);
     	stk[++top]=j;
	 }
     for(int j=1;j<=n;j++)
       add(l[j][i]+1,j,j,r[j][i]-1,a[j][i]);
  } 
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      {
      	f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
      	if(j>=i) ans=max(ans,f[i][j]-(dis[j]-dis[i]));
	  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 208512
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int i, j, c, k[4], s, t, u, v, ans[4], mai=0;
	while(1){
		cin >> c;
		if(!c) break;
		if(mai)cout << "\n";
		mai = 10000;
		for(i=0;i<4;i++) cin >> k[i];
		for(s=0;s<=k[0];s++){
			for(t=0;t<=k[1];t++){
				for(u=0;u<=k[2];u++){
					for(v=0;v<=k[3];v++){
						int ch = (s*10+t*50+u*100+v*500) - c;
						if(ch < 0)continue;
						else{
							if((!((ch/500)&&v)) && (!(((ch/100)%5)&&u)) && (!(((ch/50)%2)&&t)) && (!(((ch/10)%5)&&s))){
								//cout << s << " " << t << " " << u << " " << v << " " << ch/500 << " " << (ch/100)%5 << " " << (ch/50)%2 << " " << (ch/10)%5 << "\n";
								int now = 1;
								now += ch/500 + (ch/100)%5 + (ch/50)%2 + (ch/10)%5;
								now += (k[0] - s) + (k[1] - t) + (k[2] - u) + (k[3] - v);
								if(now < mai){
									mai = now;
									ans[0] = s;
									ans[1] = t;
									ans[2] = u;
									ans[3] = v;
								}
							}
						}
					}
				}
			}
		}
		if(ans[0])cout << 10 << " " << ans[0] << "\n";
		if(ans[1])cout << 50 << " " << ans[1] << "\n";
		if(ans[2])cout << 100 << " " << ans[2] << "\n";
		if(ans[3])cout << 500 << " " << ans[3] << "\n";
	}
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s,t;cin >>s>>t;
    vector<string>ans;
    int n=s.size();
    for (int i = 0; i < n; ++i) {
        if(i+t.size()>n)break;
        bool flg=true;
        for (int j = i; j <i+t.size(); ++j) {
//            if(i==2){
//                cout <<s[j]<<" "<<t[j-i]<<endl;
//            }
            if(s[j]=='?')continue;
            if(s[j]!=t[j-i])flg=false;
        }
        if(flg){
            string key="";
            for (int j = 0; j < i; ++j) {
                if(s[j]=='?')key+='a';
                else key+=s[j];
            }
            key+=t;
            if(i+t.size()<n){
                for (int j =i+t.size(); j < n; ++j) {
                    if(s[j]=='?')key+='a';
                    else key+=s[j];
                }
            }
            ans.push_back(key);
        }
    }
    if(ans.empty())puts("UNRESTORABLE");
    sort(all(ans));
    if(!ans.empty())cout <<ans[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

long dif(long N,long h,long n,long w){
  return 4*h*n*w - N*(h*n+h*w+n*w);
}

int maxv = 3500;
int main(){
  int N;
  cin >> N ;
  for(int h = 1 ; h <= maxv ;++h){
    for(int n = h ; n <= maxv ;++n){
      int wl = n , wr = maxv+1;
      while(wl<wr){
        int w = (wl+wr)/2;
        long d = dif(N,h,n,w);
        if(d==0){
          cout << h << " " << n << " " << w << endl;
          return 0;
        }else if(d > 0){
          wr = w ;
        }else{
          wl = w + 1;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
		String str = "";
		StringTokenizer st;
		int num = 0;
		while ((str = br.readLine()) != null) {
			st = new StringTokenizer(str, " ");
			num = Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken());
			str = String.valueOf(num);
			System.out.println(str.length());
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (auto& e : h) cin >> e;
    h.push_back(1e9 + 7);
    int ans = 0;
    for (int i = 0, l = 0; i < n; i++) {
        if (h[i+1] <= h[i]) continue;
        ans = max(ans, i - l);
        l = i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
S = input()

s_set = set()
for s in S:
    s_set.add(s)

ans = ""
for temp in range(26):
    temp_s = chr(ord("a") + temp)
    if not temp_s in s_set:
        ans = temp_s
        break
else:
    ans = "None"

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

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

          const int nmmax=50;
          char A[nmmax][nmmax],B[nmmax][nmmax];


          REP(y,n) REP(x,n) cin >> A[y][x];


          REP(y,m) REP(x,m) cin >> B[y][x];

          bool exist=false;

          REP(ly,n){
                    REP(lx,n){
                              if (ly+m-1>=n or lx+m-1>=n) continue;
                              bool match=true;

                              REP(y,m) REP(x,m) if (A[ly+y][lx+x] != B[y][x]) match=false;
                              if(match) exist=true;
                    }
          }

          if(exist) cout << "Yes" << endl;
          else cout << "No" << endl;

          return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int32_t main()
{
    int visi[100005];
	int x,n;cin>>x>>n;
	vector<int>v;
	memset(visi,0,sizeof(visi));
    int diff=INT_MAX;
	for(int i=0;i<n;i++)
	{
	  int c;cin>>c;
	  visi[c]=1;
	}
	for(int i=0;i<=1000000000;i++)
	{
	int value=abs(x-i);
	if(value>=diff)
	{
	cout<<v[v.size()-1];
	return 0;
	}
	else if(visi[i]==0)
	{
	diff=abs(x-i);
	v.pb(i);
	}
	}
	
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3640
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    int ans = 1;
    while (N > 1) {
        N /= 2;
        ans *= 2;
    }
    printAns(ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int n, k, i = 1;
	long long sum = 0, ss = 0;
	cin >> n >> k;
	if (k & 1) {
		for (; i <= n; i++) {
			if (i % k == 0)
				sum++;
		}
	}
	else {
		for (; i <= n; i++) {
			if (i % k == 0)
				sum++;
			else if (i % k == (k >> 1))
				ss++;
		}
		ss = ss * ss * ss;
	}
	cout << sum * sum * sum + ss << "\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())

L = list(map(int, input().split()))

le = len(L)

score = 0

for i in range(le):
    for j in range(i+1,le):
        for k in range(j+1,le):
            if (L[i] + L[j] > L[k] and
                L[i] + L[k] > L[j] and
                    L[k] + L[j] > L[i] ):
                         if (L[i] != L[j] and
                            L[i] != L[k] and
                            L[k] != L[j]):
                                score += 1

print(score)

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  ll n,m,sum=0;cin>>n>>m;
  priority_queue<ll> a;
  rep(i,n){
    ll c;
    cin>>c;
    a.push(c);
  }
  rep(i,m){
    ll k=a.top();
    k/=2;
    a.pop();
    a.push(k);
  }
  while(!a.empty()){
    sum+=a.top();
    a.pop();
  }
  cout<<sum<<endl;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	int k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	sort(h.begin(), h.end());
	for (int i = 0; i < k and h.size() > 0; i++)
		h.pop_back();
	size_t at = 0;
	for (auto x : h)
		at += x;
	cout << at;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N, M, a, b;
  cin >> N >> M;
  int counter[55] = {0};//バケット
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    counter[a]++;
    counter[b]++;
    //cout << endl;
  }
  for (int i = 1; i < N + 1; i++){
    cout << counter[i] << endl;
  }
}

Measured memory_bytes: 256
s = str(input())
mae = int(s[:2])
usiro = int(s[2:])
if 0 < mae < 13:
    if 0 <usiro < 13:
        print("AMBIGUOUS")
    else:
         print("MMYY")
elif 0 < usiro < 13:
         print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++)
    {
        ans = (ans + v[i]) / 2;
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
#define mp make_pair
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int modpow(int n, int k, int MOD);

/**************** code starts here ****************/

void poppingfever() {
	int x, y; cin >> x >> y;
	if (x % y) cout << x;
	else cout << -1;
}

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
 
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(12);
 
	poppingfever();
 
	return 0;
}

int modpow(int n, int k, int MOD) {
	int ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	cout<<n + n*n + n*n*n;
	
	return 0;
}


Measured memory_bytes: 3608
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let hw: Vec<usize> = read_vec();
    let h = hw[0];
    let w = hw[1];
    let mut mat: Vec<Vec<u32>> = vec![vec![1000000000; w]; h];
    for i in 0..h {
        let s: String = read();
        let c: Vec<char> = s.chars().collect();
        for j in 0..w {
            if c[j] == '#' {
                mat[i][j] = 0;
            }
        }
    }

    for i in 0..h {
        for j in 1..w {
            mat[i][j] = min(mat[i][j], mat[i][j - 1] + 1);
        }
        for j in (0..w - 1).rev() {
            mat[i][j] = min(mat[i][j], mat[i][j + 1] + 1);
        }
    }

    for j in 0..w {
        for i in 1..h {
            mat[i][j] = min(mat[i][j], mat[i - 1][j] + 1);
        }
        for i in (0..h - 1).rev() {
            mat[i][j] = min(mat[i][j], mat[i + 1][j] + 1);
        }
    }

    let mut ans = 0;

    for i in 0..h {
        for j in 0..w {
            if mat[i][j] > ans {
                ans = mat[i][j];
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) {
    return a < b ? b = a, true : false;
}
template<typename T> bool chmax(T a, T &b) {
    return a > b ? b = a, true : false;
}

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

void solve();

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

    solve();
}
void solve() {
    ll n, m;
    std::cin >> n >> m;

    vvll g(n);
    for (ll i = 0; i < m; i++) {
        ll a, b; std::cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vll p(n);
    std::iota(p.begin(), p.end(), 0);

    ll ans = 0;
    do {
        bool flg = true;
        for (ll i = 0; i < n - 1; i++) {
            auto j = std::find(g[p[i]].begin(), g[p[i]].end(), p[i + 1]);
            if (j == g[p[i]].end()) { flg = false; break; }
        }
        ans += flg;
    } while (std::next_permutation(p.begin(), p.end()) && !p[0]);

    std::cout << ans << '\n';
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

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

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    ll a,b,c; cin >> a >> b >> c;
    if(a%2==0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
    else cout << min(a*b,min(b*c,a*c)) << endl;
}

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

    solve();

    return 0;
}

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

int main() {
  string s; cin >> s;
  for(int i = s.size()-2; i > 0; i -= 2) {
    if (s.substr(0, i/2) == s.substr(i/2, i/2)) {
      p(i);
      return 0;
    }
  }
}


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

struct BipartiteGraph{
    vector<vector<int>> G;
    vector<int> color,root;
    BipartiteGraph(int n):G(n),color(n,-1),root(n,-1){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    bool dfs(int v,int c,int r){
        color[v]=c; root[v]=r;
        for (int u:G[v]){
            if (color[u]==c) return false;
            if (color[u]<0&&!dfs(u,c^1,r)) return false;
        }
        return true;
    }
    bool build(){
        for (int v=0;v<G.size();++v){
            if (color[v]<0&&!dfs(v,0,v)){
                return false;
            }
        }
        return true;
    }
};

template<typename T>
void Warshall_Floyd(vector<vector<T>> &d,T id){
    int n=d.size();
    for (int k=0;k<n;++k){
        for (int i=0;i<n;++i){
            for (int j=0;j<n;++j){
                if (d[i][k]==id||d[k][j]==id) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

void AGC039_B(){
    int N; cin >> N;
    vector<string> S(N);
    for (int i=0;i<N;++i) cin >> S[i];

    BipartiteGraph BG(N);
    for (int i=0;i<N;++i){
        for (int j=i+1;j<N;++j){
            if (S[i][j]=='1'){
                BG.add_edge(i,j);
            }
        }
    }

    if (!BG.build()){cout << -1 << '\n'; return;}

    const int inf=1e9;
    vector<vector<int>> d(N,vector<int>(N,inf));
    for (int i=0;i<N;++i){
        for (int j=0;j<N;++j){
            if (i==j) d[i][j]=0;
            if (S[i][j]=='1') d[i][j]=1;
        }
    }

    Warshall_Floyd(d,inf);
    int ans=0;
    for (int i=0;i<N;++i){
        for (int j=i+1;j<N;++j){
            if (d[i][j]==inf) continue;
            ans=max(ans,d[i][j]);
        }
    }

    cout << ans+1 << '\n';
}

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

Measured memory_bytes: 3836
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
S = input()
num = [0 for _ in range(26)]

for c in S:
  num[ord(c) - ord('a')] += 1


ans = 1
for each in num:
  ans *= (1 + each)
  ans %= MOD

print(ans - 1) #1つも取らない場合を引く



Measured memory_bytes: 39920
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		switch (d) {
		case (0):
			for (int i = 1; i <= n; i++) {
				if (i / 100 == 0) {
					a[i - 1] = i;
				}else {
					a[i - 1] = i+1;
				}
			}
			System.out.println(a[n - 1]);
			break;
		case (1):
			for (int i = 1; i <= n; i++) {
				if (i / 100 == 0) {
					a[i - 1] = i;
				}else {
					a[i - 1] = i+1;
				}
			}
			System.out.println(a[n - 1]*100);
			break;
		case (2):
			for (int i = 1; i <= n; i++) {
				if (i / 100 == 0) {
					a[i - 1] = i;
				}else {
					a[i - 1] = i+1;
				}
			}
			System.out.println(a[n - 1]*10000);
			break;
		}
	}
}


Measured memory_bytes: 35632
#include <iostream>
 
using namespace std;
int main(){
    int A=0;
    int B=0;
	
	int C=0;
	
	int D=0;
	
	
	
     
    int MAX=0;
	int MIN=0;
	
	int MIN2=0;
	int MAX2=0;
    
     
     
    cin >> A >> B ;
     
    if(A>B){
        MAX=A;
		MIN=B;
    }else{
        MAX=B;
		MIN=A;
    }
     
	
	for(int i=0;i<10000;i++){
		if(A<B){
		 MIN2=A;
		 MAX2=B;
		}else{
		 MIN2=B;
		 MAX2=A;
		}
		if(MIN2!=0){
			C=A%B;
			A=B;
			B=C;
		}else{
			i=10000;
		}
	}
	 
	 
	 
   
    cout <<MAX2<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// union by size + path having
class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

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

	ll N, M;
	cin >> N >> M;

	deque<P> order;
	ll A, B;
	rep(i, M) {
		cin >> A >> B;
		order.emplace_back(--A,--B);
	}

	UnionFind tree(N);
	deque<ll> ans;

	ll score = N * (N - 1) / 2;
	ans.push_front(score);

	for (auto itr = order.rbegin(); itr != order.rend(); itr++) {
		A = itr->first;
		B = itr->second;
		if (!tree.issame(A, B)) {
			score -= tree.size(A) * tree.size(B);
			tree.merge(A, B);
		}
		ans.push_front(score);
	}


	rep2(i, 1, ans.size()) {
		cout << ans[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 5376
L =[]

N = int(input())

for i in range(N):
    S = input()
    L.append(S)

print("AC" + " x " + str(L.count("AC")))
print("WA" + " x " + str(L.count("WA")))
print("TLE" + " x " + str(L.count("TLE")))
print("RE" + " x " + str(L.count("RE")))

Measured memory_bytes: 16048
#include <iostream>
#include <queue>

using namespace std;

const int SIZE = 250000;

int board[SIZE] = {0, };
int exist[SIZE] = {0, };
int visit[SIZE] = {0, };

int main() {
	queue<int> q;
	int n, p, i, k, ans;
	
	scanf("%d", &n);
	
	// init
	for (i = 0; i < n; i++) {
		board[i] = 1;
		q.push(i);
		board[n * n - n + i] = 1;
		q.push(n * n - n + i);
		board[i * n] = 1;
		q.push(i * n);
		board[i * n + n - 1] = 1;
		q.push(i * n + n - 1);
	}
	
	while (!q.empty()) {
		k = q.front();
		q.pop();
		
		if (k >= n) {
			if (board[k - n] == 0 || board[k - n] > board[k] + 1) {
				board[k - n] = board[k] + 1;
				q.push(k - n);
			}
		}
		if (k < n * n - n) {
			if (board[k + n] == 0 || board[k + n] > board[k] + 1) {
				board[k + n] = board[k] + 1;
				q.push(k + n);
			}
		}
		if (k % n != 0) {
			if (board[k - 1] == 0 || board[k - 1] > board[k] + 1) {
				board[k - 1] = board[k] + 1;
				q.push(k - 1);
			}
		}
		if ((k + 1) % n != 0) {
			if (board[k + 1] == 0 || board[k + 1] > board[k] + 1) {
				board[k + 1] = board[k] + 1;
				q.push(k + 1);
			}
		}
	}
	
	for (i = 0; i < n * n; i++) {
		exist[i] = 1;
		visit[i] = -1;
	}
	
	ans = 0;
	for (i = 0; i < n * n; i++) {
		scanf("%d", &p);
		p--;
		board[p]--;
		exist[p] = 0;
		ans += board[p];
		q.push(p);
		visit[p] = i;
		
		while (!q.empty()) {
			k = q.front();
			q.pop();
			
			if (k >= n) {
				if (visit[k - n] != i) {
					if (board[k - n] > board[k] + exist[k - n]) {
						board[k - n] = board[k] + exist[k - n];
						q.push(k - n);
						visit[k - n] = i;
					}
				}
			}
			if (k < n * n - n) {
				if (visit[k + n] != i) {
					if (board[k + n] > board[k] + exist[k + n]) {
						board[k + n] = board[k] + exist[k + n];
						q.push(k + n);
						visit[k + n] = i;
					}
				}
			}
			if (k % n != 0) {
				if (visit[k - 1] != i) {
					if (board[k - 1] > board[k] + exist[k - 1]) {
						board[k - 1] = board[k] + exist[k - 1];
						q.push(k - 1);
						visit[k - 1] = i;
					}
				}
			}
			if ((k + 1) % n != 0) {
				if (visit[k + 1] != i) {
					if (board[k + 1] > board[k] + exist[k + 1]) {
						board[k + 1] = board[k] + exist[k + 1];
						q.push(k + 1);
						visit[k + 1] = i;
					}
				}
			}
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 6648
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	if ((a * b) % 2 == 0)
	{
		cout << "Even";
	}
	else
	{
		cout << "Odd";
	}

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c,d,e,f,g;
    cin >>a;
    
    for(int i = 0; i < a; i++){
        
        cin >>b>>c>>d>>e;
        
        
        
        f = b * d + c * e;
        
        if(d >= 5 && e >= 2){
            
            f = f * 0.8;
            
            g = f;
            
        }else if(d >= 5 && e < 2){
            
            g =  g-g+ ((b * d) + (c * 2)) * 0.8;
            
        }else if(d < 5 && e >= 2){
            
            g = g-g+ ((b * 5) + (c * e)) * 0.8;
            
        }else{
            
            g = g-g+ ((b * 5) + (c * 2)) * 0.8;
            
        }
        
        if(g > f){
            cout<<f<<endl;
        }else{
            cout <<g<<endl;
        }
        
        
        
    }
    
    
}



Measured memory_bytes: 3104
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//p,q,rに代入(これで、P,Q,Rが消滅)
string substitute(string s, int p, int q, int r) {
	REP(i, s.size()) {
		switch (s[i]) {
		case 'P':s[i] = '0' + p; break;
		case 'Q':s[i] = '0' + q; break;
		case 'R':s[i] = '0' + r; break;
		}
	}
	return s;
}


//末尾にある数値に対して、インバースを適用(これで、-が消滅)
void apply_inverse(stack<char>& info)
{
	char t = info.top();
	if (t < '0' || '2' < t)return;
	info.pop();

	while (!info.empty() && info.top() == '-') {
		info.pop();
		if (t == '2')t = '0';
		else if (t == '0')t = '2';
	}
	info.push(t);
}


//演算子を実際に適用(これで、(,+,*,)が消滅 )
void apply_operator(stack<char>& info)
{
	char r = info.top(); info.pop();
	char ope = info.top(); info.pop();
	char l = info.top(); info.pop();

	char err = info.top(); info.pop();
	if (err != '(') {
		exit(1);
	}
	l -= '0';
	r -= '0';
	char res;
	switch (ope) {
	case '+':
		if (max(l, r) == 2)res = '2';
		else if (l + r == 0)res = '0';
		else res = '1';
		break;
	case '*':
		if (min(l, r) == 0)res = '0';
		else if (l + r == 4)res = '2';
		else res = '1';
		break;
	default:
		exit(1);
	}
	info.push(res);
}

//構文を実際に計算する
bool play(string s) {
	stack<char> info;
	for (const char& c : s) {
		switch (c) {
		case '0':
		case '1':
		case '2':
			info.push(c);
			apply_inverse(info);
			break;
		case ')':
			apply_operator(info);
			apply_inverse(info);
			break;
		default:
			info.push(c);
			break;
		}
	}

	if (info.size() != 1) {
		exit(1);
	}
	else {
		return info.top() == '2';
	}
}


//全探索を行う
void calc(const string& formula)
{
	int res = 0;
	REP(p, 3)REP(q, 3)REP(r, 3) {
		string target = substitute(formula, p, q, r);
		if (play(target)) {
			res++;
		}
	}

	cout << res << endl;
}

//メイン関数
int main()
{
	while (true) {
		string formula;
		cin >> formula;

		if (formula == ".")break;
		calc(formula);
	}
	
	return 0;
}



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

const double PI=acos(-1.0);

int x[100100];

int main() {
    ll n, k, q;
    cin >> n >> k >> q;

    rep(i, q) {
        int a;
        cin >> a;
        a--;
        x[a]++;
    }

    rep(i, n) {
        if(k - (q - x[i]) >= 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int ask;
inline int Query(string s){
	++ask;
	cout<<"? "<<s<<endl,fflush(stdout);
	return read();
}

const int N = 500;
int n,cnt,pos[N],tot[N][N],suf[N][N],pre[N][N];
char s[N],ans[N];
inline void solve(int u,int l,int r){
	if (l==r){
		For(i,1,cnt) if (tot[u][i]) ans[l]=s[i];
		return;
	}
	int mid=l+r>>1,S=0,S2=0,L=0;
	For(i,1,cnt) if (tot[u][i]){
		L=i;break;
	}
	vector<int>ans(cnt+1);
	ans[L]=tot[u][L],S=tot[u][L],S2=1;
	For(i,1,cnt) if (tot[u][i]&&i!=L){
		string s;
		For(j,1,mid) s=s+::s[L];
		For(j,1,n-mid) s=s+::s[i];
		ans[i]=(n-Query(s))-pre[u][L]-suf[u][i],S+=ans[i],++S2;
	}
	tot[u<<1][L]=(S-(r-mid))/S2;
	For(i,1,cnt) if (tot[u][i]) tot[u<<1^1][i]=ans[i]-tot[u<<1][L];
	For(i,L+1,cnt) if (tot[u][i]) tot[u<<1][i]=tot[u][i]-tot[u<<1^1][i];
	For(i,1,cnt){
		suf[u<<1][i]=suf[u][i]+tot[u<<1^1][i];
		suf[u<<1^1][i]=suf[u][i];
		pre[u<<1^1][i]=pre[u][i]+tot[u<<1][i];
		pre[u<<1][i]=pre[u][i];
	}
	solve(u<<1,l,mid),solve(u<<1^1,mid+1,r);
}
inline void init(){
	For(i,0,25) s[++cnt]='a'+i;
	For(i,0,25) s[++cnt]='A'+i;
	For(i,0,9) s[++cnt]='0'+i;
	For(i,1,cnt) pos[s[i]]=i;
	vector<int>ans(cnt+1);
	int mn=1000;
	For(i,1,cnt){
		string s;s=s+::s[i];
		ans[i]=Query(s),mn=min(mn,ans[i]);
	}
	n=mn+1;
	For(i,1,cnt) if (ans[i]==mn){
		string s;
		For(j,1,mn+1) s=s+::s[i];
		tot[1][i]=n-Query(s);
	}
	if (mn==0){
		For(i,1,cnt) if (tot[1][i]==1){
			cout<<"! "<<s[i]<<endl,fflush(stdout);
			exit(0);
		}
	}
}

int main(){
	init(),solve(1,1,n);
	printf("! ");
	For(i,1,n) printf("%c",ans[i]);
	fflush(stdout);
}

Measured memory_bytes: 5204
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		while(n-->0)
		{
			BigInteger a=in.nextBigInteger();
			BigInteger b=in.nextBigInteger();
			String ans=String.valueOf(a.add(b));
			if(ans.length()>80)
				System.out.println("overflow");
			else
				System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
# include <bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	int ans=-1;
	for(int i=2;i<=31;i++)
	{
		int cnt=1,j=0;
		while(cnt<=x)
		{
			cnt=cnt*i;
			j++;
		}
		if(cnt>x)
		{
			cnt=cnt/i;
			if(j-1<2)
			continue;	
		}
		if(j<2)
		continue;
		ans=max(ans,cnt);
	}
	if(ans==-1)
	cout<<"1";
	else
	cout<<ans;
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll a,b;
    double d;
    cin >> a >> d;
    d *= 100;
    b = floor(d+1e-6);
    cout << a*b/100 << endl;
}

Measured memory_bytes: 3804
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>
#include <iostream>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    int a;
};

vector<mint> aa, bb;

S op(S l, S r) { return S{l.a * aa[r.size] + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { if (l.a == -1) return S{r.a, r.size};
                     else return S{mint(l.a) * bb[r.size], r.size}; 
                    }

F composition(F l, F r) {if (l.a == -1) return F{r.a};
                         else return F{l.a}; }

F id() { return F{-1}; }


int main(){
  int n,q;
  cin >>n>>q;
  aa.resize(n+10);
  bb.resize(n+10);
  const auto in = mint(9).inv();
  for (int i=0; i<n+10; i++){
    aa[i] = mint(10).pow(i);
    bb[i] = (aa[i] - 1) *in;
  }
  
  vector<S> a(n);
  for (int i=0; i<n; i++){
    a[i] = S{mint(1),1};
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
  for (int i=0; i<q; i++) {
    int l,r,d;
    scanf("%d %d %d", &l, &r, &d);
    seg.apply(l-1, r, F{d});
    printf("%d\n",seg.all_prod().a.val());
  }
}

Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  long long a,b,x;
  cin >> a >> b >> x;
  cout << b/x-a/x+(a%x==0 ? 1:0) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print(A+B if B%A == 0 else B-A)

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

int main(){
  int ans1=0,ans2=0,num1,num2,n;

  while(1){
    ans1=ans2=0;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>num1>>num2;
      if(num1>num2)ans1=ans1+num1+num2;
      else if(num1<num2)ans2=ans2+num1+num2;
      else {
	ans1=ans1+num1;
	ans2=ans2+num1;
      }
    }
    cout<<ans1<<" "<<ans2<<endl;
  }
 
 return 0;
}

Measured memory_bytes: 1160