akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

string S ;


int main(){
	cin >> S;

	if (S.at(2) == S.at(3) && S.at(4) == S.at(5)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

}

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

typedef long long ll;
#define endl "\n"

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
  if (!first) {
    res += ", ";
  }
  first = false;
  res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
  res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
  if (!first) {
    res += ", ";
  }
  first = false;
  res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() {cout<<endl;}
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 0
#endif


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n; cin>>n;
    unordered_map<int,int> mp;
    ll ans=0;
    for (int i=0; i<n; ++i){
        int h; cin>>h;
        int need=i-h;
        ans+=mp[need];
        mp[h+i]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 18480
#include<iostream>
using namespace std;
typedef long long ll;
int n,k;
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	ll ans=0;
	for(int i=k+1; i<=n ;i++){
		if(n%i>=k){
			ans+=1LL*((n-k)/i)*(i-k)+n%i-k+1;
		}
		else{
			ans+=1LL*((n-k)/i+1)*(i-k);
		}
	}
	if(k==0) ans-=n;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
const int MaxN = 505;

int main() {
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);
	if(a == k || (a < k && a + b >= k)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll solve(ll N, ll A, ll B){
    if(A>B) return 0;
    if(N==1 && A!=B) return 0;
    ll low = (N-1)*A + B;
    ll high = (N-1)*B + A;
    return (high - low + 1);
}

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;

    vector<int> dprow(M+2, 0);
    vector<vector<int> > grid(N+2, dprow);
    vector<vector<int> > dphor(N+2, dprow);
    vector<vector<int> > dpvert(N+2, dprow);
    vector<vector<int> > dpcnt(N+2, dprow);

    for(int y=1;y<=N;y++){
        string row;
        cin >> row;
        for(int x=1;x<=M;x++){
            grid[y][x] = row[x-1] - '0';
        }
    }

    for(int x=1;x<=M+1;x++){
        for(int y=1;y<=N+1;y++){
            dpcnt[y][x] = dpcnt[y-1][x] + dpcnt[y][x-1] - dpcnt[y-1][x-1];
            dphor[y][x] = dphor[y-1][x] + dphor[y][x-1] - dphor[y-1][x-1];
            dpvert[y][x] = dpvert[y-1][x] + dpvert[y][x-1] - dpvert[y-1][x-1];
            if(grid[y][x] == 1){
                dpcnt[y][x]++;
                if(grid[y][x+1] == 1){
                    dphor[y][x]++;
                }
                if(grid[y+1][x] == 1){
                    dpvert[y][x] ++;
                }
            }
        }
    }

    for(int i=0;i<Q;i++){
        int x1, y1, x2, y2;
        cin >> y1 >> x1 >> y2 >> x2;
        x1--;
        y1--;
        int numV = dpcnt[y2][x2] - dpcnt[y2][x1] - dpcnt[y1][x2] + dpcnt[y1][x1];
        int numE = (dphor[y2][x2-1] - dphor[y2][x1] - dphor[y1][x2-1] + dphor[y1][x1]) +
                    (dpvert[y2-1][x2] - dpvert[y2-1][x1] - dpvert[y1][x2] + dpvert[y1][x1]);
//        cout << "vertices: " << numV << endl;
//        cout << "edges: " << numE << endl;
        cout << (numV - numE) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 65152
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <map>
using namespace std;

int main()
{
    int Z=0;
    long X;
    cin>>X;
    for (long i = -300; i < 300 ;i++)
    {
        for (long j=-300; j < 300; j++)
        {
            if (((i*i*i*i*i)-(j*j*j*j*j))==X)
            {
                cout<<i<<' '<<j;
                Z=1;
                break;
            }
            
        }
        if (Z==1)
        {
            break;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-(a-b)) << endl;
  return 0;
}


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

using namespace std;

int main(){
	
	int a, b;
	
	int ans;
	
	int count[200];
	
	for(int i = 0; i < 200; i++){
		count[i] = 0;
	}
	
	cin >> a;
	
	while(true){
		if(cin.eof()){
			break;
		}
		cin >> b;
		while(a != 0 && b != 0){
			count[a]++;
			count[b]++;
			cin >> a >> b;
		}
		ans = 0;
		for(int i = 1; i < 2; i++){
			if(count[i] % 2 == 0){
				ans++;
			}
		}
		for(int i = 3; i < 200; i++){
			if(count[i] % 2 == 1){
				ans++;
			}
		}
		if(ans == 0){
			printf("OK\n");
		}else{
			printf("NG\n");
		}
		for(int i = 0; i < 200; i++){
			count[i] = 0;
		}
		cin >> a;
	}
	
	return 0;
}

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

int main(){
    int i, j, k, n, m, l;
    long long int s, A[100][100]={}, B[100][100]={};
    cin >> n >> m >> l;
    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
        cin >> A[i][j];
        }
    }

    for (i = 0; i < m; i++){
        for (j = 0; j < l; j++){
        cin >> B[i][j];
        }
    }


    for (i = 0; i < n; i++){
        s = 0;
        for (k = 0; k < m; k++){
            s += A[i][k] * B[k][0];
        }
        cout << s ;
        for (j = 1; j < l; j++){
            s = 0;
            for (k = 0; k < m; k++){
                s += A[i][k] * B[k][j];
            }
            cout << " " << s ;
        }
        cout << endl;
    }
        return 0;
}


Measured memory_bytes: 3264
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} Process;

Process Q[LEN];
int head, tail, n;

void enqueue(Process x) {
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

Process dequeue() {
    Process x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a, int b) {
    return a<b?a:b;
}

int main() {
    int elapse=0, required_time, quantum;
    Process proc;
    scanf("%d %d", &n, &quantum);
    
    for (int i=1; i<=n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    
    head=1;
    tail=n+1;
    
    while (head != tail) {
        proc=dequeue();
        required_time=min(quantum, proc.t);
        proc.t -=required_time;
        elapse +=required_time;
        if (proc.t>0) enqueue(proc);
        else printf("%s %d\n", proc.name, elapse);
    }
    return 0;
}



Measured memory_bytes: 12840
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        long ans = 0;
        for (int i = 1; i < n; i++) {
            ans += i;
        }
        System.out.println(ans);
    }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  string S;
  
  for(int i;i < W + 2;i++){
    cout << "#";
  }
  cout << endl;
  
  for(int i;i < H;i++){
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  
  for(int i;i < W + 2;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
# class Node:
#     def __init__(self, data): #コンストラクタ
#         self.data = data #ノードがもつ数値
#         self.left = None #左エッジ
#         self.right = None #右エッジ
#
# class BST:
#     def __init__(self, number_list): #コンストラクタ
#         self.root = None #ルート初期化
#         for node in number_list: #数値を持つ配列から二分木を生成
#             self.insert(node) #挿入メソッドを使ってノードを挿入する
#
#     #挿入
#     def insert(self, data):
#         n = self.root #nにルートを代入
#         if n == None: #ルートに何も入っていない場合
#             self.root = Node(data) #ルートにノードを代入(二分探索木の一番上の部分が出来る)
#             return #呼び出し部分に戻る
#         else: #ルートノードに既に数値が入ってる場合
#             while True: #return等が入るまでずっと実行
#                 entry = n.data #entryにnが持つデータ(数値)を入れる
#                 if data < entry: #entryとdata(代入するデータ)を比較してentryの方が大きい場合
#                     if n.left is None: #nの左エッジに何も入っていない場合
#                         n.left = Node(data) #nの左エッジにdata(代入するデータ)を代入
#                         return ##呼び出し部分に戻る
#                     n = n.left #nの左に何か入っている場合nにnのleftを代入
#                 elif data > entry: #entryとdata(代入するデータ)を比較してentryの方が小さい場合
#                     if n.right is None: #nの右エッジに何も入っていない場合
#                         n.right = Node(data) #nの右エッジにdata(代入するデータ)を代入
#                         return #呼び出し部分に戻る
#                     n = n.right #nの右エッジに何か入っている場合nにnのrightを代入
#                 else: #上2つの条件分岐以外の場合
#                     n.data = data #nのdataにdata(代入するデータ)を代入
#                     return #呼び出し部分に戻る

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
key = [a, b, c]
yes = 0
x, y = map(int, input().split())
for i in key:
    if x in i and y in i:
        print("Yes")
        yes = 1
        break

if not yes:
    print("No")

Measured memory_bytes: 38256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] nums = new int[n];
      for(int i = 0; i < n; i++)
        nums[i] = sc.nextInt();
      int[] sortedSort = nums.clone();
      Arrays.sort(sortedSort);
      int midNum = sortedSort[n/2];
      int nextMid = sortedSort[n/2-1];
      for(int num : nums) {
        int res = 0;
        if(num < midNum) res = midNum;
        else if(num > midNum) res = nextMid;
        else {
          if(midNum == nextMid) res = midNum;
          else res = nextMid;
        }
        System.out.println(res);
      }
  }
}

Measured memory_bytes: 89112
a, b, c, d = list(input())

ops = ['-', '+']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            if eval(a+op1+b+op2+c+op3+d) == 7:
                print(a+op1+b+op2+c+op3+d+'=7')
                exit()


Measured memory_bytes: 3060
a, b, c, d = map(int, input().split())
takahashi_turn = c // b if c % b == 0 else c // b + 1
aoki_turn = a // d if a % d == 0 else a // d + 1
if takahashi_turn <= aoki_turn:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61576
#include <bits/stdc++.h>
using namespace std;
int a[3];string s;
int main(){
cin>>s;
for(int i=0;i<s.size();i++)a[s[i]-'a']++;
cout<<((max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]}))<2?"YES":"NO")<<endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, p);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

