akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;


int N;
vector< vector <int> > w;

int dfs(int row, int col, int c){
  int n;
  n = w[row][col];
  if(col == N - 1 && row == 1){
    return n + c;
  }
  else if(col == N -1 && row == 0){
    return dfs(1, col, c+n);
  }
  else{
    if(row == 0){
      return max(dfs(0,col+1,n+c), dfs(1,col,n+c));
    }
    else{
      return dfs(1, col+1, n+c);
    }
  }
}

int main() {
  cin >> N;

  w.resize(2);
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      int k;
      cin >> k;
      w[i].push_back(k);
    }
  }

  cout << dfs(0,0,0) << endl;

    
  return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys

N = int(input())
A = [int(_) for _ in input().split()]

dict = defaultdict(int)
for n in range(N):
    dict[A[n]] += 1
    dict[A[n] + 1] += 1
    if A[n] - 1 >= 1:
        dict[A[n] - 1] += 1

count = sorted(dict.items(), key=lambda x: -x[1])
print(count[0][1])
#print(count)

"""A = Counter(sorted([int(_) for _ in input().split()])).items()
if N == 1:
    print(1)
    sys.exit()

A = list(A)
ans = 0
for n in range(1, len(A) - 1):
    tmp = A[n][1]
    if A[n - 1][0] + 1 == A[n][0]:
        tmp += A[n - 1][1]
    if A[n][0] + 1 == A[n + 1][0]:
        tmp += A[n + 1][1]
    ans = max(ans, tmp)
print(ans)
"""


