akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  string s; cin>>s;
  int left=0,right=0;
  rep(i,0,N){
    if(s[i]=='('){
      left++;
    }else{
      if(left) left--;
      else{
        right++;
      }
    }
  }
  string ans="";
  rep(i,0,right) ans+='(';
  ans += s;
  rep(i,0,left) ans+=')';
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf =1 << 28;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int n, m;
const int N = 51;
const int M = 101;

int adj[N][N][M];

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

    int a, b, c; cin >> n >> m >> a >> b >> c;

    rep(i, n) adj[i][i][0] = true;
    rep(i, m){
        int u, v; cin >> u >> v;
        u--, v--;
        adj[v][u][1] = true;
    }

    rep(i, 2, M){
        rep(s, n){
            rep(t, n){
                rep(k, n){
                    adj[s][t][i] |= (adj[s][k][1] & adj[k][t][i - 1]);
                }
            }
        }
    }

    set<int> s = { n - 1 };
    int res = 1;
    while(1){
        auto ns = s;
        rep(v, n){
            if(s.find(v) != end(s)) continue;
            bool ok_a = false; for(int nv : s) ok_a |= adj[nv][v][a];
            bool ok_b = false; for(int nv : s) ok_b |= adj[nv][v][b];
            bool ok_c = false; for(int nv : s) ok_c |= adj[nv][v][c];

            if(ok_a and ok_b and ok_c){
                ns.insert(v);

                if(v == 0){
                    cout << res << endl;
                    return 0;
                }
            }
        }

        if(ns == s){
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }

        s = ns;
        res++;
    }

    return 0;
}

Measured memory_bytes: 4228
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int n = 26, d;
	static int[] c;
	static int[][] s;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		d = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		s = new int[d][n];
		for (int i = 0; i < d; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				s[i][j] = Integer.parseInt(sa[j]);
			}
		}
//		int[] t = inputB(br);
		br.close();

		int[] t = new int[d];
		int[] last = new int[n];
		for (int i = 0; i < d; i++) {
			int max = -1;
			int idx = -1;
			for (int j = 0; j < n; j++) {
				int val = s[i][j] + c[j] * (i + 1 - last[j]);
				if (val > max) {
					max = val;
					idx = j;
				}
			}
			t[i] = idx;
		}

		for (int i = 0; i < d; i++) {
			System.out.println(t[i] + 1);
		}
//		int[] score = calc(t);
//		for (int i = 0; i < d; i++) {
//			System.out.println(score[i]);
//		}
	}

//	static int[] inputB(BufferedReader br) throws Exception {
//		int[] t = new int[d];
//		for (int i = 0; i < d; i++) {
//			t[i] = Integer.parseInt(br.readLine()) - 1;
//		}
//		return t;
//	}

	static int[] calc(int[] t) {
		int[] last = new int[n];
		int[] ret = new int[d];
		for (int i = 0; i < d; i++) {
			if (i > 0) {
				ret[i] += ret[i - 1];
			}
			ret[i] += s[i][t[i]];
			last[t[i]] = i + 1;
			for (int j = 0; j < n; j++) {
				ret[i] -= c[j] * (i + 1 - last[j]);
			}
		}
		return ret;
	}
}


Measured memory_bytes: 36016
from itertools import combinations

s = input() 
res = [s[x:y] for x, y in combinations(range(len(s) + 1), r = 2)] 

ans = 0
t = "AGCT"

for s in res:
    if all(c in t for c in s):
        if len(s) > ans: ans = len(s);

print(ans)


Measured memory_bytes: 9008
#include <stdio.h>
 
