akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}
template<typename Iterator> void printVecPair(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << it->first << " " << it->second << " ";
    if ((it - begin) % 10 == 9 || it == end - 1) std::cout << std::endl;
  }
}

int main(int argc, char* argv[])
{
  ll N, M;
  std::cin >> N >> M;

  std::vector< ll > vsum(N+1, 0LL);
  vsum[0] = 0;
  for (ll i = 0; i < N; i++) {
    ll a;
    std::cin >> a;
    vsum[i+1] = (a + vsum[i]) % M;
  }

  std::map<ll, ll> m;
  for (ll i = 0; i <= N; i++) {
    m[vsum[i]]++;
  }

  ll ans = 0;
  for (std::map<ll, ll>::iterator it = m.begin(); it != m.end(); it++) {
    //print(i, m[i]);
    ans += it->second * (it->second - 1) / 2;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 4992
D,G=map(int,input().split())
c=[0]+[list(map(int,input().split())) for i in range(D)]
def f(t,s):
	if t==0:
		return 10**9
	#点数が高いものを解けるだけとく
	#問題数or目標点数を満たす数
	l=min(s//(t*100),c[t][0])
	k=100*t*l
 
	#ボーナスを加味
	if l==c[t][0]:
		k+=c[t][1]
	#目標まで足りていないならその下の点数について再帰
	if k<s:
		l+=f(t-1,s-k)
	#その下の点数について再帰（ボーナスを加味するため）	
	return min(l,f(t-1,s))
 
print(f(D,G))

Measured memory_bytes: 3064
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                count+=1
print(count)
                

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn=4e3+10,mod=924844033;
int n,m,k,t,to[maxn],fac[maxn],dp[maxn][maxn>>1][2],p[maxn];
bool vis[maxn];
int main()
{
    int i,j;
    fac[0]=1;
    for(i=1;i<maxn;i++)
        fac[i]=1LL*fac[i-1]*i%mod;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)
    {
        if(i-k>=1)to[2*(i-k)]=2*i-1;
        if(i+k<=n)to[2*i-1]=2*(i+k);
    }
    int tot=0;
    for(i=1;i<=n<<1;i++)
    {
        if(!vis[i])
        {
            int j=i,cnt=0;
            while(j&&!vis[j])vis[j]=true,j=to[j],cnt++;
            p[++tot]=cnt;
        }
    }
    dp[0][0][0]=1;
    int pos=0;
    for(i=1;i<=tot;i++)
    {
        for(j=1;j<=p[i];j++)
        {
            pos++;
            for(k=0;k<=n;k++)
            {
                dp[pos][k][0]=(0LL+dp[pos-1][k][0]+dp[pos-1][k][1])%mod;
                if(j!=1)dp[pos][k+1][1]=dp[pos-1][k][0];
            }
        }
    }
    int ret=0,delta=1;
    for(i=0;i<=n;i++)
    {
        ret=(ret+1LL*delta*fac[n-i]%mod*(dp[n<<1][i][0]+dp[n<<1][i][1])%mod+mod)%mod;
        delta*=-1;
    }
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 62976
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b)
    {
        if(a!=c)
            printf("Yes");
        else
            printf("No");
    }
    else
    {
        if(c==a||c==b)
            printf("Yes");
        else
            printf("No");
    }
}


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

int main() {
    // input
    string N;
    cin >> N;

    // solve
    bool flag = false;
    if ((N[1] == N[2]) && (N[0] == N[1] || N[2] == N[3])) flag = true;

    // output
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int>ii;
typedef vector<ii>vii;
#define forn(i,n) for(ll i=0;i<n;i++)
#define wez(n) ll (n); cin>>(n);
#define w(t) while(t--)
#define setmax(a,b) (a)=max((a),(b))
#define setmin(a,b) (a)=min((a),(b))
#define pb push_back
#define mp make_pair
#define pie 3.1415926535897;
#define inf 1000000000;
#define outa(a,e) forn(i,e) cout << a[i] << (i==e-1?'\n':' ')
#define oute(n) cout<<n<<"\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a[3];
    forn(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<(a[0]*a[1])/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    set<ll> s;
    for (ll i = 0; i < 3; i++)
    {
        ll t;
        cin >> t;
        s.insert(t);
    }
    if (s.size() == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int ans = 0;
  for(int i = 0;i<N;i++){
    for(int k = i+1;k<N;k++){
      ans += a[i]*a[k];
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef tuple<string, int, int> restaurant;
bool Compare(const restaurant& x, const restaurant& y) {
	if (get<0>(x) != get<0>(y)) return get<0>(x) < get<0>(y);
	return get<1>(x) > get<1>(y);
}

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

	vector<restaurant> rest(n);

	string s;
	int p;

	for (int i = 0; i < n; i++) {
		cin >> s >> p;
		rest[i] = make_tuple(s, p, i);
	}

	sort(rest.begin(), rest.end(), Compare);

	for (int i = 0; i < n; i++) {
		cout << get<2>(rest[i])+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  for(auto&& e:s) {
    cin>>e;
  }
  int res=1e9;
  for(int bt=0;bt<1<<(h-1);++bt) {
    vector<int> p{0};
    for(int i=1;i<h;++i) {
      if(bt>>(i-1)&1) {
        p.push_back(i);
      }
    }
    p.push_back(h);
    int n=p.size()-1;
    int cur=n-1;
    int l=0,r=0;
    while(l<w) {
      vector<int> c(n);
      while(r<w) {
        for(int t=0;t<n;++t) {
          for(int i=p[t];i<p[t+1];++i) {
            c[t] += s[i][r] == '1';
          }
        }
        if(*max_element(begin(c),end(c))>k){
          break;
        }
        ++r;
      }
      if (l == r) {
        cur = 1e9;
        break;
      }
      l=r;
      if(l<w) cur++;
    }
    res=min(res,cur);
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
using namespace std;

// 并?集相?数据与算法
#define MAX_N 100000 + 16
int parent[MAX_N];
int height[MAX_N];

void init(const int& n)
{
	for (int i = 0; i < n; ++i)
	{
		parent[i] = i;
		height[i] = 0;
	}
}

int find(const int& x)
{
	if (parent[x] == x)
	{
		return x;
	}
	else
	{
		return parent[x] = find(parent[x]);
	}
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}

	if (height[x] < height[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (height[x] == height[y])
		{
			++height[x];
		}
	}
}

bool same(const int& x, const int& y)
{
	return find(x) == find(y);
}
// End Of 并?集

// 原始的?用它来描述
vector<int> children[MAX_N];
int parent_tree[MAX_N];
bool marked[MAX_N];
int ancestor[MAX_N];
// ?条指令被拆分? 操作 + 目?
stack<char> operation;
stack<int>  target;

void bfs(int index, int the_ancestor)
{
	queue<int> q_index;
	queue<int> q_ancestor;
	q_index.push(index);
	q_ancestor.push(the_ancestor);
	while (!q_index.empty())
	{
		the_ancestor = q_ancestor.front(); q_ancestor.pop();
		index = q_index.front(); q_index.pop();
		if (marked[index] == true)
		{
			the_ancestor = index;
		}
		ancestor[index] = the_ancestor;
		for (vector<int>::iterator it = children[index].begin(); it != children[index].end(); ++it)
		{
			q_index.push(*it);
			q_ancestor.push(the_ancestor);
		}
	}
}

int main(int argc, char *argv[])
{

	int N, Q;
	while (cin >> N, cin >> Q, N)
	{
		for (int i = 0; i < N; ++i)
		{
			children[i].clear();
			marked[i] = false;
		}
		marked[0] = true;
		int p;
		for (int i = 1; i < N; ++i)
		{
			cin >> p; --p;
			parent_tree[i] = p;
			children[p].push_back(i);
		}
		for (int i = 0; i < Q; ++i)
		{
			char o;
			int t;
			cin >> o >> t; --t;
			if (o == 'M')
			{
				if (marked[t])
				{
					continue;
				}
				else
				{
					marked[t] = true;
				}
			}
			operation.push(o);
			target.push(t);
		}
		bfs(0, 0);
		init(N);
		for (int i = 0; i < N; ++i)
		{
			unite(i, ancestor[i]);
		}
		unsigned long long result = 0;
		while (!operation.empty())
		{
			char o = operation.top(); operation.pop();
			int t = target.top(); target.pop();
			if (o == 'Q')
			{
				result += ancestor[find(t)] + 1;	// ?目index从1?始
			}
			else
			{
				// ?行“反染色”操作，之后?个?点的祖先??其父?点的祖先
				int p = ancestor[find(parent_tree[t])];
				unite(t, parent_tree[t]);
				ancestor[find(t)] = p;
			}
		}
		cout << result << endl;
	}
	

	return 0;
}

Measured memory_bytes: 11544
#include <iostream>
using namespace std;
int main(void){
    double w; //体重

    while(cin >> w){
        if(w <= 48.00) cout << "light fly" << endl;
        else if(w > 48.00 && w <= 51.00) cout << "fly" << endl;
        else if(w > 51.00 && w <= 54.00) cout << "bantam" << endl;
        else if(w > 54.00 && w <= 57.00) cout << "feather" << endl;
        else if(w > 57.00 && w <= 60.00) cout << "light" << endl;
        else if(w > 60.00 && w <= 64.00) cout << "light welter" << endl;
        else if(w > 64.00 && w <= 69.00) cout << "welter" << endl;
        else if(w > 69.00 && w <= 75.00) cout << "light middle" << endl;
        else if(w > 75.00 && w <= 81.00) cout << "middle" << endl;
        else if(w > 81.00 && w <= 91.00) cout << "light heavy" << endl;
        else cout << "heavy" << endl;
    }
}



Measured memory_bytes: 3140
a,b,m=(int(x) for x in input().split())
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
mi = (min(la) + min(lb))
for i in range(m):
	x,y,c=(int(x) for x in input().split())
	z = la[x-1]+lb[y-1]-c
	if mi > z:
		mi=z
print(mi)


Measured memory_bytes: 18740
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double total = 0;
    for (int i = 0; i < N; i++) {
      double money = sc.nextDouble();
      String A = sc.next();
      String B = "JPY";
      if (A.equals(B)) {
        total += money;
      } else {
        total += money * 380000;
      }
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 23124
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
void add_self(int & a, int b){
    a += b;
    if(a >= mod)a-=mod;
}

int main(){
   IOS

   string s; cin>>s;

   int D; cin>>D; 

   int n = s.length();

   vector<vi> dp(D, vi(2));

   //dp[sum][sm_already] : the num of ways to choose digits so far
   //st the sum of digits modulo D is 'sum' and 
   //sm_already tells whether we already chose some digit smaller than K

   dp[0][0] = 1;

   for(int where = 0; where < n; ++where){
       vector<vi>new_dp(D, vi(2));
       for(int sum = 0; sum < D; ++sum){
           for(bool sm_already : {false, true}){
               for(int digit = 0; digit < 10; ++digit){
                   if(digit > s[where]-'0' and !sm_already){
                       break;
                   }
                   add_self(new_dp[(sum+digit)%D][sm_already or digit < s[where]-'0'],dp[sum][sm_already]);

               }
           }

       }
       dp = new_dp;
   }

   int ans = (dp[0][false] + dp[0][true])%mod;
   --ans;
   if(ans == -1)
    ans = mod-1;

    cout<<ans<<"\n";

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& os, const ModInt<MOD>& mi) { return os << mi.get(); }
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb() { fac.resize(FAC_MAX + 1, 1); ifac.resize(FAC_MAX + 1, 1);
        for (int i = 1; i <= FAC_MAX; i++) fac[i] = fac[i - 1] * i;
        for (int i = 1; i <= FAC_MAX; i++) ifac[i] = T(1) / fac[i]; }
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }
    T fact(int n) { if (n < 0) return T(0); return fac[n]; }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------


int main() {
    Comb<mint, 100001> com;
    int n; cin >> n;
    vector<int> a(n + 1);
    for (int i = 0; i <= n; i++) cin >> a[i], a[i]--;

    vector<int> id(n, -1);
    int l, r;
    for (int i = 0; i <= n; i++) {
        if (id[a[i]] == -1) {
            id[a[i]] = i;
        } else {
            l = id[a[i]], r = i;
        }
    }
    int dist = r - l + 1;

    for (int k = 1; k <= n + 1; k++) {
        mint ans = com.aCb(n+1, k) - com.aCb(n+1 - dist, k-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
int main(){

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

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

    m = b - a;
    cout << m;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)

#define Rep(j,n) for(int j=0;j<(int)(n);++j)

#define int long long

using namespace std;

signed main()
{
  int x=0,y=0;
  std::cin >> x;
  int v;
rep(i,x){
cin >> v;
y+=v;
}
cout << y-x << '\n';
}


Measured memory_bytes: 256
pt = []
x1, y1, x2, y2 = map(int, input().split())
q = int(input())

for _ in range(q):
    xq, yq = map(int, input().split())
    if x2 - x1 == 0:
        pt.append([x1, yq])
    else:
        a1 = (y2-y1)/(x2-x1)
        b1 = y1 - a1*x1
        if a1 == 0:
            pt.append([xq, y1])
        else:
            a2 = -1/a1
            b2 = yq - a2*xq
            x = (b2-b1)/(a1-a2)
            y = a1*x + b1
            pt.append([x, y])

for i in range(q):
    print(pt[i][0], pt[i][1])



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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0) {
		cout<<"Zero";
		exit(0);
	}
	if(a>0) {
		cout<<"Positive";
		exit(0);
	}
	int cnt=b-a+1;
	if(cnt&1) cout<<"Negative";
	else cout<<"Positive"; 
	return 0;
} 

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  ll ans = 0;
  int flag = 0;
  REP(i,N){
    if(flag==0&&A[i]%2==0){
      ans+=A[i]/2;
    }else if(flag==1&&A[i]%2==0){
      ans+=A[i]/2;
      if(A[i]==0){
        flag=0;
      }
    }else if(flag==0&&A[i]%2==1){
      flag=1;
      ans+=A[i]/2;
    }else if(flag==1&&A[i]%2==1){
      flag=0;
      ans+=A[i]/2+1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4020
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int s,h,m,n;
  cin >>s;
  h=s/3600;
  m=(s-h*3600)/60;
  n=s-h*3600-m*60;
  cout<<h<<":"<<m<<":"<<n<<'\n';
  return(0);
}



Measured memory_bytes: 3088
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
 
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        List<PriorityQueue<Integer>> list = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            PriorityQueue<Integer> set = new PriorityQueue<>();
            list.add(set);
        }
 
        int m = sc.nextInt();
        for(int i = 0; i < m; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            list.get(s).add(t);
            list.get(t).add(s);
        }
 
        int groupnum = 0;
        int[] group = new int[n];
        for(int i = 0; i < n; i++) {
            if(group[i] == 0) {
                groupnum++;
                group[i] = groupnum;

                Stack<Integer> stack = new Stack<>();
                stack.push(i);
                while(!stack.isEmpty()) {
                    int j = stack.pop();
                    while(!list.get(j).isEmpty()) {
                        int k = list.get(j).poll();
                        if(group[k] == 0) {
                            group[k] = groupnum;
                            stack.push(k);
                        }
                    }
                }
            }
        }

        int q = sc.nextInt();
        for(int i = 0; i < q; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            System.out.println(group[s] == group[t]? "yes" : "no");
        }
 
        sc.close();
    }
}


Measured memory_bytes: 118268
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int ans = 0;
    rep(i,N-1) {
        if (A[i] == A[i+1]) {
            ans++;
            A[i+1] = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = input()
m = len(n)-1
for i in range(2**m):
  op = ['-'] * m
  for j in range(m):
    if ((i>>j) & 1):
      op[m -1 - j] = '+'
  formula = ''
  for p, q in zip(n, op+['']):
    formula += (p+q)
  if eval(formula) == 7:
    print(formula + '=7')
    exit()

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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

void solve() {
        int r; cin >> r;
        double ans = 2 * 3.14 * r;
        cout << fixed << std :: setprecision(10) << ans << "\n";
}

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

//        int t; cin >> t;
//        while (t--) {
                solve();
//        }
        return 0;
}



Measured memory_bytes: 3800
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt()
	a := make([]int64, N)
	min := int64(math.MaxInt64)
	mini := -1
	max := int64(math.MinInt64)
	maxi := -1
	for i := range a {
		a[i] = readInt64()
		if a[i] < min {
			min = a[i]
			mini = i
		}
		if max < a[i] {
			max = a[i]
			maxi = i
		}
	}

	if min == max {
		println(0)
		return
	}

	println(2*N - 2)
	if absInt64(min) > absInt64(max) {
		for i := 0; i < N; i++ {
			if i == mini {
				continue
			}
			println(mini+1, i+1)
		}
		for i := N - 1; i > 0; i-- {
			println(i+1, i)
		}
	} else {
		for i := 0; i < N; i++ {
			if i == maxi {
				continue
			}
			println(maxi+1, i+1)
		}
		for i := 0; i+1 < N; i++ {
			println(i+1, i+2)
		}
	}
}


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

using namespace std;

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

    vector<int> cnt(26);
    for(int i=0; i<s.size(); i++){
        cnt.at(s[i]-'a')++;
    }

    for(int i=0; i<26; i++){
        if(cnt.at(i) == 0){
            char c = i+'a';
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

#define MAX_N 100

int main() {
	int N, a[MAX_N + 1];
	int res;
	int p, con;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	a[N] = -1;

	res = 0; p = 1; con = 1;
	while (p <= N) {
		if (p >= 1 && a[p] == a[p - con]) {
			con++;
		}
		else {
			res += con / 2;
			con = 1;
		}
		p++;
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll k,s,count=0;
    cin>>k>>s;
    for(ll i=0;i<=k;i++){
        for(ll j=0;j<=k;j++){
            if(s-(i+j)<=k&&s-(i+j)>=0){
                count++;
            }
        }
    }
    cout<<count<<endl;
    

    
    
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)


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

int64_t kaijo(int n) {
  if (n == 0) {
    return 1;
  }
  int64_t tmp = n * kaijo(n - 1);
  if (tmp > (1000000000 + 7)) {
    return tmp % (1000000000 + 7);
  }
  else {
    return tmp;
  }
}
    
int main() {
  int n;
  cin >> n;
  int64_t result = kaijo(n);
  cout << result << endl;
}


Measured memory_bytes: 5192
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var num = +input;

var result = num;
if (num % 2 == 0) {
    result /= 2;
    while (num % 2 == 0) {
        num /= 2;
    }
}

var d = 3;
while (num / d >= d) {
    if (num % d == 0) {
        result = Math.floor(result / d);
        result *= d - 1;
        while (num % d == 0) {
            num /= d;
        }
    }
    d += 2;
}

if (num > 1) {
    result = Math.floor(result / num);
    result *= num - 1;
}
console.log(result);

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;
    cout << (c - a) * 60 + d - b - k << endl;
    return 0;
}




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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}

typedef long double D;

const int LOOP=100;
const D PI=acos(-1);
const D EPS=1e-8;
D calc(vint r){
    int n=r.size();

    D ret=0.0;
    do{

        vint rr(n);
        rep(i,n)rr[i]=r[i]*r[(i+1)%n];

        int ei=LLONG_MAX;
        rep(i,n)chmin(ei,rr[i]);
        D lb=-ei;
        D ub=ei;

        rep(i,LOOP){
            D mid=(lb+ub)/2.0;
            D sum=0.0;
            rep(j,n)sum+=acos(mid/rr[j]);
            if(sum>2*PI)lb=mid;
            else ub=mid;
        }
        D sum=0.0;
        rep(j,n)sum+=acos(lb/rr[j]);
        if(abs(sum-2*PI)>EPS){
            continue; //???????
        }
        sum=0.0;
        rep(i,n)sum+=rr[i]*sin(acos(lb/rr[i]));
        chmax(ret,sum);
    }while(next_permutation(all(r)));
    return ret;
}

signed main(){
    int N;
    cin>>N;
    vint R(N);rep(i,N)cin>>R[i];

    sort(all(R));

    D ans=0.0;

    rep(i,1<<N){
        int num=__builtin_popcount(i);
        if(num<=2)continue;
        vint r;
        rep(j,N)if(i>>j&1)r.pb(R[j]);
        chmax(ans,calc(r));
    }

    printf("%.20Lf\n",ans/2.0);
    return 0;
}



Measured memory_bytes: 3588
# AOJ 0077 Run Length
# Python3 2018.6.15 bal4u

while True:
	try: s = list(input())
	except EOFError: break
		
	ans = []
	i = 0
	while i < len(s):
		if s[i] == '@':
			for j in range(int(s[i+1])): ans += s[i+2]
			i += 2
		else: ans += s[i]
		i += 1
	print(*ans, sep='')



Measured memory_bytes: 5600
n = int(input())
a = 1
f1 = 0
f2 = 0
l = input().split()
for i in range(n):
    a *= int(l[i])
    if a > 1000000000000000000 :
        f1 = 1
        a = 1
    if a == 0:
        f2 = 1
    
if f2 == 1:
    print(0)
elif f1 == 1:
    print(-1)
else :
    print(a)


Measured memory_bytes: 19488
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i,n) cin >> x[i];
	ll ans = INF;
	for(ll i=k-1;i<n;i++){
		ll left = i-k+1;
		ll right = i;
		ll cur;
		if(x[left]*x[right]>=0)
			cur = max(abs(x[right]),abs(x[left]));
		else
			cur = abs(x[right])+abs(x[left])+min(abs(x[right]),abs(x[left]));
		
		ans = min(ans,cur);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
    long long n;
    cin >> n;

    long long a[n + 1] = {};
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    a[n] = a[0];

    long long diff = n * (n + 1) / 2;
    if (sum % diff != 0) {
        cout << "NO" << endl;
        return 0;
    }

    long long num = sum / diff;
    for (int i = 0; i < n; ++i) {
        long long tmp = a[i + 1] - a[i] - num;
        if ((tmp < 0 and tmp % n != 0) or tmp > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int cnt = 0;
  FOR(i,1,N+1) {
      if (to_string(i).length() % 2 != 0) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
    double N, buf;
    cin >> N;
    priority_queue<double, vector<double>, greater<double>> v;
    for(int i = 1; i <= N; ++i){
        cin >> buf;
        v.push(buf);
    }
    while(v.size() > 1){
        double x = v.top(); v.pop();
        double y = v.top(); v.pop();
        v.push((x+y)/2);
    }
    cout << v.top() << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        string s; cin >> s;
        for (int i = 0; i < sz(s); i += 2) cout << s[i];
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

int main(){
string s;
int a, z;
cin >> s;
for(int i = 0; i < s.size(); i++){
if(s[i] == 'A') {a = i; break;}
}
for(int i = s.size()-1; i >= 0; --i){
if(s[i] == 'Z') {z = i; break;}
}
cout << z - a + 1 << endl;
return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define int long long int
using namespace std;
const int N = 1e6 + 2; 

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0 ; i < n ;i++){
        cnt++;
        while(s[i] == s[i + 1])i++;
    }
    cout << cnt << " ";
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
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; }

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> h[i];

	for (int i = 0; i < 100010; i++) dp[i] = INF;

	dp[0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

vector<pair<int, int>> edg[100003];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		edg[u].push_back({ v, w });
		edg[v].push_back({ u, w });
	}
	vector<int> ans(n + 2, -1);
	deque<int> que;
	ans[0] = 0;
	que.push_back(0);
	while (!que.empty()) {
		int pos = que.front();
		que.pop_front();

		for (auto p : edg[pos]) {
			if (ans[p.first] != -1) continue;
			if (p.second & 1) ans[p.first] = 1 - ans[pos];
			else ans[p.first] = ans[pos];
			que.push_back(p.first);
		}
	}
	for (int i = 0; i < n; i++) cout << ans[i] << endl;
	return 0;
} 

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

int kai(int n){
  if(n<=1)
    return 1;
  else
    return n*kai(n-1);
}

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  for(int i=0;i<n;i++)
    cin >> b.at(i);
  int an=0,bn=0,x;
  set<int>num;
  for(int i=1;i<=n;i++)
    num.insert(i);
  int k=1;
  for(int i=0;i<n;i++){
    int j=0;
    for(auto x:num){
      if(x==a.at(i)){
        break;
      }
      j++;
    }
    num.erase(a.at(i));
    an=an+kai(n-k)*j;
    k++;
  }
  num.clear();
  for(int i=1;i<=n;i++)
    num.insert(i);
  k=1;
  for(int i=0;i<n;i++){
    int j=0;
    for(auto x:num){
      if(x==b.at(i)){
        break;
      }
      j++;
    }
    num.erase(b.at(i));
    bn=bn+kai(n-k)*j;
    k++;
  }
  cout << abs( an - bn ) << endl;
  return 0;
}

Measured memory_bytes: 3568
n=int(input())
s=int(input())

No=0
if n==s:
    print(n+1)
    No =1
else:
    for b in range(2,int(n**0.5)+2):
        m=0
        N=n
        while N!=0:
            m+=N%b
            N=N//b
            if m>s:
                break    
        if m==s:
            print(b)
            No=1
            exit()
    for p in range(int(n**0.5-1),0,-1):
        b = float(n-s)/float(p)+1.0
        if abs(b-int(b))<10**(-10)and b>0:
            b=int(b)
            m=0
            N=n
            while N!=0:
                m+=N%b
                N=N//b
                if m>s:
                    break    
            if m==s:
                print(b)
                No=1
                exit()
if No==0:
    print(-1)

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var n = r[0].ToInt64();
            var k = r[1].ToInt64();
            var sum = new long[n + 1];
            for (long i = 0; i <= n; i++)
            {
                if (i - 1 >= 0)
                {
                    sum[i] = sum[i - 1] + i;
                }
            }
            long count = 0;
            for (long i = k; i <= n + 1; i++)
            {
                if (i == n + 1)
                {
                    count++;
                    break;
                }
                var min = sum[i - 1];
                var max = sum[n] - sum[n - i];
                count += max - min + 1 % mod;
            }
            WriteRead(count % mod);
        }

        private static long mod = 1000000007;
        public static long ModPow(long x, long n)
        {
            x = x % mod;
            if (n == 0)
            {
                return 1;
            }
            else if (n % 2 == 1)
            {
                return (x * ModPow(x, n - 1)) % mod;
            }
            else
            {
                return ModPow((x * x) % mod, n / 2) % mod;
            }
        }
        public static long Combination(long n, long k)
        {
            long x = 1;
            for (long i = n - k + 1; i <= n; i++)
            {
                x = x * i % mod;
            }
            long y = 1;
            for (int i = 1; i <= k; i++)
            {
                y = y * i % mod;
            }
            y = ModPow(y, mod - 2);
            return x * y % mod;
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18500
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    int S,W;
    cin >> S >> W;
    string str;
    if(W >= S) str = "unsafe";
    else str = "safe";

    cout << str << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3628
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = list(map(int, input().split()))

print(max(a) - min(a))




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

int main(){
    ll n;cin >> n;
    set<char> st;
    rep(i,n){
        char c;cin >> c;
        st.insert(c);
    }
    if(st.size()==3)cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n: usize = get_input().parse().unwrap();
    let p:Vec<i64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut s_p = p.clone();
    s_p.sort();

    let mut ans = 0;
    for i in 0..n {
        if p[i] != s_p[i] {
            ans += 1;
        }
    }

    println!("{}", if ans <= 2 { "YES" } else { "NO" } );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N,M;
  cin >> N >> M;
  set<pair<int,int>> a;
  rep(i,M){
    int x,y;
    cin >> x >> y;
    a.insert(make_pair(x,y));
    a.insert(make_pair(y,x));
  }
  int flag;
  vector<int> check(N-1);
  rep(i,N-1)
    check.at(i)=i;
  do{
    bool b=1;
    if(!a.count(make_pair(1,check.at(0)+2))){
      b=0;
    }
    rep(i,N-2){
      if(!a.count(make_pair(check.at(i)+2,check.at(i+1)+2))){
        b=0;
      }
    }
    if(b)
      flag ++;
  } while (next_permutation(check.begin(),check.end()));
  cout << flag << endl;
}
      
  

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      String s = sc.next();
      int cnt = 0;
      int groupCnt = 0;
      for(int i = 1; i < n; i++) {
        if(s.charAt(i) == s.charAt(i-1)) {
          cnt++;
        } else {
          groupCnt++;
        }
      }
      groupCnt++;
      cnt += Math.min(k, (groupCnt - 1) / 2) * 2;
      k -= (groupCnt - 1) / 2;
      if(groupCnt % 2 == 0 && k > 0) cnt++;

      System.out.println(cnt);
  }
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll c1(ll n,ll a,ll b){
  ll ans = a-1;
  b -= (a - 1);
  a = 1;
  return ans + (b-a+1)/2;
}

ll c2(ll n, ll a, ll b){
  ll ans = n-b;
  a += (n-b);
  b += (n-b);
  return ans + (b-a+1)/2;
}

int main(){
  fastIO;
  ll n, a, b;
  cin >> n >> a >> b;
  if((b-a)%2 == 0){
    cout << (b-a)/2 << "\n";
  }
  else{
    cout << min(c1(n,a,b),c2(n,a,b)) << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve_naive(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        b.append(str(a[i]))
        b.reverse()
    print(" ".join(b))
    return

def solve_(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == 0:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    if n % 2 == 0:
        b.reverse()
    print(" ".join(b))
    return

def solve__(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(" ".join(b))
    return

def solve___(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

def solve(n: int, a: "List[int]"):
    import collections
    b = collections.deque()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.appendleft(a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34364
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int a,b;
    cin>>a>>b;
    int min=100000;
    for(int i=1;i<2001;i++){
        if((i*8)/100==a&&(i*10)/100==b){
            if(i<min){min=i;}
        }
    }
    if(min==100000){cout<<-1<<endl;}
    else{cout<<min<<endl;}
    return 0;
}

Measured memory_bytes: 256