akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;
const int SIZE = 80 * 80 * 2 + 1;
int main()
{
	int H, W;
	cin >> H >> W;

	mat AB(H, vec(W));
	vector<vector<vector<int>>> st(H, vector<vector<int>>(W, vector<int>(SIZE, 0)));

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			int A;
			cin >> A;
			AB[i][j] = -A;
		}
	}

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			int B;
			cin >> B;
			AB[i][j] += B;

		}

	}

	st[0][0][abs(AB[0][0])] = 1;
	
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			for (int k = 0; k < SIZE; ++k)
			{
				if (st[i][j][k] == 0) { continue; }

				if (i < H - 1)
				{
					st[i + 1][j][abs(k + AB[i + 1][j])] = 1;
					st[i + 1][j][abs(k - AB[i + 1][j])] = 1;
				}

				if (j < W - 1)
				{
					st[i][j + 1][abs(k + AB[i][j + 1])] = 1;
					st[i][j + 1][abs(k - AB[i][j + 1])] = 1;
				}
			}
		}
	}
	
	int ans = SIZE;
	
	for (int i = 0; i < SIZE; ++i)
	{
		if (st[H - 1][W - 1][i] == 0)continue;

		ans = min(ans, abs(i));
	}
	cout << ans << endl;

	return 0;
}

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

template <typename T>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main() {
  ll h, w;
  cin >> h >> w;
  auto a = make_v<ll>(h, w);
  for (ll i = 0; i < h; i++)
    for (ll j = 0; j < w; j++) cin >> a[i][j];

  using T = tuple<ll, ll, ll, ll>;
  vector<T> ans;
  for (ll i = 0; i < h; i++) {
    if (i & 1) {
      for (ll j = w - 1; j; j--) {
        if (a[i][j] & 1) {
          ans.emplace_back(i, j, i, j - 1);
          a[i][j]--;
          a[i][j - 1]++;
        }
      }
      if (i + 1 < h) {
        ll j = 0;
        if (a[i][j] & 1) {
          ans.emplace_back(i, j, i + 1, j);
          a[i][j]--;
          a[i + 1][j]++;
        }
      }
    } else {
      for (ll j = 0; j + 1 < w; j++) {
        if (a[i][j] & 1) {
          ans.emplace_back(i, j, i, j + 1);
          a[i][j]--;
          a[i][j + 1]++;
        }
      }
      if (i + 1 < h) {
        ll j = w - 1;
        if (a[i][j] & 1) {
          ans.emplace_back(i, j, i + 1, j);
          a[i][j]--;
          a[i + 1][j]++;
        }
      }
    }
  }

  cout << ans.size() << endl;
  for (auto t : ans) {
    ll a, b, c, d;
    tie(a, b, c, d) = t;
    a++;
    b++;
    c++;
    d++;
    cout << a << " " << b << " " << c << " " << d << endl;
  }
  return 0;
}


