akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<cstdio>
#include<map>
#pragma warning(disable : 4996)
#define P pair<int,int>
using namespace std;

bool g[1000][1000]{};
int x[] = { -1,0,0,1 }, y[] = { 0,-1,1,0 };
map<int, P>j;
int a, b, c;
int meiro(int d) {
	queue<P> e;
	vector<vector<int>>f(a, vector<int>(b));
	for (int g = 0; g < a; g++) {
		for (int h = 0; h < b; h++) {
			f[g][h] = 1 << 29;
		}
	}
	e.push(j[d]);
	f[(j[d]).first][(j[d]).second] = 0;
	while(e.size()) {
		P p = e.front(); e.pop();
		if (p == j[d+1])break;
		for (int q = 0; q < 4; q++) {
			int l = p.first + x[q];
			int r = p.second + y[q];
			if (l >= 0 && l < a&&r >= 0 && r < b&&g[l][r] && f[l][r] == 1 << 29) {
				P w(l, r);
				e.push(w);
				f[l][r] = f[p.first][p.second] + 1;
			}
		}
	}
	return f[(j[d + 1]).first][(j[d + 1]).second];
}
int main() {
	scanf("%d%d%d", &a, &b, &c);
	for (int d = 0; d < a; d++) {
		for (int e = 0; e < b; e++) {
			char f;
			cin >> f;
			if (f == 'X')g[d][e] = false;
			else if (f == '.')g[d][e] = true;
			else if (f == 'S') {
				g[d][e] = true;
				P h(d, e);
				j[0] = h;
			}
			else {
				g[d][e] = true;
				P h(d, e);
				j[f - 48] = h;
			}
		}
	}
	int s = 0;
	for (int l = 0; l < c; l++) {
		s += meiro(l);
	}
	printf("%d\n", s);
}

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

int main() {
    long long n,s;
    cin >> n;
    vector<long long> a(n);
    cin >> a.at(0);
    s=0;
    for (int i=1; i < n; i++){
        cin >> a.at(i);
        if (a.at(i-1)> a.at(i)){
            s=s+a.at(i-1)-a.at(i);
            a.at(i)=a.at(i-1);
        }
    }
    cout << s;
}

Measured memory_bytes: 4832
import sys

h, w, m = map(int, input().split(' '))
H = [0 for _ in range(h+1)]
W = [0 for _ in range(w+1)]
bomb = set()
for m in range(m):
  i, j = map(int, input().split(' '))
  bomb.add((i, j))
  H[i] += 1
  W[j] += 1
  
max_h = max(H)
max_w = max(W)
target_h = [i for i, v in enumerate(H) if v == max_h]
target_w = [i for i, v in enumerate(W) if v == max_w]

for m in target_h:
  for n in target_w:
    if (m, n) not in bomb:
      print(max_h + max_w)
      sys.exit()
	
print(max_h + max_w - 1)

Measured memory_bytes: 83432
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                for (int i = 0; i < 9; i++)
                    n -= int.Parse(Console.ReadLine());
                Console.WriteLine(n);
            }
        }
    }
}

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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll n, a[100010],b[100010],c[100010],dp[100010][3];

ll solve(){
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    fore(i,1,n){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i]; 
    }
    return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


