akhauriyash/Code-Regression huggingface dataset:
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Sun Oct 22 21:05:50 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint32_t> array;
static int32_t a[10];

uint32_t pattern(uint32_t i)
{
  uint32_t ret = 0;
  if (i == array.size()) {
    int32_t count = 1;
    for (uint32_t j = 0; j < array.size(); j++) {
      count *= a[j];
    }
    return (count % 2 == 0);
  } else {
    a[i] = array[i] - 1;
    ret += pattern(i + 1);
    a[i] = array[i] + 0;
    ret += pattern(i + 1);
    a[i] = array[i] + 1;
    ret += pattern(i + 1);
  }

  return ret;
}

int32_t main()
{
  uint32_t N;
  cin >> N;
  for (uint32_t i = 0; i < N; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
  }

  cout << pattern(0) << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll mod = 1000000007;
const ll INF = 1ll << 50;


ll h,w;
string a[101];
ll cnt[128];

void error(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  cin >> h >> w;
  for(ll i = 0;i < h;i++) cin >> a[i];
  for(ll i = 0;i < h;i++){
    for(ll j = 0;j < w;j++){
      cnt[a[i][j]]++;
    }
  }
  if(h%2 == 0 && w%2 == 0){
    for(ll i = 0;i < 128;i++){
      if(cnt[i]%4 != 0) error();
    }
  }else if(h%2 == 1 && w%2 == 1){
    ll odd = 0;
    ll even = 0;
    for(ll i = 0;i < 128;i++){
      if(cnt[i]%4 != 0){
        if(cnt[i]%2 == 0){
          even++;
        }else{
          odd++;

        }
      }
    }
    if(even*2 > h-1+w-1) error();
    if(odd != 1) error();
  }else if(h%2 == 1){
    ll odd = 0;
    ll even = 0;
    for(ll i = 0;i < 128;i++){
      if(cnt[i]%4 != 0){
        if(cnt[i]%2 == 0){
          even++;
        }else{
          odd++;

        }
      }
    }
    if(even*2 > w) error();
    if(odd != 0) error();
  }else if(w%2 == 1){
    ll odd = 0;
    ll even = 0;
    for(ll i = 0;i < 128;i++){
      if(cnt[i]%4 != 0){
        if(cnt[i]%2 == 0){
          even++;
        }else{
          odd++;

        }
      }
    }
    if(even*2 > h) error();
    if(odd != 0) error();
  }
  cout << "Yes" << endl;

}


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

vector<pair<int,int>> v;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int sx, sy, tx, ty, n, x, y;
    cin >> sx >> sy >> tx >> ty >> n;
    for(int i=0; i<n; i++){
        cin >> x >> y;
        if( min(sx,tx) <= x && max(sx,tx) >= x && min(sy,ty) <= y && max(sy,ty) >= y )
            v.push_back({x,y});
    }
    if( sx < tx && sy < ty || tx < sx && ty < sy ) sort(v.begin(),v.end());
    else sort(v.rbegin(),v.rend());
    vector<int> u;
    for(int i=0; i<v.size(); i++){
        if( i == 0 || v[i].second >= u.back() )
            u.push_back(v[i].second);
        else{
            *lower_bound(u.begin(),u.end(),v[i].second) = v[i].second;
        }
    }
    double delta = 20 - 5*acos(-1.0);
    long long s = 100*(LL)abs(sx-tx) + 100*(LL)abs(sy-ty);
    cout.precision(15);
    if( min(abs(sx-tx), abs(sy-ty)) == u.size()-1 ) cout << s - (u.size()-1)*delta + (u.size()!=0)*(10*acos(-1.0)-20) << "\n";
    else cout << s - u.size()*delta << "\n";
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main(){
	int n=0,k=0,ans=0;
    bool hit = true;
	bool d[10];
    for(int i=0;i<10;i++) d[i] = true;
    cin >> n >> k;
    ans = n;
	for(int i=0;i<k;i++){
		int num=0;
		cin >> num;
		d[num]=false;
	}
   while(1){ 
        hit = true;int num=ans;
		while(num){

		  if(d[num%10] == false){ hit=false; break;}
		  num/=10;
        }
        if(hit){ cout << ans << "\n";return 0;}
		ans++;  
		
   }
}
/*
#include <iostream>
#include "cstdio"
#include <string>
#include <vector>

#define NMAX 100
using namespace std;

int main(){
	int N,K,ans,D[10] = {};
	cin >> N >> K;
	for (int i = 0; i < K; ++i)
	{
		int a;
		cin >> a;
		D[a]++;//嫌いな数字なら1違うなら0
	}
	ans = N;//品物の金額（買う時の最低額）
	while(1){
		int s = true,num = ans;
		while(num){//0になるまでやる
			if(D[num%10] == 1){//一の位を取り出してリストに存在したら
				s = false;
				break;
			}
			num /= 10;//桁を一つ減らす
		}
		if(s){//リストにかからない
			cout << ans <<"\n";
			break;
		}
		ans++;
	}
	return 0;
}
*/


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

int main(){
	
	string str;
	
	while(cin>>str){
		
		int n=str.size();
		string a;
		
		for(int i=0;i<n;i++){
			if(str[i]!='@')
				a+=str[i];
			else{
			int p = str[i+1]-'0';
			
			for(int j=0;j<p;j++)
				a+=str[i+2];
			i+=2;
		}
		}
		cout<<a<<endl;
	}
	
}

Measured memory_bytes: 1184
#include <cstdio>
#include <algorithm>
using namespace std;

#define MAX_N 1000

int main(){
	int N, M, P[MAX_N + 1];
	int table[(MAX_N + 1) * (MAX_N + 1)];
	int size;
	int ub, lb, mid;
	int res;
	
	while(true){
		scanf("%d%d", &N, &M);
		if(N == 0 && M == 0) break;
		for(int i = 1; i <= N; i++){
			scanf("%d", &P[i]);
		}
		P[0] = 0;
		
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				table[(i * (N + 1)) + j] = P[i] + P[j];
			}
		}
		size = (N + 1) * (N + 1);
		sort(table, table + size);
		
		res = 0;
		for(int i = 0; i < size; i++){
			if(table[i] > M) continue;
			ub = size; lb = 0;
			while(ub - lb > 1){
				mid = (ub + lb) / 2;
				if(table[i] + table[mid] <= M){
					lb = mid;
				}
				else{
					ub = mid;
				}
			}
			if(res < table[i] + table[lb]){
				res = table[i] + table[lb];
			}
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

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

const int INF = (int)1e9;
struct dat {
    int x, y, d;
};

int H, W;
char grid[1000][1000];
int dist[1000][1000];
int ans;

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

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

    queue<dat> que;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            dist[i][j] = INF;
            if (grid[i][j] == '#') {
                que.push({i, j, 0});
                dist[i][j] = 0;
            }
        }
    }

    while (que.size()) {
        dat from = que.front(); que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = from.x+dx[i], ny = from.y+dy[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W || dist[nx][ny] != INF) continue;
            que.push({nx, ny, from.d+1});
            dist[nx][ny] = from.d+1;
            ans = max(ans, dist[nx][ny]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 17296
from collections import defaultdict
from bisect import *
h, w, n = map(int, input().split())

d = defaultdict(list)
q = [list(map(int, input().split())) for i in range(n)]
q.sort()
ans = [0]*10
for i in range(n):
    a, b = q[i]
    d[a].append(b)

for a, b in q:
    for i in range(max(1, a-2), min(h-2, a)+1):
        for j in range(max(1, b-2), min(w-2, b)+1):
            count = 0
            for k in range(3):
                count += bisect_right(d[i+k], j+2) - bisect_left(d[i+k], j)
            ans[count] += 1


for i in range(1, 10):
    ans[i] //= i

ans[0] = (w-2)*(h-2) - sum(ans[1:])
for i in range(10):
    print(ans[i])


Measured memory_bytes: 115452
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define strcin(s) string (s); cin >> (s);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin(n);
    strcin(s);
    int x = 0;
    int max = 0;
    rap(n,i){
        if(s[i]=='I'){
            x++;
        }else{
            x--;
        }
        if(x>max){
            max = x;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
using namespace std;
#define ll long long

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

  vector<vector<ll>> D(C+1);
  for(ll i=1; i<C+1; ++i) {
    vector<ll> row(C+1, 0);
    for(ll j=1; j<C+1; ++j) cin >> row[j];
    D[i] = row;
  }

  vector<map<ll, ll>> E(3);
  for(ll i=0; i<N; ++i){
    for(ll j=0; j<N; ++j){
      ll c;
      cin >> c;
      map<ll, ll>& e = E[(i+j)%3];
      if(e.find(c)!=e.end()) {++e[c];} else {e[c]=1;}
    }
  }

  ll ans = 10000000000;

  for(ll c1=1; c1<=C; ++c1)
  for(ll c2=1; c2<=C; ++c2)
  for(ll c3=1; c3<=C; ++c3) {
    if (c1==c2 || c2==c3 || c3==c1) continue;

    ll cost = 0;

    for(auto itr = E[0].begin(); itr!=E[0].end(); ++itr)  cost += D[itr->first][c1] * (itr->second);
    for(auto itr = E[1].begin(); itr!=E[1].end(); ++itr)  cost += D[itr->first][c2] * (itr->second);
    for(auto itr = E[2].begin(); itr!=E[2].end(); ++itr)  cost += D[itr->first][c3] * (itr->second);

    if(cost < ans) ans = cost;

  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	int mi = a[n - 1],sum=0;
	rep(i, n - 1)sum += a[i];
	if (mi < sum)cout << "Yes";
	else cout << "No";
	return 0;
}












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

int main() {
  string A;
  int B,C;
  cin >> B >> A >> C ;
  
  int sum ;
  if(A=="+"){
    sum = B+C ;
    cout << sum << endl;
  }
  if(A=="-"){
    sum = B-C ;
    cout << sum << endl;
    }
  }


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int,input().split()))

cnt = 0
tmp_cnt = 0
tmp_a = 0
for a in a_list:
    if a == tmp_a:
        tmp_cnt += 1
        if tmp_cnt % 2 == 0:
            cnt += 1
    else:
        tmp_a = a
        tmp_cnt = 1
        
print(cnt)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll h,n;
    cin>>h>>n;
    string ans="";

    vector<ll> a(n);
    for(ll i=0; i<n; i++) {
        cin>>a[i];
    }
    //sort(a.begin(), a.end(),greater<ll>());
    for(ll i=0; i<n; i++) {
        h -= a[i];
        if(h<=0){
            break;
        }
    }
    if(h<=0){
        ans="Yes";
    }else{
        ans="No";
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;
const i64 mod = 1e9 + 7;

int main()
{
	int n, k;
	vector<int> as;

	scanf("%d%d", &n, &k);
	as.resize(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &as[i]);
	}

	i64 inner_inv = 0;
	i64 outer_inv = 0;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(i < j && as[i] > as[j]) {
				inner_inv += 1;
			}
			if(as[i] > as[j]) {
				outer_inv += 1;
			}
		}
	}

	i64 seg = (i64)k * (k - 1) / 2 % mod;
	i64 ans = (seg * outer_inv + inner_inv * k) % mod;

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 256
S=input()
n=len(S)

def f(a):
  return a*(a+1)//2

ans=0
i=0
if S[i]=='>':
  while i<n and S[i]=='>':
    i+=1
    
  ans+=f(i)
  
while i<n:
  j=i+1
  while j<n and S[j]=='<':
    j+=1
    
  if j==n:
    ans+=f(j-i)
    i=j+1
  else:
    k=j+1
    while k<n and S[k]=='>':
      k+=1
      
    if j-i>k-j:
      ans+=f(j-i)+f(k-j-1)
    else:
      ans+=f(j-i-1)+f(k-j)
      
    i=k
    
print(ans)

Measured memory_bytes: 45476
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    vector<int>p(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        sum+=p[i];
    }
    sort(all(p));
    sum-=p[n-1]/2;
    cout<<sum<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    for(int i=0; i<b; i++) cout << a;
    cout << endl;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K+1):
    if dp[i] == 0:
        for s in S:
            if i+s > K:
                continue
            else:
                dp[i+s] = 1