Measured memory_bytes: 9440
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int s,c;
  cin >> s >> c;
  int ans=0;
  if(s*2 >= c){
    // sあまり
    ans = c/2;
  }
  else{
    // sあまらない
    ans = s;
    c -= s*2;
    ans += c/4;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*
class Rewrite(b: Int, c: Int) {
    val b = b
    val c = c
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextInt()
    val a: MutableList<Int> = mutableListOf()
    for (i in 0..n-1) {
        a.add(cin.nextInt())
    }
    var rw: MutableList<Rewrite> = mutableListOf()
    for (i in 0..m-1) {
        rw.add(Rewrite(cin.nextInt(), cin.nextInt()))
    }
    val a_s: MutableList<Int> = a.sorted().toMutableList()
    val rws = rw.sortedByDescending {it.c}

    var i = 0
    var now = 0
    var nowused = 0
    while (n > i && m > now) {
        if (rws[now].c > a_s[i]) {
            a_s[i] = rws[now].c
        } else {
            break
        }
        i += 1
        nowused += 1
        if (nowused >= rws[now].b) {
            now += 1
            nowused = 0
        }
    }
    var ans: Long = 0
    for (j in 0..n-1) {
        ans += a_s[j].toLong()
    }
    println(ans)
}

Measured memory_bytes: 116328
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    
    if (S.at(2)==S.at(3)){
        if (S.at(4)== S.at(5)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
            
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.to_i

if s == n
  p n + 1
  exit
end

def test!(n, b, s)
  sum = 0
  k = n
  while k >= b
    sum += k % b
    k /= b
  end
  sum += k
  if sum == s
    p b
    exit
  end
end

rn = Math.sqrt(n).floor
2.upto(rn) do |b|
  test!(n, b, s)
end

rn.downto(1) do |p_|
  b = (n-s)/p_ + 1 
  test!(n, b, s) if b >= 2
end

p -1


Measured memory_bytes: 1916
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
if a<=c and c<=b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74636
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


def Base_10_to_n(X, n):

    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

N = int(input())

if N == 0:
	print(0)
	sys.exit()

ans = []
def calc(x):
	global ans

	if x%4 == 0:
		ans.append(0)
		ans.append(0)

	elif x%4 == 1:
		ans.append(1)
		ans.append(0)
		x -= 1
	elif x%4 == 2:
		ans.append(0)
		ans.append(1)
		x += 2
	elif x%4 == 3:
		ans.append(1)
		ans.append(1)
		x += 3

	return x//4

while N !=0:
	N = calc(N)


ans.reverse()
print(int(''.join(map(str,ans))))


Measured memory_bytes: 4584
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define input freopen("input.txt", "r", stdin);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
int n, e, par[maxn], cnt[maxn];
void make_set()
{
    for(int i=1; i<=n; i++) par[i]=i;
}
int find_rep(int u)
{
    if(par[u]==u) return u;
    return par[u] = find_rep(par[u]);
}
void make_union(int u, int v)
{
    u = find_rep(u);
    v = find_rep(v);
    if(u!=v) par[v]=u;
}
int main()
{
    cin>>n>>e;
    make_set();
    for(int i=1; i<=e; i++){
        int u, v;
        cin>>u>>v;
        make_union(u, v);
    }
    int ans=0;
    for(int i=1; i<=n; i++){
        int id = find_rep(i);
        cnt[id]++;
        ans = max(ans, cnt[id]);
    }
    cout<<ans;
}







Measured memory_bytes: 4980
N, M = map(int,input().split())
List = [list(map(int,input().split())) for i in range(M)]

mi = 1
ma = N

for i in range(M):
    if mi < List[i][0]:
        mi = List[i][0]
    if ma > List[i][1]:
        ma = List[i][1]

diff = ma - mi + 1
if diff < 0:
    diff = 0
print("{}".format(diff))

Measured memory_bytes: 27332
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

        vector<int> A(N + 1);
        rep(i, N) cin >> A[i];
        bool ok = true;
        int odd = 0;

        rep(i, N)
        {
                if (A[i] % 2 == 1)
                {
                        odd++;
                }
        }
        if (odd % 2 == 0)
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 640
N , M = map(int, input().split())
As =[input() for _ in range(N)]
Bs =[input() for _ in range(M)]
m = N-M
for i in range(m+1):
    for j in range(m+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if As[k+i][l+j] != Bs[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')
            
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
 
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
 
typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;
 
typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
 
mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  auto xorsum = [&](ll x) -> ll {
    ll res[] = {x, 1, x + 1, 0};
    return res[x % 4];
  };
  
  ll a, b;
  cin >> a >> b;
  ll ans = (xorsum(b)) xor ((a == 0 ? 0 : xorsum(a - 1)));
  cout << ans << endl;
}
 
/*
USE LONG LONG!!!!
 
:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:
 
          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

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

namespace zyt
{
	const int N = 1e5 + 10, P = 1e9 + 7;
	char s[N];
	int dp[N][13];
	void add(int &a, const int b)
	{
		a = (a + b) % P;
	}
	int work()
	{
		scanf("%s", s);
		int n = strlen(s);
		dp[0][0] = 1;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < 13; j++)
			{
				if (s[i] != '?')
					add(dp[i + 1][(j * 10 + s[i] - '0') % 13], dp[i][j]);
				else
					for (int k = 0; k < 10; k++)
						add(dp[i + 1][(j * 10 + k) % 13], dp[i][j]);
			}
		}
		printf("%d", dp[n][5]);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 5376
#include <iostream>
#include <set>

using namespace std;

int main() {
  int X, N, p, ans;
  cin >> X >> N;

  set<int> s;
  while (cin >> p) s.insert(p);

  for (int i = 0;; ++i) {
    if (!s.count(X - i)) {
      ans = X - i;
      break;
    } else if (!s.count(X + i)) {
      ans = X + i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second

int main()
{
    fast
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    cout<<floor((a*x)/b)<<endl;
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
int main(){
int a;
scanf("%d",&a);
if(a/100==7){
	printf("Yes");
}
else if(((a/100)-7)%10==0){
	printf("Yes");
}
else if (((a/10)-7)%10==0){
	printf("Yes");
}
else if((a-7)%10==0){
	printf("Yes");
}
else{
	printf("No");
}
return 0;
}


Measured memory_bytes: 1712
def main():
    A = list(map(int,str(input())))

    s1 = "+"
    s2 = "+"
    s3 = "+"    

    if A[0] + A[1] + A[2] + A[3] == 7:
        s1 = "+"
        s2 = "+"
        s3 = "+"
    elif A[0] + A[1] + A[2] - A[3] == 7:
        s1 = "+"
        s2 = "+"
        s3 = "-"
    elif A[0] + A[1] - A[2] + A[3] == 7:
        s1 = "+"
        s2 = "-"
        s3 = "+"
    elif A[0] - A[1] + A[2] + A[3] == 7:   
        s1 = "-"
        s2 = "+"
        s3 = "+"
    elif A[0] + A[1] - A[2] - A[3] == 7:   
        s1 = "+"
        s2 = "-"
        s3 = "-"
    elif A[0] - A[1] + A[2] - A[3] == 7:   
        s1 = "-"
        s2 = "+"
        s3 = "-"
    elif A[0] - A[1] - A[2] + A[3] == 7:   
        s1 = "-"
        s2 = "-"
        s3 = "+"
    elif A[0] - A[1] - A[2] - A[3] == 7:   
        s1 = "-"
        s2 = "-"
        s3 = "-"

    print(str(A[0]) + s1 + str(A[1]) + s2 + str(A[2]) + s3 + str(A[3]) + "=7")


if __name__ == "__main__":
    main()

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

int main() {
  string s;
  cin >> s;
  cout << s[0] << s[1]<<  s[2]<< endl;
}

Measured memory_bytes: 3624
using System;
using System.Linq;

namespace ABC158B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            long[] nab = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long sumAb = nab[1] + nab[2];
            long cnt = nab[0] / sumAb;
            long mod = nab[0] % sumAb;
            long res = nab[1] * cnt;
            res += mod > nab[1] ? nab[1] : mod;
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, k, ans = 0; cin >> n >> k;
    vi v(n); rep(i, n) cin >> v[i];
    
    // 左からa個、右からa個取り出すパターンを全探索
    for(ll a=0; a<=min(k, n); a++){
        for(ll b=0; a+b<=min(k, n); b++){
            vi current; ll sum = 0;
            // 左からa個取り出す
            for(ll i=0; i<a; i++){
                current.push_back(v[i]);
                sum += v[i];
            }
            // 右からb個取り出す
            for(ll i=0; i<b; i++){
                current.push_back(v[n-1-i]);
                sum += v[n-1-i];
            }
            // ソートして昇順にしマイナスの物を戻せるだけ戻す
            sort(all(current));
            for(ll i=0; i<min(k-a-b, a+b); i++) if(current[i]<0) sum -= current[i];
            chmax(ans, sum);
        }
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;

int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
int a,b;
cin >> a >>b;
if(a*b%2==1){
  cout << "Yes" << endl;
}else cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int mini, int maxx) {
  vector < int > int_array;
  for (int i = 2; i <= maxx; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(maxx);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  while(true)if(mini<=sosu[0])break;else sosu.erase(sosu.begin());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b) swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b) swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {return nPr(n, n);}

ll nCr(ll n, ll r) {
  if (0 != n - r && n - r < r) r = n - r;
  return nPr(n, r) / nE(r);
}








Measured memory_bytes: 892
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
 
  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
    if(*it == x){
      data.erase(it);
      break;
    }
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}


Measured memory_bytes: 34304
n = int(input())
s = input()

ans = n
w_to_r = 0
r_to_w = s.count('R')

ans = min(ans, max(w_to_r, r_to_w))

for i in range(n):
    if s[i] == 'W':
        w_to_r += 1        
    else:
        r_to_w -= 1
    ans = min(ans, max(w_to_r, r_to_w))

print(ans)

Measured memory_bytes: 9472
#include <stdio.h>
int main(){
        int N,a,b,c,d,A,B,C,D,E,F,G,H;
        int count=0;
        scanf("%d",&N);
        for(a=0;a<=9;a++){
                for(b=0;b<=9;b++){
                        for(c=0;c<=9;c++){
                                for(d=0;d<=9;d++){
                                        if(1000*a+100*b+10*c+d==N){
                                                goto LABEL;
                                        }
                                }
                        }
                }
        }
LABEL:
        A=a+b+c+d;
        B=a+b+c-d;
        C=a+b-c+d;
        D=a-b+c+d;
        E=a+b-c-d;
        F=a-b-c+d;
        G=a-b+c-d;
        H=a-b-c-d;


        if(A==7){
                printf("%d+%d+%d+%d=7\n",a,b,c,d);
                count = 1;
        }
        if(B==7){
                if(count!=1){
                        printf("%d+%d+%d-%d=7\n",a,b,c,d);
                }
                count = 2;
        }
        if(C==7){
                if(count!=2&&count !=1){
                        printf("%d+%d-%d+%d=7\n",a,b,c,d);
                }
                count = 3;
        }
        if(D==7){
                if(count!=3&&count!=2&&count!=1){
                        printf("%d-%d+%d+%d=7\n",a,b,c,d);
                }
                count = 4;
        }
        if(E==7){
                if(count!=4&&count!=3&&count!=2&&count!=1){
                        printf("%d+%d-%d-%d=7\n",a,b,c,d);
                }
                count = 5;
        }
        if(F==7){
                if(count!=5&&count!=4&&count!=3&&count!=2&&count!=1){
                        printf("%d-%d-%d+%d=7\n",a,b,c,d);
                }
                count = 6;
        }
        if(G==7){
                if (count!=6&&count!=5&&count!=4&&count!=3&&count!=2&&count!=1){
                        printf("%d-%d+%d-%d=7\n",a,b,c,d);
                }
                count = 7;
        }
        if(H==7){
                if(count!=7&&count!=6&&count!=5&&count!=4&&count!=3&&count!=2&&count!=1){
                        printf("%d-%d-%d-%d=7\n",a,b,c,d);
                }
        }

        return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int H;
int A[500001];
void maxHeapify(int i){//ヒープソート
  int l = i*2;
  int r = l+1;
  int largest;
  int tmp;
  if(l<=H && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r<=H && A[r]>A[largest]){
    largest = r;
  }
 
  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(void){
  int i;
  for(i=H/2;i>0;i--) maxHeapify(i);
}
int del(int i){
  int tmp;
  tmp = A[i];
  A[i] = A[H];
  A[H] = tmp;
  return A[H];
}
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
   
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
     
  return 0;
}


Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	vector<string> a,b;
	vector<int>t;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		string p;
		int r;
		cin >> p;
		cin >> r;
		b.push_back(p);
		t.push_back(r);
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	vector<int>w;
	for (int i = 0; i < n; i++) {
		int z = -1; int y = 0;
		for (int j = 0; j < n; j++) {
			if (a[i] == b[j]) {
				if (z < t[j]) {
					z = t[j]; y = j;
				}
			}

		}
	//	cout << a[i] << " " << z <<" "<<y<< endl;
		w.push_back(y+1);
		t[y] = -10;


	}

	for (int i = 0; i < n; i++)
		cout << w[i] << endl;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int h, w;
    for (;;) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) {
            break;
        }
        else {
            for (int i = 0; i < w; i++) {
                printf("#");
            }
            printf("\n");
            for (int i = 1; i < h-1; i++) {
                printf("#");
                for(int j = 1; j < w-1; j++) {
                    printf(".");
                }
                printf("#\n");
            }
            for (int i = 0; i < w; i++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


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

enum{CARROT,BATERU,GOAL};
struct Event{
    int type;
    double pos;
};

bool operator<(const Event &lhs,const Event &rhs){
    return lhs.pos==rhs.pos ? lhs.type>rhs.type : lhs.pos>rhs.pos;
}


int main(){
    int n,k,t,u,v,l;
    cin>>n>>k>>t>>u>>v>>l;
        vector<int> d(n);
        for(int i=0;i<n;i++) cin>>d[i];
        priority_queue<Event> que;
        for(int i=0;i<n;i++){
            que.push(Event{CARROT,double(d[i])});
        }
        que.push(Event{GOAL,double(l)});
        double ver=u;
        double pos=0;
        int cnt=0;
        int charge=0;
        double res=0;
        while(true){
            Event eve=que.top(); que.pop();
            res+=(eve.pos-pos)/ver;
            pos=eve.pos;
            
            if(eve.type==CARROT){
                
                if(cnt==k){
                    charge++;
                    que.push({Event{BATERU,pos+v*t}});
                }
                else{
                    
                    cnt=cnt+1;
                    if(ver==u){
                        assert(charge==0);
                        cnt--;
                        charge++;
                        ver=v;
                        que.push({Event{BATERU,pos+v*t}});
                    }
                }
            }
            else if(eve.type==GOAL){
                break;
            }
            else if(eve.type==BATERU){
                
                charge--;
                if(charge==0){     
                    if(cnt>0){
                        cnt--;
                        charge++;
                        que.push(Event{BATERU,pos+t*v});
                    }
                    else{
                        ver=u;
                    }
                }
                
            }
        }
        cout<<setprecision(10)<<fixed;
        cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 3276
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String [] s = sc.next().split("");
		for(int i = 0; i < a+b+1; i++) {
			if(i < a && s[i].equals("-")) {
				System.out.println("No");
				return;
			}
			if(i > a && s[i].equals("-")) {
				System.out.println("No");
				return;
			}
		}
		if(!s[a].equals("-")) {
			System.out.println("No");
		}
		else System.out.println("Yes");
		sc.close();
	}

}


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

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

   if (13 <= a) {
       cout << b << endl;
   } else if (6 <= a && a <= 12) {
       cout << b / 2 << endl;
   } else if (a <= 5) {
       cout << 0 << endl;
   }
}


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

int main(){

  int n;
  ll ans = 0;
  cin >>n;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        ans += gcd(i,gcd(j,k));
      }
    }
  }
  
  cout << ans << endl;
  
    
    return 0;
}


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

int main(){
	ll n;
	cin >> n;
	string s = to_string(n);
	ll sum = 0;
	rep(i,s.size()){
		sum += s[i] - '0';
	}
	if(n % sum == 0){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
    return 0;
}



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

int M,N,P[10010],C[510],E[510],dp[510][10010] =  {},cost[10010];

int main(){
	cin >> M >> N;
	for(int i=1;i<=M;i++){
		cin >> P[i];
	}
	for(int i=1;i<=N;i++){
		cin >> C[i] >> E[i];
	}
	for(int i=0;i<=N;i++){
		for(int j=1;j<=10001;j++){
			dp[i][j] = (int) 2e9;
			cost[j] = (int) 2e9;
		}
	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<=M;j++){
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			dp[i][min(j+C[i],M)] = min(min(dp[i][min(j+C[i],M)],dp[i-1][min(j+C[i],M)]),dp[i-1][j]+E[i]);
		}
		for(int j=M-1;j>=0;j--) dp[i][j] = min(dp[i][j],dp[i][j+1]);
	}
/*	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
*/	sort(P+1,P+M+1,greater<int>());
	int sum = 0,ans = 0;
	for(int i=1;i<=M;i++){
		sum += P[i];
		ans = max(ans,sum-dp[N][i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 22832
#include <bits/stdc++.h>
#define int long long
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
int K;

inline int cal(int n) {
  return n < 10 ? n : cal(n / 10) + (n % 10);
}

main(void) {
  read(K);
  int r = 0, x = 1;
  for(; K --;) {
    for(; cal(r + x) * (r + x * 10) < cal(r + x * 10) * (r + x); x *= 10);
    cout << (r += x) << "\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
long long dp[maxn][13];
char s[maxn];
int main(){
	cin>>s+1;
	int n=strlen(s+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]!='?'){
			s[i]-='0';
			for(int j=0;j<13;j++){
				dp[i][(j*10+s[i])%13]=(dp[i][(j*10+s[i])%13]+dp[i-1][j])%mod;
			}
		}else{
			for(int k=0;k<10;k++){
				for(int j=0;j<13;j++){
					dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%mod;
				}
			}
		}
	} 
	cout<<dp[n][5]<<endl; 
	return 0;
}

Measured memory_bytes: 10496
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(c==b*2-a ? "YES" : "NO");
	}
}

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

using namespace std;

const int N = 3e3+10;

double dp[N][N];

int main() {
    int n;
    cin >> n;
    vector<double> p(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int cnt = 0; cnt <= n; ++cnt) {
            dp[i][cnt] = dp[i-1][cnt-1] * p[i] + dp[i-1][cnt] * (1.0-p[i]);
        }
    }
    double ans = 0;
    for (int cnt = 0; cnt <= n; ++cnt) {
        if (cnt > n-cnt) {
            ans += dp[n][cnt];
        }
    }
    cout << setprecision(20) << fixed << ans;
    return 0;
}

Measured memory_bytes: 74360
n = int(input())
L = []
for i in range(n):
    L.append(2**i)
ans = 0
comment = [[] for i in range(n)]
num = []
for i in range(n):
    t = int(input())
    num.append(t)
    for j in range(t):
        a,b = map(int,input().split())
        comment[i].append([a-1,b])
for i in range(2**n):
    cur = i
    str = ''
    flag = True
    honest_num = 0
    for j in range(len(L)):
        temp = cur&L[j]
        if temp != 0:
            str = '1'+str
            honest_num += 1
        else:
            str = '0'+str
    for j in range(n):
        d = num[j]
        if str[j] == '1':
            for k in range(d):
                pick = comment[j][k]
                if (pick[1] == 0 and str[pick[0]] == '1') or (pick[1] == 1 and str[pick[0]] == '0'):
                    flag = False
                    break
        if not flag:
            break
    if flag:
        ans = max(ans,honest_num)
print(ans)


Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(n);
    vector<string> S(n);
    FOR(i,n)cin>>S[i];
    vector<int> list(26,1<<28);
    FOR(i,n){
        FOR(j,26){
            int c=0;
            FOR(k,S[i].size()){
                if(S[i][k]==j+'a'){
                    c++;
                }
            }
            list[j]=min(list[j],c);
        }
    }
    string ans="";
    FOR(i,26){
        FOR(j,list[i]){
            ans+='a'+i;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
food_list = []
for i in range(5):
    food_list.append(str(int(input())-1))
food_list = sorted(food_list, key=lambda x: x[-1], reverse=True)
food_list = [int(i) + 1 for i in food_list]
count = 0
for i in food_list[:-1]:
    count += i + (10 -i % 10) % 10
count += food_list[-1]
print(count)

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

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

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

	string ans = "";
	if (S == "Sunny") {
		ans = "Cloudy";
	}
	else if (S == "Cloudy") {
		ans = "Rainy";
	}
	else  if (S == "Rainy") {
		ans = "Sunny";
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define mk make_pair
#define vec vector<int> 
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt") 
 
int main(){
//	finput;foutput;
	ios_base::sync_with_stdio(false);
    string s1,s2;
    int n,m;
    cin>>s1>>s2;
    n=s1.length();
    int a[n],b[n];
    int map[27]={0},check[27]={0};
    for(int i=0;i<n;i++){
    	a[i]=s1[i]-'a'+1;
    	b[i]=s2[i]-'a'+1;
    }
    
    for(int i=0;i<n;i++){
    	if(map[a[i]]==0 && check[b[i]]==0){
                map[a[i]]=b[i];
                check[b[i]]++;
                continue;
    	}
    	if(map[a[i]]!=b[i]){
    		cout<<"No";
    		return 0;
    	}
    }
    cout<<"Yes";
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N; char S[MAX_N];

int main() {
	scanf("%s", S+1);
	N = strlen(S+1);

	int l = 0, r = N+1;
	int cl = 0, cr = 0;
	int ans = 0;
	while(l < r) {
		cl = cr = 0;
		l++; r--;
		while(l <= N && S[l] == 'x') l++, cl++;
		while(r >= 1 && S[r] == 'x') r--, cr++;
		if(l > r) break;
		ans += abs(cl - cr);
		if(S[l] != S[r]) {
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int masu[14][14] = {0};
	int x, y, s, i, j, n = 0, cut = 0;
	int num[100] = {0};

	while(scanf("%d,%d,%d", &x, &y, &s) != EOF){
		x = x + 2;
		y = y + 2;
		masu[x][y] ++;
		if(s == 1){
			masu[x][y-1] += 1, masu[x][y+1] += 1, masu[x-1][y] += 1, masu[x+1][y] += 1;
		}
		else if(s == 2){
			masu[x][y-1] += 1, masu[x][y+1] += 1, masu[x-1][y] += 1, masu[x+1][y] += 1;
			masu[x+1][y-1] += 1, masu[x+1][y+1] += 1, masu[x-1][y-1] += 1, masu[x-1][y+1] += 1;
		}
		else{
			masu[x][y-1] += 1, masu[x][y+1] += 1, masu[x-1][y] += 1, masu[x+1][y] += 1;
			masu[x+1][y-1] += 1, masu[x+1][y+1] += 1, masu[x-1][y-1] += 1, masu[x-1][y+1] += 1;
			masu[x+2][y] += 1, masu[x-2][y] += 1, masu[x][y+2] +=1, masu[x][y-2] += 1;
		}
		
	}

	for(i = 2; i < 12; i ++){
		for(j = 2; j < 12; j ++){
			num[n] = masu[i][j];
			n ++;
		}
	}

	sort(num, num+100);

	for(i = 0; i < 100; i ++){
		if(num[i] == 0) cut ++;
		else break;
	}

	cout << cut << endl << num[99] << endl;

	return 0;    
}

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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=2e3+5;
const int M=1e9+7;
void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=(s[i]-'0');
	}
	if(ans%9==0)
	cout<<"Yes";
	else
	cout<<"No";
}

signed main()
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>
#include <set>

using namespace std;

using TUP = tuple<int, int, int>;

int main() {
	int n, q, s, t, x, d;
	cin >> n >> q;

	vector<TUP> queries;
	for (int i = 0; i < n; i++) {
		cin >> s >> t >> x;

		// pos 0での時間に合わせる
		queries.emplace_back(make_tuple(s - x, 1, x)); // start
		queries.emplace_back(make_tuple(t - x, 0, x)); // end
	}
	for (int i = 0; i < q; i++) {
		cin >> d;
		queries.emplace_back(d, 99, i);
	}
	sort(queries.begin(), queries.end());

	vector<int> ans(q, -1);

	int idx = 0;
	set<int> stops;
	for (auto query: queries) {
		int when = get<0>(query);
		int kind = get<1>(query);
		int val = get<2>(query);
		// printf("query %3d %3d %3d\n", when, kind, val);

		if (kind == 0) {
			stops.erase(val);
		} else if (kind == 1) {
			stops.insert(val);
		} else {
			// printf("check %2d: ", val);
			if (!stops.empty()) {
				ans[val] = *stops.begin();
				// printf("%2d\n", *stops.begin());
			}
			// printf("\n");
		}
	}

	for (auto z: ans) {
		cout << z << endl;
	}
	return 0;
}


Measured memory_bytes: 19816
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  std::string r = std::regex_replace(s, std::regex(","), " ");
  std::cout << r << std::endl;
  return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	int a = n%10;
	int b = n/100;
//	cout << a << " " << b << endl;
	if(a == b){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>
 
#define INF 100000000
#define EPS 1e-9
 
using namespace std;
 
typedef long long ll;  

#define MAX_H 30
#define MAX_W 30

int W, H;

int s[MAX_H][MAX_W];
int c[4];

//dirx,yに依存
int dp[4][MAX_H][MAX_W];
int dirx[] = {1,-1,0,0};
int diry[] = {0,0,-1,1};

vector<int> ans_list;

typedef pair<int, int> P;

int dirDec(int dir, int act){
  
  if(dir == 0){
    if(act == 0)
      return 0;
    else if(act == 1)
      return 3;
    else if(act == 2)
      return 1;
    else
      return 2;
  }

  else if(dir == 1){
    if(act == 0)
      return 1;
    else if(act == 1)
      return 2;
    else if(act == 2)
      return 0;
    else
      return 3;
  }

  else if(dir == 2){
    if(act == 0)
      return 2;
    else if(act == 1)
      return 0;
    else if(act == 2)
      return 3;
    else
      return 1;
  }

  else{
    if(act == 0)
      return 3;
    else if(act == 1)
      return 1;
    else if(act == 2)
      return 2;
    else
      return 0;
  }

}


int solve(){

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < H; j++){
      for(int k = 0; k < W; k++){
	dp[i][j][k] = INF;
      }
    }
  }


  dp[0][0][0] = 0;
  
  queue<P> que;
  queue<int> D;
  que.push(make_pair(0,0));
  D.push(0);

  while(que.size()){
    
    P p = que.front();
    int dir = D.front();
    que.pop();
    D.pop();
    int x = p.first;
    int y = p.second;

    if(s[y][x] != 4){
      int dd = dirDec(dir, s[y][x]);
      int nx = x + dirx[dd];
      int ny = y + diry[dd];
      if(nx >= 0 && nx < W && ny >= 0 && ny < H){
	if(dp[dd][ny][nx] > dp[dir][y][x]){
	  dp[dd][ny][nx] = dp[dir][y][x];
	  que.push(make_pair(nx, ny));
	  D.push(dd);
	}
      }
    }

    for(int i = 0; i < 4; i++){
      int dd = dirDec(dir, i);
      int cost = c[i];
      int nx = x + dirx[dd];
      int ny = y + diry[dd];
      if(nx >= 0 && nx < W && ny >= 0 && ny < H){
	if(dp[dd][ny][nx] > dp[dir][y][x] + cost){
	  dp[dd][ny][nx] = dp[dir][y][x] + cost;
	  que.push(make_pair(nx, ny));
	  D.push(dd);
	}
      }
    }

  }
  
  /*
  for(int i = 0; i < 4; i++){
    cout << endl;
    for(int j = 0; j < H; j++){
      for(int k = 0; k < W; k++){
	cout << " " << dp[i][j][k];
      }
      cout << endl;
    }
    cout << endl;
  }
  */

  int ans = INF;
  for(int i = 0; i < 4; i++){
    ans = min(ans, dp[i][H-1][W-1]);
  }

  return ans;

}

int main(){

  while(true){
    cin >> W >> H;
    if(W == 0)
      break;

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> s[i][j];
      }
    }

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

    ans_list.push_back(solve());

  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1268
<?php
list($n) = ints();
$a = ints();
$cnt = array_fill(0, 10, 0);
for ($i = 0; $i < $n; ++$i) {
    if ($a[$i] < 400) $cnt[0]++;
    elseif ($a[$i] < 800) $cnt[1]++;
    elseif ($a[$i] < 1200) $cnt[2]++;
    elseif ($a[$i] < 1600) $cnt[3]++;
    elseif ($a[$i] < 2000) $cnt[4]++;
    elseif ($a[$i] < 2400) $cnt[6]++;
    elseif ($a[$i] < 2800) $cnt[7]++;
    elseif ($a[$i] < 3200) $cnt[8]++;
    else $cnt[9]++;
}
$ans = 0;
for ($i = 0; $i < 9; ++$i) if ($cnt[$i] > 0) $ans++;
echo implode(' ', [max(1, $ans), $ans + $cnt[9]]);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB emplace_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,l,x;
    LL ans=0;
    string s;
    cin >> s;
    l=s.SZ;
    for(i=l-1;i>=0;i--)
    {
        x=s[i]-'0';
        if(x >= 6  ||  (x == 5  && i > 0  &&  s[i-1]-'0' >= 5))++s[i-1];
        ans+=min(x,10-x);
    }
    if(s[0]-'0' > 5)++ans;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t)
{
    std::ostringstream os;
    os << t;
    return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        for (int j = 0; j < tmp; j++)
        {
            int tmp2;
            cin >> tmp2;
            tmp2--;
            v[tmp2]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if (v[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256