akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> rates(9, 0);

  for (auto i = 0; i < N; i++) {
    ll x;
    cin >> x;
    ll rate = 8;
    for (auto j = 0; j < 8; j++) {
      if (j * 400 <= x && x < (j+1) * 400) {
        rate = j;
        break;
      }
    }
    rates[rate]++;
  }

  ll n = 0;
  ll c = rates[8];
  for (auto i = 0; i < 8; i++) {
    if (rates[i] > 0) n++;
  }
//  cout << "n=" << n << " c=" << c << endl;
  cout << max(1LL, n) << " " << n + c << endl;

//  ll minv = 0;
//  ll maxv = 0;
//  for (auto i = 0; i < 8; i++) {
//    if (rates[i] == 0 && rates[8] > 0) {
//      maxv++;
//      rates[8]--;
//    } else if (rates[i] > 0) {
//      minv++;
//      maxv++;
//    }
//  }
//
//  cout << (minv == 0 ? 1 : minv) << " " << maxv << endl;

  return 0;
}


Measured memory_bytes: 256
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

int cost[100007][6];
int dp[6][100007];
int n;
int calc(int op, int day){

	if(day > n)
		return 0;

	if(op == 0)
		return max({calc(1, day + 1), calc(2, day + 1), calc(3, day + 1)});

	if(dp[op][day] != -1)
		return dp[op][day];

	bool options[4];
	memset(options, false, sizeof(options));
	options[op] = true;

	int ans = INT_MIN;
	for(int i = 1; i < 4; i++){
		if(options[i] == false)
			ans = max(ans, calc(i, day + 1));
	}

	return dp[op][day] = cost[day - 1][op-1] + ans;

}

signed main() {
 
	crap;

	cin >> n; // n days

	for (int i = 0; i < n; ++i){
		for (int j = 0; j < 3; ++j){
			cin >> cost[i][j];
		}
	}

	memset(dp, -1, sizeof(dp));
	cout << calc(0, 0) << endl;


	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0;
vl flag, color; vll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; 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;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int main() {
	cin >> N >> M >> K;
	COMinit(N * M + 1);
	ll count = COM(N * M - 2, K - 2);
	debug(count);
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			ll sum1 = (i * (i + 1) / 2 + (N - i - 1) * (N - i) / 2) * M;
			ll sum2 = (j * (j + 1) / 2 + (M - j - 1) * (M - j) / 2) * N;
			ll sum = (sum1 + sum2) % MOD;
			//debug(sum); 
			ans = (ans + sum * count) % MOD;
		}
	}
	//cout << ans << endl;
	cout << (ans * modinv(2, MOD)) % MOD;
}