int main()
{
	char tako[101];
  	int b;
  int c;
  int d;
  int e;
  int f;
  int g;
  int h;
	
   b = 0;
	scanf("%s", tako);

  while (tako[c] != 0)
  {
    c++;
  }
  d = c;
  e = c - 1;
  g = c/2;
	while(g > 0)
    {
      if (tako[b] != tako[e])
      {
        printf("No");
        return 0;
      }
      b++;
      g--;
      e--;
    }
  d = (d - 1)/2;
  f = d - 1;
  b = 0;
  h = d/2;
  while (h > 0)
  {
    if (tako[b] != tako[f])
    {
      printf("No");
      return 0;
    }
    b++;
    h--;
    f--;
  }
  printf("Yes");
    return 0;
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  vi a(n);
  rep (i, n) {
    cin >> a[i];
  }

  int ans = 1;
  vi rgb = {0, 0, 0};
  int ni = 0;
  rep (i, n) {
    int cnt = 0;
    rep (j, 3) {
      if (rgb[j] == a[i]) cnt++;
    }
    ans = ans * cnt % MOD;
    rep (j, 3) {
      if (rgb[j] == a[i]) {
        rgb[j]++;
        break;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

bool table[1000001], dp[1000001];
int cs[30];
vector<int> primes;

int main() {
  table[2] = true;
  for (int i = 3; i <= 1000000; i += 2)
    table[i] = true;
  for (int i = 3; i <= 1000; i += 2)
    if (table[i])
      for (int j = 3 * i; j <= 1000000; j += 2 * i)
        table[j] = false;
  primes.push_back(2);
  for (int i = 3; i <= 1000000; i += 2)
    if (table[i])
      primes.push_back(i);
  for (;;) {
    int n, x;
    cin >> n >> x;
    if (!n && !x) return 0;
    for (int i = 0; i < n; i++)
      cin >> cs[i];
    fill(dp, dp+x+1, false);
    dp[0] = true;
    for (int i = 1; i <= x; i++)
      for (int j = 0; j < n; j++)
        if (i - cs[j] >= 0 && dp[i-cs[j]]) {
          dp[i] = true;
          break;
        }
    bool f = true;
    for (int i = upper_bound(primes.begin(), primes.end(), x)-primes.begin()-1; i >= 0; i--)
      if (dp[primes[i]]) {
        f = false;
        cout << primes[i] << endl;
        break;
      }
    if (f)
      cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
  const double taxrate= 1.08;
  int P_inc;
  cin >> P_inc;

  bool is_satisfied= false;
  int P_exc= P_inc/(taxrate+ 0.01);
  while((int)(P_exc* taxrate) <= P_inc){
    if((int)(P_exc* taxrate) == P_inc){
      is_satisfied= true;
      break;
    }
    
    P_exc++;
  }

  string ans= is_satisfied ? to_string(P_exc)
                           : ":(";

  cout << ans << endl;
}

Measured memory_bytes: 3664
N = int(input())
s = input()

red_counter = 0
blue_counter = 0
for i in range(N):
    if s[i] == 'R':
        red_counter += 1
    else:
        blue_counter += 1
        
if red_counter > blue_counter:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n;ll x, a[100000];
	cin >> n >> x;
	rep(i, n) {
		cin >> a[i];
	}
	ll sum = 0;
	if (a[0] > x) {
		sum = a[0] - x;
		a[0] = x;
	}
	rep(i, n - 1) {
		if (a[i] + a[i + 1] > x) {
			sum += a[i] + a[i + 1] - x;
			a[i + 1] = max((ll)0, x-a[i]);
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  ll n,k,s;
  cin>>n>>k>>s;
  ll t;
  if (s<1e9){
    t=s+1;
  }else{
    t=s-1;
  }
  
  rep(i,n){
    if(i<k){
      cout<<s<<" ";
    }else{
    	cout<<t<<" ";
    }
  }

}


Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if 0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int MODULO = MOD;
int n;
bool vis[3][1001][4];
int dp[3][1001][4];
bool blocked[3][1001];

int rec (int row, int col, int type) {
	if (vis[row][col][type]) return dp[row][col][type];
	vis[row][col][type] = true;
	if (blocked[row][col]) {
		dp[row][col][type] = 0;
		return 0;
	}
	if (type == 0) {
		if (row >= 1) {
			if (col >= n - 1 && row != 2) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row - 1, col, 2);
			dp[row][col][type] %= MODULO;
		}
	} 
	if (type == 1) {
		if (row <= 1) {
			if (col >= n - 1) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row + 1, col, 3);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 2) {
		if (col == 0 && row == 0) {
			dp[row][col][type] = 1;
			return dp[row][col][type];
		}
		if (col >= 1 && row < 2) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 3) {
		if (col >= 1 && row >= 1) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
		else {
			dp[row][col][type] = 0;
			return dp[row][col][type];
		}
	}
}
signed main () {
	start_routine;
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif 

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

	if (a > 8 || b > 8) cout << ":(";
	else cout << "Yay!";
	end_routine;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
start=10**(n-1)
if n==1:
    start=0
for i in range(start,1001):
    i = str(i)
    for s,c in sc:
        if i[s-1] != str(c):
            break
    else:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
using modint = ModInt<MOD>;

modint KAIJOU(int N) {
    modint res = 1;
    for (int i = 1; i <= N; i++) res *= i;
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N-1);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N-1; i++) B[i] = A[i+1] - A[i];
    
    modint ans = 0;
    modint S = 0; // スターリング数
    modint kaijou = 1;
    modint ne = KAIJOU(N);
    for (int i = 0; i < N-1; i++) {
        S *= (i+1);
        S += kaijou;
        kaijou *= (i+1);
        ne /= (i+1);
        modint K = S * ne * B[i];
        ans += K;
    }
    ans /= N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int solve(int, int);

int n, *arryA;

main(){
  int i, q, m;

  scanf("%d", &n);
  arryA = (int *)malloc(sizeof(int)*n);
  for(i=0; i<n; i++) scanf("%d", arryA+i);

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &m);
    if(solve(0, m)) printf("yes\n");
    else printf("no\n");
  }

  free(arryA);
  return 0;
}

int solve(int i, int m){
  int res;

  if(m==0) return 1;
  if(i==n) return 0;

  res = solve(i+1, m) | solve(i+1, m - arryA[i]);
  return res;
}

Measured memory_bytes: 580
s = list(input())
e = []
for i in range(len(s)):
    if e == []:
        if (s[i] == "0") or (s[i] == "1"):
            e.append(s[i])
    else:
        if (s[i] == "0") or (s[i] == "1"):
            e.append(s[i])
        else:
            del e[-1]
f = "".join(e)
print(f)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
ans=1

if 0 in arr:
    print(0)
    exit()

for i in arr:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 86704
#include<stdio.h>
#include<string.h>

int main ()
{
	char huruf[4];
	scanf("%s", huruf);
	if(huruf [1] == 'B')	{
		printf("ARC");
		}	
	else {
		printf("ABC");
	}	
	
	return 0;
}
	
	

Measured memory_bytes: 1728
while 1:
    n = int(input())
    if n == 0:
        break

    y = int(input())
    ans = 0
    num = 0
    for _ in range(n):
        b, r, t = map(int, input().split())
        if t == 1:
            tmp = 1 + y * (r / 100)
        else:
            tmp = pow((1 + r / 100), y)

        if tmp > ans:
            ans = tmp
            num = b

    print(num)



Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ma = 0;
    map<int,int> cnt;
    cin >> n;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        cnt[a]++;
        chmax(ma,a);
    }
    if(ma == 0) Yes();
    else if(n % 3) No(); 
    else{
        if(cnt.size() == 2){
            if(cnt[0] * 3 == n && cnt[ma] * 3 == n * 2) Yes();
            else No();
        }else if(cnt.size() == 3){
            int g = 0;
            bool flag = true;
            for(auto p : cnt){
                g ^= p.first;
                if(p.second * 3 != n) flag = false;
            }
            if(g) flag = false;
            if(flag) Yes();
            else No();
        }else No();
    }
}

Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[--x]++;
  }
  sort(a.begin(), a.end());
  vector<int> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int k = 1; k <= n; k++) {
    int lo = 0, hi = n + 1;
    while (hi - lo > 1) {
      int mid = (lo + hi) >> 1;
      int ltm = upper_bound(a.begin(), a.end(), mid) - a.begin();
      int tot = sum[ltm] + (n - ltm) * mid;
      if (tot >= mid * k) lo = mid;
      else hi = mid;
    }
    cout << lo << '\n';
  }
  return 0;
}

