akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
board=list(input() for _ in range(h))
num=0
cutting=[[0 for _1 in range(w)] for _2 in range(h)]
for row in range(h):
  if board[row].count("#")==0:
    continue
  num+=1
  col=0
  while board[row][col]==".":
    cutting[row][col]=num
    col+=1
  cutting[row][col]=num
  col+=1
  while col < w:
    if board[row][col]=="#":
      num+=1
    cutting[row][col]=num
    col+=1
    
for row in range(1,h):
  if cutting[row][0]==0:
    cutting[row]=cutting[row-1]
  if cutting[h-1-row][0]==0:
    cutting[h-1-row]=cutting[h-row]

for row in range(h):
  print(*cutting[row])

Measured memory_bytes: 7584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll s, t, d;
    cin >> s >> t >> d;
    vector<ll> v(d);
    for (auto &&i : v) scanf("%lld", &i);
    ll w = accumulate(v.begin(),v.end(), 0LL);
    if(w >= 0){
        for (int i = 0; i < d; ++i) {
            s += v[i];
            if(s <= t){
                cout << i+1 << "\n";
                return 0;
            }
        }
        puts("-1");
        return 0;
    }
    w = -w;
    ll ans = INF<ll>;
    for (ll i = 0; i < d; ++i) {
        if(i) s += v[i-1];
        if(s <= t) ans = min(ans, i);
        else ans = min(ans, i+(s-t+w-1)/w*d);
    }
    if(ans == INF<ll>) return 1;
    cout << ans << "\n";
    return 0;
}


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