Measured memory_bytes: 4992
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/4/ITP2_4_D
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> A(n);
    for (auto &x : A)
    {
        std::cin >> x;
    }

    auto itr_end = std::unique(A.begin(), A.end());

    for (auto itr = A.begin(); itr != itr_end; itr++)
    {
        std::cout << *itr;
        if (itr + 1 != itr_end)
        {
            std::cout << " ";
        }
    }
    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 3100
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		int b = in[a-1];
        System.out.println(b);
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    private static final String SUNNY = "Sunny";
    private static final String CLOUDY = "Cloudy";
    private static final String RAINY = "Rainy";

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if (A > 9 || B > 9) {
            System.out.println("-1");
        } else {
            System.out.println(A * B);
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,s;
bool f(int b){
    int ans = 0;
    int cur = n;
    while (cur){
        ans += cur%b;
        cur /= b;
    }
    return ans == s;

}
main(){
    scanf("%lld%lld",&n,&s);
    if (s == n){
        printf("%lld",n+1); return 0;
    }
    if (s > n){
        printf("-1\n");
        return 0;
    }
    for (int i = 2; i*i <= n; i++){
        if (f(i)){
            printf("%lld",i);
            return 0;
        }
    }
    for (int i = 2; i*i <= n; i++){
        if (f(i)){
            printf("%lld",i);
            return 0;
        }
    }
    int ans = -1;
    for (int i = 1; i*i <= n; i++){
        if ((n-s)%i == 0){
            int k = (n-s)/i + 1;
            if (f(k)){
                if (ans == -1 || ans > k) ans = k;
            }
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int N;
  cin >> N;
  map<int,int> cnt;
  int a;
  for(int i = 0; i < N; i++){
    cin >> a;
    cnt[a] ++;
  }
  int ans = 0;
  for(auto iter = begin(cnt); iter != end(cnt); iter++) {
    if((*iter).second % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;

void dfs(ll n, pair<double,double> p1, pair<double,double> p2)
{

    if(n == 0){
        return;
    }

    pair<double,double> s;
    pair<double,double> t;
    pair<double,double> u;
    
    s.first = (p2.first + 2 * p1.first) / 3;
    s.second = (p2.second + 2 * p1.second) / 3;
    t.first = (2 * p2.first +  p1.first) / 3;
    t.second = (2 * p2.second + p1.second) / 3;
    u.first = s.first + (t.first - s.first) * cos(M_PI / 3) - (t.second - s.second) * sin(M_PI / 3);
    u.second = s.second + (t.first - s.first) * sin(M_PI / 3) + (t.second - s.second) * cos(M_PI / 3);

    dfs(n - 1, p1, s);
    cout << setprecision(10) << s.first << " " << setprecision(10) << s.second  << "\n";
    dfs(n - 1, s, u);
    cout << setprecision(10) << u.first << " " << setprecision(10) << u.second  << "\n";
    dfs(n - 1, u, t);
    cout << setprecision(10) << t.first << " " << setprecision(10) << t.second  << "\n";
    dfs(n - 1, t, p2);
}

int main()
{
    ll n;
    cin >> n;
    cout << 0 << " " << 0 << "\n";
    dfs(n, pair<double,double>(0,0), pair<double,double>(100,0));
    cout << 100 << " " << 0 << "\n";

    return 0;
}



Measured memory_bytes: 3284
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import itertools
N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
A=list(itertools.accumulate(A))
B=list(itertools.accumulate(B))
j=M
ans=0
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 41936
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500010
#define INF 1e9
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;

	string S;
	cin >> S;

	vector<ll> ecnt(N);
	rep(i,N-1){
		if(S[i] == 'E') ecnt[i+1] = ecnt[i] + 1;
		else ecnt[i+1] = ecnt[i]; 
	}

	vector<ll> wcnt(N);
	for(ll i = N-1; i>=1; i--){
		if(S[i] == 'W') wcnt[i-1] = wcnt[i] + 1;
		else wcnt[i-1] = wcnt[i]; 
	}

	vector<ll> allcnt(N);
	rep(i,N){
		allcnt[i] = wcnt[i] + ecnt[i];
		ans = max(ans,allcnt[i]);
	}

	cout << N - ans - 1 << endl;
	return 0;
}

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

using namespace std;

string S;
string button[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

void solve() {
	int i = 0;
	int len = (int)S.size();
	
	while (i < len) {
		char c;
		c = S[i++];
		int p = 0;
		
		if (c == '0') continue;
		while (i < len && c == S[i++]) p++;
		
		int id = c - '0';
		string puts =  button[id];
		int size = (int)puts.size();
		cout << puts[p % size];
	}
	
	cout << endl;
}

int main() {
	int n; cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> S;
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1 : h2);
}

//節点uの兄弟を返す
int setSibling(int u) {
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
        return T[T[u].parent].left;
    }
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
        return T[T[u].parent].right;
    }
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", setSibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    
    if(T[u].parent == NIL) {
        printf("root\n");
    }else if(T[u].left == NIL && T[u].right == NIL) {
        printf("leaf\n");
    }else {
        printf("internal node\n");
    }
}

int main() {
    int v, l, r, root = 0;
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++) T[i].parent = NIL;
    
    for(int i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }
    
    for(int i = 0; i < n; i++) if(T[i].parent == NIL) root = i;
    
    setDepth(root, 0);
    setHeight(root);
    
    for(int i = 0; i < n; i++) print(i);
    
    return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int &i : a){
            cin >> i;
        }
        int ans = INF;
        for(int i = -200; i <= 200; i++){
            int sum = 0;
            for(int j = 0; j < n; j++){
                sum += (a[j] - i) * (a[j] - i);
            }
            ans = min(ans, sum);
        }
        cout << ans << '\n';
    }
}

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