if dp[K]:
    print("First")
else:
    print("Second")


Measured memory_bytes: 3828
#include<iostream>
const int N=100001;
using namespace std;
int main(){
    int n,x[N],y[N],t[N];
    cin>>n;
    for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
    for(int i=1;i<=n;i++)
        if(x[i]+y[i]>t[i]||(t[i]-x[i]-y[i])%2!=0){cout<<"No"; return 0;}   
        cout<<"Yes";
}

Measured memory_bytes: 1408
PROGRAM ATCODER

implicit none
integer(16) :: n,i,ti,count=0,k,j,tp
character(len=10) :: tmp
integer(16),allocatable :: p(:),turn(:)
character(len=10),allocatable :: s(:)

read*, n
allocate(s(n),p(n),turn(n))
do i = 1, n, 1
  read*, s(i),p(i)
end do

do i = 1, n, 1
  turn(i) = i
end do

do i = 1, n-1, 1
  do j = i+1, n, 1
    if ( s(i) > s(j) ) then
      tmp = s(i)
      s(i) = s(j)
      s(j) = tmp
      ti = turn(i)
      turn(i) = turn(j)
      turn(j) = ti
      tp = p(i)
      p(i) = p(j)
      p(j) = tp
    end if
  end do
end do

do k = 1, n-1, 1
  count = 0
  do i = k+1, n, 1
    if ( s(k) == s(i) ) then
      count = count + 1
    end if    
  end do
  if ( count == 0 ) cycle
  do i = k, k+count-1, 1
    do j = i+1, k+count, 1
      if ( p(i) < p(j) ) then
        tp = p(i)
        p(i) = p(j)
        p(j) = tp
        ti = turn(i)
        turn(i) = turn(j)
        turn(j) = ti
      end if
    end do
  end do