int main(void){
  int a, b, c;

  cin >> a >> b >> c;

  for(int i = 1; i <= b; i ++){
    if(a*i % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

public class Hello{
    public static void Main(){
        String[] str;
        int x = 1;
        int y = 1;
        while(x != 0 || y != 0){
            str = Console.ReadLine().Split(' ');
            x = int.Parse(str[0]);
            y = int.Parse(str[1]);
            if(x != 0 || y != 0){
                if(x < y){
                  Console.WriteLine(x + " " + y);
            }
             else{
                 Console.WriteLine(y + " " + x);
                }
            }
        }
    }
}



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

int n;
LL a[100010], b[100010], ans = 0, k = 0, c = 0;
int main(){
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i] >> b[i];
    for(int i=n-1; i>=0; i--){
        a[i] += c;
        k = (a[i] + b[i] - 1)/b[i];
        ans += k*b[i]-a[i];
        c += k*b[i]-a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)   
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720000000000ll;
const int nax = 200006;
vector<int> all[nax];
int n;
int optimum(vector<pii> v)
 {
  loop(i,1,n+1)
   all[i].clear();
  for(auto p : v)
     all[p.ff].pb(p.ss);
  multiset<int> s;
  int sz = 0,ans = 0;
  loop(i,1,n+1)
   {
    for(int x: all[i])
      {
         sz++;
         ans += x;
         s.insert(x);
      }
    while(sz>i)
       {
        sz--;
        ans -= *s.begin();
        s.erase(s.begin());
       }
   }
  return ans;
 }
void solve()
 {
  vector<pii> v1,v2;
  cin>>n;
  int ans = 0;
  loop(i,0,n)
   {
    int l,r,k;
    cin>>k>>l>>r;
    if(l>r)
        v1.pb({k,l-r});
    else
        v2.pb({n-k,r-l});
    ans += min(l,r);
   }
  ans += optimum(v1);
  ans += optimum(v2);
  cout<<ans<<END;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
 /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   freopen("error.txt","w",stderr);
  #endif*/
   int t;
   cin>>t;
   while(t--)
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;

  return 0;
} 

Measured memory_bytes: 21508
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long a, b, c, k; cin >> a >> b >> c >> k;

    while(b <= a && k--) b *= 2;
    while(c <= b && k--) c *= 2;

    if(a < b && b < c) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	char c;
	cin >> c;
	cout << (isupper(c) ? 'A' : 'a') << '\n';
}


Measured memory_bytes: 3576
n = int(input())
a = list(map(int, input().split()))
aset = set(a)

if len(aset) == 1:
  if all(i == 0 for i in a):
    print("Yes")
  else:
    print("No")
elif len(aset) == 2:
  a1, a2 = sorted(aset)
  if a1 == 0:
    if a.count(a1) * 3 == n:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(aset) == 3:
  a1, a2, a3 = aset
  if a.count(a1) == a.count(a2) == a.count(a3):
    if a1 ^ a2 == a3:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (0 <= x-r && 0 <= y-r){
        if (x+r <= W && y+r <= H){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

int ans[200005];
set<pair<ll,int> > S;
int main(){
    int n,q; cin >> n >> q;
    vector<pair<ll,pair<ll,ll> > > v;
    for(int i=0;i<n;i++){
        ll s,t,x; cin >> s >> t >> x;
        v.push_back(make_pair(x,make_pair(s-x,t-x-1)));
    }
    for(int i=0;i<q;i++){
        ll d; cin >> d;
        S.insert(make_pair(d,i));
        ans[i]=-1;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        if(S.empty())continue;
        ll l=v[i].second.first;
        ll r=v[i].second.second;
        auto iter=S.lower_bound(make_pair(l,-1));
        while(S.size()&&iter!=S.end()&&(*iter).first<=r){
            ans[(*iter).second]=v[i].first;
            iter=S.erase(iter);
        }
    }
    for(int i=0;i<q;i++){
        cout << ans[i] << endl;
    }
}

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

int main() {
    string S;
    cin >> S;
    int count = 700;
    if(S[0] == 'o') count += 100;
    if(S[1] == 'o') count += 100;
    if(S[2] == 'o') count += 100;

    cout << count << endl;
}

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

typedef long long ll;
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21){
        cout << "bust"<<endl;
    }
    else{
        cout << "win"<<endl;
    }
    return 0;
}

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

using namespace std;

void swap(int* a, int* b);
int solve(vector<int> &v, int n, int e, int o);

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> e_count(100000, 0), o_count(100000, 0);

	for (int i = 0; i < n; i++) { //偶数列と奇数列での個数数えてる
		cin >> v[i];
		if (i % 2 == 0) {
			e_count[v[i] - 1] ++;
		}
		else {
			o_count[v[i] - 1]++;
		}

	}

	int e_counter1 = 0, o_counter1 = 0, e_counter2 = 0, o_counter2 = 0;
	int e_max1 = -1, e_max2 = -1, o_max1 = -1, o_max2 = -1;

	for (int i = 0; i < 100000; i++) {

		if (e_counter1 < e_count[i]) {
			swap(&e_counter1, &e_counter2);
			e_counter1 = e_count[i];
			swap(&e_max1, &e_max2);
			e_max1 = i + 1;

		}
		else if (e_counter2 < e_count[i]) {
			e_counter2 = e_count[i];
			e_max2 = i + 1;
		}


		if (o_counter1 < o_count[i]) {
			swap(&o_counter1, &o_counter2);
			o_counter1 = o_count[i];
			swap(&o_max1, &o_max2);
			o_max1 = i + 1;

		}
		else if (o_counter2 < o_count[i]) {
			o_counter2 = o_count[i];
			o_max2 = i + 1;
		}
		
	}

	//cout <<"o:"<<o_max1 << " " << o_max2 << endl <<"e:"<< e_max1 << " " << e_max2 << endl;

	

	if (o_max1 != e_max1) {
		cout << solve(v, n, e_max1, o_max1);
	}
	else {
		cout << min(solve(v, n, e_max1, o_max2), solve(v, n, e_max2, o_max1));
	}


	return 0;
}

void swap(int* a, int* b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int solve(vector<int>& v, int n, int e, int o) {
	int ans = 0;
	for (int i = 0; i < n; i++) {

		if (i % 2 == 0) {
			if (v[i] != e) {
				ans++;
				//cout <<i<<" "<< v[i] << endl;
			}
		}
		else if (v[i] != o) {
			ans++;
			//cout << i << " " << v[i] << endl;
		}

	}
	return ans;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

string red(string s) {
	stack<char> st;
	for(auto i: s)
		if(i=='(')
			st.push('(');
		else if(i==')' && (st.size()==0 || st.top()==')'))
			st.push(')');
		else
			st.pop();
	string ans="";
	while(st.size())
		ans+=st.top(),st.pop();
	reverse(all(ans));
	return ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll k,x;cin>>k>>x;
	puts(k*500>=x?"Yes":"No");

}


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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A, B = map(int, input().split())
for i in range(1, 1100):
    a = i * 8 // 100
    b = i * 10 // 100
    if a == A and b == B:
        print(i)
        sys.exit(0)
print(-1)


Measured memory_bytes: 6352
#include <stdio.h>
#include <stdlib.h>
#define int long long

int *pro(int N, int *p, int *q){
	int i;
	int *ans = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		ans[i] = q[p[i]];
	}
	return ans;
}

int *power(int N, int *p, int K){
	if(K == 1){
		return p;
	}
	else if(K % 2 == 0){
		return power(N, pro(N, p, p), K / 2);
	}
	else{
		return pro(N, p, power(N, p, K - 1));
	}
}

signed main(){
	int N, M, K, a, tmp, i;
	scanf("%lld", &N);
	int *x = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &x[i]);
	}
	int *p = (int *)malloc(sizeof(int) * (N - 1));
	for(i = 0; i < N - 1; i++){
		p[i] = i;
	}
	scanf("%lld%lld", &M, &K);
	for(i = 0; i < M; i++){
		scanf("%lld", &a);
		tmp = p[a - 2];
		p[a - 2] = p[a - 1];
		p[a - 1] = tmp;
	}
	p = power(N - 1, p, K);
	int *ans = (int *)malloc(sizeof(int) * N);
	ans[0] = x[0];
	for(i = 1; i < N; i++){
		ans[i] = ans[i - 1] + x[p[i - 1] + 1] - x[p[i - 1]];
	}
	for(i = 0; i < N; i++){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 67840
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    double T,X;
    cin >> T >> X;
    cout << T/X << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main()
{
    string s;
    cin>>s;
    int no=0, ans =0;
    for(int i=0;i<s.length();i++) {
        if(s[i]=='R') no++;
        else {
            ans = max(ans, no);
            no=0;
        }
    }
    ans = max(ans, no);
    cout<<ans<<"\n";
}

Measured memory_bytes: 3620
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')

for i in range(N-1):
    for j in range(i+1, N):
        k = 2*j-i
        if k <= N-1 and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9180
import sys

def resolve():
    N = int(input())
    S = input()
    res = 0
    for i in range(1, N-1):
        cnt = 0
        left = S[:i]
        right = S[i:]
        counted = []
        for s in left:
            if s in right and s not in counted:
                counted.append(s)
                cnt += 1

        res = max(cnt, res)
    print(res)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#pragma GCC optimization ("O3,unroll-loops")
#pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)
#define IN(a) for (auto &it : a) cin >> it

void solve() {
    ints(n);
    vector<int> v(n); IN(v);
    int64_t sum = accumulate(v.begin(), v.end(), 0LL);
    map<int, int> fq;
    for (int i = 0; i < n; i++) fq[v[i]]++;
    
    ints(q);
    while (q--) {
        ints(b, c);
        int x = fq[b];
        fq[b] = 0;
        fq[c] += x;
        sum += (c - b) * x;
        cout << sum << '\n';
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 8040
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n, m;
int a[MAXN];

void read()
{
	cin >> n >> m;
}

int cnt[MAXN];
bool possible[MAXN];

void solve()
{
	possible[1] = 1;
	for(int i = 1; i <= n; i++) cnt[i] = 1;

	while(m--)
	{
		int a, b;
		cin >> a >> b;

		cnt[a]--;
		cnt[b]++;

		if(possible[a]) possible[b] = 1;
		if(possible[a] && cnt[a] == 0) possible[a] = 0;
	}

	int answer = 0;
	for(int i = 1; i <= n; i++)
		answer += possible[i];

	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int sumxor = array[0];
        for (int i = 1; i < n; i++) {
            sumxor ^= array[i];
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(sumxor ^ array[i]);
            
            if (i != n-1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 61376
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

num = a[0]

target = a[0]/2

diff = 1000000000000

for i in a:
    if i == num:
        continue
    dif = abs(target-i)
    if dif < diff:
        diff = dif
        num_2 = i

print(num, num_2)

Measured memory_bytes: 14428
def task(n, a, b, c, s):
    choices = []

    for i in range(0, n):
        seta = 'A' in s[i]
        setb = 'B' in s[i]
        setc = 'C' in s[i]

        picka = seta
        pickb = setb
        pickc = setc

        if seta and a - 1 < 0:
            pickb = False
            pickc = False

        if setb and b - 1 < 0:
            picka = False
            pickc = False

        if setc and c - 1 < 0:
            picka = False
            pickb = False

        nextseta = True
        nextsetb = True
        nextsetc = True

        if i < n - 1:
            nextseta = 'A' in s[i + 1]
            nextsetb = 'B' in s[i + 1]
            nextsetc = 'C' in s[i + 1]

        if picka and nextseta:
            pickb = False
            pickc = False
        elif pickb and nextsetb:
            picka = False
            pickc = False
        elif pickc and nextsetc:
            picka = False
            pickb = False

        if seta and picka:
            choices.append('A')
            a += 1
            if setb:
                b -= 1
            if setc:
                c -= 1
        elif setb and pickb:
            choices.append('B')
            b += 1
            if seta:
                a -= 1
            if setc:
                c -= 1
        elif setc and pickc:
            choices.append('C')
            c += 1
            if seta:
                a -= 1
            if setb:
                b -= 1
        else:
            print('No')
            return

    print('Yes')
    for choice in choices:
        print(choice)


n, a, b, c = map(int, input().split())
s = []
for i in range(0, n):
    s.append(input())

task(n, a, b, c, s)


Measured memory_bytes: 17144
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,t,u;
  int a, b;
  cin >> s;
  //cin >> s >> t >> u;

  if(s[0]==s[1]&&s[1]==s[2]) cout << "No" << endl; 
  else cout << "Yes" << endl; 
  
}

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

using namespace std;

bool is_right(char c) {
    static char right[] = "yuiophjklnm";
    for (int i=0; right[i]; i++) {
        if (c == right[i]) {
            return true;
        }
    }
    return false;
}

int main() {
    bool was_right;
    string input;
    while (true) {
        int count = 0;
        cin >> input;
        if (input == "#") {
            break;
        }
        for (int i=0; i<(int)input.length(); i++) {
            if (is_right(input[i])) {
                if (i>0 && !was_right) {
                    count++;
                }
                was_right = true;
            }
            else {
                if (i>0 && was_right) {
                    count++;
                }
                was_right = false;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
/*
  AUTHOR:SOURABH
  CREATED:19:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll n,i,ans=0;
    cin>>n;
    multiset<ll> b;
    multiset<ll>::iterator it;
    vll a(n);
    fn(i,n)
    {
        cin>>a[i];
        if(b.empty())
            ans++;
        else
        {
            it=b.begin();
            if(*it>=a[i])
                ans++;
        }
        b.insert(a[i]);
    }
    cout<<ans;
}









Measured memory_bytes: 11264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main
{
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int N=Integer.parseInt(br.readLine());
    int ans=0;
    if(N<100){
      ans=Math.min(N,9);
    }else if (N<10000){
      ans=9+Math.min(N-99,900);
    }else{
      ans=9+900+Math.min(N-9999,90000);
    }
    System.out.println(ans);
  }
}





Measured memory_bytes: 21204
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int A, B, C;
        cin >> A >> B >> C;

        if (A > C)
        {
                cout << "NO" << endl;
        } else if(A+B<C){
                cout << "NO" << endl;
        } else{
                cout << "YES" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	REP(tea, n) {
		int a, b, c;
		cin >> a >> b >> c;
		int ans = 0;
		while (a != 1000) {
			c++;
			ans++;
			int datum = 0;
			if (a % 3 == 0) {
				datum = 20;
			}
			else if (b % 2 == 1) {
				datum = 20;
			}
			else datum = 19;
			if (datum + 1 == c) {
				b++;
				c = 1;
				if (b == 11) {
					a++;
					b = 1;
				}
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3076
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int a[200010];
inline int read()
{
	char c=getchar();int x=0,flag=1;
	while(!isdigit(c)) flag*=c=='-'?-1:1,c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
int main()
{
	int n;
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++) a[i]-=i;
	sort(a+1,a+n+1);
	ll tmp=a[(n+1)/2],ans=0;
	for(int i=1;i<=n;i++) ans+=abs(tmp-a[i]);
	cout<<ans;
	return 0;
}

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

int main() {
	int m,f,r;
	while(true){
		cin>>m>>f>>r;
		if(m == -1 && f == -1 && r == -1)break;
		else if(m == -1 || f == -1){
			cout<<"F"<<endl;
		}else if(m+f >= 80){
			cout<<"A"<<endl;
		}else if(m+f >= 65 && m+f < 80){
			cout<<"B"<<endl;
		}else if(m+f >= 50 && m+f < 65){
			cout<<"C"<<endl;
		}else if(r >= 50){
			cout<<"C"<<endl;
		}else if(m+f >= 30 && m+f < 50){
			cout<<"D"<<endl;
		}else if(m+f < 30){
			cout<<"F"<<endl;
		}
	}
}

Measured memory_bytes: 3096
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.HashMap;

public class Main {
	public static ArrayList<HashMap<Integer, Integer>> path = new ArrayList<HashMap<Integer, Integer>>();
	public static void bitDP(int v) {
		int[][] dist = new int[(int)Math.pow(2, v)][v];
		for(int i=0; i<dist.length; i++) {
			Arrays.fill(dist[i], Integer.MAX_VALUE);
		}
		dist[1][0] = 0;
		// O(2^v * v^2)
		for(int i=1; i<(int)Math.pow(2, v); i++) {
			for(int j=0; j<v; j++) {
				if((i & (1<<j)) != 0) {
					for(int k=0; k<v; k++) {
						if((i & (1<<k)) != 0 && j != k && path.get(k).containsKey(j) && dist[i-(1<<j)][k] != Integer.MAX_VALUE) {
							dist[i][j] = Math.min(dist[i][j], dist[i-(1<<j)][k] + path.get(k).get(j));
						}
					}
				}
			}
		}
		int minDist = Integer.MAX_VALUE;
		for(int i=1; i<v; i++) {
			if(path.get(i).containsKey(0) && dist[dist.length-1][i] != Integer.MAX_VALUE) {
				minDist = Math.min(minDist, dist[dist.length-1][i] + path.get(i).get(0));
			}
		}
		if(minDist == Integer.MAX_VALUE) minDist = -1;
		System.out.println(minDist);
	}

	public static void main(String[] args) {
		FS r = new FS();
		int v = r.nextInt();
		int e = r.nextInt();
		for(int i=0; i<v; i++) {
			path.add(new HashMap<Integer, Integer>());
		}
		for(int i=0; i<e; i++) {
			int s = r.nextInt();
			int t = r.nextInt();
			int d = r.nextInt();
			path.get(s).put(t, d);
		}
		bitDP(v);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

struct EdgeF{
  int to, cap, rev;
  bool del;
  EdgeF(int to_=0, int cap_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), rev(rev_), del(false){}
};
using GraphF = vector<vector<EdgeF>>;

void add_edge(GraphF& G, int from, int to, int cap){
  G[from].emplace_back(to, cap, G[to].size());
  G[to].emplace_back(from, cap, G[from].size()-1);
}
int max_flow(GraphF& G, int s, int t, int ff = INF){
  if(s == t) return ff;
  
  const int V = G.size();
  vector<bool> used(V);
 
  function<int(int,int,int)> dfs = [&](int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
	REP(i,SZ(G[v])){
	  auto& e =  G[v][i];
      if(!used[e.to] && e.cap > 0 && !e.del){
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  };
  if(ff < INF){
    fill(used.begin(), used.end(), false);
    return dfs(s, t, ff);
  }
 
  int flow = 0;
  while(true){
    fill(used.begin(), used.end(), false);
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}


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

  int V, E, Q;
  cin >> V >> E >> Q;
  GraphF G(V);
  REP(i,E){
	int f, t;
	cin >> f >> t;
	--f;
	--t;
	add_edge(G, f, t, 1);
  }

  int f = max_flow(G, 0, V-1);
  REP(q,Q){
	int m, a, b;
	cin >> m >> a >> b;
	--a, --b;
	if(m == 1){
	  add_edge(G, a, b, 1);
	  f += max_flow(G, 0, V-1);
	}
	else{
	  for(auto& e: G[a]){
		if(e.to == b && !e.del){
		  if(e.cap == 0 || e.cap == 2){
			int orig = e.cap;
			e.cap = G[b][e.rev].cap = 0;
			e.del = G[b][e.rev].del = true;
			if(orig == 0){ // 0 -> a -> b -> V-1
			  if(max_flow(G, a, b, 1) == 0){
				--f;
				max_flow(G, a, 0, 1);
				max_flow(G, V-1, b, 1);
			  }
			}
			else{ // 0 -> b -> a -> V-1
			  if(max_flow(G, b, a, 1) == 0){
				--f;
				max_flow(G, b, 0, 1);
				max_flow(G, V-1, a, 1);
			  }
			}
		  }
		  e.cap = G[b][e.rev].cap = 0;
		  e.del = G[b][e.rev].del = true;
		  break;
		}
	  }
	}
	cout << f << endl;
  }

  return 0;
}

Measured memory_bytes: 3932
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

bool f(ll N, vector<int> &v, string &s) {
  for(ll i=1; i+1<N; i++) {
    if(v[i]==1) {
      if(s[i]=='o') {
	v[i+1] = v[i-1];
      } else {
	v[i+1] = 1-v[i-1];
      }
    } else {
      if(s[i]=='o') {
	v[i+1] = 1-v[i-1];
      } else
	v[i+1] = v[i-1];
    }
  }
  bool x, y;
  if((v[0]==1 and s[0]=='o') or (v[0]==0 and s[0]=='x')) x = v[N-1] == v[1];
  else x = v[N-1] != v[1];
  if((v[N-1]==1 and s[N-1]=='o') or (v[N-1]==0 and s[N-1]=='x')) y = v[N-2] == v[0];
  else y = v[N-2]!=v[0];
  return x and y;
}

void solve(long long N, std::string s){
  vector<int> v(N);
  for(int i=0; i<2; i++) {
    for(int j=0; j<2; j++) {
      v[0] = i; v[1] = j;
      if(f(N, v, s)) {
	for(auto x:v) {
	  if(x)
	    std::cout << 'S';
	  else
	    std::cout << 'W';
	}
	std::cout << std::endl;
	return ;
      }
    }
  }
  std::cout << -1 << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string s;
  std::cin >> s;
  solve(N, s);
  return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ba = []
for i in range(n):
    a, b = map(int, input().split())
    ba.append([b, a])
ba.sort()
now = 0
out = 0
for i, j in ba:
    now += j
    if now > i:
        out = 1
        break
if out:
    print("No")
else:
    print("Yes")

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    ll x, y;
    cin >> x >> y;
    if (x%y == 0) cout << -1 << endl;
    else cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    
    map<string, int> S;
   // int max_v = S.rbegin()->second;
    int max_v = 0;
    for(int i = 0; i < n; i++){
        string t;
        cin >> t;
        S[t]++;
        if(max_v < S[t]){
            max_v = S[t];
        }
    }
    for(auto iter = S.begin(); iter != S.end(); iter++){
        if(iter->second == max_v){
            cout << iter->first << endl;
        }
    }
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push
using namespace std;
typedef pair<int,int> pi;
queue <pi> q;
int n,m,dis[1005][1005],mx;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char s[1005];
int main(){
    cin >> n >> m;
    memset(dis,-1,sizeof(dis));
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) dis[i][j]=0;
    for (int i=1;i<=n;i++){
        scanf("%s",s+1);
        for (int j=1;j<=m;j++) if (s[j]=='#') dis[i][j]=1,q.pb((pi){i,j});
    }
    while (!q.empty()){
        pi tmp=q.front(); q.pop();
        int x=tmp.F,y=tmp.S;
        for (int o=0;o<4;o++){
            int xx=x+dx[o],yy=y+dy[o];
            if (dis[xx][yy]==0){
                dis[xx][yy]=dis[x][y]+1;
                q.pb((pi){xx,yy});
            }
        }
    }
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) mx=max(mx,dis[i][j]);
    cout << mx-1 << endl;
    return 0;
}


Measured memory_bytes: 12432
n = int(input())
p_arr = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if p_arr[i-1] < p_arr[i] and p_arr[i] < p_arr[i+1]:
        cnt += 1
    if p_arr[i+1] < p_arr[i] and p_arr[i] < p_arr[i-1]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
s=split(readline(),"")
# print(s)

function count_rain()
    num_list=[]
    count=0

    for i in 1:3
        if s[i]=="R"
            count+=1
        else
            push!(num_list, count)
            count=0
        end
    end
	push!(num_list, count)
    return(findmax(num_list)[1])
end

print(count_rain())

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, k;
    cin >> n >> k;
    int f[n] = {};
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            f[a]++;
        }
    }
    int ans = 0;
    rep(i,n)if(f[i] == 0)ans++;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr>void dump(Itr begin, Itr end) {
  for(;begin != end; ++begin) clog << ' ' << *begin;
  clog << LF;
}

signed main()
{
  string to = "keyence";
  string s;

  cin >> s;
  for (int a = 0; a < LEN(s); ++a) {
    for(int b = a; b < LEN(s); ++b) {

      string tmp = s;

      for (int j = a; j < b; ++j) tmp[j] = '?';
      string hoge = "";
      for (int j = 0; j < LEN(s); ++j) {
        if (tmp[j] != '?') hoge += tmp[j];
      }
      // printf("%d~%d: %s\n", a, b, hoge.c_str());
      if (hoge == to) {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 314;

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

    typedef pair<int, int> P;
    priority_queue<P, vector<P>, std::greater<P>> q;

    vector<int> d(k, INF);
    for (int i = 1; i <= min(9, k - 1); i++) {
        d[i % k] = i % k;
        q.push({d[i % k], i % k});
    }

    while (not q.empty()) {
        const P tmp = q.top();
        const int c = tmp.first;
        const int v = tmp.second;
        q.pop();

        if (c > d[v]) {
            continue;
        }

        for (int i = 0; i <= 9; i++) {
            const int u = (10 * v + i) % k;
            if (d[v] + i < d[u]) {
                d[u] = d[v] + i;
                //cerr << "update " << v << " " << u << " " << d[u] << endl;
                q.push({d[u], u});
            }
        }
    }

    cout << d[0] << endl;

    return 0;
}


Measured memory_bytes: 2804
Scanf.scanf "%d %d %d" (fun h w n ->
    let f a b = a lsl 30 + b in
    let module M = Map.Make (struct type t = int let compare = compare end) in

    let hist = Array.make 10 0 in
    hist.(0) <- (h - 2) * (w - 2);

    let rec loop i map =
        if i = n then hist else
            let map = Scanf.scanf " %d %d" (fun a b ->
                List.fold_left (fun map (vx, vy) ->
                    let x = b + vx in
                    let y = a + vy in
                    if x > 1 && x < w && y > 1 && y < h then (
                        let key = f x y in
                        let v = try M.find key map with _ -> 0 in
                        hist.(v) <- hist.(v) - 1;
                        hist.(v + 1) <- hist.(v + 1) + 1;
                        M.add key (v + 1) map
                    ) else map
                ) map [ -1, -1; -1, 0; -1, 1; 0, -1; 0, 0; 0, 1; 1, -1; 1, 0; 1, 1 ]
            ) in
            loop (i + 1) map
    in
    Array.iter (Printf.printf "%d\n") @@ loop 0 M.empty
)

Measured memory_bytes: 70680
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int p, q, r, mx;
  	scanf("%d%d%d", &p, &q, &r);
  	if(p>q)
    {
      if(p>r)
        mx=p;
      else
        mx=r;
    }
  	else
    {
      if(q>r)
        mx=q;
      else
        mx=r;
    }
  	printf("%d\n", p+q+r-mx);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int c2i(char c)
{
	switch (c)
	{
	case '0':
		return 0;
		break;
	case '1':
		return 1;
		break;
	case '2':
		return 2;
		break;
	case '3':
		return 3;
		break;
	case '4':
		return 4;
		break;
	case '5':
		return 5;
		break;
	case '6':
		return 6;
		break;
	case '7':
		return 7;
		break;
	case '8':
		return 8;
		break;
	case '9':
		return 9;
		break;
	default:
		break;
	}
}
int main() {
	char nums[4];
	cin >> nums;
	if (c2i(nums[0]) + c2i(nums[1]) + c2i(nums[2]) + c2i(nums[3]) == 7)
	{
		printf("%c+%c+%c+%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) + c2i(nums[1]) + c2i(nums[2]) - c2i(nums[3]) == 7)
	{
		printf("%c+%c+%c-%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) + c2i(nums[1]) - c2i(nums[2]) + c2i(nums[3]) == 7)
	{
		printf("%c+%c-%c+%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) + c2i(nums[1]) - c2i(nums[2]) - c2i(nums[3]) == 7)
	{
		printf("%c+%c-%c-%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) - c2i(nums[1]) + c2i(nums[2]) + c2i(nums[3]) == 7)
	{
		printf("%c-%c+%c+%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) - c2i(nums[1]) + c2i(nums[2]) - c2i(nums[3]) == 7)
	{
		printf("%c-%c+%c-%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) - c2i(nums[1]) - c2i(nums[2]) + c2i(nums[3]) == 7)
	{
		printf("%c-%c-%c+%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}

	if (c2i(nums[0]) - c2i(nums[1]) - c2i(nums[2]) - c2i(nums[3]) == 7)
	{
		printf("%c-%c-%c-%c=7", nums[0], nums[1], nums[2], nums[3]);
		return 0;
	}


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int H,W;
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			H=scan.nextInt();
			W=scan.nextInt();
			if(H == 0 && W== 0) {
				break;
			}

			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if((i+j)%2 == 0) {
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}

				}
				System.out.println("");
			}
			System.out.println("");
		}

	}
}

Measured memory_bytes: 34368
n, c, k = map(int, input().split())
l = [int(input()) for i in range(n)]
l.sort()
count = 0
first = l[0]
people = 1
count = 1
for i in range(1, n):
    if people < c and l[i] - first <= k:
        people += 1
    else:
        first = l[i]
        people = 1
        count += 1
print(count)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    ci(s);
  ll k;
    ci(k);
  vll A(0);
  ll n=s.sz;
  ll count=1;
  ll ans=0;
  if(n==1){
    co(k/2)
  }
  
  else if(k<=10000000){
    st t=s;
    FOR(i,1,k){
      t+=s;
    }
    FOR(i,1,n*k){
      if(t[i]==t[i-1]){
        ans++;
        i++;
      }
    }
    co(ans)
  }
  
  else{    
  FOR(i,1,n){
    if(s[i-1]==s[i]){
      count++;
    }
    else{
      A.push_back(count);
      count=1;
    }
  }
  if(count!=1){
    A.push_back(count);
  }
  
  ll a=A.sz;
  
  FOR(i,1,a-1){
    ans+=A[i]/2*k;
  }
  
  if(s[0]==s[n-1]){
    if(a!=1){
    ans+=(A[0]+A[a-1])/2*(k-1);
    ans+=A[0]/2;
    ans+=A[a-1]/2;
    }
    else{
    ans+=k/2*A[0];
      if(k%2==1){
        ans+=A[0]/2;
      }
    }
  }
  else{
    ans+=A[0]/2*k;
    ans+=A[a-1]/2*k;
  }
  
  co(ans)
  }
}

Measured memory_bytes: 1024
# 貰うDP
N,K=map(int,input().split())
h=[int(_) for _ in input().split()]

INF=10**9
dp=[0]*(N)

for n in range(1,N):
    dp[n]=min([dp[k] + abs(h[n] - h[k]) for k in range(max(0,n-K), n)])
print(dp[N-1])

Measured memory_bytes: 52448
h,w=list(map(int,input().split()))
s=[input() for _ in range(h)]

dp=[[1000]*(w+1) for _ in range(h+1)]

#(1,1)が白か黒か確かめ、黒の場合は+1
if s[0][0]=='.':
    dp[0][0]=0
else:
    dp[0][0]=1

for i in range(h):
    for j in range(w):
        if i-1>=0:
#h（縦）に対して、白⇒黒の場合はdp[i][j]は+1、そうでなければ同じ。
            dp[i][j]=dp[i-1][j]+(1 if s[i-1][j]=='.' and s[i][j]=='#' else 0)
        if j-1>=0:
#w（横）に対して、白⇒黒の場合はdp[i][j]は+1、そうでなければ同じ。
            dp[i][j]=min(dp[i][j],dp[i][j-1]+(1 if s[i][j-1]=='.' and s[i][j]=='#' else 0))

print(dp[h-1][w-1])

Measured memory_bytes: 42864
#include<iostream>
#include<algorithm>
#include<array>
using namespace std;
const int N=3005;
int n,m;
array<int,2> a[N];
int b[N*2];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i][0]>>a[i][1];
	sort(a,a+n);
	for(int i=0;i<n;i++){
		for(int j=m+a[i][0]-1;j>=a[i][0];j--){
			b[j]=max(b[j],b[j-a[i][0]]+a[i][1]);
		}
	}
	int ans=0;
	for(int i=0;i<=6000;i++) ans=max(ans,b[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import copy
A,B=map(int,raw_input().split())
h=100
w=100
t=list("#"*(w/2)+"."*(w/2))
l=[ copy.deepcopy(t) for i in range(h)]

A-=1
B-=1

flag=0
# Shiro
if A>0:
	for x in range(1,h,2):
		if flag==1: break
		for y in range(1,w/2-1,2):
			l[x][y]="."
			A-=1
			if A==0:
				flag=1
				break

	
flag=0
# Kuro
if B>0:
	for x in range(1,h,2):
		if flag==1: break
		for y in range(w/2+1,w-1,2):
			l[x][y]="#"
			B-=1
			if B==0:
				flag=1
				break

print "100 100"
for i in l:
	print "".join(i)
	


Measured memory_bytes: 2812