typedef long long ll;
using namespace std;
constexpr ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> dp(1 << n);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        vector<ll> after(1 << n);
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            if (a == 1) {
                for (int bit = 0; bit < 1 << n; bit++) {
                    if (bit & (1 << j))continue;
                    after[bit | (1 << j)] += dp[bit], after[bit | (1 << j)] %= MOD;
                }
            }
        }
        dp = after;
    }

    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 33148
#include<iostream>
int main(){
  int a,b;
  char op;
  while(1){
    std::cin >> a >> op >> b;
    if(op == '?') return 0;
    else if(op == '+') std::cout << a + b << std::endl;
    else if(op == '-') std::cout << a - b << std::endl;
    else if(op == '*') std::cout << a * b << std::endl;
    else if(op == '/') std::cout << a / b << std::endl;
  }
}

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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int nolm(int a){
	return max(a, -a);
}

int main() {
int H, W, D;
cin >> H >> W >> D;
int map[H*W+10][2];

rep(i,H){ rep(j,W) {
	int tmp;
	cin >> tmp;
	tmp--;
	map[tmp][0] = i;
	map[tmp][1] = j;
}}

int cost[H*W+10];
rep(i,H*W){
	if(i >= D){
		cost[i] = cost[i-D];
		cost[i] += nolm(map[i][0] - map[i-D][0]) + nolm(map[i][1] - map[i-D][1]);
	}
}

int64_t Q;
cin >> Q;

for(int64_t n=0;n < Q; n++){
	int L, R;
	cin >> L >> R;
	L--; R--;

	cout << cost[R] - cost[L]<<endl;
}

return 0;
}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
	public static int swap(int[] array, int a, int b){
		int tmp = array[a];
		array[a] = array[b];
		array[b] = tmp;
		
		return array[a] + array[b];
	}
	
	public static int do_swap(int[] array, int[] sorted, int min_pos, boolean act){
		final int min = array[min_pos];
		int loop = min_pos;
		int sum = 0;
		
		do{
			for(int i = 0; i < array.length; i++){
				if(array[i] == sorted[loop]){
					if(act){
						sum += swap(array, i, loop);
					}else{
						sum += (array[i] + min);
					}
					
					loop = i;
					break;
				}
			}
			
		}while(min != sorted[loop]);
		
		return sum;
	}
	
	public static int swapping(int[] array, int[] sorted){
		final int absolute_min = sorted[0];
		int absolute_min_pos = -1;
		int min = Integer.MAX_VALUE, min_pos = -1;
		
		for(int i = 0; i < array.length; i++){
			if(array[i] == absolute_min){
				absolute_min_pos = i;
				break;
			}
		}
		
		for(int i = 0; i < array.length; i++){
			if(sorted[i] != array[i] && min > array[i]){
				min = array[i];
				min_pos = i;
			}
		}
		
		if(min_pos == -1){
			return 0;
		}
		
		final int direct = do_swap(array, sorted, min_pos, false);
		
		swap(array, min_pos, absolute_min_pos);
		final int indirect = do_swap(array, sorted, min_pos, false) + min + absolute_min;
		swap(array, min_pos, absolute_min_pos);
		
		if(direct <= indirect){
			return do_swap(array, sorted, min_pos, true);
		}else{
			swap(array, min_pos, absolute_min_pos);
			return do_swap(array, sorted, min_pos, true) + min + absolute_min;
		}
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		int[] array  = new int[n];
		int[] sorted = new int[n];
		for(int i = 0; i < n; i++){
			array[i]  = sc.nextInt();
			sorted[i] = array[i];
		}
		Arrays.sort(sorted);
		
		int answer = 0, ret = 0;
		while((ret = swapping(array, sorted)) != 0){
			answer += ret;
		}
		
		System.out.println(answer);
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}

}