end do

print'(i0)', turn(1:n)

END PROGRAM ATCODER


Measured memory_bytes: 640
/**    Rose's very long and elaborated template    **/

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
int n,m,x,y;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>n>>m>>x>>y;
    int maxi = -200;
    int mini = 200;
    for(int i = 1; i <= n; ++i)
    {
        int nr;
        cin >> nr;
        maxi = max(maxi, nr);
    }
    for(int i = 1; i <= m; ++i)
    {
        int nr;
        cin >> nr;
        mini = min(mini, nr);
    }
    bool gg = 0;
    for(int i = maxi + 1; i <= mini; ++i)
        if(i > x && i <= y)
        {
            cout << "No War";
            return 0;
        }
    cout << "War";
    return 0;
}


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



int main(){
int n;
cin>>n;
vector<double> a(n);
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a.begin(),a.end());
double sum= 0.0;
for(int i=0;i<n-1;i++)sum+=a[i];
	//cout<<sum<<' '<<a[n-1]<<endl;
	if(a[n-1]<sum){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import bisect
import sys
import collections
input = sys.stdin.readline
N = int(input())
A = [int(input()) for i in range(N)]
B = [A[0]]
B = collections.deque(B)
tmp = [0]*N
ans = 1
for i in range(1, N):
    id = bisect.bisect_left(B, A[i])
    if id == 0:
        B.appendleft(A[i])
    else:
        B[id-1] = A[i]
print(len(B))


Measured memory_bytes: 48220
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, cnt = 0; cin >> N;
    int minv = INF;
    REP(i, N){
        int P; cin >> P;
        if(P <= minv){
            ++cnt;
            minv = P;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
    double x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    double d=sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    printf("%lf\n",d);
    
    return 0;
}


Measured memory_bytes: 3292
#include<stdio.h>
#define N 100

int main(){
  int n, A[N], i, j, change, flag, cont=0;

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &A[i]);

  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      flag = 0;
      if(A[j] < A[j-1]){
	change = A[j];
	A[j] = A[j-1];
	A[j-1] = change;
	flag = 1;
      }
       if(flag == 1) cont++;
    }
  }

  for(i=0; i<n-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[n-1]);
  printf("%d\n", cont);
  
  return 0;
}