int main() {
    int l, r; cin >> l >> r;
    int res = 2020;
    for(ll i = l; i < min(r, l+2019); i++) {
        for(ll j = i + 1; j <= min(r, l+2020); j++) {
            int x = (i * j) % 2019;
            res = min(res, x);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 764
a,b,c,d=map(int,input().split())
s=[[0]*3001for i in range(3001)]
s[a][b]=1
m=998244353
for i in range(3000):
    for j in range(3000):
        s[i+1][j+1]+=(s[i+1][j]*(i+1)+s[i][j+1]*(j+1)-s[i][j]*i*j)%m
print(s[c][d])

Measured memory_bytes: 137020
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	cout<<(1000-N%1000)%1000<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
void change_to_min(int& target, const int suspect) {
	if (target > suspect) target = suspect;
}
int square(const int value) { return value * value; }
int cal_min_diff(const std::vector<int>& signal, const std::vector<int>&code, const int current_pos, const int prev_value, std::vector<std::vector<int>>& memo) {
	if (current_pos == signal.size()) return 0;
	if (memo[current_pos][prev_value] >= 0) return memo[current_pos][prev_value];
	memo[current_pos][prev_value] = INT_MAX;
	for (const auto c : code) {
		if (prev_value + c < 0) change_to_min(memo[current_pos][prev_value], cal_min_diff(signal, code, current_pos + 1, 0, memo) + square(signal[current_pos]));
		else if (255 < prev_value + c) change_to_min(memo[current_pos][prev_value], cal_min_diff(signal, code, current_pos + 1, 255, memo) + square(255 - signal[current_pos]));
		else change_to_min(memo[current_pos][prev_value], cal_min_diff(signal, code, current_pos + 1, prev_value + c, memo) + square(signal[current_pos] - prev_value - c));
	}
	return memo[current_pos][prev_value];
}
int main() {
	while (true) {
		int n, m; std::cin >> n >> m; if (n == 0 && m == 0) return 0;
		std::vector<int> code_book(m); for (auto& c : code_book) std::cin >> c;
		std::vector<int> signal(n); for (auto& s : signal) std::cin >> s;
		std::vector<std::vector<int>>memo(n, std::vector<int>(256, -1));
		std::cout << cal_min_diff(signal, code_book, 0, 128, memo) << std::endl;
	}
}



Measured memory_bytes: 25976
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
inline int read() {
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
	return x * f;
}
int a,b;
int main()
{
	a = read() ,b = read();
	printf("%d\n",max(max(a+b,a-b),a*b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int N,D,Q,cpos;
pii rec[500000]; // true below certain point, false above
vi d,q;
bool ans[500000];

bool get(int ind, int mx) {
    if (mx == 0) return 1;
    if (ind == N) return 0;
    if (mx <= rec[ind].f) return 1;
    if (mx >= rec[ind].s) return 0;
    bool x = get(ind+1,max(mx-d[ind],min(mx,d[ind]/2)));
    if (x) rec[ind].f = max(rec[ind].f,mx);
    else rec[ind].s = min(rec[ind].s,mx);
    return x;
}

int main() {
    cin >> N >> D; d.resize(N); cpos = D;
    F0R(i,N) {
        cin >> d[i];
        rec[i] = {0,2000000000};
    }
    F0R(i,N) {
        ans[i] = get(i+1,cpos);
        cpos = min(cpos,abs(cpos-d[i]));
    }
    cin >> Q; 
    F0R(i,Q) {
        int q; cin >> q;
        if (ans[q-1]) cout << "NO\n";
        else cout << "YES\n";
    }
}

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

int main() {
    string s;
    int n;
    cin >> n >> s;
    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    rep(i, s.size()) {
        rep(j, al.size()) {
            if(s[i] == al[j]) {
                s[i] = al[j + n];
                break;
            }
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

AB.sort()
INF = 10 ** 10

B_min = INF
answer = 0
for A, B in AB:
  if A >= B_min:
    answer += 1
    B_min = B
  else:
    B_min = min(B_min, B)
answer += 1

print(answer)

Measured memory_bytes: 61016
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
const int maxn=2e5+7;
const int maxab=1e5+7;
int a[maxn],b[maxn];
int sum_a[maxab],sum_b[maxab];
int sum[maxab];
int main()
{
    int n;
    cin>>n;
    int maxt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        sum_a[a[i]]++;
        sum_b[b[i]]++;
        sum[a[i]]++;
        sum[b[i]]--;
        maxt=max(maxt,b[i]);
    }
    for(int i=1;i<=maxt;i++)
    {
        sum_a[i]+=sum_a[i-1];
        sum_b[i]+=sum_b[i-1];
        sum[i]+=sum[i-1];
    }
    int policy1=0,policy2=0;
    for(int i=1;i<=n;i++)
        policy1=max(policy1,sum_a[b[i]-1]-sum_b[a[i]]);
//该人在车上时段，上过车的人数与下过车的人数的差值，即此时刻车上有的人数
    for(int i=1;i<=maxt;i++)
        policy2=max(policy2,sum[i]);
//以最优方案，某时刻车上人数的最大值
    cout<<policy1<<" "<<policy2<<endl;
    return 0;
}


Measured memory_bytes: 5812
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int X;
	cin >> X;

	bool ok[1002] = { false };
	ok[1] = true;

	for (int i = 2; i * i <= X; i++) {
		for (int j = 2; (int)pow(i, j) <= X; j++) {
			ok[(int)pow(i, j)] = true;
		}
	}

	for (int i = X; i > 0; i--) {
		if (ok[i] == true) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 4032
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  sort(ALL(S));
  cout<<(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3]?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
 
struct test {
  int p;
  string s;
};
 
int main(){
  int n, m;
  cin >> n >> m;
  
  vector<test> tests(m);
  for(int i=0; i<m; i++){
    cin >> tests.at(i).p >> tests.at(i).s;
  }

  vector<int> ac(n), wa(n);
  for(int i=0; i<n; i++) ac[i] = wa[i] = 0;
  
  int correct = 0;
  int penalty = 0;
  
  for(int i=0; i<m; i++){
    if(ac[tests.at(i).p-1]) continue;
    if(tests.at(i).s=="AC"){
      ac[tests.at(i).p-1] = 1;
      penalty += wa[tests.at(i).p-1];
      correct++;
    }
    else wa[tests.at(i).p-1]++;
  }
 
  cout << correct << " " << penalty << endl;
  
  return 0;
}

Measured memory_bytes: 7296
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0

for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    ans += a*(n-c)

print(ans)

Measured memory_bytes: 29244
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	cin>>a>>b;
	puts((a*b)%2?"Odd":"Even");
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

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

  int lower = (int)(floor((double)N / 1.08));
  int upper = (int)(ceil((double)(N + 1) / 1.08));

  rep2(i, lower, upper+1){
    int pay = (int)(floor((double)i * 1.08));
    if(pay == N){
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 1000000000
#define MOD 1000000007
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
inline ll power(ll a,ll b){ll ans=1;while(b){if(b&1){ans=ans*a%MOD;--b;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	#ifdef zincsabian
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
	int a=read();a=min(a,read());
	int b=read();b=min(b,read());
	cout<<a+b<<"\n"; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    long startTime = System.currentTimeMillis();
    Scanner stdIn = new Scanner(System.in);
    try {
      int sideNum = stdIn.nextInt();
      int[] sideArray = new int[sideNum];
      for (int sideCnt = 0; sideCnt < sideNum; sideCnt++) {
        sideArray[sideCnt] = stdIn.nextInt();
      }

      int triagleNum = 0;
      for (int side1Cnt = 0; side1Cnt < sideNum; side1Cnt++) {
        for (int side2Cnt = side1Cnt; side2Cnt < sideNum; side2Cnt++) {
          for (int side3Cnt = side2Cnt; side3Cnt < sideNum; side3Cnt++) {
            if (side1Cnt != side2Cnt && side2Cnt != side3Cnt && side1Cnt != side3Cnt) {
              if ((sideArray[side1Cnt] + sideArray[side2Cnt]) > sideArray[side3Cnt]
                  && (sideArray[side2Cnt] + sideArray[side3Cnt]) > sideArray[side1Cnt]
                      && (sideArray[side3Cnt] + sideArray[side1Cnt]) > sideArray[side2Cnt]) {
                if (sideArray[side1Cnt] != sideArray[side2Cnt]
                    && sideArray[side2Cnt] != sideArray[side3Cnt]
                      && sideArray[side1Cnt] != sideArray[side3Cnt]) {
                  triagleNum++;
                }
              }
            }
          }
        }
      }
      System.out.println(triagleNum);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      stdIn.close();
    }
    long endTime = System.currentTimeMillis();
    double resultTime = (double)(endTime - startTime) / 1000;
    //System.out.println("処理時間：" + resultTime + "ミリ秒");
  }
}

Measured memory_bytes: 36048
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int D, N;
int T[1000];
vint ok[1000];
int C[1000];

int dp[1000][1000];

int main() {
    while (cin >> D >> N) {
        for (int i = 0; i < D; ++i) {
            cin >> T[i];
            ok[i].clear();
        }
        for (int i = 0; i < N; ++i) {
            int a, b; cin >> a >> b;
            for (int j = 0; j < D; ++j) if (a <= T[j] && T[j] <= b) ok[j].PB(i);
            cin >> C[i];
        }
        
        memset(dp, -1, sizeof(dp));
        for (int i = 0; i < ok[0].size(); ++i) dp[1][ok[0][i]] = 0;
        
        int res = -1;
        for (int i = 1; i < D; ++i) {
            for (int j = 0; j < N; ++j) {
                if (dp[i][j] == -1) continue;
                
                //cout << i << ", " << j << " : " << dp[i][j] << endl;
                
                for (int k = 0; k < ok[i].size(); ++k) {
                    int nj = ok[i][k];
                    chmax(dp[i+1][nj], dp[i][j] + abs(C[nj] - C[j]));
                    
                    if (i == D-1) chmax(res, dp[i+1][nj]);
                }
            }
        }
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int n,m,size_subtree=0,ans=0;
vector<vector<int>>adj(202020);
vector<bool>vis(202020,false);
void DFS(int source){
  vis[source]=true;
  for(auto node:adj[source]){
    if(!vis[node]){
      size_subtree++;
      DFS(node);
    }
  }
}
int main(){
  fastIO();
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int nodeA,nodeB;
    cin>>nodeA>>nodeB;
    adj[nodeA].push_back(nodeB);
    adj[nodeB].push_back(nodeA);
  }
  for(int i=1;i<=n;i++){
    if(!vis[i]){
      size_subtree=0;
      DFS(i);
      ans=max(ans,size_subtree);
    }
  }
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 20556
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int N=Integer.parseInt(sc.nextLine());
        for(int i=0;i<N;i++){
            run();
        }
    }
    static void run(){
        String[] s = sc.nextLine().split(" ");
        int x=Integer.parseInt(s[0]);
        int y=Integer.parseInt(s[1]);
        int b=Integer.parseInt(s[2]);
        int p=Integer.parseInt(s[3]);
        int ans=b*x+y*p;
        if(b>4&&p>1){
            x=x*4/5;
            y=y*4/5;
            ans=b*x+y*p;
        }else{
            if(b<5)b=5;
            if(p<2)p=2;
            int a=(b*x+y*p)*4/5;
            if(ans>a)ans=a;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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

    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N],b[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=n;i>=1;i--) scanf("%d",&b[i]);
    for(int i=1;i<=n;i++){
        if(a[i]==b[i]){
            bool flag=0;
            for(int j=1;j<=n;j++){
                if(b[j]!=a[i]&&b[i]!=a[j]){
                    swap(b[i],b[j]);
                    flag=1;
                    break;
                }
            }
            if(!flag){
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes\n");
    for(int i=1;i<=n;i++) printf("%d ",b[i]);
    return 0;
}

Measured memory_bytes: 5344
#include <stdio.h>

int main(){
	int countTable[256] = {0};
	char ch;

	while((ch = getchar()) != EOF){
				countTable[ch]++;
	}
	for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}

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

const int MX = 105, MK = 1e5+10, MOD = 1e9+7;
// dp[i][j]: numbers of ways to distribute j candies to the children from 1 to i
int a[MX];
long long dp[MX][MK];

int main() {
    //cin.sync_with_stdio(0), cin.tie(0);
    //cout.sync_with_stdio(0), cout.tie(0);
    
    //freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", a+i);
	
	for (int i = 0; i <= k; i++)
		dp[0][i] = 1;
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			
			if (j > a[i])
				dp[i+1][j] = dp[i][j] - dp[i][j-a[i]-1];
			else
				dp[i+1][j] = dp[i][j];
			if (j)
				dp[i+1][j] += dp[i+1][j-1];
			dp[i+1][j] %= MOD;
		}
	}
	
	if (k)
		printf("%lld\n", (dp[n][k] - dp[n][k-1] + MOD) % MOD);
	else
		puts("1");		
    
    return 0;
}


Measured memory_bytes: 80128
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	s = readline() |> chomp
	t = readline() |> chomp
	flg = n
	for i in 0:n
		f = 0
		for j in 1:n-i
			if s[j+i]!=t[j]
				f = 1
				break
			end
		end
		if f == 0
			flg = i
			break
		end
	end
	println(flg+n)
end
main()


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;

constexpr int INF = 1001001001;

vector<int> to[2505];
vector<int> ot[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
    if (reachableFrom1[v])return;
    reachableFrom1[v] = true;
    for (int u : to[v]) {
        dfs(u);
    }
}
void rdfs(int v) {
    if (reachableToN[v])return;
    reachableToN[v] = true;
    for (int u : ot[v]) {
        rdfs(u);
    }
}

void Main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<tuple<int, int, int>> edges;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;   //1-indexed;
        c -= p;
        c = -c;
        edges.emplace_back(a, b, c);
        to[a].push_back(b);
        ot[b].push_back(a);

    }
    dfs(0);
    rdfs(n - 1);
    rep(i, n) ok[i] = reachableFrom1[i] && reachableToN[i];
    {
        //bellman-ford
        vector<int> d(n, INF);
        d[0] = 0;
        bool upd = true;
        int step = 0;
        while (upd) {
            upd = false;
            rep(i, m) {
                int a, b, c;
                tie(a, b, c) = edges[i];
                if (!ok[a])continue;
                if (!ok[b])continue;
                int newD = d[a] + c;
                if (newD < d[b]) {
                    upd = true;
                    d[b] = newD;
                }
            }
            ++step;
            if (step > n) {
                puts("-1");
                return;
            }
        }
        int ans = -d[n - 1];
        ans = max(ans, 0);
        cout << ans << endl;
    }

    vector<int> d(n, INF);
    rep(i, n) {
        
    }
}

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


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


int main(){
  ll a,b,c,d;
  cin >> a>> b>>c >>d;
  ll g=c / __gcd(c, d) * d;
  ll ans=0;
  ll v=(a-1)/c+(a-1)/d-(a-1)/g;
  ans=(b-a+1)-(b/c+b/d-b/g-v);
  cout << ans << endl;
}

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

using namespace std;

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

int main() {
	string str[8] = {"AAA","AA","A","B","C","D","E","NA"};
	double st[2][8] = {
		{35.50, 37.50, 40.0, 43.0, 50.0, 55.0, 70.0, INF},
		{71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, INF}
	};
	
	double t[2];
	while (cin >> t[0] >> t[1]) {
		int ans[2];
		REP(i, 2) REP(j, 8) {
			if (st[i][j] > t[i]) {
				ans[i] = j;
				break;
			}
		}
		cout << str[max(ans[0], ans[1])] << endl;
		
	}
	
	return 0;
}

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


void solve()
{
   int mod = 1e9+7;
   int n,m; cin >> n >> m;

   vector<string>res;
   
   for(int i = 0 ; i < n ; i ++) 
   {
       string t; cin >> t;
       //cout << t << endl; 
       res.push_back(t);
   }
   
   int memo[n+1][m+1];
   
    
   //memo[0][0] = 1; 
   
   for(int i = 0 ; i < n ; i ++){
       
    for(int j = 0 ; j < m ;  j++){
        
          if( i == 0 and j == 0 ){
              memo[i][j] = 1;
          }
          else if( i == 0 )
          {  
              memo[i][j] = ( (res[i][j] == '.') * 1l * memo[i][j-1] ) % mod;
          }
          else if(j == 0)
          {
              memo[i][j] = ( (res[i][j] == '.')*1l*memo[i-1][j] ) % mod;
          }
          else
          {
              memo[i][j] = ( (res[i][j] == '.') * ( 0l +  memo[i][j-1] + memo[i-1][j] ) ) % mod;
          }
          
          //cout << " i " << i << " j " << j << " " << memo[i][j] << endl; 
        }
   }

    cout << memo[n-1][m-1] << endl; 


}

int main()
{

    solve(); 
    return 0;
}




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

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

int main(void){
	int32 N;
	cin >> N;
	int32 res = 0;
	FOR(i, 2, 55556){
		int32 cnt = 0;
		FOR(j, 2, i){
			if(i%j == 0) cnt++;
		}
		if(cnt == 0 && i%5 == 1){
			cout << i << endl;
			res++;
			if(res == N) break;
		}
	}
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    s = list(input())
    init = [["S","S"], ["S","W"], ["W","S"], ["W","W"]]
    def addsheep (prev, now):
        if s[now] == "o":
            if ans[now] == "S" and ans[prev] == "S":
                return "S"
            elif ans[now] == "S" and ans[prev] == "W":
                return "W"
            elif ans[now] == "W" and ans[prev] == "S":
                return "W"
            elif ans[now] == "W" and ans[prev] == "W":
                return "S"
        if s[now] == "x":
            if ans[now] == "S" and ans[prev] == "S":
                return "W"
            elif ans[now] == "S" and ans[prev] == "W":
                return "S"
            elif ans[now] == "W" and ans[prev] == "S":
                return "S"
            elif ans[now] == "W" and ans[prev] == "W":
                return "W"

    OK = False
    for i in init:
        ans = i
        for j in range(n-2):
            ans.append(addsheep(j, j+1))

        if addsheep(n-2, n-1) == ans[0] and addsheep(n-1,0) == ans[1]:
            OK = True
            break
    if OK:
        print("".join(ans))
    else:
        print(-1)
resolve()

Measured memory_bytes: 13056
//AtCoder Beginner Contest 065 A

#include <iostream>

using namespace std;

int main() {
	int day_over;//X(賞味期限を過ぎた日数)
	int day_before;//A(賞味期限の何日前に買ったか)
	int day_after;//B(買ってから何日か)

	//////////////////読み込み////////////////////////////
	cin >> day_over >> day_before >> day_after;

	//賞味期限を基準として(0)賞味期限から何日経ったかを調べる
	//マイナスなら賞味期限前delicious
	//正の数かつ賞味期限を過ぎても大丈夫な日数以下であればsafe
	//それ以外がdengerous

	if (day_after - day_before <= 0) {
		cout << "delicious" << endl;
	}
	else if (day_after - day_before <= day_over) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

	i64 ans = 0;
	const int MOD = 1e9 + 7;
	for(i64 k = 0; k < 60; k++) {
		i64 A = 0, B = 0;
		for(auto v: a) {
			A += (v >> k & 1);
			B += !(v >> k & 1);
		}

		(ans += (1LL << k) % MOD * A % MOD * B % MOD) %= MOD;
	}
	
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, char, long long, string> > vt(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    char c;
    long long d;
    string e;
    cin >> a >> b >> c >> d >> e;
    vt.at(i) = make_tuple(a, b, c, d, e);
  }
  sort(vt.begin(), vt.end());
  for (int i = 0; i < n; i++) {
    cout << get<0>(vt.at(i)) << " " << get<1>(vt.at(i)) << " " << get<2>(vt.at(i))
     << " " << get<3>(vt.at(i)) << " " << get<4>(vt.at(i)) << endl;
  }
}


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

string position_change(string str, int h){
    string head = str.substr(0, h);
    string tail = str.substr(h);
    return tail + head;
}

int main(){

    while(true){
        string str;
        int m;
        cin >> str >> m;
        if ( str == "-" ){
            break;
        }
        for(int i = 0; i < m; ++i){
            int h;
            cin >> h;
            str = position_change(str, h);
        }
        cout << str << endl;
    }

    return 0;
}


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


int sum(int a,int b)
{
    int tot=0;
    while(a!=0){
        tot+=a%10;
        a/=10;
    }
    while(b!=0){
        tot+=b%10;
        b/=10;
    }
    return tot;
}


int main()
{
    int ret=1e9;
    int n;
    cin>>n;
    for(int i=1;i<=n/2;i++){
        ret=min(ret,sum(i,n-i));
    }
    cout<<ret;



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max({a,b,c})-min({a,b,c})<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define F first 
#define S second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

template <class T>
T in(){ T x; cin >> x; return (x);}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n=in<int>();
    int p[100100];
    REP(i,1,n+1) cin >> p[i];
    int cnt = 0;
    REP(i,1,n+1){
        if(p[i]==i){
            cnt++;
            swap(p[i], p[i + 1]);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
vector<ll int>ed[N];
ll int k;
ll n;
ll w[N];
void dfs(int i,ll d,int p)
{
	//w[i]=max(0,k-d);
	ll int cnt=0;
	for(int j:ed[i]){
		if(j==p)continue;
		w[j]=max(k-d-cnt,0ll);
		cnt++;
	}
	for(int j:ed[i]){
		if(j==p)continue;
		dfs(j,min(d+1,2ll),i);
	}
}
void solve(){
	cin>>n>>k;
	rep(i,n-1){
		int u,v;
		cin>>u>>v;
		ed[u].pb(v);
		ed[v].pb(u);
	}
	dfs(1,1,-1);
	ll res=1;
	w[1]=k;
	for(int i=1;i<=n;i++){res=(res*w[i])%mod;}//cout<<w[i]<<" ";}
	cout<<res;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

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

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;

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

    int n, m; cin >> n >> m;
    int temp; int sum = 0; int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> temp;
        a[i] = temp; sum += temp;
    }
    int count = 0;
    double num = (double) 1/(4*m);
    forn(i, n) if(a[i] >= sum*num) ++count;

    if(count < m)  cout << "No" << endl;
    else cout << "Yes" << endl;

}


Measured memory_bytes: 256