Measured memory_bytes: 5632
import math

A, B = map(int, input().split())

i = math.floor(A / 0.08)
while i < 10001:
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        print(i)
        break
    i += 1
else:
    print(-1)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct SegmentTree {
  const int MAX = 2147483647;
  vi32 v;
  int n;
  SegmentTree(int size) {
    n = 1;
    while (n < size) n <<= 1;
    v.resize(n * 2, MAX);
  }
  void update(int k, int x) {
    v[k += n] = x;
    while (k >>= 1) {
      v[k] = min(v[k * 2 + 0], v[k * 2 + 1]);
    }
  }
  int find(int a, int b, int k = 1, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (b <= l || r <= a) return MAX;
    if (a <= l && r <= b) return v[k];
    int ret = MAX;
    amin(ret, find(a, b, k * 2 + 0, l, (l + r) / 2));
    amin(ret, find(a, b, k * 2 + 1, (l + r) / 2, r));
    return ret;
  }
};

void solve() {
  int n, q; cin >> n >> q;
  auto st = SegmentTree(n);
  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    switch (com) {
    case 0:
      st.update(x, y);
      break;
    default:
      cout << st.find(x, y + 1) << '\n';
    }
  }
}



Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
int main()
{
#ifdef DOC
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a,b,c;
  cin >> a >> b >> c;
  int at[8]; at[5] = at[7] = 0;
  ++at[a]; ++at[b]; ++at[c];
  if (at[5] == 2 && at[7] == 1) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int a[] = new int[3];
		for(int i = 0; i < 3 ; i++) {
			list.add(scanner.nextInt());
		}

		Collections.sort(list, Collections.reverseOrder());

		int sum = 0;
		int buf = 0;
		int count = 0;
		for(int i : list) {
			if(count != 0) {
				sum += (buf - i);
			}
			count++;
			buf = i;
		}
		System.out.println(sum);
	}

}

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

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

    vector<int> v;
    for(int i = 0; i < k; ++i){
        int tmp; cin >> tmp;
        v.push_back(tmp);
    }

    int ans = 0;

    for(int i = n; i < 100000; ++i) {
        int current_num = i;
        bool find = true;
        while(current_num != 0) {
            int cur = current_num % 10;
            for(int k = 0; k < v.size(); k++) {
                if(cur == v[k]) {
                    find = false;
                    break;
                }
            }
            current_num /= 10;
        }
        if(find) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,x=2,y=1,z[500][500];
    cin>>n;
    while(n>y){
        y+=x;
        x++;
    }
    if(n!=y){
        cout<<"No"<<endl;
        return 0;
    }
    
    int a=0,c=0;
    for(int i=1;i<=n;i++){
        z[a][a+c]=i;
        z[1+a+c][a]=i;
        c++;
        if(a+c==x-1){
            a++;
            c=0;
        }
    }
    
    
    cout<<"Yes"<<endl;
    cout<<x<<endl;
    for(int i=0;i<x;i++){
        cout<<x-1<<" ";
        for(int j=0;j<x-2;j++){
            cout<<z[i][j]<<" ";
        }
        cout<<z[i][x-2]<<endl;
    }
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A < C & C < B) cout << "Yes" << endl;
  else if(B < C & C < A) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[2][101];