Measured memory_bytes: 2140
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static ArrayList<String> list;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 文字数
		int n = sc.nextInt();

		// 順列のリストを格納する変数
		list = new ArrayList<>();

		// p,qの入力受け取り
		String p = "";
		String q = "";
		String[] p_sort = new String[n]; // 順列の最初の要素を格納したい
		for (int i = 0; i < n; i++) {
			String tmp = sc.next();
			p += tmp;
			p_sort[i] = tmp;
		}
		for (int i = 0; i < n; i++) {
			q += sc.next();
		}

		Arrays.parallelSort(p_sort); // p_sortを順列の最初の要素にした
		String p_sort_str = "";
		for (String p_sort_tmp : p_sort) {
			p_sort_str += p_sort_tmp;
		}

		// listに値を詰めていく
		permutation(p_sort_str, "");

		// indexの絶対値を出力
		System.out.println(Math.abs(list.indexOf(q) - list.indexOf(p)));
	}

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			list.add(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}
}

Measured memory_bytes: 60544
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    sc.close();
    String[] str=new String[s.length()];
    int counter=0;
    for(int i=0;i<str.length;i++){
      str[i]=s.substring(i, i+1);
    }
    for(int i=0;i<str.length-1;i++){
      if(!str[i].equals(str[i+1])){
        counter++;
      }
    }
    System.out.println(counter);
  }
}

