akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin >> n;
    map<ll,ll> mp;
    rep(i,n-1){
        ll a; cin >> a;
        a--;
        mp[a]++;
    }
    rep(i,n) cout << mp[i] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)


int main() {
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];

    //累積MAxをとる
    ll sum = 0;
    ll accum[N];
    accum[N - 1] = A[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        accum[i] = max(accum[i], accum[i + 1]);
    }
    ll total = 0;
    ll minAbs = INT_MAX;
    vector<int> minusIdx;
    rep(i, N) {
        if (A[i] < 0) {
            minusIdx.push_back(i);
        }
        ll ab = abs(A[i]);
        minAbs = min(minAbs, ab);
        total += ab;
    }
    if (minusIdx.size() % 2 == 0) {
        //全区間プラスに変換可能
    } else {
        //もっとも絶対値の小さい値を負にして切り捨てる
        total -= minAbs * 2; //totalに加算されているので、二倍にして引く
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 2428
import java.util.*;

// ABC 54-D
// https://beta.atcoder.jp/contests/abc054/tasks/abc054_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		char[] s = in.next().toCharArray();
		System.out.printf("2018");
		for (int i = 4; i < s.length; i++) {
			System.out.printf("%c", s[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}


Measured memory_bytes: 3516
#include <stdio.h>

int main(void){
    int n1, n2;
    char s[4];
    if(scanf("%s", s) == 1);
    n1 = (s[0] - '1' + 1) * 10 + (s[1] - '1' + 1);
    n2 = (s[2] - '1' + 1) * 10 + (s[3] - '1' + 1);
    if(1 <= n1 && n1 <= 12){
        if(1 <= n2 && n2 <= 12){
            printf("AMBIGUOUS\n");
        } else {
            printf("MMYY\n");
        }
    } else if(1 <= n2 && n2 <= 12){
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    import itertools
    n = int(input())
    p = tuple(map(int,input().split()))
    q = tuple(map(int,input().split()))
    seq = list(range(1,n+1))
    l = sorted(list(itertools.permutations(seq)))
    d = {}
    for j in range(len(l)):
        d[tuple(l[j])] = j+1
    print(abs(d[p]-d[q]))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 49392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (b-a == c-b) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}


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

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

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

	int N, Q;
	cin >> N >> Q;
	vector<int> a(N);
	rep(i, 0, N) cin >> a[i];

	rep(i, 0, Q) {
		ll x;
		cin >> x;

		int right = 0;
		ll sum, res = 0;
		rep(left, 0, N) {
			while(right < N and sum + a[right] <= x) {
				sum += a[right++];
			}

			res += right - left;

			if(right == left) right++;
			else sum -= a[left];
		}

		cout << res << endl;
	}


}



Measured memory_bytes: 3332
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
if a==b:
    if c==d:
        if a!=c: print("Yes")
        else: print("No")
    else: print("No")
elif a==d:
    if b==c: print("Yes")
    else: print("No")
elif a==c:
    if b==d: print("Yes")
    else: print("No")
else: print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		int a, b; cin >> a >> b;
		v.push_back({b,a});
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int r = -1;
	for(int i=0;i<m;i++){
		if(v[i].second<r){
			continue;
		}else{
			ans++;
			r = v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        ans += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(ans)

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

// pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
// gp_hash_table<int, int> table;

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;

    cin >> n;

    vector< int > a(n), b(n);

    for(int &x : a) cin >> x;
    for(int &x : b) cin >> x;

    ll rem = 0;
    int res = 0;

    for(int i = 0;i < n;i++) {
        if(a[i] < b[i]) {
            rem += b[i] - a[i];
            res++;
            a[i] = b[i];
        }
    }

    vector< int > diff;
    diff.reserve(n);

    for(int i = 0;i < n;i++) {
        if(a[i] > b[i]) diff.push_back(a[i] - b[i]);
    }

    sort(diff.rbegin(), diff.rend());

    for(int x : diff) {
        if(rem == 0) break;
        int dl = min(rem, ll(x));
        rem -= dl;
        res++;
    }

    if(rem > 0) {
        cout << "-1\n";
    }else {
        cout << res << "\n";
    }

    return 0;
}


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

int main()
{
	string str;
	string ring[100];
	cin >> str;
	int n;
	cin >> n;
	int count = 0;
	for(int i=0;i<n;i++){
		cin >> ring[i];
		ring[i] += ring[i];
		for(unsigned j=0;j<10+str.size();j++){
			bool flag = true;
			if(ring[i][j] == str[0]){
				for(unsigned k=1;k<str.size();k++){
					if(ring[i][j+k] != str[k])
						flag = false;
				}
				if(flag){
					count++;
					break;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

int n, k, i;
long long int T[100000];

long long int check(int p)
{
  int j = 0;
  long long int s;

  for(i = 0; i < k; i++){
    s = 0;
    while(s + T[j] <= p){
      s += T[j];
      j++;
      if(i == n) return n;
    }
  }
  return j;
}

long long int solve()
{
  long long int left = 0;
  long long int right = 100000 * 10000;
  long long mid;
  int v;

  while(right - left > 1){
    mid = (left + right) / 2;
    v = check(mid);
    if(v >= n){
      right = mid;
    }
    else{
      left = mid;
    }
  }
  return right;
}

int main(void)
{
  long long int ans;

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

  for(i = 0; i < n; i++){
    scanf("%d", &T[i]);
  }
  ans = solve();
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 2620
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ansa = n / (a + b) * a;
    ll ansb = n / (a + b) * b;
    ll md = n % (a + b);
    ll mi = min(a,md);
    ansa += mi;
    md -= mi;
    mi = min(ansb,md);
    ansb += mi;
    cout << ansa <<'\n';

}

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

ji = {}
ans = 1
m = 1000000007
for i in range(n):
    tmp = i + 1
    j = 2
    while tmp != 1:
        if tmp % j == 0:
            if not j in ji:
                ji[j] = 0
            
            ji[j] += 1
            tmp /= j
        else:
            j += 1 

for i in ji.values():
    ans *= (i + 1)
    ans %= m
    

print(ans)


Measured memory_bytes: 9120
def dfs(visited, s):
    visited = visited[:]
    global ans
    visited[s] = True
    for t in graph[s]:
        if not visited[t]:
            dfs(visited, t)
    if all(visited):
        ans += 1


N, M = map(int, input().split())  # N頂点, M辺存在する

graph = [[] for _ in range(N)]
visited = [False] * N

for _ in range(M):  # M辺を受け取る
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)


ans = 0
dfs(visited, 0)

print(ans)


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

using namespace std;

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

    int *b = new int[n], *w = new int[n]; //b[i]=i番目以上で白色の数　w[i] = i番目以下で黒色の数
    b[n-1] = (s[n-1] == '.') ? 1 : 0;
    w[0] = (s[0] == '#') ? 1 : 0;
    for (int i = 0; i < n-1; i++) {
        b[n-i-2] = (s[n-2-i] == '.') ? b[n-i-1] + 1 : b[n-i-1];
        w[i+1] = (s[i+1] == '#') ? w[i] + 1 : w[i];
    }
    int ans = min(b[0], w[n-1]);
    for (int i = 1; i < n; i++) {
        ans = min(b[i] + w[i-1], ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2172
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int count=1;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]!=s[i+1])
			count++;
	}
	cout<<count<<endl;
}

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

int main(void) {
  int n, k;
  cin >> n >> k;
  double p = ((n < k) ? 0 : 1.0 * (n-k+1)/n);
  int u = min(n, k-1);
  int l = k;
  double pow = 1;
  
  while (l>u && l>1) {
    l = (l+1)/2;
    pow *= 0.5;
  }
  
  while (u >= 1) {
    p += pow * (u-l+1)/n;
    u = l - 1;
    l = (l+1)/2;
    pow *= 0.5;
  }
  
  cout << setprecision(15) << p;
  return 0;
}

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

string a[8];
int h, w;

bool dfs(int x, int y){
    if(a[y][x] == '.')return false;
    a[y][x] = '.';
    if(x == w - 1 && y == h - 1)return true;
    if(x < w - 1 && y < h - 1 && a[y+1][x] == '#' && a[y][x+1] == '#')return false;
    if(x < w - 1 && a[y][x+1] == '#')return dfs(x+1, y);
    if(y < h - 1 && a[y+1][x] == '#')return dfs(x, y+1);
    return false;
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;++i){
        cin >> a[i];
    }

    bool flag = true;
    if(dfs(0, 0)){
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                if(a[i][j] == '#'){
                    flag = false;
                    break;
                }
            }
        }
        cout << (flag ? "Possible" : "Impossible") << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){

ll ir,dr;
ll n,r; cin >> n >> r;

if(n<10){
  cout << r+100*(10-n) << endl;
}else{
  cout << r << endl;
}



}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1149&lang=jp

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

int main() {
  int n, w, d;
  while (cin >> n >> w >> d && w) {
    vector<tuple<int, int, int, int>> V; // 世代、面積、縦、横。
    V.push_back(make_tuple(-1, w*d, w, d));
    for (int i=0; i<n; i++) {
      int p, s;
      cin >> p >> s; p--;
      int wid = get<2>(V[p]);
      int dep = get<3>(V[p]);
      V.erase(V.begin() + p);
      s = s%(wid+dep);
      if (s < wid) {
	V.push_back(make_tuple(i, s*dep, s, dep));
	V.push_back(make_tuple(i, (wid-s)*dep, wid-s, dep));
      } else {
	s -= wid;
	V.push_back(make_tuple(i, wid*s, wid, s));
	V.push_back(make_tuple(i, wid*(dep-s), wid, dep-s));	
      }
      sort(V.begin(), V.end());
    }
    vector<int> S;
    for (unsigned int i=0; i<V.size(); i++) {
      S.push_back(get<1>(V[i]));
    }
    sort(S.begin(), S.end());
    for (unsigned int i=0; i<S.size(); i++) {
      if (i > 0) cout << " ";
      cout << S[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1228
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
if 0 not in A:
  ans = sum(A)//2
else:
  now = 0
  for i in range(N):
    if A[i] == 0 or i == N-1:
      ans += sum(A[now:i+1])//2
      now = i+1
print(ans)

Measured memory_bytes: 7452
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
 
using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////
 
 void solve(){
  ini(N);
  vi a(N); in(a);

  vi b = a;
  sort(all(b));

  map<int , int> m;
  rep(i , N){
    m[a[i]] = i;
  }
  int cnt = 0;
  rep(i , N){
    cnt += abs(i - m[b[i]]) & 1;
  }
  out(cnt / 2);


}

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


int main(){
	int N; cin>>N;
	vector<int> sides(N);
	for(int i=0;i<N;i++) cin>>sides[i];
	sort(sides.rbegin(),sides.rend());
	int tot = 0;
	for(int i=1;i<sides.size();i++) tot += sides[i];
	if(sides[0] >= tot) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    vector<int> val(9,0);
    int i;
    rep(i,9)cin>>val[i];
    rep(i,9)n-=val[i];
    cout<<n<<endl;
    cin>>n;
  }
}




Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b; cin>>n>>a>>b;
  int digit,sum, sum_sum;
  sum = 0; sum_sum = 0;
  for(int i=1; i<=n; ++i){
    int j = i;
    digit = 1; sum = 0;
    while ( (j/=10) >= 1){
      digit++;
    }
    j = i;
    for ( int k = digit; k>=1; --k){
      sum += (j / pow(10,k-1)); j -= (int)( j / pow(10,k-1)) * pow(10,k-1);
    }
    if ( sum>=a && sum<=b){
      sum_sum += i;
    }
  }
  cout <<sum_sum<< endl;
  return 0;
}

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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

const LL MOD = 1e9+7;

inline LL fpow(LL bs, LL idx){
	LL res = 1;
	while(idx){
		if(idx & 1)	(res *= bs) %= MOD;
		(bs *= bs) %= MOD;
		idx >>= 1;
	}
	return res;
}

LL fact[2005] = {1}, invfact[2005] = {1};

int main(){
	for(int i = 1; i <= 2000; i++){
		fact[i] = fact[i-1] * i % MOD;
		invfact[i] = fpow(fact[i], MOD-2);
	}
	LL S, ans = 0; read(S);
	for(int k = 1; k <= S / 3; k++){
		ans += fact[S-2*k-1] * invfact[k-1] % MOD * invfact[S-3*k] % MOD;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  string s;
  char op_a,op_b,op_c;
  cin >> s;
  int a = s.at(0)-'0',b = s.at(1)-'0';
  int c = s.at(2)-'0',d = s.at(3)-'0';
  if(a+b+c+d == 7){op_a='+';op_b='+';op_c='+';}
  else if(a+b+c-d == 7){op_a='+';op_b='+';op_c='-';}
  else if(a+b-c+d == 7){op_a='+';op_b='-';op_c='+';}
  else if(a+b-c-d == 7){op_a='+';op_b='-';op_c='-';}
  else if(a-b+c+d == 7){op_a='-';op_b='+';op_c='+';}
  else if(a-b+c-d == 7){op_a='-';op_b='+';op_c='-';}
  else if(a-b-c+d == 7){op_a='-';op_b='-';op_c='+';}
  else if(a-b-c-d == 7){op_a='-';op_b='-';op_c='-';}
  cout << a << op_a << b << op_b << c << op_c << d << "=7" << endl;
}
                   


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

using namespace std;
const int mxn = 10;
int main()
{
	int a[3][3];
	bool check[3][3];
	
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
		
	}
	
	int n;
	cin >> n;
	int arr[mxn];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			check[i][j] = false;
			for (int k = 0; k < n; k++)
			{
				if (a[i][j] == arr[k])
				{
					check[i][j] = true;
				}
			}
		}
		
	}
	
	string ans = "No";
	for (int i = 0; i < 3; i++)
	{
		if (check[i][0] == true && check[i][1] == true && check[i][2] == true)
		{
			ans = "Yes";
		}
	}
	
	for (int i = 0; i < 3; i++)
	{
		if (check[0][i] == true && check[1][i] == true && check[2][i] == true)
		{
			ans = "Yes";
		}
	}
	
 	if (check[0][0] == true && check[1][1] == true && check[2][2] == true)
	{
		ans = "Yes";
	}
	
	if (check[2][0] == true && check[1][1] == true && check[0][2] == true)
	{
		ans = "Yes";
	}
	cout << ans;
	return 0;
}



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

using namespace std;
using ll = long long;

constexpr ll INF = 1LL << 60;

ll scanll(){
    ll ret = 0;
    for(char c = getchar_unlocked(); isdigit(c); c = getchar_unlocked()){
        ret = 10 * ret + c - '0';
    }
    return ret;
}

ll f(ll b, ll n){
    ll ret = 0;
    for(; n; n /= b) ret += n % b;
    return ret;
}

int main(){
    ll n = scanll();
    ll s = scanll();
    ll d = n - s;

    if(d < 0) puts("-1");
    else if(!d) printf("%lld\n", n + 1);
    else{
        ll ans = INF;
        for(ll i = 1; i <= sqrt(d); i++){
            if(d % i) continue;

            ll b = i + 1;
            if(ans > b && f(b, n) == s) ans = b;

            b = d / i + 1;
            if(ans > b && f(b, n) == s) ans = b;
        }

        if(ans == INF) puts("-1");
        else printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n*3)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i*2+1]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>a(n),b(n,0);
  rep(i,n)cin >> a[i];
  int cnt=0;
  do{
    rep(i,n)b[i]=0;
    rep(i,n){
      ll r,l;
      l=max((ll)0,i-a[i]);
      r=min(n-1,i+a[i]);
      b[l]++;
      if(r+1<n)b[r+1]--;
    }
    rep(i,n){
      if(i!=n-1)b[i+1]+=b[i];
      a[i]=b[i];
    }
    cnt++;
    if(cnt==k)break;
  }while(a[0]!=n);

  rep(i,n)cout << a[i] << " ";
}


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

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define int long long
#define INF 1e+9
#define MAX_V 100008
const int MOD = 1e9 + 7;
const int inf = 1 << 30;
vector<int> seen(50005, -1);
vector<long long> P(50005+1), C(50005+1);
vector<vector<long long>> G(50005+1);
vector<long long> GN(50005, 0);
vector<long long> GM(50005, 0);
long long  cnt = 0;

signed main(){
  IOS
  int  N, K;
  cin >> N >> K;
  vector<int> p(N), c(N);
  rep(i, 0, N) cin >> p[i];
  rep(i, 0, N) cin >> c[i];
  rep(i, 0,N)  p[i]--;

  ll ans = -1e18;
  rep(si, 0, N){
    int x = si;
    vector<int> s;
    ll tot = 0;
    while(1) {
      x = p[x];
      s.push_back(c[x]);
      tot += c[x];
      if( x == si) break;
    }
    long long l = s.size();
    long long t = 0;
    ll now = 0;
    rep(i, 0, l){
      t += s[i];
      if( i + 1 > K) break;
      now = t;
      if(tot > 0){
        now += tot * ((K - (i + 1)) / l);
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6700
#include <iostream>
using namespace std;
    
int main()
{   
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {   
        int j = i;
        if (j % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        while(j)
        {   
            if (j % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            j /= 10;
        }
    }
    cout << endl;
    return 0;
}  
   
                     


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin>>n;
	long long int arr[n+1];
	for(int i=1;i<=n;i++)
	arr[i]=1;
	for(int i=2;i<=n;i++){
		int j=i;
		while(j<=n){
			arr[j]+=1;
			j+=i;
		}
	}
	long long int ans=0;
	for(long long int i=1;i<=n;i++){
		ans+=i*arr[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 81692
#include<bits/stdc++.h>
using namespace std;
int f[11];
int main()
{
	int r,d,s,i;
	scanf("%d %d %d",&r,&d,&s);
	f[0]=s;
	for(i=1;i<=10;i++)
	{
		f[i]=r*f[i-1]-d;
		printf("%d\n",f[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int i,n;
	char s[101];
  
	scanf("%s", s);
    n = strlen(s);
  
    printf("%c%d%c\n", s[0], n-2, s[n-1]);
    
    return 0;
}

Measured memory_bytes: 128
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int q[210000];
long long segtree[524288];
long long query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return 0;
	if(c<=a&&b<=d)return segtree[e];
	return max(query(a,(a+b)/2,c,d,e*2),query((a+b)/2+1,b,c,d,e*2+1));
}
void update(int a,long long b){
	a+=262144;
	while(a){
		segtree[a]=max(segtree[a],b);
		a/=2;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<a;i++){
		scanf("%d",q+i);
	}
	for(int i=0;i<524288;i++)segtree[i]=0;
	for(int i=0;i<a;i++){
		long long t=query(0,262143,0,p[i]-1,1);
		long long cur=t+q[i];
		update(p[i],cur);
	}
	printf("%lld\n",segtree[1]);
}

Measured memory_bytes: 5760
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int i;
    int array[n];
    int dp[n] = {0};
    dp[0] = 0;
    for(i = 0; i<n; i++)
    {
        cin>>array[i];
    }
    int maximum = 0;
    for(i = 1; i<n; i++)
    {
        if(array[i] <= array[i-1])
            dp[i] = dp[i-1] + 1;
        else
            dp[i] = 0;
        maximum = max(maximum,dp[i]); 
    }
    cout<<maximum;

}

Measured memory_bytes: 1024
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>

using namespace std;

void solution() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

    solution();

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define output(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef string::const_iterator State;

void assume(State &begin1, State &begin2, char expected, string &s) {
    // cerr << "assume: " << *begin1 << ", " << *begin2 << ", " << expected << ", " << s << endl;

    assert(*begin1 == expected && *begin2 == expected);
    s += *begin1;
    begin1++;   begin2++;
}

string number(State &begin1, State &begin2) {
    // cerr << "number: " << *begin1 << ", " << *begin2 << endl;

    int val1 = 0;
    while (isdigit(*begin1)) {
        val1 *= 10;
        val1 += *begin1 - '0';
        begin1++;
    }
    int val2 = 0;
    while (isdigit(*begin2)) {
        val2 *= 10;
        val2 += *begin2 - '0';
        begin2++;
    }
    return to_string(val1 + val2);
}

void pass(State &begin) {
    int depth = 1;
    for (;;) {
        if (*begin == '(') {
            depth++;
        } else if (*begin == ')') {
            depth--;
        }

        if (depth == 0) {
            return;
        }
        begin++;
    }
}

string node(State &begin1, State &begin2) {
    // cerr << "node: " << *begin1 << ", " << *begin2 << endl;

    if (*begin1 == ')') {
        pass(begin2);
        return "";
    }
    if (*begin2 == ')') {
        pass(begin1);
        return "";
    }

    string ret = "";

    assume(begin1, begin2, '(', ret);
    ret += node(begin1, begin2);
    assume(begin1, begin2, ')', ret);
    assume(begin1, begin2, '[', ret);
    ret += number(begin1, begin2);
    assume(begin1, begin2, ']', ret);
    assume(begin1, begin2, '(', ret);
    ret += node(begin1, begin2);
    assume(begin1, begin2, ')', ret);

    return ret;

}

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

    string s1, s2;
    cin >> s1 >> s2;
    State begin1 = s1.begin();
    State begin2 = s2.begin();
    cout << node(begin1, begin2) << endl;
    assert(begin1 == s1.end() && begin2 == s2.end());

}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

typedef tuple<ll, int, int, int> PC;

int main() {

    map<char, char> p = {
            {'A', 'T'},
            {'T', 'A'},
            {'C', 'G'},
            {'G', 'C'},
    };

    char b;
    cin >> b;

    cout << p[b] << endl;

}



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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    vector<P> v;
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        v.push_back(P(a, i));
        v.push_back(P(b, N+i));
    }

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

    ll rest = H;
    int ind = 0;
    int cnt = 0;
    while(rest > 0){
        if(v[ind].second < N) {
            cnt += rest/v[ind].first;
            if(rest % v[ind].first != 0) cnt++;
            break;
        }
        rest = rest - v[ind].first;
        cnt++;
        ind++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    map<int, int> xmp;
    map<int, int> ymp;
    for(int i = 0; i < N; i++) {
        int key = v[i];
        if(i % 2 == 0) {
            if(ymp.count(key)) {
                ymp[key]++;
            } else {
                ymp[key] = 1;
            }
        } else {
            if(xmp.count(key)) {
                xmp[key]++;
            } else {
                xmp[key] = 1;
            }
        }
    }

    int ymax = 0;
    vector<pair<int, int>> p2;
    vector<pair<int, int>> p;
    for(auto y : ymp) {
        pair<int, int> tmpp = make_pair(y.second, y.first);
        p2.push_back(tmpp);
    }
    for(auto x : xmp) {
        pair<int, int> tmpp = make_pair(x.second, x.first);
        p.push_back(tmpp);
    }
    sort(p2.begin(), p2.end());
    sort(p.begin(), p.end());
    // cout << ykey << endl;
    // cout << p[p.size() - 2].second << endl;
    int ykey = p2[p2.size() - 1].second;
    int xkey = p[p.size() - 1].second;
    ll xans = 0;
    if(ykey == xkey) {
        if(p.size() == 1) {
            xkey = ykey + 1;
        } else {
            xkey = p[p.size() - 2].second;
        }
    }

    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            if(v[i] != ykey) {
                xans++;
            }
        } else {
            if(v[i] != xkey) {
                xans++;
            }
        }
    }

    int ykey2 = p2[p2.size() - 1].second;
    int xkey2 = p[p.size() - 1].second;
    ll yans = 0;
    if(ykey2 == xkey2) {
        if(p.size() == 1) {
            ykey2 = xkey2 + 1;
        } else {
            ykey2 = p2[p2.size() - 2].second;
        }
    }

    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            if(v[i] != ykey2) {
                yans++;
            }
        } else {
            if(v[i] != xkey2) {
                yans++;
            }
        }
    }

    cout << min(xans, yans) << endl;
}


Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
const int maxn = 40400;
int a[maxn], b[maxn], c[maxn];
int id[maxn], pos[maxn], cid[maxn];
int fw[maxn];
void add(int x, int v){
	for(x += 1; x < maxn; x += x & -x)
		fw[x] += v;
}
int sum(int x){
	int ans = 0;
	for(x += 1; x; x -= x & -x)
		ans += fw[x];
	return ans;
}
int query(int l, int r){
	return sum(r) - sum(l - 1);
}
int sig(double x){
	if(x > 0) return 1;
	if(x < 0) return -1;
	return 0;
}
double rv[maxn];
const double inf = 1e9;
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	cout << fixed << setprecision(15);
	for(int rot = 0; rot < 2; rot++){
		iota(id, id + n, 0);
		sort(id, id + n, [&](int x, int y){
			double px = (c[x] + a[x] * inf) * 1. / b[x];
			double py = (c[y] + a[y] * inf) * 1. / b[y];
			return px < py;
		});
		for(int i = 0; i < n; i++) pos[id[i]] = i;
		double lo = -inf, hi = inf;
		int tot = n * (n - 1) / 2;
		for(int j = 0; j < 100; j++){
			double mid = (lo + hi) * .5;
			iota(cid, cid + n, 0);
			for(int i = 0; i < n; i++) rv[i] = (double)(((double)c[i]) - ((double)a[i]) * mid) / ((double)b[i]);	
			sort(cid, cid + n, [&](int x, int y){
				//if(fabs(rv[x] - rv[y]) < 1e-9) return pos[x] < pos[y];
				return rv[x] < rv[y];
			});
			int now = 0;
			for(int i = 0; i < n; i++){
				now += query(pos[cid[i]], n);
				add(pos[cid[i]], 1);
			}
			for(int i = 0; i < n; i++) add(pos[cid[i]], -1);
			if(now >= (tot + 1) / 2) hi = mid;
			else lo = mid;
		}
		cout << hi << " ";
		for(int i = 0; i < n; i++) swap(a[i], b[i]);
	}
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int dp[100040][3] = {};
int main() {
	int n;
	cin >> n;
	vector<vector<int>> s(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			int a;
			cin >> a;
			s[i].push_back(a);
		}
	}
	dp[0][0] = s[0][0];
	dp[0][1] = s[0][1];
	dp[0][2] = s[0][2];
	if (n == 1) {
		cout << max(dp[0][0], max(dp[0][1], dp[0][2]));
	}
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + s[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + s[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + s[i][2];
		if (i == n - 1) {
			cout << max(dp[i][0], max(dp[i][1], dp[i][2]));
		}
	}
}

Measured memory_bytes: 6912
#include <stdio.h>
int main(){
 
  int a,b,i,d;
 
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
 
  for(i=0;i<a;i++){

    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
 
  
  }
  printf("\n");
  }
  
 
  return 0;
  }



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
//    cout.precision(15);
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
//    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+5);
void max_self(ll &a, ll b) {
    a = max(a, b);
}
void min_self(ll &a, ll b) {
    a = min(a, b);
}
void mul(ll &a, ll b) {
    a = (a * b) % mod;
}
void add_self(ll &a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}

ll run() {
    int n;
    cin>>n;
    vector<double> p(n+1);
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }

    vector<double> dp(n+1);
    dp[0]=1.0;

    for(int coin=1;coin<=n;coin++){
        vector<double> dp2(n+1);
        for(int i=1;i<=n;i++){
            dp2[i] = dp[i-1]*p[coin] + dp[i]*(1-p[coin]);
        }
        dp2[0] = dp[0]*(1-p[coin]);
        dp = dp2;
    }

    double ans = 0;
    for(int i=n/2+1;i<=n;i++){
        ans += dp[i];
    }
    printf("%0.12lf",ans);

}

































Measured memory_bytes: 256
h,w = map(int, input().split())

a = [['x'] * w for i in range(h)]
for i in range(h):
    tmp = list(str(input()))
    for j in range(w):
        a[i][j] = tmp[j]


for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] == '#':
            flag = False

    if flag:
        for j in range(w):
            a[i][j] = 'x'

arr = []
for i in range(h):
    if a[i][0] == 'x':
        pass
    else:
        arr.append(a[i])


s = [len(v) for v in arr]
h = len(s)
w = s[0]

for i in range(w):
    flag = True
    for j in range(h):
        if arr[j][i] == '#':
            flag = False

    if flag:
        for j in range(h):
            arr[j][i] = 'x'

for i in range(h):
    for j in range(w):
        if arr[i][j] != 'x':
            print(arr[i][j], end='')
    print('')


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int d, mans=-imax, ans;
	vector<int> c, t, ld, at, us;
	vector< vector<int> >s;

	cin>> d;

	c.resize(26);
	rep(i, 26) cin>> c[i];
	s.resize(d);
	rep(i, d){
		s[i].resize(26);
		rep(j, 26) cin>> s[i][j];
	}
	t.resize(d);
	at.resize(d);
	rep(i, d){
		int tmp=1, ma=-1;
		rep(j, 26){
			if(ma<s[i][j]){
				tmp=j;
				ma=s[i][j];
			}
		}
		at[i]=tmp+1;
	}

	rep(i, d){
		//cout<< t[i] <<endl;
	}

	ld.resize(26);
	us.resize(26);

	/*int m;
	vector<int> qd, qq;
	cin>> m;
	qd.resize(m);
	18875
24854
43469
55888
60565
61786
62459
62952
66424
66996
67742
70781
74134
76245
76970
78168
78566
79404
79455
79507
	qq.resize(m);
	rep(i, m) cin>> qd[i] >> qq[i];*/
	
  	std::random_device seed_gen;
  	std::mt19937 engine(seed_gen());

	int ti = clock();
    while (clock() - ti < 185 * CLOCKS_PER_SEC / 100){
	
		rep(i, 26) us[i]=0;

    	rep(i, d){
			int rs=engine();
			rs=abs(rs)%26;
			while(us[rs]>(i+0)/26) rs=(rs+1)%26;
			us[rs]++;
			t[i]=rs;
			//PV(us);
		}
		ans=0;
		rep(i, 26) ld[i]=0;

		rep(i, d){
			ans+=s[i][t[i]];
			ld[t[i]]=i+1;
			rep(j, 26) ans-=(i-ld[j]+1)*c[j];
		}

		if(mans<ans){
			rep(i, d) at[i]=t[i]+1;
			mans=ans;
			//cout<< mans <<endl;
		}
	}

	rep(i, d) cout<< at[i] <<endl;
 
	return 0;
}

Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int a,b;string s;
main()
{
	cin>>a>>b>>s;int i;
	for(i=0;i<a;i++)
	{
		if(s[i]=='-')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(s[a]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(i=a+1;i<a+b+1;i++)
	{
		if(s[i]=='-')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<cstring>
using namespace std;
int global_int[100];
typedef struct 
{
int arr[300];
int top;
} stack;

bool isEmpty(stack  tony_stack)
{
	return tony_stack.top == 0;
}

bool isFull(stack tony_stack)
{
	return tony_stack.top >= 300;
}

bool initialize(stack * tony_stack)
{
	for (int i = 0; i < 300; i++) (*tony_stack).arr[i] = 0;
	(*tony_stack).top = 0;
	return true;
}

bool push(stack &tony_stack, int pushInt)
{
	if (!isFull(tony_stack))
	{
		tony_stack.arr[tony_stack.top] = pushInt;
		tony_stack.top++;
		return true;
	}
	else return false;
}

int pop(stack &tony_stack)
{
	if (!isEmpty(tony_stack))
	{
		tony_stack.top--;
		return tony_stack.arr[tony_stack.top];
	}
	else return false;
}

int main()
{
	stack tony_stack;
	tony_stack.top = 0;
	char tem[100];
	initialize(&tony_stack);
	//fstream fcin;
	//fcin.open("test.txt",ios::in);
	while (cin >> tem)
	{
		if (strcmp(tem,"+")==0)
		{
			int a = pop(tony_stack);
			int b = pop(tony_stack);
			push(tony_stack, a + b);
		}
		else if (strcmp(tem, "-")==0)
		{
		
			int a = pop(tony_stack);
			int b = pop(tony_stack);
			push(tony_stack, b - a );
		}
		else if (strcmp(tem, "*")==0)
		{
			int a = pop(tony_stack);
			int b = pop(tony_stack);
			push(tony_stack, b*a);

		}
		
		else
		{
			int pushInt = atoi(tem);
			push(tony_stack, pushInt);
		}
	}
	cout << tony_stack.arr[0]<<endl;
}

Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	
	if(x < b - a)
	{
		cout << "dangerous" << endl;
	}
	else if(a < b)
	{
		cout << "safe" << endl;
	}
	else
	{
		cout << "delicious" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 30
#define INF (1<<29)
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
 
int H,W,sx,sy,gx,gy,cnt;
char field[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
 
struct State{
    int x,y,S;
    State(){}
    State(int x,int y,int S) : x(x),y(y),S(S) {}
};
 
bool isValid(int x,int y){
    if(x < 0 || x >= W || y < 0 || y >= H) return false;
    if(field[y][x] == '#') return false;
    return true;
}
 
int solve(){
    queue<State> Q;
    Q.push(State(sx,sy,0));
    map<piii,int> dist;
    dist[piii(pii(sx,sy),0)] = 0;
 
    while(!Q.empty()){
	State now = Q.front(); Q.pop();
	int x = now.x, y = now.y, S = now.S;
	piii pp = piii(pii(x,y),S);
     
	if(x == gx && y == gy){
	    return dist[pp];
	}
	for(int i = 0 ; i < 4 ; i++){
	    int nx = x + dx[i], ny = y + dy[i];
	    if(!isValid(nx,ny)) continue;
	    piii cp = piii(pii(nx,ny),S);
 
	    if(islower(field[ny][nx])){
		int p = field[ny][nx]-'a';
		int nS = S;
		if((S >> p) & 1){
		    nS -= (1<<p);
		}else{
		    nS |= (1<<p);
		}
		cp.second = nS;
		if(dist[pp] + 1 < dist[cp] || dist[cp] == 0){
		    dist[cp] = dist[pp] + 1;
		    Q.push(State(nx,ny,nS));
		}
	    }else if(isupper(field[ny][nx])){
		int p = field[ny][nx]-'A';
		if((S >> p) & 1){
		    if(dist[pp] + 1 < dist[cp] || dist[cp] == 0){
			dist[cp] = dist[pp] + 1;
			Q.push(State(nx,ny,S));
		    }
		}
	    }else{
		if(dist[pp] + 1 < dist[cp] || dist[cp] == 0){
		    dist[cp] = dist[pp] + 1;
		    Q.push(State(nx,ny,S));
		}
	    } 
	}
    }
    return -1;
}
 
int main(){
    while(cin >> W >> H,(W | H)){
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> field[i][j];
		if(field[i][j] == '@'){
		    field[i][j] = '.';
		    sx = j; sy = i;
		}else if(field[i][j] == '<'){
		    gx = j; gy = i;
		    field[i][j] = '.';
		}
	    }     
	}
	cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 15516
import math
N,M=map(int,input().split())

if N>=2:
    n=math.factorial(N)/math.factorial(N-2)/2
else:
    n=0
## print(n)

if M>=2:
    m=math.factorial(M)/math.factorial(M-2)/2
else:
    m=0
## print(m)
print(int(m+n))

Measured memory_bytes: 3060
A,B=map(int,input().split())

keta=0
b=B
while b:
  keta+=1
  b>>=1
  
d=[0]*keta

for i in range(keta):
  # 繰り返す単位　この中にpaircnt//2個の1が含まれる
  paircnt=2**(i+1)
  # ペアの数
  Bpair=(B+1)//paircnt
  # ペアに含まれる1の数
  BpairBit=Bpair*(paircnt//2)
  
  rest=(B+1)%paircnt
  if rest>paircnt//2:
    BpairBit+=(rest-paircnt//2)
    
  Apair=A//paircnt
  ApairBit=Apair*(paircnt//2)
  restA=A%paircnt
  if restA>paircnt//2:
    ApairBit+=(restA-paircnt//2)
    
  bitCnt=BpairBit-ApairBit
  d[i]=bitCnt%2
  
ans=0
for i in range(len(d)):
  ans+=d[i]*(2**i)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, i;
    cin >> n >> i;
    int ans = n-i+1;
    cout << ans << endl;

}

Measured memory_bytes: 3524
x=int(input())
list=list(map(int,input().split()))

if x==1:
    print(0)
else:
    a=sorted(list)
    b=a[0]
    c=a[-1]
    if c-b==1:
        print(1)
    elif b==0:
        if c%2!=0:
            print(c//2+1)
        else:
            print(c//2)
    elif (c-b)%2!=0:
        print((c-b)//2+1)
    else:
        print((c-b)//2)


Measured memory_bytes: 5620