int n, x, maxi = -1;

void dfs( int x, int y, int tot ){
	tot += a[x][y];
	if( y == n-1 ){
		if( x == 1){
			maxi = max(maxi, tot);
		} else {
			dfs(1, y, tot);
		}
		return;
	} 
	if( x == 0 ){
		dfs(1, y, tot);
	}
	dfs(x, y+1, tot);
}

int main(){
	cin >> n;
	for( int i = 0; i < 2; ++i ){
		for( int j = 0; j< n; ++j ){
			cin >> a[i][j];
		}
	}

	dfs(0,0,0);
	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX = 1000000;
int N;
int D[MAX], H[MAX];
struct Node{ int id, parent, left, right; int depth, height; };
Node nodes[MAX];

const int NIL = -1;
int root;

// ??\???????????????????????????????????°?????±?????????????????\???????¨???????

void setDepth(int i, int depth){
	nodes[i].depth = depth;
	int left = nodes[i].left;
	int right = nodes[i].right;

	if (left != NIL){
		setDepth(left, depth + 1);
	}
	if (right != NIL){
		setDepth(right, depth + 1);
	}
}

int setHeight(int i){

	int height = 0;
	int left = nodes[i].left;
	int right = nodes[i].right;

	if (left != NIL){
		height = max(setHeight(left) + 1, height);
	}
	if (right != NIL){
		height = max(setHeight(right) + 1, height);
	}

	nodes[i].height = height;
	return height;
}

int getSibling(Node node){
	if (node.parent == NIL) return -1;
	Node p = nodes[node.parent];
	int left = p.left;
	int right = p.right;
	if (p.left != node.id) return p.left;
	if (p.right != node.id) return p.right;
	throw new exception;
}

int getDegree(Node node){
	int ret = 0;
	if (node.left != NIL) ret++;
	if (node.right != NIL) ret++;
	return ret;
}

string getType(Node node){
	if (node.parent == NIL) return "root";
	if (node.left == NIL && node.right == NIL) return "leaf";
	return "internal node";
}

void print(int u){
	Node node = nodes[u];

	printf("node %d: ", u);
	printf("parent = %d, ", node.parent);
	printf("sibling = %d, ", getSibling(node));
	printf("degree = %d, ", getDegree(node));
	printf("depth = %d, ", node.depth);
	printf("height = %d, ", node.height);
	printf("%s\n", getType(node).c_str());
}

int main() {

	cin >> N;

	// initialize and set child
	rep(ii, N){
		int id, left, right;
		cin >> id;
		cin >> left;
		cin >> right;
		nodes[id].id = id;
		nodes[id].parent = NIL;
		nodes[id].left = left;
		nodes[id].right = right;
	}

	// set parent
	rep(i, N){
		int left, right;
		left = nodes[i].left;
		right = nodes[i].right;

		if (left != NIL){
			nodes[left].parent = i;
		}
		if (right != NIL){
			nodes[right].parent = i;
		}
	}

	// set root
	rep(i, N){
		if (nodes[i].parent == NIL) root = i;
	}

	// set depth, height
	setDepth(root, 0);
	setHeight(root);

	rep(i, N){
		print(i);
	}

}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int r;
    cin>>r;
    cout << 3 * r * r << endl;
    return 0;
}



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

