akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int ma[11];
int a[11];int b[11];

bool ch;

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

void dfs(int deep,int aa,int bb)
{
    if(ch)return ;
    if(deep==10)
    {
        ch=true;
        return ;
    }


    if(ma[deep]>a[aa-1])
    {
        a[aa]=ma[deep];
        dfs(deep+1,aa+1,bb);
    }

    if(ch==false&&ma[deep]>b[bb-1])
    {
        b[bb]=ma[deep];
        dfs(deep+1,aa,bb+1);
    }

}


int main()
{
    int f;
    scanf("%d",&f);
    while(f--)
    {
        ch=false;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=0;i<10;i++)
            scanf("%d",&ma[i]);
        dfs(0,1,1);
        if(ch)
            printf("YES\n");
        else
            printf("NO\n");
    }


}

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

using namespace std;

int main()
{
  string c[2]; cin >> c[0] >> c[1];
  if (c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

int dp[3010][3010];
string x,y;

void chk(string a,string b)
{
	int l1=a.size();
	int l2=b.size();
	
	for(int i=1;i<l1;i++)
	{
		for(int j=1;j<l2;j++)
		{
			if(a[i]==b[j]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
}

void print(int i,int j)
{
	if(i==0 || j==0) return;
	if(x[i]==y[j])
	{
		print(i-1,j-1);
		cout<<x[i];
	}
	else if(dp[i-1][j]==dp[i][j]) print(i-1,j);
	else if(dp[i][j-1]==dp[i][j]) print(i,j-1);
}

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

	cin>>x>>y;
	x="2"+x;
	y="1"+y;
	chk(x,y);
	
	print(x.size()-1,y.size()-1);
		
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

vector<string> toV(string s){
  string x;
  vector<string> res;
  FOR(i,0,s.size()){
    if(s[i]=='b'){
      x.push_back('b');
    }
    else if(s[i]=='/'){
      res.push_back(x);
      string inst;
      x=inst;
    }
    else{
      ll p = s[i] - '0';
      FOR(i,0,p){
        x.push_back('.');
      }
    }
  }
  res.push_back(x);
  return res;
}

string toS(vector<string> v){
  ll m = v[0].size();
  ll n = v.size();
  string res;
  FOR(i,0,n){
    char x='0';
    FOR(j,0,m){
      if(v[i][j]=='b'){
        if(x!='0')res.push_back(x);
        res.push_back('b');
        x = '0';
      }
      else if(v[i][j]=='.'){
        x++;
      }
    }
    if(x!='0')res.push_back(x);
    x='0';
    if(i!=n-1)res.push_back('/');
  }
  return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    vector<string> v;
    cin>>s;
    while(s!="#"){
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      v=toV(s);
      v[a-1][b-1]='.';
      v[c-1][d-1]='b';
      s=toS(v);
      cout<<s<<endl;

      cin>>s;
    }
}



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

int main() {
 int n ; 
 cin>>n; int a ;
 vector<int> inp ;
 for(int i = 0 ; i<n ; i++){
    cin>>a ;
    inp.push_back(a);
 }
 vector<int> ans(n,-1) ; int m1,m2 ;
 ans[0] = 0 ; ans[1] = abs(inp[1] - inp[0]) ;
 for(int i = 2 ; i<n;i++){
     m1 = ans[i-2] + abs(inp[i] - inp[i-2]) ;
     m2 = ans[i-1] + abs(inp[i] - inp[i-1]) ;
     ans[i] = min(m1,m2) ;
 }
 cout<<ans[n-1] ;   
    
}

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

int main(){
  int N,T,A,count;
  double min = DBL_MAX;
  cin >> N >> T >> A;
  for (int i = 0;i < N;i++){
    int H;
    cin >> H;
    if (min > abs(A -( T - H * 0.006))){
      min = abs(A -( T - H * 0.006));
      count = i + 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/**
 *    author:  zjsdut
 *    created: 2020/03/09 17:17:52
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  string s, t;
  int a, b;
  scan(s, t, a, b);
  string u;
  scan(u);
  if (s == u) {
    --a;
  } else {
    --b;
  }
  println(a, b);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <map>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    
    long long X;
    cin >> X;
    long long ans = 0;
    long long kane = 100;
    
    while(true){
        
        if(X <= kane){
            cout << ans << endl;
            return 0;
        }
        
        kane += (kane / 100);
        ans++;
    }
    
    
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int LIMIT = 1e9 + 7;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

template<class T>
class UnionFind {
  vector<T> par;
public:
  UnionFind(T n) : par(n, -1) { }
  void init(T n) { par.assign(n, -1); }
  
  T root(T x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  
  bool isSame(T x, T y) {
    return root(x) == root(y);
  }
  
  bool merge(T x, T y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  T size(T x) {
    return -par[root(x)];
  }
};


int main(){
	ll N,M;cin>>N>>M;
  vi A(M), B(M);
  rep(i,M){
    cin>>A[i]>>B[i];
    A[i]--; B[i]--;
  }

  UnionFind<ll> uf(N);

  vector<ll> ans(M+1);
  ans[M] = N*(N-1)/2; //ここでオーバーフローするので "ll N"
  for(int i=M-1; i>=0; i--){
    ll a = uf.size(A[i]);
    ll b = uf.size(B[i]);
    if( !uf.merge(A[i], B[i]) ){
      ans[i] = ans[i+1];
    }else{
      ans[i] = ans[i+1] - (a*b);
    }
  }

  for(int i=1; i<=M; i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 5624
#include<iostream>
#include<cstdio>
using namespace std;
 
int main(){
  int i,j,n,ans[100000],calc[100000];
 
  calc[0]=2;
  for(i=1;i<100000;i++)calc[i]=calc[i-1]+1;
  ans[1]=2;
  for(i=2;i<100000;i++)ans[i]=ans[i-1]+calc[i-2];
 
  while(cin >> n){
    cout << ans[n] << endl;
 
  }
 
}


Measured memory_bytes: 3764
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B,C,D=map(int,input().split())
    print(max(A*B,C*D))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
HH = inpl()
cnts = [0]*(N+1)
HH.append(INF)

for i in reversed(range(N)):
    if HH[i] >= HH[i+1]:
        cnts[i] = cnts[i+1] + 1
    else:
        continue

print(max(cnts))


Measured memory_bytes: 16032
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-19 21:06:30
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    void connect(int x, int y) {
        //x は yの上司
        par[y] = x;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int sub(int x) {
        int sum = 0;
        for (int i = 0; i < par.size(); i++) {
            if (par[i] == x) sum++;
        }

        return sum;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> a(n-1);
    for (int i = 0; i < n-1; i++) {
        cin >> a[i];
    }

    map<int, int> sub;
    for (int i = 0; i < n-1; i++) {
        sub[a[i]]++;
    }

    for (int i = 1; i <= n; i++) {
        if (sub[i] > 0) cout << sub[i] << endl;
        else cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 13552
A, B, C, D, E, F = gets.chomp.split.map(&:to_i)

maxDensity = 0
ans = []

0.upto(F/100) do |a|
  0.upto(F/100) do |b|
    w = a * A + b * B
    water = w * 100
    next if water > F
    limit = w * E

    0.upto(F/C) do |c|
      0.upto(F/D) do |d|
        sugar = c * C + d * D
        sugarWater = water + sugar
        next if sugarWater > F || sugarWater == 0
        density = (sugar * 100) / sugarWater.to_f

        if sugar <= limit && maxDensity <= density 
          maxDensity = density
          ans = [sugarWater, sugar]
        end
      end
    end
  end
end

puts ans.join(' ')

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

typedef long long ll;

int A,B,C,X,Y;
ll ans = 1e9;
ll sum = 0;
void solve1() {
  while(1) {
    if( A >= C*2 ) {
      sum += C*2;
      X--;
      if( X == 0 ) return;
    } else {
      sum += A;
      X--;
      if( X == 0 ) return;
    }
  }
}

void solve2() {
  while(1) {
    if( B >= C*2 ) {
      sum += C*2;
      Y--;
      if( Y == 0 ) return;
    } else {
      sum += B;
      Y--;
      if ( Y == 0 ) return;
    }
  }
}

int main() {
  cin >> A >> B >> C >> X >> Y;
  if ( A+B > C*2 ) {
    while(1) {
      sum += C*2;
      X--;
      Y--;
      if ( X == 0 || Y == 0 ) break;
    }
    if ( X > Y ) solve1();
    else if ( X < Y ) solve2();
  } else if ( A+B < C*2 ) {
    while(1) {
      sum += A+B;
      X--;
      Y--;
      if ( X == 0 || Y == 0 ) break;
    }
    if ( X > Y ) solve1();
    else if ( X < Y ) solve2();
    
  } else if ( A+B == C*2 ) {
    while(1) {
      sum += A+B;
      X--;
      Y--;
      if ( X == 0 || Y == 0 ) break;
    }
    if ( X > Y ) solve1();
    else if ( X < Y ) solve2();
    
  }

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


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

int main(){
    int n, k, temp, sum1, sum2, min;
    sum1 = 0;
    sum2 = 0;
    cin >> n;
    vector <int> N(n);
    for(int i = 0; i < n; i++){
        cin >> N.at(i);
        sum1 += N.at(i);
    }
    temp = sum1 / n;
    for (int j = 0; j < n; j++){
        sum2 += (temp - N.at(j))*(temp - N.at(j));
    }
    min = sum2;
    sum2 = 0;
    for (int j = 0; j < n; j++){
        sum2 += (temp + 1 - N.at(j))*(temp + 1 - N.at(j));
    }
    if(min > sum2){
        min = sum2;
    }

    cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#define PI acos(-1)
using namespace std;
int R;
float ans;
int main( ) {
    cin>>R;
    // scanf("%d", &R);
    ans = 2*R*PI;
    cout<<ans;
    // printf("%f", ans);
    return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	int a[n];
  	for (int i = 0; i < n; i++)	cin >> a[i];
  	int ans = 1;
  	sort(a, a + n);
  	for (int i = 1; i < n; i++)
      	if (a[i] > a[i-1]) ++ans;
  	cout << ans << endl;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

						  // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {

	long long a, b;	cin >> a >> b;

	if (a == 1 || b == 1) {
		cout << 1 << endl;
		return 0;
	}

	vector<pair<long long, long long>> a_prime;
	vector<pair<long long, long long>> b_prime;

	a_prime = prime_factorize(a);
	b_prime = prime_factorize(b);

	vector<long long> c;
	for (long long i = 0; i < a_prime.size(); i++) {
		c.push_back(a_prime[i].first);
	}
	for (long long i = 0; i < b_prime.size(); i++) {
		c.push_back(b_prime[i].first);
	}

	sort(c.begin(), c.end());
	
	long long ans = 1; // 1を考慮
	for (long long i = 0; i < c.size() - 1LL; i++) {
		if (c[i] == c[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
test = int(input())
l = []
for i in range(test):
    l.append(str(input()))
wrong = l.count('WA')
accepted = l.count('AC')
tle = l.count('TLE')
re = l.count('RE')
print('AC x', str(accepted))
print('WA x', str(wrong))
print('TLE x', str(tle))
print('RE x', str(re))

Measured memory_bytes: 16184
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define f first
#define s second

using namespace std;
typedef long long ll;

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

	int n,x,t;
	cin >> n >> x >> t;
	cout << t*((n+x-1)/x) << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
int N, L, a[100001];
int main()
{
	scanf("%d%d", &N, &L);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	for (int i = 1; i < N; i++)
		if (a[i] + a[i + 1] >= L)
		{
			puts("Possible");
			for (int j = 1; j < i; j++)
				printf("%d\n", j);
			for (int j = N - 1; j > i; j--)
				printf("%d\n", j);
			printf("%d\n", i);
			return 0;
		}
	puts("Impossible");
	return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int, h: "List[int]"):
    def can(n, A, B, a):
        tmp = 0
        base = B * n
        diff = A - B
        for v in a:
            rest = v - base
            if rest > 0:
                tmp += (rest - 1) // diff + 1
        if tmp <= n:
            return True
        return False
    h.sort(reverse=True)
    mx = h[0]
    l = 0
    r = (mx - 1) // B + 1
    while r - l > 1:
        m = (r + l) // 2
        if can(m, A, B, h):
            r = m
        else:
            l = m
    #print(l, r)
    ret = r
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B, h)

if __name__ == '__main__':
    main()


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

using namespace std;
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define pii pair<ll, ll>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define tiii tuple<ll, ll, ll>
#define INF 1e18
#define MOD 1000000007

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


	for (int i = 0; i < S.length(); i++)
		if (S[i] == '?')
			if (i > 0 and S[i - 1] == 'P')
				S[i] = 'D';
			else if (i + 1 < S.length() and (S[i + 1] == 'D' or S[i + 1] == '?'))
				S[i] = 'P';
			else
				S[i] = 'D';
	cout << S << "\n";

	return 0;
}

Measured memory_bytes: 3784
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int PN = 12;
const int KM = 1 << (PN - 1);
ll dat[1 << PN];

ll check(int L, int R, int A, int l, int r) {
	if (L <= l && r <= R) return dat[A];
	if (r <= L || R <= l) return 1ll << 60;
	return min(check(L, R, A * 2, l, (l + r) >> 1), check(L, R, A * 2 + 1, (l + r) >> 1, r));
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002] = {};
	rep1(i, N) {
		A[i] = ((ll)getint() << 11) + i;
		dat[KM + i] = A[i];
	}
	for (int i = KM - 1; i > 0; i--) {
		dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
	}

	priority_queue<int> q;
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 11) - 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 11;
		int k = A[i] & m;

		int l = !LR[k - 1] ? k : LR[k - 1];
		int r = !LR[k + 1] ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		int kosuu = min(K - 1, r - k) + min(K - 1, k - l) + 1;
		int abureta = max(0, kosuu - K + 1);

		rep(i, abureta) {
			ll tmp = check(l, r + 1, 1, 0, KM);
			q.push(tmp >> 11);
			int k = 31 - __builtin_clz(tmp & m);
			int C = (tmp & m) + KM;
			dat[C] = 1ll << 60;
			rep(j, k) {
				ll tmp2 = min(dat[C], dat[C ^ 1]);
				dat[(C >>= 1)] = tmp2;
			}
		}

		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int>q;
  q.push(s);
  for(int i=0;i<n;i++)d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!=INFTY)continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<( (d[i]==INFTY) ? (-1):d[i] ) << endl;
  }
}
int main(){
  int u,k,v;

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

 for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
 bfs(0);
	
  return	 0;

}



Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
  double x1,y1,x2,y2,x,y,c,s;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&x,&y)!=EOF) {
	  x-=x1; y-=y1; x2-=x1; y2-=y1;
	  c=x2/sqrt(x2*x2+y2*y2); s=y2/sqrt(x2*x2+y2*y2);
	   x2=x; x=c*x+s*y; y=-s*x2+c*y;
	   x2=x; x=x1+c*x+s*y; y=y1+s*x2-c*y;
	  printf("%.6lf %.6lf\n",x,y);
  }	  
 return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

class Solver {
    public void Solve() {
        int q = sc.nextInt();
        int ruiseki[] = new int[200_000];
        ruiseki[0] = 0;
        for (int i = 1; i < ruiseki.length; i++) {
            if (isPrime(i) && isPrime((i + 1) / 2)) {
                ruiseki[i] = ruiseki[i - 1] + 1;
            } else {
                ruiseki[i] = ruiseki[i - 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = ruiseki[r] - ruiseki[l - 1];
            System.out.println(ans);
        }

    }

    boolean isPrime(int n) {
        if (n == 2)
            return true;
        if (n == 0 || n == 1) {
            return false;
        }
        if (n % 2 == 0) {
            return false;
        } else {
            int i = 3;
            while (true) {
                if (i * i > n) {
                    return true;
                }
                if (n % i == 0) {
                    return false;
                }
                i += 2;
            }
        }
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 64264
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         ll a,b;
        cin>>a>>b;
        ll sum=0;
        for(int i=0;i<b;i++)
        {
          ll p;
          cin>>p;
          sum+=p;
        }
        if(sum>=a) cout<<"Yes\n";
        else cout<<"No\n";
         



      }
      
}






Measured memory_bytes: 256
import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
String s3 = sc.next();
String cs1 = s1.toUpperCase();
String cs2 = s2.toUpperCase();
String cs3 = s3.toUpperCase();
char ps1 = cs1.charAt(0);
char ps2 = cs2.charAt(0);
char ps3 = cs3.charAt(0);
System.out.print(ps1);
System.out.print(ps2);
System.out.print(ps3);
}
}

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

void trace(int a[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

void bubblesort(int a[], int n) {
  int chnum = 0;
  bool flag = true;
  while (flag) {
    int i;
    flag = false;
    for (i = n - 1; i > 0; i--) {
      if (a[i] < a[i-1]) {
        int tmp = a[i];
        a[i] = a[i - 1];
        a[i - 1] = tmp;
        chnum++;
        flag = true;
      }
    }
  }
  trace(a, n);
  cout << chnum << endl;
}

int main(void) {
  int i, n, j, k, v;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  bubblesort(a, n);
  return 0;
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	k := ((b * b) - (a * a)) / (2 * (b - a))
	mod := ((b * b) - (a * a)) % (2 * (b - a))
	if mod == 0 {
		fmt.Println(k)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = []
c = []

for i in a:
    if i % 2 == 0:
        b.append(i)

for s in b:
    if s % 3 == 0 or s % 5 == 0:
        c.append(True)

if len(b) == len(c):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	int n;
	cin>>n;
	int x[n],y[n],h[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
		cin>>y[i];
		cin>>h[i];
	}
	int cx,cy,H;
	for(cx=0;cx<=100;cx++){
		for(cy=0;cy<=100;cy++){
			int j=1;
			while(h[0]==0&&j!=n){
				swap(h[0],h[j]);
				swap(x[0],x[j]);
				swap(y[0],y[j]);
				j++;
			}
			H=h[0]+abs(x[0]-cx)+abs(y[0]-cy);
			for(int i=1;i<n;i++){
				if(h[i]!=0){
					if(H!=h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
						goto aiueo;
					}
				}else{
					if(H-abs(x[i]-cx)-abs(y[i]-cy)>0){
						goto aiueo;
					}
				}
				if(i==n-1)goto goal;
			}
			aiueo: ;
		}
	}
	goal:cout<<cx<<" "<<cy<<" "<<H<<endl;
	return 0;
}
		
		

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

int main(){
  string s;
  cin >> s;
  int l = 0, r = s.size()-1;
  int ans = 0;
  while(l<r){
    int xnum = 0;
    while(l<s.size()-1 && s[l] == 'x'){
      ++l;
      ++xnum;
    }
    while(r>0 && s[r] == 'x'){
      --r;
      --xnum;
    }
    if(s[l] != s[r]){
      cout << -1 << endl;
      return 0;
    }
    if(l<=r) ans += abs(xnum);
    ++l; --r;
  }
  cout << ans << endl;
}

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

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

using namespace std;

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

    if ((a <= c) && (b >= c))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;cin>>S;
    string su="Sunny",cl="Cloudy",ra="Rainy";
    if(S==su){
        cout<<cl<<endl;
    }else if(S==cl){
        cout<<ra<<endl;
    }else{
        cout<<su<<endl;
    }
}


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

typedef unsigned long long ull;

const int max_size=1010;
char pattern[max_size][max_size];
char target[max_size][max_size];

ull hash[max_size][max_size],tmp[max_size][max_size];

void calc(char a[max_size][max_size],int n,int m,int r,int c){
	const ull br=1000000007;
	const ull bc=1000000009;

	ull tc=1;
	rep(i,c) tc*=bc;

	rep(i,n){
		ull e=0;
		rep(j,c) e=e*bc+a[i][j];
		rep(j,m){
			tmp[i][j]=e;
			if(j+c>=m) break;
			e=e*bc-tc*a[i][j]+a[i][j+c];
		}
	}

	ull tr=1;
	rep(j,r) tr*=br;

	rep(j,m-c+1){
		ull e=0;
		rep(i,r) e=e*br+tmp[i][j];
		rep(i,n){
			hash[i][j]=e;
			if(i+r>=n) break;
			e=e*br-tr*tmp[i][j]+tmp[i+r][j];
		}
	}
	return;
}

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,h)rep(j,w) cin >> target[i][j];
	int r,c;
	cin >> r >> c;
	rep(i,r)rep(j,c) cin >> pattern[i][j];
	calc(pattern,r,c,r,c);
	ull pattern_hash=hash[0][0];
	calc(target,h,w,r,c);
	for(int i=0;i+r<=h;++i)
		for(int j=0;j+c<=w;++j)
			if(pattern_hash==hash[i][j])
				cout << i << " " << j << endl;
	return 0;
}

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

int main(){
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll cnt = 0;
    for (auto u: mp){
        cnt += u.second;
        if(cnt>=k){
            cout << u.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second





vi vect_2pow;
void pow_of_2(){
    vect_2pow.assign(32,0);
      for(int i=0;i<=32;i++){
           LL y = 1<<i;
           vect_2pow[i]=y;
      }
}
bool Ispalindrome(string str){
        LL len = str.size();
		bool flag;
		for(int i=0;i<len/2;i++){
				if(str[i]==str[len-i-1])
				     {
						 flag=0;
						 continue;
					 }
					 else 
					    {
							flag=1;
							break;
						}
			}
		if (flag==1)
		  return false;
		else return true;  
		
}
vector<LL> prime_check;
mii get_high_prime;
int high_prime_factor(){
	//cout<<"ecd";
	LL max_prime=0;
	for(int i=2;i<100000;i++)
	{
		LL n=i;
		
		while(n%2==0)
		{
			max_prime=2;
			n>>=1;
		}
		for(int j=3;j<=sqrt(n);j++)
		{
			while(n%j==0){
				max_prime=j;
				n/=j;
			}
		}
		if(n>2)
		  max_prime=n;
		  
		//prime_check.pb(max_prime);
		get_high_prime[i]=max_prime;
	}
	
			
}
int main()
{
	LL n;
	
	cin>>n;
	LL sum=0;
	int p;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			
			 
			for(int k=1;k<=n;k++)
			{
				 p=__gcd(i,j);
				p = __gcd(p,k);
				//cout<<p<<endl;
				sum+=p;
			}
		}
	}
	cout<<sum<<endl;

}

Measured memory_bytes: 3656
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
  
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;
const int INF = 1e9;


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int _ : in(m)) {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    vector<pair<int, int>> bridge;
    vector<int> depth(n, INF), ub(n, INF);
    function<void(int, int, int)> dfs = [&](int v, int p, int d) {
        depth[v] = d;
        ub[v] = d;
        for(int nv : adj[v]) {
            if(nv == p) continue;
            if(depth[nv] != INF) {
                ub[v] = min(ub[v], depth[nv]);
                continue;
            }
            dfs(nv, v, d + 1);
            ub[v] = min(ub[v], ub[nv]);
            if(ub[nv] > depth[v])
                bridge.emplace_back(min(v, nv), max(v, nv));
        }
    };
    dfs(0, -1, 0);
    sort(bridge.begin(), bridge.end());
    for(auto p : bridge) cout << p.first << ' ' << p.second << '\n';
    return 0;
}

Measured memory_bytes: 4776
<?php
# 入力部
// fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d %d", $s, $w);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr1 = str_split($s1);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
$r = "safe";
if ($s <= $w) {
  $r = "unsafe";
}

# 出力部
echo $r . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 15948
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()

int isEven(vector<ll> a) {

	rep(i, a.size()) if (a[i] % 2 == 1) { return 0; }
	return 1;
}
int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	int cnt = 0;
	while (isEven(a)) {
		rep(i, n) a[i] /= 2;
		cnt++;
	}
	cout << cnt << endl;


	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int al[30] = {0} ; 
    char b[2000] = {0} ; 
    int i , j , n ;
    
    i = 0 ;
    
    while( scanf("%c" , &b[i]) != EOF){
        
        if(b[i] >= 'A' && 'Z' >= b[i]){
            n = b[i] - 'A' ;
            al[n] += 1 ;
        }
        else if(b[i] >= 'a' && b[i] <= 'z'){
            n = b[i] - 'a' ;
            al[n] += 1 ;
        }
        i = i + 1 ;
    }
    
    for(j = 97 ; j <= 122 ; j++){
        n = j - 'a' ;
        printf("%c : %d\n" , j , al[n]);
    }
    return 0 ;
}


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

int main(){
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i <= sqrt(x); i++){
        int j = i * i;
        while (j <= x){
            ans = max(ans, j);
            j *= i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m,i,ans=0,cnt,j;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cnt=0;
        if(i%2==0)
            continue;
        for(j=1;j<=n;j++)
        {
            if(i%j==0)
                cnt++;
        }
        if(cnt==8)
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $l, $r);

$base = 2019;

$multiple = $base;
while ($multiple <= $r) {
    if ($l <= $multiple) {
        echo 0;
        return;
    }
    $multiple += $base;
}


$min = $base;
for ($i = $l ; $i <= $r; $i++) {
    for ($j = $i + 1; $j <= $r; $j++) {
        if ($j <= $i) {
            continue;
        }
        $tmp = $i * $j % $base;
        $min = $tmp < $min? $tmp: $min;
    }
}
echo $min;


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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(char s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp  
    long double n, m, d;

    cin >> n >> m >> d;

    long double score = (n - d) * powl(n, -2.0) * (m - 1.0);

    if(d != 0) {
        score *= 2.0;
    }

    cout << fixed << setprecision(18) << score << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    string S,T;
    cin >> S >> T;
    ll mi = 10000;
    REP(i,S.size() - T.size() + 1){
        ll count = 0;
        REP(l,T.size()){
            if(S[l+i] == T[l])count++;
        }
        chmin(mi,(ll)T.size() - count);
    }
    cout << mi << "\n";
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int R;
  cin >> R;
  cout << (2 * R * acos(-1)) << endl;
  return 0;
}


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

int main(){
    ll N; cin>>N;
    vector<pair<ll, ll>> p;
    for(ll i=2; i*i<=N; i++){
        if(N%i != 0) continue;
        ll e = 0;
        while(N%i==0){
            e++;
            N /= i;
        }
        p.push_back({i, e});
    }

    if(N != 1) p.push_back({N, 1});

    ll count = 0;
    for(pair<ll, ll> pair : p){
        ll e = 0;
        while(pair.second > 0){
            e++;
            count++;
            pair.second -= e;
            if(e >= pair.second) break;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main() {
  int n;
  cin>>n;
  int f[201010];
  rep(i,n){
      cin>>f[i];
  }
  ll ans=0,mi=f[0];
  rep(i,n){
      if(mi>=f[i]){
          mi=f[i];
          ans++;
      }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  ll n, x;
  cin >> n >> x;
  
  vector<ll> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] + a[i - 1] > x) {
      ll num = (a[i] + a[i - 1] - x);
      ans += num;
      a[i] -= num;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x,y):
	return (x * y) // gcd(x,y)

N = int(input())
a = list(map(int,input().split()))
a.sort()
tlcm = lcm(a[0],a[1])

for i in range(2,len(a)):
	tlcm = lcm(a[i],tlcm)

tlcm = tlcm - 1
result = 0
for i in range(len(a)):
	result += tlcm % a[i]
print(result)

Measured memory_bytes: 3316
#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ
# 最小化
# dp = Hash.new{ Float::INFINITY }
# dp[i] = [dp[i], dp[i-1] + hoge].min
# dp[0] = 0
# 最大化
# dp = Hash.new{ 0 }
# dp[i] = [dp[i], dp[i-1] + hoge].max
# dp[0] = 0

n,k = gets.split(' ').map(&:to_i)
P = gets.split(' ').map(&:to_i)
P.sort!
puts P.take(k).sum


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define y first
#define x second

using namespace std;
typedef long long ll;

int cnt[100005];
int main()
{
    int n;
    cin >> n;
    fr(i, 0, n){
        cnt[abs(n - i - 1 - i)] ++;
    }
    fr(i, 0, n){
        int x;
        cin >> x;
        cnt[x] --;
        if(cnt[x] < 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll mod = 1e9 + 7;
    fr(i, 0, n / 2){
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 640