akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   long long n,k,a,b,c;
   cin>>n>>k;
   a=n/k;
   b=n-a*k;
   c=min(k-b,b);
   cout<<c<<endl;
   
   
}

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

bool colored[8];

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

	int color = 0;
	int pro = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;

		if (a < 3200) {
			if (colored[a / 400])
				continue;

			colored[a / 400] = true;
			++color;
		}
		else
			++pro;
	}

	std::cout << std::max(color, 1) << " " << color + pro << std::endl;
}

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

string S[3];int v[3],t;
int main(){
	cin>>S[0]>>S[1]>>S[2];
	while(true){
		if(v[t]==S[t].size()){
			cout<<(char)('A'+t)<<endl;
			break;
		}
		int u=(S[t][v[t]]-'a');
		v[t]++;t=u;
	}
	return 0;
}


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

int main(){
  	int n,memo = 0;
  
  	cin >> n;
  	
  	for(int i = 1;;i++){
      memo += i;
      if(memo >= n){
        cout << i << endl;
        return 0;
      }
    }
 	return 0; 
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int a,b,c; 
  cin >> a >> b >> c;
  
  if(a == b && b == c) cout << "No" << endl;
  else if(a == b || a == c || b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

string S;

int main(void) {

    cin >> S;
    if (S == "ARC") {
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N,M = input().split()
l = [0]*int(N) #flg
m = [0]*int(N) #counter
c =0

for i in range(int(M)):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)






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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 112345
#define MAXD 112

int d;
string num;
ll dp[MAXN][MAXD][2];
int vis[MAXN][MAXD][2];

ll const mod = 1e9+7;

ll add_mod(ll a, ll b)
{
    return a + b >= mod ? a + b - mod: a + b;
}

ll solve(int idx, int sum, int smaller)
{
    if (idx == (int)num.size())
    {
        return sum == 0;
    }

    if (vis[idx][sum][smaller])
        return dp[idx][sum][smaller];
    vis[idx][sum][smaller] = 1;
    
    ll res = 0;
    if (!smaller)
    {
        res = solve(idx + 1, (sum + (num[idx] - '0')) % d, 0);
        for (int i = 0; i < num[idx] - '0'; i++)
        {
            res = add_mod(res, solve(idx + 1, (sum + i) % d, 1));
        }
    }
    else
    {
        for (int i = 0; i < 10; i++)
        {
            res = add_mod(res, solve(idx + 1, (sum + i) % d, 1));
        }
    }
    
    return dp[idx][sum][smaller] = res;    
}

int main()
{
    cin >> num >> d;
    cout << (solve(0, 0, 0) - 1 + mod) % mod << endl;
}

Measured memory_bytes: 29696
def str2int(s):
    i=0
    for c in s:
        i*=5
        if c=='A':
            i+=1
        elif c=='C':
            i+=2
        elif c=='G':
            i+=3
        elif c=='T':
            i+=4
    return i

n=int(input())
l=set()
for i in range(n):
    S=list(input().split())
    k=str2int(S[1])
    if S[0]=='insert':
        l.add(k)
    else:
        print ('yes' if k in l else 'no')


Measured memory_bytes: 23356
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val h = (1..N).map { readLine()!!.toInt() }.sorted()
    val d = mutableListOf<Int>()
    for (i in 0..(N - K)) {
        d.add(h[i + K - 1] - h[i])
    }
    println(d.min())
}

Measured memory_bytes: 48772
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
d_a={}
d_b={}
flg=0
for i in range(n):
  d_a[a[i]]=d_a.get(a[i],0)+1
for i in range(m):
  d_b[b[i]]=d_b.get(b[i],0)+1
for i in b:
  c=d_a.get(i,0)
  if c < d_b[i]:
    flg=1
if flg == 1:
  print('NO')
else:
  print('YES')

Measured memory_bytes: 56788
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
vector<vector<pair<ll,ll>>> adj;
vector<pair<ll,ll>> lis; // graph represented as an adjacency list
ll n; // number of vertices

vector<bool> visited;

ll depth=0;
int main(){

ll n,m,a,b,r=0,c,k;

scanf("%lld",&n);
adj.assign(n,vector<pair<ll,ll>>(0));
for (ll i =0;i<(n-1);i++)
{
    cin>>a;
    cin>>b;

    adj[a-1].push_back({b-1,0});
    adj[b-1].push_back({a-1,0});
    lis.push_back({a-1,b-1});
}
queue<ll> q;
vector<ll> used(n);
ll s=0;
vector<ll> d(n), p(n);
q.push(s);
used[s] = true;
p[s] = -1;
ll imax=0;
while (!q.empty()) {
    ll v = q.front();
    q.pop();
    ll imin=0;
    for (ll j=0;j<adj[v].size() ;j++) {
            ll col=p[v];
            auto u=adj[v][j];

        if (!used[u.first]) {
            used[u.first] = true;
            q.push(u.first);
            d[u.first] = d[v] + 1;
            while(1)
            {
                imin=imin+1;
                if(imin!=col)
                {
                    break;
                }
            }
            adj[v][j].second=imin;

            p[u.first] = imin;
        }
        else
        {
            adj[v][j].second=p[v];
        }
if(imin>imax)
{
    imax=imin;
}
    }
}
cout<<imax<<endl;
for (ll i=0;i<n-1;i++)
{
    a=lis[i].first;
    b=lis[i].second;
    for (auto nn:adj[a])
    {
        if(nn.first==b)
        {
            cout<<nn.second<<endl;
        }

    }

}

    return 0;

    }


Measured memory_bytes: 11888
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    vector<ll> b(n+1);
    b[0] = 0;
    map<ll,ll> rest;
    rep(i,0,n){
        b[i+1] = b[i]+a[i];
        rest[b[i+1]%m]++;
    }
    ll ans = 0ll;
    for(auto x: rest){
        ans += x.second*(x.second-1ll);
    }
    ans /=2ll;
    ans += rest[0];
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

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

typedef struct {
    int x, y, z;
} cake;

int n, m;

int sum_plus_minus(cake c, int i) {
    int res = 0;
    res += (i & (1 << 2)) ? c.x : -c.x;
    res += (i & (1 << 1)) ? c.y : -c.y;
    res += (i & (1 << 0)) ? c.z : -c.z;
    return res;
}

int solve(cake c[]) {
    int ans = -(1LL << 50);
    int sum[n];
    rep(1 << 3, i) {
        rep(n, j) {
            sum[j] = sum_plus_minus(c[j], i);
        }
        sort(sum, sum + n, greater<int>());
        int res = 0;
        rep(m, j) {
            res += sum[j];
        }
        ans = max(ans, res);
    }
    return ans;
}

signed main() {
    cin >> n >> m;
    cake c[n];
    rep(n, i) {
        cin >> c[i].x >> c[i].y >> c[i].z;
    }
    cout << solve(c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
using namespace std;
int main(void){
  int X;
  cin >> X;
  if(X / 10 % 111 == 0 || X % 1000 % 111 == 0){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
n = int(input())
l = 1
li = []
while l < n+1:
  if l % 3 == 0 and l % 5 == 0 or l % 3 == 0 or l % 5 == 0:
    l+=1
  else:
    li.append(l)
    l+=1

print(sum(li))

Measured memory_bytes: 30004
#include <iostream>

using namespace std;

int sumNumericalPositions(int num);

int main(void)
{
	int num;
    int tmp;
	int sum = 0;

	cin >> num;

	for (int i = 1; i <= num / 2; i++) {
		for (int j = num; j >= num / 2; j--) {
			if (i + j == num) {
				tmp = sumNumericalPositions(i) + sumNumericalPositions(j);
				if (sum == 0 || sum > tmp) {
					sum = tmp;
				}
			}
		}
	}

	cout << sum << endl;

	return 0;
}

int sumNumericalPositions(int num)
{
	int sum = 0;
	int tmp;

    while (num != 0) {
        tmp = num % 10;
        sum += tmp;
        num /= 10;
    }

	return sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int len,i,score=0,p=0;
//g->rock  p->paper  p=rock-paper>=0
int main()
{cin>>s;
len=strlen(s);
 for(i=0;i<len;i++)
  if(s[i]=='g')
  {if(p<1) p++;
   else {p--; score++;} 
  }
  else{
  if(p<1) {p++; score--;}
  else p--;
  }
 cout<<score; 
 return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,k,dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char c[100][100];
int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++)
		for (int j=0;j<k;j++)
			cin>>c[i][j];
	for (int i=0;i<n;i++)
		for (int j=0;j<k;j++){
			int f=0;
			for (int l=0;l<4;l++)
				if (i+dx[l]>=0&&i+dx[l]<n&&j+dy[l]>=0&&j+dy[l]<k&&c[i+dx[l]][j+dy[l]]=='.'&&c[i][j]=='#') f++;
			if (f==4){
				cout<<"No"<<endl;
				return 0;
			}
		}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
  int n, t, a;
  vector<int> h;

  cin >> n;
  cin >> t >> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    h.push_back(x);
  }

  double min = fabs(a - t + h[0]*0.006);
  int index = 1;
  for (int i = 1; i < n; i++) {
    if (min > fabs(a - t + h[i]*0.006)) {
      min = fabs(a - t + h[i]*0.006);
      index = i + 1;
    }
  }

  cout << index << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(n) ((n + 1LL) * (n) / 2)
using namespace std;
const int mod = 1e9 + 7;
int main() {
    int n, k; cin >> n >> k;
    int ans = 1;
    for (int i = k; i <= n; i++) 
        ans = (ans + f(n) - f(n - i) - f(i - 1) + 1) % mod;
    cout << ans;
}


Measured memory_bytes: 3668
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1203A_live
gi = lambda : list(map(int,input().split()))
n, = gi()
l = gi()
print(1 / sum([1 / e for e in l]))

Measured memory_bytes: 3060
import java.util.Scanner;

     class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
        
                if(a > b){
                    System.out.println("a > b");
                }else if(a < b){
                    System.out.println("a < b");
                }else if(a == b){
                    System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26400
//abc045_a.cpp
//Fri Oct 19 22:34:43 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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


	cout << (a+b)*h/2 << endl;
}

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

int main(){
  int X;
  cin >> X;
  int degree = 0;
  for(int i = 1;;i++){
    degree += X;
    if(degree >= 360) degree -= 360;

    if(degree == 0){
      cout << i;
      break;
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,m; cin >> n >> m;
    const int nmax = 50;
    int v[nmax] = {0};
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
    }
    rep(i,n){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXS 2097162
#define MAXM 30
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dp[2][MAXM][MAXS],ans;
int nxt[MAXS][MAXM],mp[MAXM][MAXM];
int n,m,p;
int main(){
	SF("%d%d%d",&n,&m,&p);
	n--;
	for(int i=0;i<(1<<n);i++){
		int t=-1;
		for(int j=n-1;j>=0;j--){
			if((i&(1<<j)))
				t=j;
			nxt[i][j]=t;
		}
	}
	for(int i=1;i<=m;i++)
		for(int j=0;j<n;j++)
			mp[i][j]=-1;
	int x,y,z;
	for(int i=1;i<=p;i++){
		SF("%d%d%d",&x,&y,&z);
		mp[x][y-1]=z;	
	}
	dp[0][n][0]=1;
	int now=1;
	for(int i=1;i<=m;i++){
		for(int mask=0;mask<(1<<n);mask++)
			dp[now][0][mask]=dp[now^1][n][mask];
		for(int j=0;j<=n;j++)
			for(int mask=0;mask<(1<<n);mask++)
				dp[now^1][j][mask]=0;
		for(int j=0;j<n;j++)
			for(int mask=0;mask<(1<<n);mask++)
				if(dp[now][j][mask]){
					for(int k=0;k<=1;k++){
						if(mp[i][j]!=-1&&mp[i][j]!=k)
							continue;
						int t=min((mask&(1<<j)),1);
						if(k==0&&t==1)
							continue;
						if(k==t)
							dp[now][j+1][mask]=(dp[now][j+1][mask]+dp[now][j][mask])%MOD;
						else{
							int r=nxt[mask][j];
							if(r==-1)
								dp[now][j+1][mask+(1<<j)]=(dp[now][j+1][mask+(1<<j)]+dp[now][j][mask])%MOD;
							else
								dp[now][j+1][mask+(1<<j)-(1<<r)]=(dp[now][j+1][mask+(1<<j)-(1<<r)]+dp[now][j][mask])%MOD;
						}
					}
				}
		now^=1;	
	}
	for(int mask=0;mask<(1<<n);mask++)
		ans=(ans+dp[now^1][n][mask])%MOD;
	PF("%d",ans);
}

Measured memory_bytes: 227456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int array[] = new int[N];
		int minj, tmp, pointer = 0, count = 0;

		for(int i = 0; i < array.length; i ++){
			array[i] = sc.nextInt();
		}

		for(int i = 0; i < array.length; i ++){
			minj = Integer.MAX_VALUE;
			for(int j = i ; j < array.length; j++){
				if(i != j){
					if(array[j] < minj){
					minj = array[j];
					pointer = j;
					}
				}
			}
			if(array[i] > minj){
				tmp = array[i];
				array[i] = minj;
				array[pointer] = tmp;
				count++;
			}
		}
		for(int i = 0; i < array.length; i++){
			if(i == array.length -1){
				System.out.println(array[i]);
			}else{
				System.out.print(array[i] + " ");
			}
		}
		System.out.println(count);
		sc.close();
	}

}



Measured memory_bytes: 26308
import java.io.IOException;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;

class Solve{
	final Scanner in = new Scanner(System.in);
	
	static final double INF = 1e9;
	int n;
	boolean solve(){
		n = in.nextInt();
		if(n == 0) return false;
		int[] r = new int[n];
		int[] w = new int[n];
		Book[] b = new Book[n];
		int all = 0;
		for(int i=0; i<n; i++){
			r[i] = in.nextInt();
			w[i] = in.nextInt();
			all += r[i]+w[i];
			b[i] = new Book(r[i], w[i]);
		}
		Arrays.sort(b);
		int wsum = 0;
		for(int i=1; i<n; i++){
			wsum += b[i].r;
		}
		int sp = b[0].r - wsum;
		if(sp <= 0){
			System.out.println(all);
			return true;
		}
		int[] nw = new int[n-1];
		wsum = 0;
		for(int i=1; i<n; i++){
			nw[i-1] = b[i].w;
			wsum += b[i].w;
		}
		if(wsum <= sp){
			System.out.println(all+(sp-wsum));
			return true;
		}
		Arrays.sort(nw);
		n--;
		res = 0;
		int[] ww = new int[n];
		for(int i=0; i<n; i++) ww[i] = nw[n-1-i];
		dfs(0, 0, sp, ww, new BitSet(n));
		System.out.println(all+(sp-res));
		return true;
	}
	
	int res = 0;
	boolean dfs(int sum, int st, int sp, int[] w, BitSet used){
		if(sum == sp){
			res = sum;
			return true;
		}
		if(sum > sp) return false;
		if(sum > res) res = sum;
		for(int i=used.nextClearBit(st); i<n && sum+w[i]*(n-i)>res; i=used.nextClearBit(i+1)){
			used.set(i);
			if(dfs(sum+w[i], i+1, sp, w, used)) return true;
			used.clear(i);
		}
		return false;
	}
	
}

class Book implements Comparable<Book>{
	int r, w;
	Book(int r, int w){
		this.r = r;
		this.w = w;
	}
	@Override
	public int compareTo(Book o) {
		return o.r-r;
	}
}


public class Main{
	public static void main(String[] args) throws IOException{
		Solve solve = new Solve();
		while(solve.solve());
	}
}

Measured memory_bytes: 73420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
ll n;
vector<int> a(2e5+10);
vector<int> b(2e5+10,-1);
int res=0;
int dfs(int i){
    if(b[i]!=-1)return b[i];
    ll buf=0;
    for(int j=2;i*j<=n;j++){
        buf+=dfs(i*j);
    }
    buf%=2;
    int t=0;
    if(a[i]!=buf){
        t++;
        res++;
    }
    b[i]=t;
    return t;
}
int main(void){
    cin>>n;
    rep(i,n) cin>>a[i+1];
    for(int i=1;i<=n;i++){
        dfs(i);
    }
    cout<<res<<endl;
    rep(i,n){
        if(b[i+1]!=0)cout<<i+1<<endl;
    }
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p+q, q+r, r+p}) << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long
    #define int long long 
    #define ull unsigned long long 
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define mn3(a, b, c) min(min(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define SP(n) cout.precision(n)
    const ld PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    const ll MD = 998244353;
    
    int32_t main() {
        fio;
        string s;
        cin>>s;
        if(s=="ABC")cout<<"ARC";
        else cout<<"ABC";
        return 0;
    }


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	vector<int>arr(5);
	for(int i=0; i<5; i++)
	 cin>>arr[i];
	int ans;
	for(int i=0; i<5; i++)
	{
		if(arr[i]==0)
		 ans=i+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608
n = int(input())
a_array = [int(x) for x in input().split()]
ruiseki = [0]
now = 0
sum_a = sum(a_array)
half = sum_a//2
diff = float("inf")
for a in a_array:
    ruiseki.append(ruiseki[-1] + a)
    left = ruiseki[-1]
    right = sum_a - left
    diff = min(diff, abs(half-left) + abs(half-right))
print(diff)

Measured memory_bytes: 26396
from sys import exit, stdin
N, A, B, C, D = [int(_)-1 for _ in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
if C < D:
    if '##' in S[A:D]:
        print('No')
    else:
        print('Yes')
else:
    if '##' in S[A:C] or '...' not in S[B-1:D+2]:
        print('No')
    else:
        print('Yes')


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

int main()
{
int W;int H;int x;int y;int r;
	cin >> W;
	if(W<0||W>100){
	cout << "error" << endl;
       return 0;
	}
     cin >> H;
     if(H<0||H>100){
     cout << "error" << endl;
       return 0;
	}
     cin >> x;
	if(x<-100||x>100){
     cout << "error"<< endl;
       return 0;
	}
     cin >> y;
	if(y<-100||y>100){
     cout << "error" << endl;
       return 0;
	}
     cin >> r;
     if(r<0||r>100){
     cout << "error" << endl;
       return 0;
	}
       if(x-r<0||x+r>W){
	cout << "No" << endl;
	}else if(y-r<0||y+r>H){
       cout << "No" << endl;       
       }else{
       cout << "Yes" << endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
	char S[20];
	char ans[20];
	int ans_ite = 0;
	cin >> S;
	for(int i=0; S[i]!='\0', i<20; ++i){
		char c = S[i];
		switch(S[i]){
			case '0':
				ans[ans_ite] = '0';
				ans_ite++;
				break;
			case '1':
				ans[ans_ite] = '1';
				ans_ite++;
				break;
			case 'B':
				if(ans_ite == 0){
					break;
				} else {
					ans_ite --;
					ans[ans_ite] = '\0';
					break;
				}
		}
	}
	ans[ans_ite] = '\0';
	cout << ans << endl;
	return 0;

}

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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define INF 1e16

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 2e5+2;
const int M = 1e9+7;

ll n, k, tab[MAX], sum, mx = -1;
int main()
{
    //_upgrade;
    cin>>k>>n;
    FOR(i, 0, n)
        cin>>tab[i];
    FOR(i, 1, n)
    {
        sum += tab[i] -tab[i-1];
        mx = max(mx, tab[i] - tab[i-1]);
    }
    sum += (k-tab[n-1] + tab[0]);
    mx = max(mx, k-tab[n-1] + tab[0]);
    cout<<sum-mx<<"\n";
    return 0;
}


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

lr = [0]*n
lb = [0]*n

ans = 0
r = 0
g = 0
b = 0
for i in range(n):
    if s[i]=="R":
        r += 1 
    elif s[i]=="G":
        g += 1
    else:
        b += 1
ans = r*b*g


for i in range(n):
    ans += lr[i]*lb[i]

for i in range(n):
    for j in range(n):
        if i>j:
            if (i+j)%2 == 0:
                if s[i]!=s[j] and s[i]!=s[(i+j)//2] and s[j]!=s[(i+j)//2]:
                    ans -= 1
print(ans)

Measured memory_bytes: 68320
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    a,b = map(int, input().split())

    cnt = 0
    if a > b:
        cnt += a
        a -= 1
    else:
        cnt += b
        b -= 1
    if a > b:
        cnt += a
        a -= 1
    else:
        cnt += b
        b -= 1
    print(cnt)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 65004
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long h,w,n;
    scanf("%ld%ld%ld", &h, &w, &n);

    vector<long> a(n);
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    long ans[101][101]={0};

    long sum=0;
    i=0;
    for(j=0; j<n; j++) {
        long k;
        for(k=0; k<a[j]; k++) {
            long ii = i/w;
            long jj = i%w;
            if(ii%2==1) jj = w-1-jj;
            ans[ii][jj]=j+1;
            i++;
        }
    }

    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            printf("%ld ", ans[i][j]);
        }
        printf("\n");
    }

    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
#define SpaceNewLine(a) Rep(i,a.size())cout<<a[i]<<(i==a.size()-1?'\n':' ')
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

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

    int N;
    Scd(N);

    vi A(N);
    Rep(i,N){
        Scd(A[i]);
    }

    multiset<int> S;

    Rep(i,N){
        auto it = S.upper_bound( -A[i] );
        // printf ("!!%d\n", *it );
        if( it != S.end() ){
            S.erase( it );
        }
        S.insert( -A[i]);
    }

    printf ("%d\n", S.size() );


    return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    string S;   cin>>S;
    long long int K;    cin>>K;
    if(S[0]!='1')cout<<S[0];
    else{
        int count=0;
        int i=0;
        while(S[i]=='1'){
            count++;
            i++;
        }
        if(count>=K)cout<<'1';
        else cout<<S[count];
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, m;
	cin>>n>>m;
	ll sum = 0;
	int a[m];
	for(int i = 0; i < m; i++) {
		cin>>a[i];
		sum += a[i];
	}
	if(sum > n)
		cout<<"-1\n";
	else
		cout<<n-sum<<"\n";
	return 0;
}

Measured memory_bytes: 3692
from collections import deque
H, W = map(int, input().split())
maze = [input()for _ in range(H)]


def bfs(queue: deque, reached: set) -> int:
    ans = 0
    dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while queue:
        d = queue.pop()
        if ans < d[2]:
            ans = d[2]
        for a in dxdy:
            x = d[0] + a[0]
            y = d[1] + a[1]
            if 0 <= x < W and 0 <= y < H and not reached[y][x]:
                queue.appendleft((x, y, d[2] + 1))
                reached[y][x] = True
    return ans


queue = deque()
reached = [[False for i in range(W)] for j in range(H)]
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            queue.append((j, i, 0))
            reached[i][j] = True
print(bfs(queue, reached))


Measured memory_bytes: 137564
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int cursor = s.size() - 1;
  while (cursor >= 0) {
    if (cursor >= 4 && s.substr(cursor - 4, 5) == "dream")
      cursor -= 5;
    else if (cursor >= 6 && s.substr(cursor - 6, 7) == "dreamer")
      cursor -= 7;
    else if (cursor >= 4 && s.substr(cursor - 4, 5) == "erase")
      cursor -= 5;
    else if (cursor >= 5 && s.substr(cursor - 5, 6) == "eraser")
      cursor -= 6;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    string str;
    cin >> str;
    for(char c: str){
        if(c == '1'){
            cout << '9';
        }
        else if(c == '9'){
            cout << '1';
        }
        else {
            cout << c;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,i,l;
cin>>n>>l;
vector<string>m(n);
for(i=0;i<n;i++){
cin>>m[i];
}
sort(m.begin(),m.end());
for(i=0;i<n;i++){
cout<<m[i];}
cout<<endl;
}





 

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

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

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

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



int D, n, m, score;
string str;
vector<pint> inp;

int dp[100][15];

int main() {
    while (cin >> D) {
         inp.clear();
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> str >> score;
            if (str == "D") inp.PB( pint(1, score) );
        }
        cin >> m;
        for (int i = 0; i < m; ++i) {
            cin >> str >> score;
            if (str == "DD") inp.PB( pint(2, score) );
        }
        
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;
        for (int i = 0; i < inp.size(); ++i) {
            for (int d = 0; d <= D; ++d) {
                chmax( dp[i+1][d], dp[i][d] );
                if (d + inp[i].first <= D && dp[i][d] >= 0) {
                    chmax( dp[i+1][d+inp[i].first], dp[i][d] + inp[i].second );
                }
            }
        }
        int res = 0;
        for (int d = 0; d <= D; ++d) {
            chmax(res, dp[inp.size()][d]);
        }
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1224
using System;
using System.Collections.Generic;

namespace AOJ0013
{
    class Program
    {
        static void Main()
        {
            var stack = new Stack<int>();
            foreach (var op in ReadOperation())
            {
                if (op == 0)
                {
                    Console.WriteLine(stack.Pop());
                }
                else
                {
                    stack.Push(op);
                }
            }
        }

        public static IEnumerable<int> ReadOperation()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                yield return int.Parse(line);
            }
        }
    }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n;
	double d1, x;
	cin >> n >> d1 >> x;
	double ans = 0.;
	for(; n > 0; n--){
		ans += d1 + (2. * n - 1.) / 2. * x;
		//d1 = (n + 1.) / n * d1 + (2. * n - 1.) / 2. * x;
		//x = 2. / n * x;
		
		d1 = (n + 1.) / n * d1 + 5. / (2. * n) * x;
		x = (n + 2.) / n * x;
		
		//cout << ans << " " << d1 << " " << x << endl;
	}
	printf("%.12lf\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        int i = 1;
        while(true){
            str = br.readLine();
            if(str.equals("0")){
                break;
            }//if
            System.out.println("Case " + i + ": " + str);
            i++;
        }//while
        br.close();
    }
}

Measured memory_bytes: 31728
#include <stdio.h>
 
struct Card{
  char mark;
  int num;
};
 
 
int Partition(struct Card A[], int left, int pivot, int right){
  int i, j;
  struct Card x, temp;
  x = A[right];
  i = pivot-1;
  for(j=pivot; j<right; j++){
    if(A[j].num<=x.num){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[right];
  A[right] = temp;
  return i+1;
}
 
 
void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q=Partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}
 
void Merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k, n1, n2;
  struct Card L[100001/2+2], R[100001/2+2];
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++)
    L[i] = A[left+i];
  for(i=0;i<n2;i++)
    R[i] = A[mid+i];
  L[n1].num=2000000000;
  R[n2].num=2000000000;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num){
      A[k]=L[i];
      i++;;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }
}
 
void MergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if (left+1<right){
    mid = (left + right)/2;
    MergeSort(A, n, left, mid);
    MergeSort(A, n, mid, right);
    Merge(A, n, left, mid, right);
  }
}
    
 
 
int main(){
  int n, i, j, v, stable=0;
  char s[10];
  struct Card A[100001], B[100001]; 
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s %d", s, &v);
    A[i].mark=s[0];
    B[i].mark=A[i].mark;
    A[i].num=v;
    B[i].num=A[i].num;
  }
 
  quickSort(A, n, 0, n-1);
  MergeSort(B, n, 0, n);
   
  for(i=0; i<n; i++){
    if(A[i].mark==B[i].mark)stable++;
  }
 
  if(stable==n)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].mark, A[i].num);
  }  
  return 0;
}

Measured memory_bytes: 2952
mod = 10**9+7
S = [int(x) if x != "?" else -1 for x in input()]

dp = [[0] * 13 for i in range(len(S)+1)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] == -1:
        for d in range(10):
            for j in range(13):
                dp[i+1][(j*10+d) % 13] += dp[i][j]
    else:
        d = S[i]
        for j in range(13):
            dp[i+1][(j*10+d) % 13] += dp[i][j]

    for k in range(13):
        dp[i+1][k] = dp[i+1][k] % mod

    # print(dp)

print(dp[len(S)][5])


Measured memory_bytes: 63776
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, t = 1, k;
int main()
{
	//run();
	M_Sayed;
	//cin >> t;
	while (t--) {
		cin >> n>>m;
		if (n > m)RT("safe");
		RT("unsafe");

	}

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
pair<ll,ll>a[N];
vector<pair<ll,ll>>v;
map<pair<ll,ll>,int>vis,vv;
bool sum[N];
int n;
ll ans,res=1,A,B,p[N];
int main()
{
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&a[i].fi,&a[i].se);
        ll k=__gcd(a[i].fi,a[i].se);
        if(k!=0) a[i].fi/=k,a[i].se/=k;
        if(a[i].se<0) a[i].fi*=-1,a[i].se*=-1;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
        if(a[i].fi==0&&a[i].se==0) ans++;
    else if(a[i].fi==0) A++;
    else if(a[i].se==0) B++;
    else
    {
        if(!vis[a[i]]) v.push_back(a[i]);
        vis[a[i]]++;
    }
    for(int i=0;i<v.size();i++)
    {
        pair<ll,ll>x=v[i];
        swap(x.fi,x.se);
        x.fi*=-1;
        if(x.se<0) x.fi*=-1,x.se*=-1;
        if(vv[x])
        {
            sum[vv[x]]=sum[i+1]=true;
            res=res*(p[vis[v[vv[x]-1]]]+p[vis[v[i]]]+mod-1)%mod;
        }
        else vv[v[i]]=i+1;
    }
    for(int i=0;i<v.size();i++)
        if(!sum[i+1])
        res=res*p[vis[v[i]]]%mod;
    res=res*(p[A]+p[B]+mod-1)%mod;
    printf("%lld\n",(ans+res+mod-1)%mod);
}


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

int main()
{
  string input;
  int ans = 0;
  cin >> input;
  for(int i = 0; i < (int)input.size(); ++i){
    char ch = input[i];
    if(ch == '+')
    {
      ans++;
    }else{
      ans--;
    }
  }
  printf("%i\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,r,b,g,ans;
string s;
int main ()
{
	cin>>n;
	cin>>s;
	
	for (i=0; i<s.size(); i++)
	if (s[i]=='R') r++;
	else
	if (s[i]=='B') b++;
	else 
	g++;
	ans=r*b*g;
	for (i=1; i<=n; i++)
	
		for (j=i+2; j<=n; j++)
		if ((i+j)%2==0 && s[i-1]!=s[j-1] && s[i-1]!=s[(i+j)/2-1] && s[j-1]!=s[(i+j)/2-1]) 
		ans--;
	
	cout<<ans;

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

int main() {
    int N;
    cin >> N;
    map<string, int> s;
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        sort(WHOLE(S));
        if(!s.count(S)) {
            s[S] = 0;
        }
        s[S]++;
    }
    i64 ans = 0;
    for(auto x : s) {
        i64 tmp = x.second;
        ans += (tmp * (tmp - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#D
import math
N,K = map(int,input().split())
R,S,P = map(int,input().split())

def get(st):
    if st == "r":
        return P
    if st == "s":
        return R
    if st == "p":
        return S

T = list(str(input()))
ans = 0
for j in range(K):
    klist = []
    for i in range(math.ceil((N-j)/K)):
        klist.append(T[j+i*K])
    
    klen = len(klist)
    old = 0
    for i in range(klen):
        if i < klen-1:
            if old == 0:
                if klist[i] != klist[i+1]:
                    ans += get(klist[i])
                else:
                    ans += get(klist[i])
                    old = 1
            else:
                old = 0
        else:
            if old == 0:
                ans+=get(klist[i])
    #print(klist)
                
print(ans)
                
                
    


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);

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

	for(int i = 1; i <= n; ++i)
	{
		cout << a[i] << "\n";
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX=1e9+7;

int main()
{
    fast;
    int n;
    cin>>n;
    vector<int> nums(n);
    for(int i=0; i<n; i++) cin>>nums[i];
    int count = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if(nums[i]==nums[j]) continue;
                for (int k = j + 1; k < n; k++) {
                    if(nums[i]==nums[k] || nums[j]==nums[k]) continue;
                    if (nums[i] + nums[j] > nums[k] && nums[i] + nums[k] > nums[j] && nums[j] + nums[k] > nums[i])
                        count++;
                }
            }
            
        }
        cout<<count;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int score[200];

int main(void)
{
	int N;
	int pl[200][3];
	int i, j, k;
	int c;
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++){
		scanf("%d %d %d", &pl[i][0], &pl[i][1], &pl[i][2]);
	}
	
	for (i = 0; i < N; i++){
		for (j = 0; j < 3; j++){
			c = 1;
			for (k = 0; k < N; k++){	
				if (c == 1 && pl[i][j] != pl[k][j]){
					c = 1;
				}
				else if (i != k && pl[i][j] == pl[k][j]){
					c = 0;
				}
			}
			if (c == 0){
				score[i] += 0;
			}
			else if (c == 1){
				score[i] += pl[i][j];
			}
		}
	}
	for (i = 0; i < N; i++){
		printf("%d\n", score[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >>H>>W;
  vector<string> aW(H);
  for (int i=0;i<W+2;i++){cout<<"#";}
  cout <<endl;
  for (int i=0;i<H;i++){
    cout <<"#";
    cin >>aW.at(i);
    cout<<aW.at(i);
    cout <<"#"<<endl;
  }
  for (int i=0;i<W+2;i++){cout<<"#";}
  cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC082B - Two Anagrams
  // 英小文字のみの文字列s, t。sを好きな順に並び替え。tも好きな順に並び替え。
  // 辞書順でs<tとできるか
  string s, t; cin >> s >> t;
  if(s == t){
    cout << "No" << endl;
    return 0;
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  vector<string> ST = {s, t};
  sort(ST.begin(), ST.end());
  if(ST[0] == s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
while(True):
    s = input()
    m = len(s)
    if s == "0":
        quit()
    dp = [[0 for j in range(11)] for i in range(m)]
    for i in range(m):
        n = int(s[i])
        if n == 0:
            tmp = dp[i-1][1:]
            tmp.reverse()
            dp[i] = [dp[i-1][0]]+tmp
        else:
            tmp = dp[i-1][1:]
            tmp.reverse()
            tmp = [dp[i-1][0]]+tmp
            dp[i] = tmp[-n:]+tmp[:-n]
            dp[i][n] += 1
    ans = 0
    for i in range(m):
        ans += dp[i][0]
    print(ans)



Measured memory_bytes: 37200