int main(){
    cin>>n;
    fore(i,0,n)cin>>a[i]>>b[i]>>c[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const lint MOD = 1000000007LL;

lint modpow(lint a, lint x)
{
    if (x == 0)
        return 1;
    if (x % 2 == 1)
        return a * modpow(a, x - 1) % MOD;
    lint t = modpow(a, x / 2);
    return t * t % MOD;
};

lint choose(lint n, lint a)
{
    // n! / (n - a)! / a!
    // (n - a + 1) ... (n) / (1 2 ... a)
    lint ret = 1;
    FOR(i, 1, a + 1) {
        ret = ret * (n - a + i) % MOD;
        ret = ret * modpow(i, MOD - 2) % MOD;
    }

    return ret;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, a, b;
    cin >> N >> a >> b;

    lint ret = modpow(2, N) + MOD - 1;
    ret %= MOD;
    ret += MOD - choose(N, a);
    ret += MOD - choose(N, b);
    cout << ret % MOD << endl;
    return 0;
};

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>

bool check(std::vector<std::string> A,std::vector<std::string> B,int x,int y){
    int m=B.size();
    for (size_t i = 0; i < m; i++) {
        for (size_t j = 0; j < m; j++) {
            if (A[x+i][y+j]!=B[i][j]) {
                return false;
            }
        }
    }
    return true;
}

void print(std::vector<std::string> X){
    int n = X.size();
    for (size_t i = 0; i < n; i++) {
        std::cout << X[i] << '\n';
    }
}


int main(int argc, char const *argv[]) {
    int N,M; std::cin >> N >> M;
    std::vector<std::string> A(N);
    std::vector<std::string> B(M);
    char c;
    for (size_t i = 0; i < N; i++) {
        for (size_t j = 0; j < N; j++) {
            std::cin >> c;
            A[i]+=c;
        }
    }
    for (size_t i = 0; i < M; i++) {
        for (size_t j = 0; j < M; j++) {
            std::cin >> c;
            B[i]+=c;
        }
    }

    //print(A);
    //print(B);

    bool flag=false;
    for (size_t i = 0; i < N-M+1; i++) {
        for (size_t j = 0; j < N-M+1; j++) {
            if (check(A,B,i,j)){
                flag=true;
            }
        }
    }
    if (flag) {
        std::cout << "Yes" << '\n';
    }else{
        std::cout << "No" << '\n';
    }
    return 0;
}


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

//constexpr ld PI = 3.14159265358979323846264338327950288;
constexpr ld PI = acos(-1);
constexpr ld eps = 1e-10;

void solve(){
  int a, b, x; cin >> a >> b >> x;
  std::cout << std::fixed << std::setprecision(20);
  if(x==a*a*b) {cout << 0.0 << endl; return;}
  ld l = 0, r=PI/2, m;
  if(x>1.0*a*a*b/2){
  while(r-l>eps){
    m = (l+r)/2;
    ld v = a*a*b - 0.5*a*a*a*tan(m);
    if(v>x) l = m;
    else r = m;
  }
  }else{
    while(r-l>eps){
      m = (l+r)/2;
      ld v = a*b*b/tan(m)/2;
      if(v>x) l = m;
      else r = m;
    }
  }
  cout << (l/PI*180) << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N, K;
	uint64_t answer;
	uint64_t asumisu, mizuhasu;
	if (scanf("%" SCNu64 "%" SCNu64, &N, &K) != 2) return 1;
	/* a, b, c = 0 (mod K) */
	asumisu = N / K;
	answer = asumisu * asumisu * asumisu;
	/* a, b, c = K/2 (mod K) */
	if (K % 2 == 0) {
		mizuhasu = (N / K) + (N % K >= K / 2);
		answer += mizuhasu * mizuhasu * mizuhasu;
	}
	printf("%" PRIu64 "\n", answer);
	return 0;
}

/*

a+b = 0 (mod K)
b+c = 0 (mod K)
c+a = 0 (mod K)

a+b = a+c (mod K)
b = c (mod K)

2*b = 0 (mod K)

同様に 2*a = 0 (mod K), 2*c = 0 (mod K)

すなわち a = K/2 (mod K), b = K/2 (mod K), c = K/2 (mod K)
または a = 0 (mod K), b = 0 (mod K), c = 0 (mod K)

*/


Measured memory_bytes: 128
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
vector < vector < int > > v;
int x;
int m;

ll func(int n, vector < int > &ans)
{
	if(n == 0) {
		bool flag = 0;
		for(auto y: ans) {
			if(y < x) {
				flag= 1;
				break;
			}
		}
		if(flag) {
			return 1e9;
		} else {
			return 0;
		}
	}

	ll a = func(n - 1, ans);
	for(int i = 0; i < m; i ++) {
		ans[i] += v[n - 1][i + 1];
	}
	ll b = v[n - 1][0] + func(n - 1, ans);
	for(int i = 0; i < m; i ++) {
		ans[i] -= v[n - 1][i + 1];
	}
	return min(a, b);
}

int main()
{
  int n;
  cin>> n >> m >> x;
  for(int i = 0; i < n; i ++) {
  	vector < int > res(m +1);
  	for(auto &x: res) {
  		cin >> x;
  	}
  	v.push_back(res);
  }

  vector < int > ans(m);

  ll res = func(n, ans);
  if(res >= 1e9) {
  	res = -1;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3636
/**
 *    author:  tourist
 *    created: 23.01.2020 04:45:14       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  string s, t;
  cin >> s >> t;
  vector<int> x(max(n, m) + k + k, 0);
  vector<int> y(max(n, m) + k + k, 0);
  vector<int> a;
  vector<int> b;
  for (int it = max(n, m) - 1; it >= 0; it--) {
    x[it] = (it < n && s[n - 1 - it] == '1');
    y[it] = (it < m && t[m - 1 - it] == '1');
    a.push_back(it);
    int ops = k;
    while (!a.empty()) {
      int i = a.back();
      if (x[i] + y[i] <= 1) {
        break;
      }
      a.pop_back();
      if (x[i] == 2) {
        x[i + 1] += 1;
        x[i] = 0;
        b.push_back(i);
        if (a.empty() || a.back() != i + 1) {
          a.push_back(i + 1);
        }
        continue;
      }
      if (y[i] == 2) {
        y[i + 1] += 1;
        y[i] = 0;
        b.push_back(i);
        if (a.empty() || a.back() != i + 1) {
          a.push_back(i + 1);
        }
        continue;
      }
      x[i] = y[i] = 0;
      if (a.empty() || a.back() - i > ops) {
        x[i + ops] += 1;
        y[i + ops] += 1;
        a.push_back(i + ops);
        break;
      }
      int steps = a.back() - i;
      ops -= steps;
      x[a.back()] += 1;
      y[a.back()] += 1;
    }
    while (!b.empty()) {
      a.push_back(b.back());
      b.pop_back();
    }
  }
  auto Out = [&](const vector<int>& p) {
    int zero = 1;
    for (int i = (int) p.size() - 1; i >= 0; i--) {
      if (p[i] == 0 && zero) {
        continue;
      }
      cout << p[i];
      zero = 0;
    }
    cout << '\n';
  };
  Out(x);
  Out(y);
  return 0;
}


Measured memory_bytes: 34448
#include<stdio.h>
    int main(){
      int a,b,c,d;
      scanf("%d %d %d %d",&a,&b,&c,&d);
      while(1){
      	if(0 >= (c = c - b)){
        	printf("Yes\n");
            return 0;    
        }
        if(0 >= (a = a - d)){
        	printf("No\n");
      		return 0;    
        }
      }
    }

Measured memory_bytes: 1664
a, b = gets.split.map(&:to_i)

def xor_sum(num, digit)
  return (num + 1) / 2 % 2 if digit == 1
  loop_num = 2 ** digit
  rest = (num + 1) % loop_num
  count = rest - loop_num / 2
  if count < 0 || count.even?
    0
  else
    1
  end
end

array = []

b.to_s(2).size.downto(1) do |digit|
  sum = xor_sum(b, digit) - xor_sum(a - 1, digit)
  if sum.even?
    array << 0
  else
    array << 1
  end
end

puts array.join.to_i(2)


Measured memory_bytes: 3836
n = int(input())
S = input()
ans = 0
for i in range(10):
    a = S.find(str(i))
    if a != -1:
        for j in range(10):
            b = S[a+1:].find(str(j))
            if b != -1:
                for k in range(10):
                    c = S[a+1:][b+1:].find(str(k))
                    if c!=-1:
                        ans+=1
                        #print(i,j,k,a,b,c)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <vector>

template <class T>
class WeightedUnionFind {
public:
    std::vector<int> par, num;
    std::vector<T> dist;  // A[par[v]] - A[v] = dist[v]

    explicit WeightedUnionFind(int N)
        : par(N), num(N, 1), dist(N, 0) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        if (par[v] == v) {
            return v;
        } else {
            int p = find(par[v]);
            dist[v] += dist[par[v]];
            return par[v] = p;
        }
    }

    // A[u] - A[v] = d
    void unite(int u, int v, T d) {
        find(u), find(v);
        d += dist[u];
        d -= dist[v];
        u = par[u], v = par[v];
        if (u == v) return;

        if (num[u] < num[v]) {
            std::swap(u, v);
            d = -d;
        }

        num[u] += num[v];
        par[v] = u;
        dist[v] = d;
    }

    // A[v] - A[u]
    T diff(int u, int v) {
        find(u), find(v);
        return dist[u] - dist[v];
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return num[find(v)]; }
};

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

    int N, Q;
    std::cin >> N >> Q;
    WeightedUnionFind<long long> wuf(N);
    for (int q = 0; q < Q; ++q) {
        int t, u, v;
        std::cin >> t >> u >> v;
        if (t == 0) {
            long long d;
            std::cin >> d;
            wuf.unite(v, u, d);
        } else {
            if (!wuf.same(u, v)) {
                std::cout << "?\n";
            } else {
                std::cout << wuf.diff(u, v) << '\n';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4412
#include<stdio.h>
int abs(int n){
  return n>0? n:-1*n;
}
int main(){
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  
  if (abs(a-x)<abs(b-x)){
    printf("A");
  }
  else{
    printf("B");
  }
  return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <stack>

using namespace std;

vector<std::string> split(const string& input, char delimiter)
{
    istringstream stream(input);

    string field;
    vector<string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

int main(int argc, const char * argv[]) {
    string in;
    getline(cin, in);
    auto v = split(in, ' ');

    stack<int> st;
    for (auto t : v) {
        if (t == "+") {
            auto op1 = st.top(); st.pop();
            auto op2 = st.top(); st.pop();
            st.push(op2 + op1);
        } else if (t == "-") {
            auto op1 = st.top(); st.pop();
            auto op2 = st.top(); st.pop();
            st.push(op2 - op1);
        } else if (t == "*") {
            auto op1 = st.top(); st.pop();
            auto op2 = st.top(); st.pop();
            st.push(op2 * op1);
        } else {
            st.push(stoi(t));
        }
    }

    cout << st.top() << endl;

    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    int ans;
    if(a == b) ans = c;
    else if(a == c) ans = b;
    else ans = a;
    printf("%d\n", ans);
    return 0;
}

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

int main(void)
{
char S[7];
  
  scanf("%s", &S);
  if (S[2]==S[3] && S[4]==S[5]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


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

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

  vector<vector<int>> A(2, vector<int>(N));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {

    int sum = 0;
    for (int j = 0; j < N; ++j) {
      if (j < i) {
        sum += A[0][j];
      } else if (j > i) {
        sum += A[1][j];
      } else {
        sum += A[0][j] + A[1][j];
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)

ans = 0
b = g%mod
for a in A:
  ans += b*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	long long int h, w, n, flag, len;
	long long int a[100005];
	long long int b[100005];
	long long int c[1000006] = {};
	cin >> h >> w >> n;
	long long int i, j, k;
	long long int ans[10] = {};
	len = -1;
	for (i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}

	for (i = 0; i < n; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 3; k++){
				if (a[i] - 1 + j >= 2 && a[i] - 1 + j <= h - 1 && b[i] - 1 + k >= 2 && b[i] - 1 + k <= w - 1){
					len = len + 1;
					c[len] = (a[i] - 1 + j) * w + (b[i] - 1 + k);
				}
			}
		}
	}

	if (len != -1){
		sort(begin(c), begin(c) + len + 1);
	}
	flag = 1;
	for (i = 0; i < len + 1; i++){
		if (c[i] == c[i + 1]){
			flag = flag + 1;
		}
		else{
			ans[flag] += 1;
			flag = 1;
		}
	}

	ans[0] = (h - 2)*(w - 2) - ans[1] - ans[2] - ans[3] - ans[4] - ans[5] - ans[6] - ans[7] - ans[8] - ans[9];
	if (ans[0] <= 0){
		ans[0] = 0;
	}
	for (i = 0; i < 10; i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <vector>

using namespace std;

constexpr auto BASE = 1000000007;


class atcalc {

public:
	static int add(int a, int b)
	{
		return (int)(((long long)a + b) % BASE);
	}
	static int times(int a, int b)
	{
		return (int)(((long long)a * b) % BASE);
	}
	static int div(int a, int b)
	{
		return (int)(((long long)a * atcalc::modinv(b,BASE)) % BASE);
	}

	static int comb(int a, int b)
	{
		if (a < b) { return 0; }
		if (b > a / 2) { b = a - b; }
		if (b == 0) { return 1; }


		int ans = 1;
		for (int i = 0; i < b; i++) {
			ans = atcalc::times(ans, a-i);
		}
		for (int i = 0; i < b; i++) {
			ans = atcalc::div(ans, i+1);
		}


		return ans;
	}
	
	static int modinv(int a, int m)
	{

		long long x = 0, y = 1, gcd = m;
		long long  px = 1, py = 0, pgcd = a;
		long long temp = 0;

		while (gcd > 0)
		{
			long long quotient = pgcd / gcd;

			temp = x;
			x = px - quotient * temp;
			px = temp;

			temp = y;
			y = py - quotient * temp;
			py = temp;

			temp = gcd;
			gcd = pgcd - quotient * temp;
			pgcd = temp;
		}

		while (px < 0) {
			px += BASE;
		}
		return (int)px;
	}
};


int N,K;
vector<int> d;


int main()
{
	cin >> N;
	cin >> K;
	
	for (int i = 0; i < K; i++) {
		int tmp = atcalc::times(atcalc::comb(K-1,i),atcalc::comb(N-K+1,i+1));
		cout << tmp << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb     push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    priority_queue<int>pq;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
    }
    while(m!=0)
    {
        int tp=pq.top();
        pq.pop();
        tp/=2;
        pq.push(tp);
        m--;
    }
    int sum=0;
    while(!pq.empty())
    {
        sum+=pq.top();
        pq.pop();
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1912
import java.io.IOException;
import java.util.Scanner;
import java.lang.String;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
      Scanner sc = new Scanner(System.in);
     
      int d;
      String b;
      b="+";
      d=0;
      
      while(!b.equals("?")){
    	  int a = sc.nextInt();
          b = sc.next();
          int c = sc.nextInt();
      if(b.equals("+")){d=a+c;
      System.out.println(d);}
      else if (b.equals("-")){d=a-c;
      System.out.println(d);}
      else if (b.equals("*")){d=a*c;
      System.out.println(d);}
      else if (b.equals("/")){d=a/c;
      System.out.println(d);}
      else if (b.equals("?")){return;}
      }
	}

}

Measured memory_bytes: 26280
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $x = <STDIN>);

my $ans = length $x;
my ($sc, $tc);
for my $i (0..length($x)-1) {
  if (substr($x, $i, 1) eq 'S') {
    $sc++;
  } else {
    if ($sc > 0) {
      $ans -= 2;
      $sc--;
    }
  }
}
say $ans;

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    var (a, b, k) = readLine()!!.split(" ").map { it.toLong() }

    if (a >= k) {
        println("${a - k} $b")
    } else {
        k -= a
        b = if (k >= b) 0 else b - k
        println("0 $b")
    }
}

Measured memory_bytes: 37940
def sub():
  import sys
  input = sys.stdin.readline
  n = int(input())
  a1 = int(input())
  a = [a1]
  ap = a.append
  for _ in range(n-1):
    ai = int(input())
    if ai <= a[-1]:
      ap(ai)
    elif ai > a[0]:
      a[0] = ai
    else:
      h = 0
      l = len(a)-1
      while l-h>1:
        m = (l+h)//2
        if ai > a[m]:
          l = m
        else:
          h = m
      a[l] = ai
  print(len(a))   
sub()

Measured memory_bytes: 44764
def readinput():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    return (a,b,c,x)

def main(a,b,c,x): 
    result = []
    for na in range(a+1):
        residue = x - 500*na
        if (residue < 0):
            break
        for nb in range(b+1):
            residue = x - 500*na - 100*nb
            if(residue < 0):
                break
            nc = residue // 50
            if (nc > c):
                break
            result.append((na,nb,nc))
    return result

def main_(a,b,c,x): 
    result = []
    for na in range(a+1):
        residue = x - 500*na
        if (residue < 0):
            break
        for nb in range(b+1):
            residue = x - 500*na - 100*nb
            if(residue < 0):
                break
            nc = residue // 50
            if (nc > c):
                continue
            result.append((na,nb,nc))
    return result

def main2(a,b,c,x):
    result = []
    for na in range(a+1):
        for nb in range(b+1):
            for nc in range(c+1):
                if (500*na+100*nb+50*nc == x):
                    result.append((na,nb,nc))
                    break
    return result

def main3(a,b,c,x):
    result = []
    for na in range(a+1):
        for nb in range(b+1):
            res = x - na*500 - nb*100
            nc = res // 50
            if (0<= nc and nc <= c):
                result.append((na,nb,nc))
                continue
    return result

if __name__ == '__main__':
    a,b,c,x = readinput()
#    result=main(a,b,c,x)
    result=main_(a,b,c,x)
    for res in result:
        (na,nb,nc)=res
#        print(res)
#        print(na*500+nb*100+nc*50)
    print(len(result))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int N;
  cin >> N;
  bool flag = false;
  int rN = sqrt(N);
  for(int i = 1; i <= rN; i++){
    if(N % i == 0 && N / i <= 9 && N / i >= 1) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL x[100010];
LL y[100010];
LL ans;
int main()
{
    int N;
    LL X;
    scanf("%d %lld",&N,&X);
    for(int i=1;i<=N;i++){
        scanf("%lld",&x[i]);
    }
    x[N+1]=X;
    sort(x+1,x+N+2);
    for(int i=1;i<=N;i++){
        y[i]=x[i+1]-x[i];
    }
    ans=__gcd(y[1],y[2]);
    for(int i=3;i<=N;i++){
        ans=__gcd(ans,y[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int A , c , capital;
    A=0,c=0,capital=0;
    string s;
    cin>>s;
    if(s[0]=='A'){
        A++;
    }
    for(int i = 2 ;i<s.size()-1;i++){
        if(s[i]=='C'){c++;
        }
    }
    for (int i=0;i<s.size();i++)
    {
        if(isupper(s[i])){
            capital++;
        }
    }
    if (A==1&&capital==2&&c==1){
        cout<<"AC"<<endl;
    }else cout<<"WA"<<endl;}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int d[100010];
int x[100010], y[100010];
int ans[100010];
int main()
{
	int H, W, D;
	cin >> H >> W >> D;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int A; cin >> A;
			x[A] = i + 1;
			y[A] = j + 1;
		}
	}
	for (int i = 1; i <= D; i++) {
		d[i] = 0;
	}
	for (int i = 1 + D; i <= H * W; i++) {
		d[i] = d[i - D] + abs(x[i - D] - x[i]) + abs(y[i - D] - y[i]);
	}
	int Q; cin >> Q;
	//cout << d[5] <<" "<< d[8] << endl;
	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;
		ans[i] = d[R] - d[L];
		cout << ans[i] << endl;
	}
	for (int i = 0; i < Q; i++) {
		//cout << ans[i] << endl;
	}
}

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

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

  int n;
  vector<int> a(3);
  cin >> n >> a[0] >> a[1] >> a[2];
  sort(&a[0], &a[3]);

  deque<int> ll(n);
  for (int i = 0; i < n; ++i) {
    cin >> ll[i];
  }
  sort(ll.begin(), ll.end());
  uint64_t ans = INT_MAX;
  do {
    deque<int> l(ll);
    uint64_t local_ans = 0;
    for (int i = 0; i < 3; ++i) {
      vector<int> used;
      int min_diff = INT_MAX;
      do {
        for (int j = 1; j <= l.size(); ++j) {
          int sum = 0;
          for (int k = 0; k < j; ++k) {
            sum += l[k];
          }
          int diff = abs(a[i] - sum);
          diff += (j - 1) * 10;

          if (diff < min_diff) {
            min_diff = diff;
            used.clear();
            for (int k = 0; k < j; ++k) {
              used.emplace_back(l[k]);
            }
          }
          if (min_diff == 0) break;
        }
        if (min_diff == 0) break;
      } while (next_permutation(l.begin(), l.end()));
      for (int j = 0; j < used.size(); ++j) {
        for (auto it = l.begin(); it != l.end(); ++it) {
          if (*it == used[j]) {
            l.erase(it);
            break;
          }
        }
      }
      local_ans += min_diff;
    }
    ans = min(ans, local_ans);
  } while (next_permutation(a.begin(), a.end()));
  cout << ans << "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicode001
{
    class Program
    {
        static void Main()
        {
            Program pg = new Program();
            string word = Console.ReadLine();

            int a = word
                .Select((content, index) => new
                {
                    Index = index,
                    Content = content
                })
                .Where(x => x.Content == 'A')
                .Select(x => x.Index)
                .First();

            int z = word
                .Select((content, index) => new
                {
                    Index = index,
                    Content = content
                })
                .Where(x => x.Content == 'Z')
                .Select(x => x.Index)
                .Last();

            var new_word = word.Skip(a).Take(z - a + 1).Count();

            Console.WriteLine(new_word);
            //Console.WriteLine(z);

           

        }
    }
}


Measured memory_bytes: 7896
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  int pos = 0;
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (pos == 1) {
      cout << count << endl;
      return 0;
    }
    pos = a.at(pos) - 1;
    count++;
  }

  cout << -1 << endl;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sysp system("pause")
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 1

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;};
//}

int n,ans;
map<int,int> a;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int dis;
		cin>>dis;
		if(a.count(dis)==0){
			a.insert(mp(dis,1));
		}else{
			a[dis]++;
		}
	}
	for(auto ite=a.begin();ite!=a.end();ite++){
		ans+=(ite->second)%2;
	}
	cout<<ans<<endl;
	sysp;
}

Measured memory_bytes: 5120
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn is_prime(n: usize) -> bool {
    match n {
        0|1 => false,
        n => {
            (2..).take_while(|x| x * x <= n).all(|x| n % x != 0)
        }

    }
}

fn main() {
    let mut x = read::<usize>();

    
    loop {
        if is_prime(x) {
            println!("{}", x);
            break;
        }
        x += 1;
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int N,M;
int ans=0;
vector<int> connect[8];
int passed[8]={0};
int node=0;
int check(int n){
  passed[n]=1;
  node++;
  if(node==N){
    ans++;
  }
  for(int i=0;i<connect[n].size();i++){
    if(passed[connect[n][i]]==0){
      check(connect[n][i]);
    }
  }
  passed[n]=0;
  node--;
  return 0;
}

int main(){
  
  cin>>N>>M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    connect[a[i]-1].push_back(b[i]-1);
    connect[b[i]-1].push_back(a[i]-1);
  }
  check(0);
  cout<<ans<<endl;
  

  return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
  private static bool Check(int price, int[] source, int[] count)
  {
    return price == source[0] * count[0] + source[1] * count[1] + source[2] * count[2] +
      source[3] * count[3] +source[4] * count[4] +source[5] * count[5];
  }
  
  private static int Sum(int[] a)
  {
    int sum = 0;
    foreach(int n in a)
    {
      sum += n;
    }
    
    return sum;
  }
  
  public static void Main()
  {
    int[] P = new int[6]{100, 101, 102, 103, 104, 105};
    
    int price = int.Parse(Console.ReadLine());
    int count = (int)(price / 100) + 1;
    
    int[] c = new int[6]{0, 0, 0, 0, 0, 0};
    
    for(c[0] = 0; c[0] < count; c[0]++)
    {
      for(c[1] = 0; c[1] < count; c[1]++)
      {
        for(c[2] = 0; c[2] < count; c[2]++)
        {
          for(c[3] = 0; c[3] < count; c[3]++)
          {
            for(c[4] = 0; c[4] < count; c[4]++)
            {
              for(c[5] = 0; c[5] < count; c[5]++)
              {
                if(Check(price, P, c))
                {
                  Console.WriteLine(1);
                  return;
                }
              }
            }
          }
        }
      }
    }
    
    Console.WriteLine(0);
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

const int nmax = 1e5;
int n;
ll x[nmax], l[nmax];
pair <ll, ll > robo[nmax];

void solve() {
	rep(i, n) {
		robo[i].first = x[i] + l[i];
		robo[i].second = x[i] - l[i];
	}
	sort(robo, robo + n);
	ll ans = 0, t = -1e9 - 10;
	rep(i, n) {
		if (t <= robo[i].second) {
			ans++;
			t = robo[i].first;
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> l[i];
	}
	solve();
	return 0;
}


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

using ll = long long;
constexpr ll inf = 1e18;

int main() {
  int N, M, L;
  cin >> N >> M >> L;
  vector<ll> K(N), S(M);
  for(int i = 0; i < N; ++i) {
    cin >> K[i];
    K[i]--;
  }
  vector<ll> sum(M + 1);
  for(int i = 0; i < M; ++i) {
    cin >> S[i];
    sum[i + 1] = sum[i] + S[i];
  }
  sort(begin(K), end(K));
  vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, inf));
  dp[1][1] = 0;
  for(int i = 1; i < N; ++i) {
    for(int p1 = 1; p1 <= i; ++p1) {
      int p2 = i;
      if(dp[p1][p2] == inf) continue;
      ll c1 = (sum[K[i] + 1] - sum[K[p1 - 1]]) / L; // put left
      assert(c1 >= 0);
      dp[i + 1][p2] = min(dp[i + 1][p2], dp[p1][p2] + c1);
      ll c2 = (sum[K[i] + 1] - sum[K[p2 - 1]]) / L;
      assert(c2 >= 0);
      dp[p1][i + 1] = min(dp[p1][i + 1], dp[p1][p2] + c2);
    }
    for(int p2 = 1; p2 <= i; ++p2) {
      int p1 = i;
      if(dp[p1][p2] == inf) continue;
      ll c1 = (sum[K[i] + 1] - sum[K[p1 - 1]]) / L;
      assert(c1 >= 0);
      dp[i + 1][p2] = min(dp[i + 1][p2], dp[p1][p2] + c1);
      ll c2 = (sum[K[i] + 1] - sum[K[p2 - 1]]) / L;
      assert(c2 >= 0);
      dp[p1][i + 1] = min(dp[p1][i + 1], dp[p1][p2] + c2);
    }
  }

  ll ans = inf;
  for(int i = 1; i < N; ++i) {
    if(dp[N][i] == inf) continue;
    ans = min(ans, dp[N][i] + (sum[K[N - 1] + 1] - sum[K[i - 1]]) / L);
    assert(sum[K[N - 1] + 1] - sum[K[i - 1]] >= 0);
  }
  cout << ans << endl;
}



Measured memory_bytes: 35888
import java.util.*;

class Reader {
  Scanner sc = new Scanner(System.in);

  public int ini() {
    return sc.nextInt();
  }

  public int[] vi(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    return a;
  }
}

public class Main extends Reader {
  public static void main(String[] args) {
    Main main = new Main();
    main.show(main.solve());
  }

  int n;
  int l;

  public Main() {
    n = ini();
    l = ini();
  }
  
  int solve() {
    int left = l;
    int right = l + n - 1;

    if (0 < left) {
      return calc(left + 1, right);
    } else if (right < 0) {
      return calc(left, right - 1);
    } else {
      return calc(left, right);
    }
  }

  int calc(int left, int right) {
    int ans = 0;
    for (int i = left; i <= right; i++) {
      ans += i;
    }
    return ans;
  }

  void show(int ans) {
    System.out.println(ans);
  }
}




Measured memory_bytes: 35792
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;

int ary[100010];
int main(){
	priority_queue<pair<int,int> > que;
	int N,L,tim,hog;
	pair<int,int> pa;
	set<int> se;
	set<int>::iterator it;
	cin>>N>>L;
	for(int i=1;i<=N;i++){
		cin>>ary[i];
	}
	ary[0]=ary[N+1]=0;
	for(int i=1;i<=N;i++){
		if(ary[i-1]<ary[i]&&ary[i+1]<ary[i]){
			que.push(make_pair(ary[i],i));
		}
	}
	tim=0;
	while(!que.empty()){
		se.clear();
		pa=que.top();
		que.pop();
		tim=L-pa.first;
		ary[pa.second]=0;
		se.insert(pa.second-1);
		se.insert(pa.second+1);
		while(!que.empty()&&que.top().first==pa.first){
			ary[que.top().second]=0;
			se.insert(que.top().second-1);
			se.insert(que.top().second+1);
			que.pop();
		}
		for(it=se.begin();it!=se.end();it++){
			hog=(*it);
			if(hog>0&&hog<N+1&&ary[hog-1]<ary[hog]&&ary[hog+1]<ary[hog]){
				que.push(make_pair(ary[hog]-tim,hog));
			}
		}
	}
	cout<<tim<<endl;
	return 0;
}

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

int rec(string s,char a){
  
  int f=1;
  for(int i=1;i<s.size();i++){
    if(s[i]!=s[i-1])f=0;
  }
  if(f)return s.size();
  
  for(int i=0;i<s.size();i++){
    string t;
    int f=1;
    for(int i=0;i<s.size()-1;i++){
      if(s[i]==a||s[i+1]==a)t+=a;
      else {
	t+='.';
	f=0;
      }
    }
    s=t;
    if(f)return t.size();
  }
  return 1;
}

int main(){
  string s;
  cin>>s;
  int t=0;
  for(int i=0;i<s.size();i++){
    t=max(t,rec(s,s[i]));
  }
  cout<<s.size()-t<<endl;
  return 0;
}


Measured memory_bytes: 256
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

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

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	string s;
	cin >> s;
	
	int max = 0;
	for (int i = 0; i < s.size(); i++)
	{
		int counter = 0;
		for (int j = i; j < s.size(); j++)
		{
			if ((s[j] == 'A') || (s[j] == 'C') || (s[j] == 'G') || (s[j] == 'T'))
			{
				counter++;
				if (j == (s.size() - 1))
				{
					if (counter > max)
					{
						max = counter;
					}
				}
			}
			else
			{
				if (counter > max)
				{
					max = counter;
				}
				break;
			}
		}
	}
	
	cout << max << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3436
#include<iostream>
#include<vector>
using namespace std;
vector<pair<pair<int,int>,pair<int,int> > >ans;
int h,w;
int m[500][500];
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>m[i][j];
	for(int i=0;i<h-1;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(m[i][j]%2)
			{
				ans.push_back(make_pair(make_pair(i+1,j+1),make_pair(i+2,j+1)));
				m[i+1][j]++;
			}
		}
	}
	for(int j=0;j+1<w;j++)
	{
		if(m[h-1][j]%2)
		{
			ans.push_back(make_pair(make_pair(h,j+1),make_pair(h,j+2)));
			m[h-1][j+1]++;
		}
	}
	cout<<ans.size()<<endl;
	for(pair<pair<int,int>,pair<int,int> >p:ans)
	{
		cout<<p.first.first<<" "<<p.first.second<<" "<<p.second.first<<" "<<p.second.second<<endl;
	}
}


Measured memory_bytes: 5232
/*
   * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
   * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
   * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
   * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
   * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
         * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
         * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
   * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
   * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/
 
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)
#define sz(a) int((a).size())
#define shit while(t--)
#define fr for(int i=0;i<n;i++)
int maxo=1e9+7;
using namespace std;
int arr[95];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d,ans=-1000000000000000000;
    cin>>a>>b>>c>>d;
 
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,c*b);
    ans=max(ans,d*b);
 
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  string s;
  bool flag = true;
  cin >> s;
  
  Rep(i, s.size()/2) {
    if( s[i] == 'b' ) {
      if( s[s.size()-1-i] != 'd' ) flag = false;
    } else if( s[i] == 'd' ) {
      if( s[s.size()-1-i] != 'b' ) flag = false;
    } else if( s[i] == 'p' ) {
      if( s[s.size()-1-i] != 'q' ) flag = false;
    } else {
      if( s[s.size()-1-i] != 'p' ) flag = false;
    }
  }

  if( flag && !(s.size() % 2) ) cout << "Yes\n";
  else cout << "No\n";
  
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
int A,B,X;cin>>A>>B>>X;
if(A>X)
{
    cout<<"NO";
    return 0;
}
if(A==X)
{
    cout<<"YES";
    return 0;
}
if(A<X)
{
    if((A+B)>=X)
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
}
    return 0;
}



Measured memory_bytes: 256
from itertools import product
from operator import add, sub


def op_to_str(op):
  if op == add:
    return "+"
  else:
    return "-"


def main():
  a, b, c, d = map(int, input())
  
  op = (add, sub)
  for op1, op2, op3 in product(op, op, op):
    if op3(op2(op1(a, b), c), d) == 7:
      answer = (
        str(a) + op_to_str(op1)
      	+ str(b) + op_to_str(op2) 
        + str(c) + op_to_str(op3)
        + str(d) + "=7"
      )
      print(answer)
      break
      

if __name__ == "__main__":
  main()
  

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> b(N);
    rep(i, N) cin >> b[i];

    vector<ll> ans(N);
    rep(i, N) {
        bool flg = false;

        repr(j, SZ(b) - 1) {
            if (b[j] == j + 1) {
                flg = true;
                b.erase(b.begin() + j);
                ans[i] = j + 1;
                break;
            }
        }

        if (!flg) {
            cout << -1 << endl;
            return 0;
        }

        // repv(b) cout << *it << " ";
        // cout << endl;
    }

    reverse(ALL(ans));
    repv(ans) cout << *it << endl;

    return 0;
}

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

int main()
{
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> A;

    if (S != 1e9 && K != 0)
    {
        for (int i = 0; i < K; i++)
        {
            A.push_back(S);
        }

        for (int i = 0; i < N - K; i++)
        {
            A.push_back(S + 1);
        }
    }

    else if (S != 1e9)
    {
        for (int i = 0; i < N; i++)
        {
            A.push_back(S + 1);
        }
    }

    else if (K != 0)
    {
        for (int i = 0; i < K; i++)
        {
            A.push_back(S);
        }

        for (int i = 0; i < N - K; i++)
        {
            A.push_back(S - 1);
        }
    }

    else
    {
        for (int i = 0; i < N; i++)
        {
            A.push_back(S - 1);
        }
    }

    for (int x : A)
    {
        cout << x << " ";
    }
    cout << endl;
}

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

#define N 100

int n;
int f[N][10];
int p[N][11];

int main()
{
	int ans = INT32_MIN;

	cin >> n;
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < 10; j++ ) {
			cin >> f[i][j];
		}
	}
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < 11; j++ ) {
			cin >> p[i][j];
		}
	}

	for( int mask = 1; mask < (1 << 10); mask++ ) {
		int sum = 0;
		for( int i = 0; i < n; i++ ) {
			int cnt = 0;
			for( int j = 0; j < 10; j++ ) {
				if( mask & (1 << j) ) {
					if( f[i][j] != 0 ) {
						cnt++;
					}
				}
			}
			sum += p[i][cnt];
		}
		ans = max( ans, sum );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256