int main(){
 int K;
 std::string S;
 std::cin>>K;
 std::cin>>S;
 int s_size=(int)S.size();
 int flag=0;

 if(s_size<=K){
  K=s_size;
 }else{
  flag=1;
 }
 for(int i=0;i<K;i++){
  std::cout<<S[i];
 }
 if(flag==1){
  std::cout<<"...";
 }
 std::cout<<std::endl;
 
}

Measured memory_bytes: 3612
//Date : Sun Feb 25 21:33:21 2018
//Author : Rishabh Paul
 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(int i=0;i<n;i++)
#define rep(i ,a ,b)	for(int i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define LEFT(i)	2*i + 1
#define RIGHT(i)	2*i + 2
#define EPS 0.00000000000001
#define NIL -1

int a[MAX];
int min(int a,int b){	return (a<b?a:b);	}
int max(int a,int b){	return (a>b?a:b);	}
int cmp(const void *a ,const void *b){
	int *a1 = (int *)a;
	int *b1 = (int *)b;
	if((*a1) > (*b1))	return 1;
	if((*a1) == (*b1))	return 0;
	return -1;
}
int main(){
	int n;
	s(n);
	printf("%d" ,n / 3);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void)
{
  int n,tmp;
  int f=0;

  cin >> n;

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

  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		double N = scanner.nextInt();

		if(N % 2 == 0) {
			// 偶数
			log(0.5);
		} else {
			// 奇数
			log(((N - 1) / 2 + 1 )/ N);
		}



	}

	private static void dfs(int[] treeArray,int parrent, int children) {
		Vector<Vector> aa = new Vector<>();
		Vector<Integer> bb = new Vector<>();
		bb.add(1);
		aa.add(bb);
	}


	/**
	 * バブルソートの交換数を算出
	 * ※転倒数
	 * @param array
	 * @return
	 */
	private static long countSwapBabbleSort(int[] array, int N) {
		long ans = 0;
		int[] binary = new int[N + 1];

		for (int index = 0; index < array.length; index++) {
			ans = ans + (index - sum(binary, array[index]));
			add(binary, array[index], 1);
		}
		return ans;
	}

    //add value at idx on bit O(logN)
	private static void add(int[] bit,int idx,int value) {
        for(int i=idx;i<bit.length;i=i+(i&-i)) {
        	bit[i] += value;
        }
    }

    //return sum [1,idx] O(logN)
	private static long sum(int[] bit,int idx) {
        long ret = 0;
        for(int i=idx;i>0;i-=(i&-i)) {
        	ret += bit[i];
        }
        return ret;
    }

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(long str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

	private static void log(BigInteger str) {
		System.out.println(str);
	}

}



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