Measured memory_bytes: 29772
#include<stdio.h>

int main(){
  int  N,K,d,a,i,j,ans;
  bool sn[101] = {false,};
  scanf("%d%d",&N,&K);
  for(i=0;i<K;i++){
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&a);
      sn[a-1] = true;
    }
  }
  ans = 0;
  for(i=0;i<N;i++){
    if(!sn[i]){
      ans++;
    }
  }
  printf("%d",ans);
}

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

const int kN = 700 + 5;
int adj[kN][kN], cl[kN], uf[kN], ck[kN][2];
bitset<kN> dp;

bool Dfs(int x, int c, int n) {
    cl[x] = c;
    for (int i = 0; i < n; ++i) {
        if (x == i || adj[x][i]) continue;
        if (cl[i] == -1) {
            if (!Dfs(i, c ^ 1, n)) return false;
        } else {
            if (cl[i] == cl[x]) return false;
        }
    }
    return true;
}

int Find(int x) {
    if (x == uf[x]) return x;
    return uf[x] = Find(uf[x]);
}

void Merge(int x, int y) {
    uf[Find(x)] = Find(y);
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        --u, --v;
        adj[u][v] = adj[v][u] = 1;
    }
    memset(cl, -1, sizeof(cl));
    for (int i = 0; i < n; ++i) {
        if (cl[i] == -1) {
            if (!Dfs(i, 0, n)) {
                puts("-1");
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i) uf[i] = i;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (!adj[i][j]) Merge(i, j);
        }
    }
    for (int i = 0; i < n; ++i) ++ck[Find(i)][cl[i]];
    dp[0] = true;
    for (int i = 0; i < n; ++i) {
        if (Find(i) == i)
            dp = ((dp << ck[i][0]) | (dp << ck[i][1]));
    }
    int ans = n * n;
    for (int i = 0; i <= n; ++i) {
        if (dp[i])
            ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()
{
    string str;
    cin >> str;

    size_t s, e;
    s = 0;
    e = str.size()-1;
    while (true)
    {
        bool flag = true;
        if (str[s] != 'A')
        {
            flag = false;
            s++;
        }
        if (str[e] != 'Z')
        {
            flag = false;
            e--;
        }
        if (flag)
        {
            break;
        }
    }
    cout << e-s+1 << endl;

    return 0;
}

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

int main(){
    int hako[3];
    int tmp_a, tmp_b, tmp_c;
    int i;

    scanf("%d", &hako[0]);
    scanf("%d", &hako[1]);
    scanf("%d", &hako[2]);

    //A,B SWAP
    tmp_a = hako[0];
    hako[0] = hako[1];
    hako[1] = tmp_a;

    //A,C SWAP
    tmp_a = hako[0];
    hako[0] = hako[2];
    hako[2] = tmp_a;

    printf("%d %d %d\n", hako[0], hako[1], hako[2]);

    return 0;
}


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

n,m = map(int, input().split())
t = sorted([tuple(map(int, input().split())) for i in range(m)])
INF = 10 ** 18
dp = [0,0] + [INF] * (n-1) # 頂点1から各頂点(0~n)までの最短距離
for l,r,c in t:
  for i in range(r,l,-1):
    if dp[l] + c < dp[i]:
      dp[i] = dp[l] + c
    else:
      break
ans = dp[n]
if ans == INF:
  print(-1)
else:
  print(ans)


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





int main(){
    int N;
    cin >> N;
    
    //グラフの構造をもつ
    vector<vector<int>> to(N),cost(N);
    rep(i,N-1){
        int a,b,w;
        cin >> a >> b >> w;
        a--;
        b--;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }
    
    //根から探索
    vector<int> ans(N,-1);
    queue<int> q;
    ans[0]=0;
    q.push(0);
    
    while(!q.empty()){
        int v = q.front();
        q.pop();
        rep(i,to[v].size()){
            int u= to[v][i];
            int w= cost[v][i];
            if(ans[u] != -1) continue;
            ans[u] = (ans[v] + w) %2;
            q.push(u);
        }
    }
    
    for(int i:ans){
        cout << i << endl;
    }
}


Measured memory_bytes: 13064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	string S;
	cin>>S;
	if(S=="Sunny")
		cout<<"Cloudy\n";
	if(S=="Cloudy")
		cout<<"Rainy\n";
	if(S=="Rainy")
		cout<<"Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ?????¢??¢?´¢ '''

# n??????????´??????????????????????q????????¢?´¢????????£?????´???
# ?¨??????????O(qn)


def linear_search(S, T):
    count = 0
    for t in T:
        if t in S:
            count += 1
    return count

if __name__ == '__main__':
    NS = int(input())
    S = list(map(int, input().split()))
    NT = int(input())
    T = list(map(int, input().split()))

    print(linear_search(S, T))

Measured memory_bytes: 8564
/**
*    author:  y_takano
*    created: 19.06.2020 09:04:22
**/

#include <bits/stdc++.h>

using namespace std;

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

    int h, w;

    for (;;)
    {

        cin >> h >> w;

        if (h != 0 || w != 0)
        {
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                    {
                        cout << '#';
                    }
                    else
                    {
                        cout << '.';
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
        else
        {
            break;
        }
    }

    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


int main() {
    int N, X; cin >> N >> X;
    vector<int> L(N); cin >> L;

    int prev = 0;
    int ans = 1;
    rep(i, N) {
        int nxt = prev + L[i];
        ans += nxt <= X;
        prev = nxt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize,m:usize,mut ab:[[usize;2];n]);
    let mut aaa = Vec::new();
    ab.sort();
    for v in &ab {
        for _vv in 0..v[1] {
            aaa.push(v[0]);
            if aaa.len() > m {
                break;
            }
        }
    }
    aaa.sort();

    println!("{}", aaa.iter().take(m).sum::<usize>());
}


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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int dfs(int l, char c, string s) {
    if (l == 0 || s == string(l + 1, c))return l;

    string t = "";
    for (int i = 0; i < l; ++i) {
        if (s[i] == c || s[i + 1] == c)t += c;
        else t += s[i];
    }
    return dfs(l - 1, c, t);
}

int main() {
    int n, k;
    cin >> n >> k;
    ll sum = 0;
    for (int i = k + 1; i <= n; ++i) {
        sum += (n / i) * (i - k);
        if (n % i >= k) {
            sum += n % i - (k - 1);
        }
    }
    if (k == 0)sum -= n;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3612
a, b, c, d = (int(i) for i in input())

op = ["+", "-"]

def calculate(n_1, n_2, op):
    if op == 0:
        return n_1 + n_2
    else:
        return n_1 - n_2

for i in range(2):
    ans_1 = calculate(a, b, i)
    for j in range(2):
        ans_2 = calculate(ans_1, c, j)
        for k in range(2):
            if calculate(ans_2, d, k) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, op[i], b, op[j], c, op[k], d))
                exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n;cin>>n;
  
  int now_num=0,result=0;
  
  char tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp=='I'){
      now_num++;
      result=max(result,now_num);
    }else{
    now_num--;
    }
  
  }


  cout<<result<<endl;
  return 0;
}

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