Measured memory_bytes: 20376
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int tate,yoko;
    while(1){
        cin>>tate>>yoko;
        if(tate==0||yoko==0)
        break;
    for(int i=1;i<=tate;i++){
        for(int j=1;j<=yoko;j++){
            if((i+j)%2==0){
                cout<<"#";
            }else{
                cout<<".";
            }
        }cout<<endl;
    }cout<<endl;
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int x;
    cin >> x;
    if(x==3||x==5||x==7) YES
    NO
    
    return 0;
}
    


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

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	int X, Y;
	scanf("%d %d", &X, &Y);
	int ans = 0;
	if (A + B >= 2 * C) {
		ans += 2 * C * min(X, Y);
		if (X >= Y) {
			ans += min(A, 2 * C) * (X - Y);
		} else {
			ans += min(B, 2 * C) * (Y - X);
		}
	} else {
		ans += A * X + B * Y;
	}
	printf("%d\n", ans);

	return 0;
}


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


#pragma comment(linker, "/STACK:256000000")

using namespace std;

int main(){
	string S;
	long long ans = 0;

	cin >> S;

	string tmp;
	for(int i = 0; i < (1 << (S.size() - 1)); ++i){
		for(int j = 0; j < S.size(); ++j){
			tmp += S[j];
			if(i & (1 << j)){
				ans += strtoll(tmp.c_str(), NULL, 0);
				tmp.clear();
			}
		}
		ans += strtoll(tmp.c_str(), NULL, 0);
		tmp.clear();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int Taka=A;
  int Aoki=C;
  while(Taka>0&&Aoki>0)
  {
    Taka-=D;
    Aoki-=B;
  }
  if(Taka<=0&&Aoki>0)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
r,g,b,n = map(int,input().split())
cnt=0
rr = 0
gg = 0
bb = 0
for i in range(0,n+1,r):
    for j in range(0,n-i+1,g):
        if (n-i-j)%b == 0:
            cnt += 1
print(cnt)


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

const int N = 2e3 + 5;
int a[N];

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n<3200){
    cout<<"red\n";
  }
  else cout<<s;
}


Measured memory_bytes: 256
N, D = map(int, input().split())

lst_A = []

ans = 0

for i in range(N):
    lst_W = input().split()
    for j in range(len(lst_W)):
        lst_W[j] = int(lst_W[j])
    lst_A.append(lst_W)

for i in range(len(lst_A) - 1):
    for j in range(i + 1, len(lst_A)):
        res = 0
        for k in range(D):
            res += (lst_A[i][k] - lst_A[j][k]) ** 2
        check = res ** 0.5 % 1
        if check == 0.0:
            ans += 1

print(ans)

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

typedef complex<int> point;
typedef long long int lli;
typedef long double ld;
#define pii pair<int,int>
#define lasB(b) (b&(-b))
#define pld pair<ld,ld>
#define mod 1000000007
#define PI acos(-1.0)
#define PB push_back
#define N      100005
#define EPS (1e-8)
#define ss substr
#define S second
#define IM image
#define F first
#define RE real
#define B begin
#define E end