int main()
{
    long n;
    cin >> n;
    int ans = 0;
    long x = (long)sqrt(n);
    while (x > 0)
    {
        if (n % x == 0)
        {
            long b = n / x;
            while (b > 0)
            {
                ans++;
                b /= 10;
            }
            cout << ans << endl;
            return 0;
        }
        x--;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>


using namespace std;
int used[10 + 7];
int    s[10 + 7][10 + 7];

int ans = 0;
int n, m;
void DFS(int depth,int now)
{
    for(int i = 1;i <= n;++i)
    {
        if(s[now][i] && !used[i])
        {
            used[i] = 1;
            DFS(depth + 1, i);
            used[i] = 0;
        }
    }

    if(depth == n)
        ans++;
}
int main()
{   

    scanf("%d%d",&n,&m);

    for(int i = 1;i <= m;++i)
    {
        int fr,to;
        scanf("%d%d",&fr,&to);
        s[fr][to] = s[to][fr] = 1;
    }
    used[1] = 1;
    DFS(1,1);
    printf("%d\n",ans);
    return 0;
}

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

class UF {
public:
    vector<int> p;
    UF(size_t n) : p(n) {
        for(size_t i=0; i<n; i++)
            p[i] = i;
    };
    int find(int x) {
        if(p[x] == x) return x;
        return p[x] = find(p[x]);
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        p[x] = y;
    };
};


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

    vector<pair<long,long>> x(n);
    vector<pair<long,long>> y(n);
    for(long i=0; i<n; i++) {
        long s, t;
        cin >> s >> t;
        x[i] = make_pair(s, i);
        y[i] = make_pair(t, i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<tuple<long, long, long>> v(2*(n-1));
    for(long i=0; i<n-1; i++)
        v[i] = make_tuple(x[i+1].first-x[i].first, x[i+1].second, x[i].second);
    for(long i=0; i<n-1; i++)
        v[n-1+i] = make_tuple(y[i+1].first-y[i].first, y[i+1].second, y[i].second);

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

    UF uf(n);
    long r = 0;
    for(auto &e: v) {
        long c, i, j;
        tie(c, i, j) = e;
        if(uf.find(i) == uf.find(j)) continue;
        uf.unite(i, j);
        r += c;
    }
    cout << r << endl;
}


Measured memory_bytes: 8448
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        
        for(int i = 0; i < 10; i++){
            x = r*x - d;
            System.out.println(x);
        }
     
    }
}

Measured memory_bytes: 20684
#include<bits/stdc++.h>
const int P=998244353;
struct pos{
	int x,y;
}ps[207];
int n,pw2[207],ans;
struct dir{
	int a,b,z;
	bool operator<(const dir&w)const{return z<w.z;}
}ds[40007];
int dp=0,f[207],sz[207];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int gf(int x){
	while(x!=f[x])x=f[x]=f[f[x]];
	return x;
}
int main(){
	scanf("%d",&n);
	for(int i=pw2[0]=1;i<=n;++i)pw2[i]=pw2[i-1]*2%P;
	for(int i=0;i<=n;++i)pw2[i]=(pw2[i]-i-1)%P;
	ans=pw2[n];
	for(int i=0;i<n;++i)scanf("%d%d",&ps[i].x,&ps[i].y);
	for(int i=0;i<n;++i){
		for(int j=0;j<i;++j){
			int xd=ps[i].x-ps[j].x,yd=ps[i].y-ps[j].y;
			int g=gcd(xd,yd);
			xd/=g,yd/=g;
			if(!xd)yd=1;
			if(!yd)xd=1;
			if(xd<0)xd=-xd,yd=-yd;
			ds[dp++]=(dir){i,j,xd*30000+yd};
		}
	}
	std::sort(ds,ds+dp);
	for(int i=0,j=0;i<dp;i=j){
		for(;j<dp&&ds[i].z==ds[j].z;++j);
		for(int k=0;k<n;++k)f[k]=k,sz[k]=1;
		for(int k=i;k<j;++k){
			int x=gf(ds[k].a),y=gf(ds[k].b);
			if(x!=y)f[x]=y,sz[y]+=sz[x];
		}
		for(int k=0;k<n;++k)if(f[k]==k)ans=(ans-pw2[sz[k]])%P;
	}
	printf("%d\n",(ans%P+P)%P);
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y,next;
}a[200010];int len,last[100010];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int du[100010];
bool pd,id[100010];
inline void dfs(int x,int fa)
{
	int cnt=0;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y==fa)continue;
		dfs(y,x);
		if(id[y])cnt++;
	}
	if(cnt>=2)pd=true;
	if(!cnt)id[x]=1;
	if(!cnt && !fa)pd=true;
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y),ins(y,x);du[x]++,du[y]++;
	}
	for(int i=1;i<=n;i++)if(du[i]>1){dfs(i,0);break;}
	if(pd==true)puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 3328