using ll=int64_t;

ll mod=1e9+7;

int main(){
  int N; cin >>N;
  ll ans=1;
  rep_eq(i,1,N) {
    ans=(ans*i)%mod;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
dp = np.zeros((10, 10)).astype(int)
dp[1, 1] = 1
ans = 1
for i in range(2, N + 1):

    i_str = str(i)
    i_start = int(i_str[0])
    i_end = int(i_str[-1])
    # print(i_start,i_end)
    if i_start == i_end:
        ans += 1
    ans += dp[i_end, i_start]*2
    dp[i_start, i_end] += 1
    # print(dp)
print(ans)


Measured memory_bytes: 12504
a,b,c,d = map(int,list(input()))

bins = []

for i in range(2**3):
    bins.append(list(str(format(i,'b').zfill(3))))


for i in range(8):
    res = a
    
    for j in range(3):
        if j == 0 and bins[i][j] == '0':
            res += b
        
        if j == 0 and bins[i][j] == '1':
            res -= b
        
        if j == 1 and bins[i][j] == '0':
            res += c
        
        if j == 1 and bins[i][j] == '1':
            res -= c
        
        if j == 2 and bins[i][j] == '0':
            res += d
        
        if j == 2 and bins[i][j] == '1':
            res -= d
    
    if res == 7:
        ans = str(a)
        for k in range(3):
            if bins[i][k] == '0':
                ans += '+'
            
            else:
                ans += '-'
            
            ans += str([a,b,c,d][k+1])

print(ans+'=7')

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
int main() {
	int n ; cin >> n;
	cout << 800*n -(n/15)*200<< endl;

	return 0;
}





Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

struct Point {
  double x, y;
};

void koch(int d, Point a, Point b) {
  if (d == 0) return;
  Point s, t, u;
  double th = M_PI / 3;
  s.x = ((a.x * 2) + b.x) / 3;
  s.y = ((a.y * 2) + b.y) / 3;
  t.x = (a.x + (b.x * 2)) / 3;
  t.y = (a.y + (b.y * 2)) / 3;
  u.x = ((t.x - s.x) * cos(th)) - ((t.y - s.y) * sin(th)) + s.x;
  u.y = ((t.x - s.x) * sin(th)) + ((t.y - s.y) * cos(th)) + s.y;

  koch(d - 1, a, s);
  printf("%f %f\n", s.x, s.y);
  koch(d - 1, s, u);
  printf("%f %f\n", u.x, u.y);
  koch(d - 1, u, t);
  printf("%f %f\n", t.x, t.y);
  koch(d - 1, t, b);
}

int main() {
  int n;
  Point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  scanf("%d", &n);
  printf("%f %f\n", a.x, a.y);
  koch(n, a, b);
  printf("%f %f\n", b.x, b.y);
}



Measured memory_bytes: 2688
#include <stdio.h>
int main(void){
    int i = 0;
    int n = 0;
    int h = 0;
    int w = 0;

    int a = 0;
    int b = 0;

    int c = 0;

    scanf("%d %d %d",&n,&h,&w);

    for(i = 0;i < n;i++){
        scanf("%d %d",&a,&b);
        if(a >= h && b >= w)c++;
    }

   printf("%d\n",c);

    return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 20050321;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}


int n;
vector<pii> G[maxn];
int a[maxn];
int ans[maxn];

void dfs(int u, int fa)
{

    int val = 1;
    for(auto p : G[u])
    {
        int v = p.fi, idx = p.se;
        if(v == fa) continue;

        if(val == a[u]) val++;
        ans[idx] = val;
        a[v] = val;

        dfs(v, u);

        val++;
    }

}

void work()
{
    cin >>n;
    for(int i = 1; i <= n - 1; i++)
    {
        int x, y;
        cin >>x >>y;
        G[x].pb(mk(y, i));
        G[y].pb(mk(x, i));
    }

    dfs(1, 1);

    int mx = 0;
    for(int i = 1; i <= n - 1; i++) mx = max(mx, ans[i]);
    cout <<mx <<endl;

    for(int i = 1; i <= n - 1; i++)
        cout <<ans[i] <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 11648
S = input()
max_S = 0
ACGT = ['A', 'C', 'G', 'T']
S2 = [1 if x in ACGT else 0 for x in S]
for i in range(len(S2)):
  for j in range(i+1, len(S)+1):
    if len(S[i:j])==sum(S2[i:j]):
      if len(S[i:j])>max_S:
        max_S = len(S[i:j])
print(max_S)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
        int[] A=new int[n];
        
        for(int i=0; i<n;i++) {
        	A[i]=gi();
        }
        Map<Integer,Integer> l=new HashMap<Integer,Integer>();
        int c=0;
        int q=1;
        while(true) {
        	l.put(q,q);
        	int a= A[q-1];
        	q=a;
        	c++;
        	if(q==2)break;
        	if (l.containsKey(q)) {
        		System.out.print(-1);
        		return;
        	}
        }
	   
	    System.out.print(c);

//        if (t.equals("Sunny")) {
//        	System.out.print("Cloudy");
//        }else if(t.equals("Cloudy")){
//        	System.out.print("Rainy");
//        } else {
//        	System.out.print("Sunny");
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    if( a[a.size()-1] == b[0] && b[b.size()-1] == c[0] ) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256