int n,t,sol=100000000;
int occ1[100005],occ2[100005],mx1[N],mx2[N],mn1[N],mn2[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t;
        if(i%2)occ1[t]++;
        else occ2[t]++;
    }
    mx1[1]=occ1[1];
    for(int i=2;i<N;i++)
        mx1[i]=max(mx1[i-1],occ1[i]);

    mx2[n]=occ1[n];
    for(int i=N-1;i>=0;i--)
        mx2[i]=max(mx2[i+1],occ1[i]);

    mn1[1]=occ2[1];
    for(int i=2;i<N;i++)
        mn1[i]=max(mn1[i-1],occ2[i]);

    mn2[n]=occ2[n];
    for(int i=N-1;i>=0;i--)
        mn2[i]=max(mn2[i+1],occ2[i]);

    for(int i=1;i<N;i++)
    {
        if(occ1[i])
            sol = min(sol,(n/2-occ1[i])+(n/2- max( mn1[i-1] , mn2[i+1] ) ) );
        if(occ2[i])
            sol = min(sol,(n/2-occ2[i])+(n/2- max( mx1[i-1] , mx2[i+1] ) ) );
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> v;
    int count = 0;
    int tmp;
    for(int i = 0;i < N;++i)
    {
        cin >> tmp;
        for(int j = 0;j < (int)v.size(); ++j)
        {
            if(tmp == v[j])
                goto end;
        }
        count++;
        v.push_back(tmp);
        end:
        count = count;
    }
    cout << count << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int kans(int a){
    if(a%2==0){
        return a/2;
    }else{
        return 3*a+1;
    }
}
using namespace std;
int main(){
    int N;
    cin >> N;

    map<int, int> mp;

    bool fl = true;
    mp[N]++;
    int i=1;
    while(fl){
        N = kans(N);
        mp[N]++;
        i++;
        if(mp[N]==2){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<long long > A(N);
  long long sum = 0;
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
    sum += A[i];
  }
  std::vector<long long > yakusuu;
  for (long long i=1; i*i<=sum; i++) {
    if (sum%i==0) {
      yakusuu.push_back(i);
      if (i*i!=sum) {
        yakusuu.push_back(sum/i);
      }
    }
  }
  std::sort(yakusuu.rbegin(), yakusuu.rend());
  for (long long y : yakusuu) {
    //printf("y=%lld\n", y);
    std::vector<long long > AA(N);
    long long sumsum = 0;
    for (int i=0; i<N; i++) {
      AA[i] = A[i]%y;
      sumsum += AA[i];
    }
    std::sort(AA.begin(), AA.end());
    int change = (int)(sumsum/y);
    //printf("change=%d\n", change);
    for (int i=N-1; i>N-1-change; i--) {
      sumsum -= AA[i];
    }
    //printf("negative=%lld, positive_sum=%lld\n", negative_sum, positive_sum);
    //printf("sum=%lld\n", sumsum);
    if (sumsum<=K) {
      printf("%lld\n", y);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[3][3],n;
  for ( int i=0; i<3 ; i++){
    for (int j=0 ; j<3 ; j++){
      cin >> a[i][j];
    }
  }
  cin >> n;
  int b[n] ;
  for ( int i= 0 ; i<n ; i++) {
    cin >> b[i] ;
  }
  bool c[3][3];
   for ( int i=0; i<3 ; i++){
    for (int j=0 ; j<3 ; j++){
      c[i][j]=false ;
      for ( int k = 0 ; k<n ; k++){
      if ( a[i][j]==b[k]){
        c[i][j]=true ;
      }
      }
    }
  } 
  string ans="No" ; 
  for ( int i=0 ; i<3 ; i++){
    if ( c[i][1] && c[i][2]&&c[i][0]){
      ans= "Yes" ;
    }
    if ( c[0][i] && c[1][i]&&c[2][i]){
      ans= "Yes" ;
    }
  }
    if ( c[0][0] && c[1][1]&&c[2][2]){
      ans= "Yes" ;
    }
    if ( c[0][2] && c[1][1]&&c[2][0]){
      ans= "Yes" ;
    }
    cout << ans << endl;
  
}

Measured memory_bytes: 3596
def calc(D, C, S, T):
    s = 0
    l = [-1] * len(C)
    for d, t in enumerate(T):
        t -= 1
        s += S[d][t]
        s -= C[t] * (d - l[t]) * (d - l[t] - 1) // 2
        l[t] = d
    s -= sum(c * (d - l[i]) * (d - l[i] + 1) // 2 for i, c in enumerate(C))
    return s


def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    
    M = [0] * 26
    
    for d in range(D):
        for i in range(26):
            M[i] += C[i]
        T = [m + s for m, s in zip(M, S[d])]
        i = T.index(max(T))
        M[i] = 0

        print(i + 1)

main()


Measured memory_bytes: 9272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        long[] a = sc.LongArray();

        if (a.Contains(0))
        {
            Console.WriteLine(0);
            return;
        }

        long answer = 1;
        for (int i = 0; i < n; i++)
        {
            try
            {
                checked
                {
                    answer *= a[i];
                    if (answer > 1000000000000000000)
                    {
                        Console.Write(-1);
                        return;
                    }
                }
            }
            catch (OverflowException)
            {
                Console.Write(-1);
                return;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 42460
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define R register
#define Maxn 100005

int main()
{
	R int n,sum=0;
	scanf("%d",&n);
	for (R int i=1;i<=n;++i)
	{
		sum += i;
		if(sum == n)
		{
			puts("Yes");
			printf("%d\n",i+1);
			R int j=1,cnt1=2;
			for (;j<=n;j+=cnt1,cnt1++)
			{
				printf("%d ",i);
				for (R int k=j-cnt1+2;k<=j;++k)printf("%d ",k);
				R int cnt2=cnt1-1;
				for (R int k=j+cnt2;k<=n;++cnt2,k+=cnt2)printf("%d ",k);
				puts("");
			}
			j=1,cnt1=2;
			printf("%d ",i);
			for (;j<=n;j+=cnt1,cnt1++)printf("%d ",j);
			return 0;
		}
	}
	puts("No");	
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    vector<pair<int,int>> v(n) ;
    REP(i,n){
        cin>>v[i].second>>v[i].first;

    }
    sort(v.begin(),v.end(),greater<pair<int,int>>());
    int now_where=inf;
    REP(i,n){

        now_where=min(now_where,v[i].first);
        now_where-=v[i].second;

    }
    if(now_where<0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }


    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
using namespace std;
int main () {
    char x,y;
    cin>>x>>y;
    if(x>y){
        cout<<">"<<endl;
    }else if(y>x){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int A;
int B;
int C;

int main() {
	scanf("%d %d %d", &A, &B, &C);
	for (int i = 1; i <= B; i++) {
		if ((i*A) % B == C) {
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool g[22][22];

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			char c;
			cin >> c;
			g[i][j] = (c == '.');
		}
	}
	vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
	int ans = 0;
	queue<pair<int, int>> q;
	for (int xx = 0; xx < h; ++xx){
		for (int yy = 0; yy < w; ++yy){
			if (!g[xx][yy]) continue;
			vector<vector<int>> d(h + 1, vector<int>(w + 1, -1));
			d[xx][yy] = 0;
			q.push({xx, yy});
			while (q.size()){
				int x = q.front().first, y = q.front().second;
				q.pop();
				for (int i = 0; i < 4; ++i){
					int nx = x + dx[i], ny = y + dy[i];
					if (nx < 0 || nx > h || ny < 0 || ny > w) continue;
					if (!g[nx][ny]) continue;
					if (d[nx][ny] > -1) continue;
					d[nx][ny] = d[x][y] + 1;
					ans = max(ans, d[nx][ny]);
					q.push({nx, ny});
				}
			}

		}
	}
	cout << ans;
	return 0;
}



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

vector<pair<int, int> > solve(int n) {
    if (__builtin_popcount(n) == 1) return vector<pair<int, int> >();
    vector<pair<int, int> > edges;
    REP (i, (n - 1) / 2) {
        int a = 2 * i + 2;
        int b = 2 * i + 3;
        edges.emplace_back(1, a);
        edges.emplace_back(a, b);
        edges.emplace_back(1, n + b);
        edges.emplace_back(n + b, n + a);
    }
    edges.emplace_back(3, 1 + n);
    if (n % 2 == 0) {
        REP3 (a, 2, n) {
            int b = n ^ a ^ 1;
            if (b < 2 or n - 1 < b) continue;
            if (a == b) continue;
            edges.emplace_back((a % 2 == 0 ? 0 : n) + a, n);
            edges.emplace_back((b % 2 == 0 ? 0 : n) + b, n + n);
            break;
        }
    }
    return edges;
}

int main() {
    int n; cin >> n;
    auto edges = solve(n);
    if (edges.empty()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        assert (edges.size() == 2 * n - 1);
        for (auto e : edges) {
            assert (1 <= e.first and e.first <= 2 * n);
            assert (1 <= e.second and e.second <= 2 * n);
            assert (e.first != e.second);
            cout << e.first << ' ' << e.second << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4080
N, M = map(int, input().split())

if N == 1 and M > 2:
    print(M - 2)
elif M == 1 and N > 2:
    print(N - 2)
elif N == 1 and M == 1:
    print(1)
elif N == 2 and M != 2:
    print(0)
elif M == 2 and N != 2:
    print(0)
elif N == 2 and M == 2:
    print(0)
else:
    a = 2*(N + M - 2)
    print(N*M - a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3, 0));
  vector<vector<int>> dp(n, vector<int>(3, 0));
  for (int i = 0; i < n; i++){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  for (int i = 1; i < n; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        if (j != k){
          dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
      }
    }
  }
  }
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << '\n';  
  return 0;
}


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

int main() {
  string n;
  cin >> n;
  int cnt = 1;

  string ans;
  bool flag = false;

  for (int i = 0; i < int(n.size()) - 1; i ++) {
    if (n[i+1] == n[i]) {
      cnt++;
      if (cnt == 3) {
        ans = "Yes";
        flag = true;
      }
    } else {
      cnt = 1;
    }
  } 
  if (!flag) {
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<long long> sale(4001, -1);
        vector<int> id;

        for(int i=0; i<n; ++i){
            int a, b, c;
            cin >> a >> b >> c;
            if(sale[a] == -1){
                sale[a] = 0;
                id.push_back(a);
            }
            sale[a] += (long long)b * c;
        }


        bool na = true;
        for(unsigned i=0; i<id.size(); ++i){
            if(sale[id[i]] >= 1000000){
                cout << id[i] << endl;
                na = false;
            }
        }
        if(na)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 0
// 5/2

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

// ll A[100010];

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

    vector<ll> A(N);

    rep(i, N) cin >> A[i];

    map<ll, ll> Lmp, Rmp;

    rep(i, N) {
        ll L = A[i] + i;
        ll R = i - A[i];

        Lmp[L]++;

        if (R >= 0) Rmp[R]++;
    }

    ll ans = 0;

    for (auto itr = Lmp.begin(); itr != Lmp.end(); ++itr) {
        // cout << "key = " << itr->first << ", val = " << itr->second << endl;

        ll value = itr->first;

        ans += Lmp[value] * Rmp[value];
    }

    // cout << Lmp[10] << endl;  // なんと初期値はゼロ！便利な...。コンパイラによっても違いそうな気がするが...。

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


Measured memory_bytes: 30020
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	string s;cin >> s;
	for(int i = 0; i < (int)s.size();){
		string now =s.substr(i, 7);
		if(now == "dreamer"){
			string next = s.substr(i + 7, 5);
			deb(next);
			if(next == "dream" || next == "erase" || next.size() == 0)i += 7;
			else i += 5;
		}
		else{
			now = s.substr(i, 6);
			if(now == "eraser"){
				string next = s.substr(i + 6, 5);
				deb(next);
				if(next == "dream" || next == "erase" || next.size() == 0)i += 6;
				else i += 5;
			}
			else{
				now = s.substr(i, 5);
				deb(now);
				if(now == "dream" || now == "erase" || now.size() == 0)i += 5;
				else{
					puts("NO");
					return 0;
				}
			}
		}
		deb(i);
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

class Main {


    public static long getMaxValue(int[] weights, int[] values, int numWeights, int weightPossible) {
        long[][] memo = new long[numWeights][weightPossible+1];
        for(int i=0; i<numWeights; i++)
            Arrays.fill(memo[i], -1);
        return getMaxValueHelper(0, weights, values, numWeights, weightPossible, memo);
    }

    private static long getMaxValueHelper(int i, int[] weights, int[] values, int numWeights, int weightPossible, long[][] memo) {
        if(i == numWeights) {
            return 0;
        }

        if(weightPossible == 0) {
            return 0;
        }

        if(memo[i][weightPossible] != -1) {
            return memo[i][weightPossible];
        }

        long poss1 = (weightPossible - weights[i] >= 0) ? (long) values[i] + getMaxValueHelper(i+1, weights, values, numWeights, weightPossible - weights[i], memo) : 0;
        long poss2 = getMaxValueHelper(i+1, weights, values, numWeights, weightPossible, memo);
        return memo[i][weightPossible] = Math.max(poss1, poss2);
    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numWeights = scanner.nextInt();
        int bagSize = scanner.nextInt();

        int[] weights = new int[numWeights];
        int[] value = new int[numWeights];

        for(int i=0; i<numWeights; i++) {
            weights[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }

        System.out.println(getMaxValue(weights, value, numWeights, bagSize));

    }
}


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

int check_lunlun(vector<int64_t>Lun, int keta, int nagasa){
  //keta:今調べている桁,nagasa:lunlun(K-1)の桁数
  //lunlun(K-1)を1の位から調べる
  //0を返すまで桁を増やし続ける（while)
  
  if(keta == nagasa-1){
    return 0;
  }
  if(Lun.at(keta)+1-Lun.at(keta+1)>=2 || Lun.at(keta) == 9){
    return 1;
  }
  else{
    return 0;
  }
}

int64_t lunlun(int K){
  if(K==1){
    return 1;
  }
  else{
    int64_t lunlun_old = lunlun(K-1);
    
    //lunlun(K-1)の桁数チェック
    string L_str = to_string(lunlun_old);
    int nagasa = L_str.length();
    
    //lunlun(K-1)が一桁の場合
    if(nagasa == 1){
      return lunlun_old + 1;
    }
    
    //99...99じゃないかチェック→桁が変わるので
    int check9 = 0;
    for(int i=0; i<nagasa; i++){
      if(L_str.at(i) == '9'){
        check9++;
      }
    }
    if(check9==nagasa){
      return lunlun_old+1;
    }
    
    //Lunにlunlun(K-1)を一桁ずつ入れる（一の位はLun[0]...）
    vector<int64_t> Lun(nagasa);
    int64_t lunlun_old_judge=lunlun_old;
    for(int i=0; i<nagasa; i++){
      int64_t tmp=0;
      if(lunlun_old_judge/pow(10,i+1) >= 1){
        tmp = ((int64_t)lunlun_old_judge-(int64_t)pow(10,i+1)*((int64_t)lunlun_old_judge/(int64_t)pow(10,i+1)))/(int64_t)pow(10,i);
      }
      else{
        tmp = (int64_t)lunlun_old_judge/(int64_t)pow(10,i);
      }
      Lun.at(i) = tmp;
      lunlun_old_judge -= tmp*pow(10,i);
    }
    
    int keta = 0;
    while(check_lunlun(Lun, keta, nagasa)==1){
      keta++;
    }
    
    Lun.at(keta)++;
    for(int i=1; i<=keta; i++){
      if(Lun.at(keta)-i>=1){
        Lun.at(keta-i)=Lun.at(keta)-i;
      }
      else{
        Lun.at(keta-i)=0;
      }
    }
    
    
    int64_t ans = 0;
    for(int i=0; i<nagasa; i++){
      ans+=pow(10,i)*Lun.at(i);
    }
    return ans;     
  }
}

int main() {
  int K;
  cin >> K;
  cout << lunlun(K) << endl;
  //for(int i=K-100; i<=K; i++){
    //cout << lunlun(i) << endl;
  //}
}

Measured memory_bytes: 18944
#include<iostream>
using namespace std;
int main(){
	int H;
	int W;
	for (;;){
		cin >> H >> W;
		if (H == 0 && W == 0){
			return 0;
		}else{
			for (int b = 0; b < H; b++){
				for (int c = 0; c < W; c++){
					if (c == 0){
						cout << "#";
					}
					else if (c == W-1){
						cout << "#";
					}
					else if (b == 0){
						cout << "#";
					}
					else if (b == H-1){
						cout << "#";
					}else{
						cout << ".";
					}
				}cout << endl;
			}cout << endl;
		}

	}
}

Measured memory_bytes: 3096