Measured memory_bytes: 24524
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> x(n), y(n);
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	bool f = true;
	int o = (abs(x[0]) + abs(y[0])) % 2;
	for(int i = 1; i < n; i++){
		if((abs(x[i]) + abs(y[i])) % 2 != o){
			f = false;
			break;
		}
	}
	if(f){
		vector<long long> arm;
		if(o == 0) arm.push_back(1);
		for(int i = 0; i < 32; i++){
			arm.push_back(1LL << i);
		}
		cout << arm.size() << endl;
		for(int i = 0; i < arm.size(); i++){
			if(i < arm.size() - 1){
				cout << arm[i] << " ";
			}else{
				cout << arm[i] << endl;
			}
		}
		for(int i = 0; i < n; i++){
			long long a, b;
			a = x[i]; b = y[i];
			string s;
			for(int j = arm.size() - 1; j >= 0; j--){
				long long d = arm[j];
				if(abs(a) >= abs(b)){
					if(a >= 0){
						a -= d;
						s += "R";
					}else{
						a += d;
						s += "L";
					}
				}else{
					if(b >= 0){
						b -= d;
						s += "U";
					} else{
						b += d;
						s += "D";
					}
				}
			}
			reverse(s.begin(), s.end());
			cout << s << endl;
		}
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#define N 10002
using namespace std;
int eratos[N]; // [N]=0 -> N is prime
void createPrimeTable(){
	for(int i = 2; i < N; ++i){
		if( eratos[i] == 0 ){
			for(int j = 2; i * j < N; ++j){
				eratos[ i * j ] = 1;
			}
		}
	}
}
int main()
{
	createPrimeTable();
	while(true){
		int n;
		int p = 0;
		int q = 0;
		cin >> n;
		if( n == 0 ) break;
		for(int i = 3; i <= n - 2; ++i){
			if( eratos[ i ] == 0 && eratos[ i + 2 ] == 0 ){
				p = i;
				q = i + 2;
			}
		}
		cout << p << ' ' << q << '\n';
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
    int wa =0;
    int ac =0;
    int tle=0;
    int re =0;
    int n;
    string s;
    cin >>n;
    for(int  i=0;i<n;i++){
        cin >> s;
        if(s== "WA") wa+=1;
        if(s== "AC") ac+=1;
        if(s=="TLE") tle+=1;
        if(s== "RE") re+=1;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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


int main(){

    string S;
    cin >> S;
    for(int i=0;i<3;i++){
        if(S[i]==S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

ll ans = 10000000000ll;
ll k;
map<ll,ll> dp[50][5];

void solve(ll n,ll d,ll op){
    if(n == 0){
        ans = min(ans,d);
        return ;
    }
    if(dp[n][op].count(d) != 0){
        return ;
    }
    solve(n-1,d*2,0);
    solve(n-1,d+k,1);
    dp[n][op][d] = 1;
}

int main(){
    ll x;
    cin >> x >> k;
    solve(x,1,0);
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a[3];rep(i,3)cin>>a[i];
    sort(a,a+3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

typedef long long ll;
int main()
{
	ll n; cin >> n;
	map<ll,int> m;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			m[i]++;
			n /= i;
		}
	}
	if(n > 1) m[n]++;
	int ans = 0;
	for(auto it : m){
		int x = it.second;
		int p = 1;
		while(x-p >= 0){
			x -= p;
			p++;
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
char get(int x){
    if(x<10) return x+'0';
    else if(x<36) return x-10+'a';
    else return x-36+'A';
}
int main(){
    setprecision(20);
        double a,b,h,m;
        cin>>a>>b>>h>>m;
       double hour_angle = 0.5 * (h * 60.0 + m);  
    double minute_angle = 6.0 * m;  
    double angle = abs(hour_angle - minute_angle);  
    angle = min(360.0 - angle, angle);  
    double ans=(double)sqrt((a * a) + (b * b) - 2.0 * a * b * cos(angle * (3.14159265358979323 / 180.0)));
    cout<<fixed << std::setprecision(20)<<ans<<endl;
    return 0;
}

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

int N;
int a[100];
int Alice = 0;
int Bob = 0;

void quickSort_greater(int* array, int begin, int end);
void swap(int* a, int* b);

int main() {
	cin >> N;

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

	quickSort_greater(a, 0, N - 1);

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) Alice += a[i];
		else Bob += a[i];
	}

	cout << Alice - Bob << endl;


	return 0;
}

void quickSort_greater(int * array, int begin, int last)
{
	if (begin >= last) return;

	int pivot = array[begin];
	int lastindex = begin;

	for (int i = begin + 1; i <= last; i++) {
		if (array[i] > pivot) {
			lastindex++;
			swap(&array[lastindex], &array[i]);
		}
	}

	swap(&array[lastindex], &array[begin]);

	quickSort_greater(array, begin, lastindex);
	quickSort_greater(array, lastindex + 1, last);

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28
typedef pair<int,int> Pi;
#define F first
#define S second
#define pb push_back

inline void chmax(int &a, int b) { a = max(a,b); }
inline void chmin(int &a, int b) { a = min(a,b); }

int main()
{
  int N, M;
  while(cin >> N, N) {
    string s;
    cin >> M >> s;
    int cnt = -1, sum = 0;
    char save = 'N';
    Rep(i,M) {
      if(save != s[i] && ~cnt) {
	cnt++;
	if(cnt >= N * 2 + 1 && cnt % 2 == 1)sum++;
      }else cnt = -1;
      if(s[i] == 'I')chmax(cnt,1);
      save = s[i];
    }
    cout << sum << endl;
  }
  return 0;
}

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

using namespace std;
const int maxn = 200005;

struct P
{
    int i;
    int n;
    int p;
}num[maxn];

bool cmp(P a,P b)
{
    return a.n<b.n;
}

bool cmp1(P a,P b)
{
    return a.i<b.i;
}
void action(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i].n);
        num[i].i=i;
    }
    sort(num,num+n,cmp);
    int mid=n/2;
    for(int i=0;i<n;i++)
    {
        if(num[i].n<num[mid].n)
            num[i].p=num[mid].n;
        else
            num[i].p=num[mid-1].n;
    }
    sort(num,num+n,cmp1);
    for(int i=0;i<n;i++)
        printf("%d\n",num[i].p);
}
int main()
{
    action();
    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    double dist = sqrt(x * x + y * y);
    if (dist <= d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> dig(n+1, -1);

    // 桁を入力
    bool can = true;
    for (size_t i = 0; i < m; i++)
    {
        int si , ci;
        cin >> si >> ci;

        // 既に入力された数値と違う
        if (dig[si] != -1 && dig[si] != ci) {
            can = false;
        }
        // 1 桁目が 0 である．
        if (si == 1 && ci == 0 && n != 1) {
            can = false;
        }
        // 桁に数字をセットする
        dig[si] = ci;
    }

    // 数値を計算する
    if (can == false) {
        cout << -1 << endl;
    } else {
        int res = 0;
        for (size_t i = 1; i <= n; i++)
        {
            if (dig[1] == -1 && i == 1 && n != 1) {
                res += pow(10, (n-1));
            } else if (dig[i] != -1) {
                res += pow(10, (n-i)) * dig[i];
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = map(int, input().split())
l = [0 for i in range(9)]

for i in a:
    if i // 400 >= 8:
        l[8] += 1
    else:
        l[i // 400] = 1
print(max(1, sum(l[:8])), sum(l))


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
A.sort()
M = max(A)
B = [0] * (M + 1)

for a in A:
    B[a] += 1

for a in A:
    if B[a] > 0:
        i = 2
        b = a * i
        while b <= M:
            B[b] = 0
            i += 1
            b = a * i
for i in range(M + 1):
    if B[i] > 1:
        B[i] = 0
print(sum(B))

Measured memory_bytes: 32256
N, M = gets.chomp.split.map(&:to_i)

paths = {}

M.times do
  a, b = gets.chomp.split.map(&:to_i).sort

  if a == 1
    if paths[b]
      puts "POSSIBLE"
      exit
    else
      paths[b] = true
    end
  elsif b == N
    if paths[a]
      puts "POSSIBLE"
      exit
    else
      paths[a] = true
    end
  end
end

puts 'IMPOSSIBLE'



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int mod = 1000000007;

int main() {
    int D, T, S;
    cin >> D >> T >> S;

    if (S * T < D) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

ll f(ll i) {
    ll ret = (i/3)*4 + (i/5)*4;
    ll l = 1, r, keta = 1;
    while (l <= i) {
        r = min(l*10-1, i);
        ret += keta * ((r-l+1) - (r/3-(l-1)/3) - (r/5-(l-1)/5) + (r/15-(l-1)/15));
        l *= 10;
        keta ++;
    }
    return ret;
}

int main() {
    ll s;
    cin >> s;
    
    ll l = 0; // short
    ll r = 1e18; // long
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (s <= f(mid)) r = mid;
        else l = mid;
    }
    ll i = r;
    ll k = s-f(l)+19;
    stringstream ss;
    while ((int)ss.str().size() < k) {
        if (i % 15 == 0) ss << "FizzBuzz";
        else if (i % 5 == 0) ss << "Buzz";
        else if (i % 3 == 0) ss << "Fizz";
        else ss << i;
        i ++;
    }
    cout << ss.str().substr(k-20, 20) << endl;

    return 0;
}


Measured memory_bytes: 3220
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

gcdl = [1]*N
gcdl[0] = A[0]

gcdr = [1]*N
gcdr[-1] = A[-1]

for i in range(1, N):
    gcdl[i] = gcd(gcdl[i-1], A[i])
    gcdr[N-i-1] = gcd(gcdr[N-i], A[N-i-1])

res = max(gcdl[N-2], gcdr[1])

for i in range(1, N-1):
    res = max(gcd(gcdl[i-1], gcdr[i+1]), res)

print(res)

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

using namespace std;

#define ll long long

int main()
{
	int A, B, Q;
	cin >> A >> B >> Q;

	vector < ll > s(A);
	vector < ll > t(B);
	vector < ll > x(Q);

	for (int i = 0; i < A; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < Q; i++) {
		ll sl, sr, tl, tr;
		sl = -1;
		sr = A;
		tl = -1;
		tr = B;

		while (sr - sl > 1) {
			int mid = (sl + sr) / 2;
			if (s[mid] > x[i]) {
				sr = mid;
			} else {
				sl = mid;
			}
		}
		while (tr - tl > 1) {
			int mid = (tr + tl) / 2;
			if (t[mid] > x[i]) {
				tr = mid;
			} else {
				tl = mid;
			}
		}

		ll ans = LLONG_MAX;
		if (sl >= 0 && tl >= 0) {
			ans = min(ans, max(x[i] - t[tl], x[i] - s[sl]));
		}
		if (sr < A && tr < B) {
			ans = min(ans, max(t[tr] - x[i], s[sr] - x[i]));
		}
		if (sl >= 0 && tr < B) {
			ans = min(ans, (x[i] - s[sl]) * 2 + t[tr] - x[i]);
			ans = min(ans, (t[tr] - x[i]) * 2 + x[i] - s[sl]);
		}
		if (sr < A && tl >= 0) {
			ans = min(ans, (x[i] - t[tl]) * 2 + s[sr] - x[i]);
			ans = min(ans, (s[sr] - x[i]) * 2 + x[i] - t[tl]);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N  100005
#define pi acos(-1)
using namespace std;

int a[N];

int main()
{
__

int n,ans=0;

cin >> n ;

for(int i=0;i<n;i++) cin >> a[i];

for(int v=0,curr=a[n-1],i=n-2;i>=0;i--)
{

if(a[i]>=curr) v++;

else{
ans = max(ans,v);
v=0;
}

if(i==0) ans = max(ans,v);

curr = a[i];

}

cout << ans << '\n';

return 0;
}

Measured memory_bytes: 640
function main(input) {
  const args = input.split('\n');
  let ary1 = args[0].split(' ').map(n => parseInt(n, 10));
  const N = ary1[0];
  const L = ary1[1];
  let ary = [];
  let ans;
  
  for (let i = 1; i < args.length; i++) {
    a = args[i].split(' ').map(n => parseInt(n, 10));
    if (a[1] <= L) {
      ary.push(a);
    }
  }
  
  for (let i = 0; i < ary.length; i++) {
    if (!ans || ary[i][0] < ans) {
      ans = ary[i][0];
    }
  }
  
  if (!ans) {
    console.log('TLE');
  } else {
    console.log(ans);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29556
//#include "bits/stdc++.h"
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	int N = 0;
	cin >> N;
	int a = sqrt(N);
	int u = 0;
	for (int i = 0; i <= a; i++)
	{
		if (i *i <= N)
		{
			u = i * i;
		}
	}
	std::cout << u << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a=a-1;
        b=b-1;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B;
    cin >> A >> B;
    cout << max(0LL, A - 2 * B) << '\n';
}

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


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)

using namespace std;
int solve()
{	
	int a,b;
	cin>>a>>b;
	int strip=1;
	int cnt=0;
	while(strip<b){
		--strip;
		strip+=a;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            
            return false;
        }
    }
    return true;
}

int main(){
	static bool prime[100002];
	int Q; SCD(Q);
	
	FORq(i,2,100000){
		if (IsPrime(i)) prime[i] = true;
	}
	
	int Sprime[100002];
	Sprime[0] = 0; Sprime[1] = 0; Sprime[2] = 0;
	
	FORq(i,3,100000){
		if ((prime[i]) and (prime[(i+1)/2])){
			Sprime[i] = Sprime[i-1] + 1;
		}else{
			Sprime[i] = Sprime[i-1];
		}
	}
	
	REP(i,Q){
		int l,r; SCD2(l,r);
		PRINTD(Sprime[r] - Sprime[l-1]);
	}
	

	return 0;
}


Measured memory_bytes: 1152
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,arr[200005],sum=0,cnt[200005]={0},a,b,q;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
        cnt[arr[i]]++;
    }
    cin>>q;
    while(q--)
    {
        cin>>a>>b;

        sum=sum+cnt[a]*(b-a);

         cnt[b]+=cnt[a];
        cnt[a]=0;

        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 5944
N = int(input())
count = 0
flg = False
for i in range(N):
    
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count ==3:
            flg = True
    else:
        count = 0
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll M = 1000000000;
ll n, p[20005];
ll a[20005], b[20005];
ll ans1[200005];
ll ans2[200005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &p[i]);
        a[i] = i;
        b[i] = M - i + 1;
    }
    for(ll i = 1; i <= n; i++)
    {
        ans1[p[i]] += i - 1;
        ans2[p[i] + 1] -= i - 1;
    }
    for(ll i = 1; i <= n; i++)
    {
        ans1[i] += ans1[i - 1];
        ans2[i] += ans2[i - 1];
        a[i] += ans1[i];
        b[i] += ans2[i];
    }
    for(ll i = 1; i <= n; i++)
    {
        printf("%lld ", a[i]);
    }
    puts("");
    for(ll i = 1; i <= n; i++)
    {
        printf("%lld ", b[i]);
    }
    return 0;
}


Measured memory_bytes: 1408
// CODE by Kazhybay Askar

//#include <ext/pb_ds/assoc_cont ainer.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC    optimize("Ofast")
//#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a,b,c,d;

void solve(){
    cin>>n>>a>>b>>c>>d;
    if(abs(a-b)>(n-1)*d){
        cout<<"NO";
        return;
    }
    for(int i=1;i<=n;i++){
        ll x=n-i-1;
        if(a+d*i - c*x>=b && a+c*i-d*x<=b){
            cout<<"YES";
            return ;
        }
    }
    cout<<"NO";
}



int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		
		for(int i=0; i<values.length; i++){
			values[i] = i+1;
		}
		
		for (int i=0; i<n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0])-1;
			int b = Integer.parseInt(ab[1])-1;
			
			int z=values[a];
			values[a]=values[b];
			values[b]=z;
		}
		for(int i=0; i<values.length; i++){
			System.out.println(values[i]);
		}
		
	}
}

Measured memory_bytes: 26112
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var a = int.Parse(list[0]);
        var p = int.Parse(list[1]);

        Console.WriteLine((a * 3 + p) / 2);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int n;	string s;	cin >> n >> s;
  	string x = "ABC";
  	int cnt = 0;
  	rep(i,n-2){
    	if(s.substr(i,3) == x) cnt++;
    }
  	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

class P{
public:
  int cost;
  vector<int> v,pos,gap;

  P(){}
  P(int _cost,vector<int> _v,vector<int> _pos,vector<int> _gap){
    cost = _cost;
    v = _v;
    pos = _pos;
    gap = _gap;
  }

  bool goal(){
    rep(i,4){
      rep(j,7){
        int idx = i * 8 + j;
        if(v[idx] / 10 != i + 1 || v[idx] % 10 != j + 1) return false;
      }
    }
    return true;
  }
};

int bfs(P start){
  queue<P> open;
  set<vector<int> > closed;
  open.push(start);
  closed.insert(start.v);

  while(!open.empty()){
    P p = open.front(); open.pop();

    if(p.goal()){
      return p.cost;
    }

    rep(i,4){
      vector<int> nv = p.v;
      vector<int> npos = p.pos;
      vector<int> ngap = p.gap;
      int idx = ngap[i];
      int val = nv[idx-1] + 1;
      if(npos[val] == 0) continue;

      nv[idx] = val;
      nv[npos[val]] = 0;
      ngap[i] = npos[val];
      npos[val] = idx;

      if(closed.find(nv) != closed.end()) continue;
      closed.insert(nv);
      open.push(P(p.cost+1,nv,npos,ngap));
    }
  }

  return -1;
}

int main(void){
  int T;
  scanf("%d",&T);

  while(T--){
    vector<int> v(32);
    vector<int> pos(50);
    vector<int> gap;

    rep(i,4){
      rep(j,7){
        int idx = i * 8 + j + 1;
        scanf("%d",&v[idx]);
        if(v[idx] % 10 == 1){
          int row = v[idx] / 10 - 1;
          v[row*8] = v[idx];
          v[idx] = 0;
          gap.push_back(idx);
        }
        else{
          pos[v[idx]] = idx;
        }
      }
    }

    printf("%d\n",bfs(P(0,v,pos,gap)));
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll w, h, n, ans = 0; cin >> w >> h >> n;
    ll a1 = -1, a2 = INF, a3 = -1, a4 = INF;
    rep(i, n){
        ll x, y, a; cin >> x >> y >> a;
        if(a == 1) chmax(a1, x);
        if(a == 2) chmin(a2, x);
        if(a == 3) chmax(a3, y);
        if(a == 4) chmin(a4, y);
    }
    rep(i, h){
        if(i < a3 || i >= a4) continue;
        rep(j, w){
            if(j >= a1 && j < a2) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
// i will show you da wae
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fill(x,v) memset(x,v,sizeof(x))
#define FOR(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int manh(int a, int b, int c, int d){
	return abs(a-c) + abs(b-d);
}

int main(){
	    
	int n,t,a,b;
	int x = 0, y = 0, prevt = 0;
	cin >> n;
	FOR(i,0,n){
		cin >> t >> a >> b;
		int dist = manh(x,y,a,b);
		int dif = t - dist - prevt;
		x = a, y = b, prevt = t;
		if(!(dif >= 0 and ((dif%2) == 0) )){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W;char S[52][52];int dist[52][52],check[52][52];
deque<pair<int,int>> task;
const int INF=2500;int direct[8]={-1,0,1,0,0,-1,0,1};
int a,b,c,d;
void bfs(){
    while(task.size()>0){
        a=task.front().first;
        b=task.front().second;
        for(int i=0;i<4;i++){
            c=a+direct[i];
            d=b+direct[i+4];
            if(S[c][d]=='.'&&check[c][d]==0){
                task.push_back(make_pair(c,d));
                dist[c][d]=dist[a][b]+1;
                check[c][d]++;
            }
        }task.pop_front();
    }return;
}
int main(){
    cin>>H>>W;
    int count=0;
    for(int i=0;i<=W+1;i++){
        S[0][i]='#';
    }for(int i=1;i<=H;i++){
        S[i][0]='#';
        for(int j=1;j<=W;j++){
            cin>>S[i][j];
            dist[i][j]=INF;
            check[i][j]=0;
            if(S[i][j]=='.'){
                count++;
            }
        }S[i][W+1]='#';
    }for(int i=0;i<=W+1;i++){
        S[H+1][i]='#';
    }task.push_back(make_pair(1,1));
    dist[1][1]=1;
    check[1][1]=1;
    bfs();
    if(dist[H][W]!=INF){
        cout<<count-dist[H][W]<<endl;
    }else{
        cout<<-1<<endl;
    }
}

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

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

int main(){
  int a,b;
  double h;
  scanf("%d %d",&a,&b);
  while(a<1&&a>pow(h,9.0)&&b<1&&b>pow(h,9.0)){
    scanf("%d %d",&a,&b);
  }
  printf("%d\n",cal(a,b));

  return 0;
}





Measured memory_bytes: 2120
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Dubious Document 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

inline bool match(string &s, string &t, int i) {
  for (int j = 0; j < t.size(); i++, j++)
    if (s[i] != '?' && s[i] != t[j]) return false;
  return true;
}

/* main */

int main() {
  string s, t;
  cin >> s >> t;

  for (int k = s.size() - t.size(); k >= 0; k--)
    if (match(s, t, k)) {
      string w(s);
      for (int i = 0; i < w.size(); i++)
	if (w[i] == '?')
	  w[i] = (i >= k && i < k + t.size()) ? t[i - k] : 'a';
      puts(w.c_str());
      return 0;
    }

  puts("UNRESTORABLE");
  return 0;
}


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

#define ll long long
#define mx  205
#define mod 1000000009
#define lim 10000000
#define inf 1e9
#define N 18
using namespace std;
int d[mx];

int main(){
	ios_base::sync_with_stdio(false);
     memset(d,0,sizeof(d));

     for(int i=1;i<=mx-5;i++)
	{
		for(int j=i;j<=mx-5;j+=i)
		{
		   d[j]++;
		}
	}

	int n,ans=0;
	cin>>n;

	for(int i=1;i<=n;i+=2)
	    if(d[i]==8)
	      ans++;
	cout<<ans<<"\n";


     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, count=0;
    string s;
    char c, last_char;
    cin >> n >> s;
    
    for(int i=0; i<n; i++){
        c = s[i];
        
        if (last_char!= c) {
            count++;
        }
        
        last_char = c;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    ll N ,M ,K; cin >> N >> M >> K;

    ll ans = 0;
    rep(i, K + 1){
      ans += ( M * modpow(M - 1 , N - (i + 1) , MOD) % MOD ) * COM(N - 1, i) % MOD;
      ans %= MOD;
    }
    cout << ans << endl;
  	return 0;
}


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

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

using ll = long long;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll pr(ll x){//因数の個数を返す
  vector<ll> v;
  ll y = x;
  for(ll i = 2LL;i*i<=x;i++) {
    if(y%i==0LL){
      ll z = 0LL;
      while(y%i==0LL){
        y/=i;
        z++;
      }
      v.push_back(z);
    }
  }
  if(y!=1LL) v.push_back(1LL);
  ll cnt = 1LL;
  for(auto t:v){
    cnt*=(t+1);
  }
  return cnt;
}

int main() {
  ll N,M;
  cin>>N>>M;
  ll t = M;
  if(pr(M)!=2LL){
    for(ll i = N; i <= M;i++) {
      if(M%i==0LL){
        t=i;
        break;
      }
    }
  }
  cout<<M/t<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int X;
	cin>>X;
	if(X%7==0){
		cout<<"thu"<<endl;
	}else if(X%7==1){
		cout<<"fri"<<endl;
	}else if(X%7==2){
		cout<<"sat"<<endl;
	}else if(X%7==3){
		cout<<"sun"<<endl;
	}else if(X%7==4){
		cout<<"mon"<<endl;
	}else if(X%7==5){
		cout<<"tue"<<endl;
	}else{
		cout<<"wed"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

//四方向への移動ベクトル
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> s(H);
  bool check = true;
  for (int i = 0; i < H; i++) cin >> s[i];
  for (int i = 0; i<H; i++){
      for(int j=0; j<W; j++){
        if (s[i][j] == '.') continue;
        bool next = false;
        for (int idx = 0; idx < 4; idx++) {
          ll next_x = j + dx[idx];
          ll next_y = i + dy[idx];
          if (next_y < 0 || next_y >= H || next_x < 0 || next_x >= W) continue;
          if (s[i][j] == s[next_y][next_x] && s[i][j] == '#') {
            next = true;
          }
        }
        if (!next) check = false;
      }
  }
  if (check) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        S = sc.next();
    }
    
    //解答処理
    String solve() {
        String[] s = S.split("");
        int A = Integer.parseInt(s[0]);
        int B = Integer.parseInt(s[1]);
        int C = Integer.parseInt(s[2]);
        int D = Integer.parseInt(s[3]);
        
        String op1 = null;
        String op2 = null;
        String op3 = null;
        
        if (A+B+C+D == 7){
            op1 = "+"; op2 = "+"; op3 = "+";
        } else if (A-B+C+D == 7){
            op1 = "-"; op2 = "+"; op3 = "+";
        } else if (A+B-C+D == 7){
            op1 = "+"; op2 = "-"; op3 = "+";
        } else if (A+B+C-D == 7){
            op1 = "+"; op2 = "+"; op3 = "-";
        } else if (A-B+C-D == 7){
            op1 = "-"; op2 = "+"; op3 = "-";
        } else if (A+B-C-D == 7){
            op1 = "+"; op2 = "-"; op3 = "-";
        } else if (A-B-C+D == 7){
            op1 = "-"; op2 = "-"; op3 = "+";
        } else if (A-B-C-D == 7){
            op1 = "-"; op2 = "-"; op3 = "-";
        }
        
        
        String f = A + op1 + B + op2 + C + op3 + D + "=7";
        return f;
    }
    
    //出力
    void show(String answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 41532
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	while (true) {
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		int res = 0;
		FOR(i, 1, n - 1) {
			FOR(j, i + 1, n) {
				FOR(k, j + 1, n + 1) {
					if (i + j + k == x) ++res;
				}
			}
		}
		cout << res << endl;
	}

	return 0;
}



Measured memory_bytes: 3128
n,k = map(int,input().split())
v=list(map(int,input().split()))
kaisuu = min(n,k)
res = 0
for i in range(kaisuu+1):
    for j in range(kaisuu-i+1):
        tres = v[:i]+v[n-j:]
        tres.sort(reverse=True)
        for l in range(k-i-j):
            if not tres: break
            if tres[-1] < 0:
                tres.pop()
            else:break
        res = max(res,sum(tres))

print(res)

Measured memory_bytes: 41196
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

class UnionFind {
public:
  UnionFind(int size) : size(size) {

    par = vector<int>(size, -1);
  }

  int GetRoot(int v) {
    int root = v;
    while (par[root] >= 0) {
      root = par[root];
    }
    if (root != v) {
      par[v] = root;
    }
    return root;
  }

  bool IsUnion(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    return ra == rb && ra >= 0;
  }

  int GetUnionSize(int a) {
    return -par[GetRoot(a)];
  }

  void Unite(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    if (ra == rb) return;

    if (GetUnionSize(ra) > GetUnionSize(rb)) {
      par[ra] += par[rb];
      par[rb] = ra;
    }
    else {
      par[rb] += par[ra];
      par[ra] = rb;
    }
  }

protected:

  // 親がいれば、親のindexを入れる
  // 親がいなければ、グループのサイズを負にして入れておく（一人なら-1）
  vector<int> par;

  int size;
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  UnionFind uf(N);

  // x/yいずれかが一致する点ごとをグループ化していく

  vector<pair<int, int>> ps(N);
  // x/yの座標と、そのx/y座標にある点のうちいずれかのindex
  unordered_map<int,int> xs, ys;
  F0R(i, N) {
    int x, y;
    cin >> x >> y;
    ps[i] = { x,y };
    
    auto it = xs.find(x);
    if (it == xs.end()) {
      xs[x] = i;
    }
    else {
      uf.Unite(it->second, i);
    }

    it = ys.find(y);
    if (it == ys.end()) {
      ys[y] = i;
    }
    else {
      uf.Unite(it->second, i);
    }
  }

  // グループごとの、x/yの座標
  unordered_map<int, set<int>> rxs, rys;

  // グループごとの点の数
  unordered_map<int, int> cs;

  F0R(i, N) {
    int r = uf.GetRoot(i);
    cs[r]++;
    rxs[r].insert(ps[i].first);
    rys[r].insert(ps[i].second);
  }

  i64 result = 0;
  for (auto p : cs) {
    result += rxs[p.first].size() * rys[p.first].size() - p.second;
  }

  cout << result;
}
#endif


Measured memory_bytes: 13228
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int a,p;
		cin>>a>>p;
		ll int tmp=3*a+p;
		cout<<tmp/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int n;
  int b, f, r, v;
  int i, j, k;
 
  int tenants[4][3][10] = {{{}}};
 
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenants[b-1][f-1][r-1] += v;
  }
 
  for(i = 0; i < 4; ++i) {
    for(j = 0; j < 3; ++j) {
      for(k = 0; k < 10; ++k) {
    printf(" %d", tenants[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3) printf("####################\n");
  }
 
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cmath>
#define INF 1e9
using namespace std;

typedef struct data{
  int f, p, a, t, x, y;
}data;

double Dist(int x, int y){
  return sqrt(x*x + y*y);
}

double flame(int current, int prev){
  return (double)(current - prev)/60;
}

int main(int argc, char *argv[]){
  int n;
  double T[2] = {INF, INF}, dist[2] = {0};
  cin >> n;
  data d[n];
  for (int i = 0; i < n; i++) {
    cin >> d[i].f >> d[i].a >> d[i].t >> d[i].x >> d[i].y;
  }
  for (int i = 1; i < n; i++) {
    if(d[i - 1].t != d[i].t)continue;
    if(d[i - 1].a == d[i].a)continue;
    if(dist[d[i].t] < Dist(d[i].x - d[i - 1].x, d[i].y - d[i - 1].y)){
      T[d[i].t] = flame(d[i].f, d[i - 1].f);
      dist[d[i].t] = Dist(d[i].x - d[i - 1].x, d[i].y - d[i - 1].y);
    }else if(dist[d[i].t] == Dist(d[i].x - d[i - 1].x, d[i].y - d[i - 1].y)){
      T[d[i].t] = min(flame(d[i].f, d[i - 1].f), T[d[i].t]);
    }
  }
  for (int i = 0; i < 2; i++) {
    if(dist[i] != 0){
      printf("%lf %lf\n", dist[i], T[i]);
    }else{
      std::cout << -1 << " " << -1 << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<u32>().ok().unwrap());
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    println!("{}", a * b);
}


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

int main()
{
    int N;

    while ( cin >> N, N != 0 ) {
        for ( int i = 0; i < N; i++ ) {
            int a, b, c;
            cin >> a >> b >> c;
            if ( a + b + c >= 240 || a + b >= 180 || a == 100 || b == 100 || c == 100 ) {
                cout << "A" << endl;
            } else if ( a + b + c >= 210 || (a + b + c >= 150 && (a >= 80 || b >= 80)) ) {
                cout << "B" << endl;
            } else {
                cout << "C" << endl;
            }
        }
    }
    return ( 0 );
}



Measured memory_bytes: 3012