#-*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A
"""
import itertools


def input_from_txt(number=1):
    import requests
    #url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_4_A/8/in"
    url = "https://judgedat.u-aizu.ac.jp/testcases/ALDS1_11_A/%s/in" % number
    res = requests.get(url)
    input = res.text.split("\n")
    n = int(input[0])
    Ss = []
    for i in range(n):
        S = list(map(int, input[1+i].split()))
        Ss.append(S)
    return (n, Ss)

def input_array():
    n = int(input())
    Ss = []
    for i in range(n):
        S = list(map(int, input().split()))
        Ss.append(S)
    return (n, Ss)


if __name__ == '__main__':
    (n, Ss) = input_array()
    #(n, Ss) = input_from_txt(1)
    #print(n, Ss)
    for i in range(n):
        vth = Ss[i][0]
        vd = Ss[i][1]
        adjs = Ss[i][2:]
        row = []
        for j in range(1, 1+n):
            if j in adjs: row.append(1)
            else: row.append(0)
        print(" ".join(map(str, row)))
    #ret = get_set4(S, T)
    #ret = get_set2(S, T)
    #ret = get_set(S, T)
    #print(len(ret))



Measured memory_bytes: 5696
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    N, M, K = list(map(int, input().split()))
    U = UnionFind(N)
    FR = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        U.union(a - 1, b - 1)
        FR[a - 1] += 1
        FR[b - 1] += 1
    r = [0] * N
    LS = {}
    for i in range(N):
        t = U.find(i)
        if t not in LS:
            LS[t] = set()
        LS[t].add(i)
        r[i] = -U.parents[t] - 1 - FR[i]
    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c - 1, d - 1
        if d in LS[U.find(c)]:
            r[c] -= 1
            r[d] -= 1
    print(' '.join(str(i) for i in r))

main()


Measured memory_bytes: 105944
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long ll;
const int N=100005;
using namespace std;

ll gcd(ll x,ll y)
{
	if (y==0) return x;
	return gcd(y,x%y);
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	int data;
	ll a,b,c,d;
	cin>>data;
	while (data--)
	{
		cin>>a>>b>>c>>d;
		if (a<b || d<b){puts("No");continue;}
		if (c>=b){puts("Yes");continue;}
		ll x=(a-c)/b;x*=b;a-=x;
		if (a==c) a+=b;
		ll g=gcd(b,d);
		ll e=(c-a)/g;e*=g,a+=e;
		while (a<=c) a+=g;
		if (a>=b){puts("Yes");continue;}
		else{puts("No");continue;}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
}

Measured memory_bytes: 35924
// https://atcoder.jp/contests/abc110/tasks/abc110_a

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a[3];

  cin >> a[0] >> a[1] >> a[2];

  sort(a, a + 3);

  cout << a[0] + a[1] + a[2] * 10 << '\n';

  return 0;
}


Measured memory_bytes: 256