akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<cassert>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 1000
#define INFTY (1<<25)

class Point{
    public:
    int x, y, adj[4];
    Point(int x = 0, int y = 0):x(x), y(y){ rep(d, 4) adj[d] = -1; }
};

class State{
    public:
    int pos, dir, dist, turn;
    State(int pos=0, int dir=0, int dist=0, int turn=0):pos(pos), dir(dir), dist(dist), turn(turn){}
    bool operator < ( const State &s ) const {
	if ( dist == s.dist ) return turn > s.turn;
	return dist > s.dist;
    }
};

int getDistance(int i, int j, Point P[MAX]){
    return max(P[i].x, P[j].x ) - min(P[i].x, P[j].x) +
	max(P[i].y, P[j].y ) - min(P[i].y, P[j].y);
}

int dijkstra(int n, int source, int target, Point P[MAX]){
    priority_queue<State> PQ;
    int D[MAX][4], T[MAX][4];

    rep(i, n) rep(j, 4) { D[i][j] = T[i][j] = INFTY; }
    
    rep(d, 4){
	PQ.push(State(source, d, 0, 1));
	D[source][d] = 0;
	T[source][d] = 1;
    }

    State u, v;

    while( !PQ.empty() ){
	u = PQ.top(); PQ.pop();
	int pos = u.pos;
	int dir = u.dir;
	if ( pos == target ) return T[pos][dir];
	for ( int d = 0; d < 4; d++ ){
	    if ( P[pos].adj[d] == -1 ) continue;
	    if ( !( d == dir || d == (dir+1)%4 ) ) continue;
	    v = State( P[pos].adj[d], d, 0, 0 );
	    
	    int cost = getDistance(pos, P[pos].adj[d], P);
	    if ( (D[pos][dir] + cost ==  D[v.pos][v.dir] && T[pos][dir] + 1 < T[v.pos][v.dir]) ||
		 D[pos][dir] + cost <  D[v.pos][v.dir]){
		v.dist = D[v.pos][v.dir] = D[pos][dir] + cost;
		v.turn = T[v.pos][v.dir] = T[pos][dir] + 1;
		PQ.push(v);
	    }
	}
    }
    return -1;
}

int getDirection(int s, int t, Point P[MAX]){
    if ( P[s].x < P[t].x ) return 0;
    else if ( P[s].x > P[t].x ) return 2;
    else if ( P[s].y < P[t].y ) return 1;
    else if ( P[s].y > P[t].y ) return 3;
}

main(){
    int m, n, x, y, s, t;
    string name, p, q;
    Point P[MAX];

    while( cin >> m >> n && m && n ){
	map<string, int> M;
	for ( int i = 0; i < m; i++ ){
	    cin >> name >> x >> y;
	    P[i] = Point(x, y);
	    M[name] = i;
	}
	for ( int i = 0; i < n; i++ ){
	    cin >> p >> q; s = M[p]; t = M[q];
	    P[s].adj[getDirection(s, t, P)] = t;
	    P[t].adj[getDirection(t, s, P)] = s;
	}
	cin >> p >> q;
	int cost = dijkstra(m, M[p], M[q], P);
	if ( cost == -1 ) cout << "impossible" << endl;
	else cout << cost << endl;
    }
}

Measured memory_bytes: 1100
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n * 2];
		for (int i = 0; i < 2 * n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i * 2];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>

using namespace std;

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

	for (i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
	return 0;
} 


Measured memory_bytes: 1536
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} 
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} 
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }
    
    
 
           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        int a=sc.i();
        int b=sc.i();
        out.print(Math.min(a,b)+" ");
        out.print(Math.max(0,a+b-n));
        out.flush();
    }
}

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

int main(){
    ll n;
    cin >> n;
    map<ll, ll> ball;
    vector<int> z(n);
    for(ll i=0; i<n; i++){
        ll a;
        cin >> a;
        ball[a]++;
        z.at(i) = a;
    }
    ll all=0;
    for(auto p: ball){
        auto v=p.second;
        all += v*(v-1)/2;
    }
    for(int i=0; i<n; i++){
        //sはボールに書かれている数、tはその数が全体で何個あるか
        ll s=z.at(i);
        ll t=ball[s];
        ll ans = all-t*(t-1)/2+(t-1)*(t-2)/2;
        cout << ans << endl; 
    }
}


Measured memory_bytes: 11944
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)
#define u_m unordered_map
#define u_s unordered_set
#define ff first
#define ss second
#define mp make_pair
using namespace std;
ll __pow(ll x, ll y) {ll res = 1;while(y>0){if(y&1) res*=x; y>>=1; x*=x;}return res;}
ll gcd(ll a , ll b){if(b==0) return a;a%=b;return gcd(b,a);}
bool isprime(ll n){for(ll i=2; i*i<=n; i++){if(n%i==0) return 0;}return 1;}
ll n,m,x,y,z,k;
ll dp(ll n){
    if(n<10) return max((ll)1, n);
    else return max((n%10)*dp(n/10), 9*dp(n/10-1));
}
void solve(){
    string a, b;
    cin>>a>>b;
    n=a.size();
    ll cnt=0;
    fo(i,n){
        if(a[i]!=b[i]) cnt++;
    }
    cout<<cnt<<endl;
}
int main(){
    ll t=1;
    //cin >> t;
    for(ll i=1; i<=t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	std::string a, b, c;

	std::cin >> a >> b >> c;

	std::cout << (char)toupper(a[0]);	std::cout << (char)toupper(b[0]);	std::cout << (char)toupper(c[0]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())

f = [0] * (1100000)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            c = x**2 + y**2 + z**2 + x*y + y*z + z*x
            f[c] += 1
for i in range(1, N+1):
    print(f[i])

Measured memory_bytes: 17684
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_M = 100000;
const double PI = 3.14159265358979323846;
int dp[5005][5005];



int main(int argc, char *args[]) {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1<< endl;
	}
	else {
		cout << (n - 1) / 2 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 5050;
char s[N];
int z[N];
int ans = 0;
int n;

void calcZ() {
	int l = 0, r = 0;
	for (int i = 0; i < n; i++)
		z[i] = 0;
	for (int i = 1; i < n; i++) {
		if (i < r)
			z[i] = min(r - i, z[i - l]);
		while(i + z[i] < n && s[z[i]] == s[i + z[i]]) z[i]++;
		if (i + z[i] > r) {
			l = i;
			r = i + z[i];
		}
	}
}

void solve() {
	calcZ();
	for (int i = 1; i < n; i++)
		ans = max(ans, min(i, z[i]));
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	scanf("%s", s);
	while(n > 0) {
		solve();
		n--;
		for (int i = 0; i < n; i++)
			s[i] = s[i + 1];
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, m, ans = 0;
int a[N], b[N], c[N];
vector<pair<int, int> > v;

int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= m; i++)
	{
		cin >> b[i] >> c[i];
		v.push_back({c[i], b[i]});
	}
	sort(v.rbegin(), v.rend());
	sort(a + 1, a + n + 1);
	int idx = 0;
	for(int i = 1; i <= n; i++)
	{
		if(idx >= m)
			ans += a[i];
		else
		{
			ans += max(a[i], v[idx].first);
			v[idx].second--;
			if(v[idx].second == 0)
				idx++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

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

    int P[M];
    string S[M];
    set<int> AC;    // ACが出た問題を重複なくカウント
    map<int, int> WA; // <問題, WA回数>
    for(int i = 0; i < M; ++i){
        cin >> P[i] >> S[i];

        if(S[i] == "AC") AC.insert(P[i]);

        if(S[i] == "WA"){
            if(AC.count(P[i]) == 0) WA[P[i]]++;
        }
    }
    int WA_count = 0; 
    for(auto itr = WA.begin(); itr != WA.end(); ++itr){
        if(AC.count(itr->first) == 1) WA_count += (itr->second); 
    }

    cout << AC.size() << " " << WA_count << endl;


}

Measured memory_bytes: 10752
S = input()
if 'N' in S and 'S' not in S:
    print('No')
elif 'S' in S and 'N' not in S:
    print('No')
elif 'W' in S and 'E' not in S:
    print('No')
elif 'E' in S and 'W' not in S:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007

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

using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<edge>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

vector<int> ans;
Graph G;

void dfs(edge v){
    for(auto nv : G.at(v.to)){
        if(ans.at(nv.to) != -1) continue;
        ans.at(nv.to) = (ans.at(v.to) + nv.weight)%2;
        dfs(nv);
    }
}


int main(){

    int n; cin >> n;
    G.resize(n);
    rep(i,n-1){
        int a,b,w; cin >> a >> b >> w;
        a--;b--;
        G.at(a).push_back(edge(b,w));
        G.at(b).push_back(edge(a,w));
    }

    ans.assign(n,-1);

    ans.at(0) = 0;

    dfs(edge(0,0));

    rep(i,n) cout << ans.at(i) << endl;
    
    return 0;
}


Measured memory_bytes: 8192
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] zahyou = new int[4];
            for (int i = 0; i < input.Length; i++)
            {
                zahyou[i] = int.Parse(input[i]);
            }
            int x3 = zahyou[2] - zahyou[3] + zahyou[1];
            int y3 = zahyou[3] + zahyou[2] - zahyou[0];
            int x4 = zahyou[0] - zahyou[3] + zahyou[1];
            int y4 = zahyou[1] + zahyou[2] - zahyou[0];

            Console.WriteLine($"{x3} {y3} {x4} {y4}");
        }
    }
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template <typename T1, typename T2>
vector<T2> accum(vector<T1>& a, T2 init) {
    int L = a.size();
    vector<T2> acc(L + 1);
    acc[0] = init;
    for (int i=0; i<L; ++i) acc[i+1] = acc[i] + a[i];
    return move(acc);
}

template <typename T>
T accumed(vector<T>& acc, int from, int to) {
    int M = acc.size() - 1;
    return acc[min(M, to)] - acc[max(0, from)];
}

int solve(int N, string& s) {
    vi a(N,0);
    rep(i,N) if(s[i]=='#') a[i]=1;
    vi b = accum(a,0);

    int best=N;
    rep(wh,N+1) {
        int bl = N-wh;
        int sc = accumed(b,0,wh) + (N-wh)-accumed(b,wh,N);
        best=min(best,sc);
    }

    return best;
}

int main() {
    int N; cin >> N;
    string s; cin >> s;
    cout << solve(N,s) << endl;
    return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 998244353LL;

ll inv(ll K) {
  ll A = MOD - 2;
  ll ret = 1;
  ll D = K;
  while (A > 0) {
    if (A % 2 == 1) {
      ret = (ret * D) % MOD;
    }
    D = (D * D) % MOD;
    A /= 2;
  }
  return ret;
}

ll MP[200005];
vector<ll> FC;
vector<ll> IFC;

void initFC(int N) {
  FC.resize(N+1);
  IFC.resize(N+1);
  FC[0] = 1;
  for (ll i=1; i<=N; i++) {
    FC[i] = (FC[i-1] * i) % MOD;
  }
  IFC[N] = inv(FC[N]);
  for (ll i=N; i>0; i--) {
    IFC[i-1] = (IFC[i] * i) % MOD;
  }
}

ll combFC(ll N, ll K) {
  ll ret = (FC[N] * IFC[K]) % MOD;
  ret = (ret * IFC[N-K]) % MOD;
  return ret;
}

void modSum(ll& N, ll B) {
  N = (N + B % MOD + MOD) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  ll N, M, K;
  cin >> N >> M >> K;
  initFC(N-1);
  MP[0] = 1;
  for (ll i=1; i<=N; i++) {
    MP[i] = MP[i-1] * (M-1);
    MP[i] = MP[i] % MOD;
  }
  ll ret = 0;
  for (ll i=0; i<=K; i++) {
    ll a = combFC(N-1, i);
    a = (a * M) % MOD;
    a = (a * MP[N-1-i]) % MOD;
    ret = (ret + a) % MOD;
  }
  cout << ret << endl;
}

Measured memory_bytes: 7924
class BITree:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def calc(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

Q=int(input())
query=[list(map(int,input().split())) for i in range(Q)]
tmp=[]
for i in range(Q):
    seq=query[i]
    if len(seq)==1:
        continue
    else:
        tmp.append((seq[1],i))
tmp.sort()
X=[(-1,-1) for i in range(Q)]
for i,sq in enumerate(tmp):
    X[sq[1]]=(i+1,sq[0])
N=len(tmp)
Idx=BITree(N)
Clc=BITree(N)
Btm=0
nowindex=0
for i in range(Q):
    if X[i]==(-1,-1):
        left=1
        right=N
        mid=(left+right)//2
        while(left<=right):
            mid=(left+right)//2
            if Idx.calc(mid)<(nowindex+1)//2:
                left=mid+1
            else:
                right=mid-1
        k=left
        x=(Clc.calc(k)-Clc.calc(k-1))
        ans=Clc.calc(N)-2*Clc.calc(k)-x*(Idx.calc(N)-2*Idx.calc(k))+Btm
        print(x,ans)
    else:
        Idx.add(X[i][0],1)
        Clc.add(X[i][0],X[i][1])
        Btm+=query[i][2]
        nowindex+=1



Measured memory_bytes: 106160
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#define left left___
#define right right__

void dfs (int x, const vvi &g, vi &color, vi &comp)
{
    for (int dest : g[x]) if (color[dest] == -1)
    {
        color[dest] = (color[x] ^ 1);
        dfs(dest, g, color, comp);
    }
    comp.pb(x);
}

void solve (int n)
{
    int m;
    cin >> m;

    vvi g(n);
    forn (i, m)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }

    vi color(n, -1);
    ll ans = 0;

    forn (i, n) if (color[i] == -1)
    {
        color[i] = 0;
        vi comp;
        dfs(i, g, color, comp);

        bool ok = true;
        int cnt = 0;
        for (int x : comp)
        {
            assert(color[x] != -1);
            cnt += (color[x] == 0);
            for (int to : g[x])
                ok &= (color[x] != color[to]);
        }

        if (ok)
            ans += (ll)cnt * (ll)(sz(comp) - cnt);
        else
            ans += (ll)sz(comp) * (ll)(sz(comp) - 1) / 2;
    }

    ans -= m;
    cout << ans << endl;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 7804
#include <iostream>
#include <climits>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define INF 1LL << 60;
 
int main() {
  
  int N;
  cin >> N;

  
  int a,b,c;
  ll da[N],db[N],dc[N];
  
  for(int i=0; i<N; i++){
    da[i] = 0;
    db[i] = 0;
    dc[i] = 0;
  }
  
  for(int i=0; i<N; i++){
    cin >> a >> b >> c;
    da[i+1] = a + max(db[i],dc[i]);
    db[i+1] = b + max(da[i],dc[i]);
    dc[i+1] = c + max(da[i],db[i]);
  }
  
  cout << max(max(da[N],db[N]),dc[N]) <<endl;
  
}

Measured memory_bytes: 2560
def longer_length(x, y):
    len_x, len_y = len(str(x)), len(str(y))
    if len_x > len_y:
        return len_x
    return len_y


def main():
    N = int(input())
    min_odd = longer_length(N, 1)
    for n in range(2, int(N ** 0.5)+1):
        if N % n == 0:
            i = longer_length(n, N // n)
            if i < min_odd:
                min_odd = i
    print(min_odd)


if __name__ == '__main__':
    main()

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

#define jk(i,j,k) for (int i = (j); i <= (k); i++)
#define kj(i,j,k) for (int i = (j); i >= (k); i--)
#define int long long
#define lb long double
#define ul unsigned long long
#define mp std::make_pair
#define pb push_back
#define pr(a,b) printf(a, b)
#define sc(a,b) scanf(a, &b)
#define x first
#define y second
#define al(x) (x).begin(), (x).end()
#define me(a) memset((a), 0, sizeof(a))

inline int rd() { int data = 0, w = 1; char ch = 0; while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar(); (ch == '-') && ( w = -1, ch = getchar() ); while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); } return data * w; }
inline void P (int v) { if (v < 0) { putchar('-'); v = -v; } if (v > 9) P(v / 10); putchar(v % 10 + '0'); }

std::string str;

signed main () {
    std::cin >> str;
    int le = str.length(), cn = 0;
    jk (i, 1, le >> 1) {
        if (str[i - 1] != str[le - i]) cn++;
    }
    P(cn);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m;
  cin>>m;
  for(int cn=0;cn<m;cn++){
    int ma[5][5];
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
	cin>>ma[i][j];
    int ans=0;
    for(int x=1;x<=5;x++)
      for(int y=1;y<=5;y++){
	for(int i=0;i<5;i++){
	  for(int j=0;j<5;j++){
	    if(i+x-1>=5||j+y-1>=5)continue;
	    int f=0;
	    for(int k=0;k<x;k++){
	      for(int l=0;l<y;l++){
		if(ma[i+k][j+l]==0)f=1;
	      }
	    }
	    if(f)continue;
	    ans=max(ans,x*y);
	  }
	}
      }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3044
fn main() {
    proconio::input! {
        n: usize,
    }
    fn factor(mut n: usize) -> Vec<(usize, usize)> {
        let mut ret = vec![];
        for i in 2.. {
            if i * i > n {
                break;
            }
            let mut cnt = 0;
            while n % i == 0 {
                cnt += 1;
                n /= i;
            }
            if cnt != 0 {
                ret.push((i, cnt));
            }
        }
        if n != 1 {
            ret.push((n, 1));
        }
        ret
    }
    let factors = factor(n);
    fn search(factor_idx: usize, v: Vec<usize>, factors: &[(usize, usize)]) -> usize {
        fn pow(u: usize, i: usize) -> usize {
            (0..i).fold(1, |sum, _| sum * u)
        }
        fn number_of_digits(u: usize) -> usize {
            let mut u = u;
            let mut count = 1;
            while u >= 10 {
                u /= 10;
                count += 1;
            }
            count
        }
        if factor_idx >= factors.len() {
            let nx = (0..factors.len()).fold(1, |sum, i| {
                sum * pow(factors[i].0, *v.get(i).or(Some(&1)).unwrap())
            });
            let ny = (0..factors.len()).fold(1, |sum, i| {
                sum * pow(factors[i].0, factors[i].1 - *v.get(i).or(Some(&1)).unwrap())
            });
            let x = number_of_digits(nx);
            let y = number_of_digits(ny);
            std::cmp::max(x, y)
        } else {
            let mut min = std::usize::MAX;
            for i in factor_idx..factors.len() {
                for j in 0..factors[i].1 {
                    let mut v = v.clone();
                    v.push(j);
                    min = std::cmp::min(min, search(i + 1, v, factors));
                }
            }
            min
        }
    }
    let ans = search(0, vec![], &factors);
    println!("{}", ans);
}


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

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

  string op = "-+";
  int sum = 0;
  int a = input[0] - '0';
  int b = input[1] - '0';
  int c = input[2] - '0';
  int d = input[3] - '0';

  for (int i = 0; i < 2; i++) {
	int tmp1;
	if (i)
	  tmp1 = a + b;
	else
	  tmp1 = a - b;

	for (int j = 0; j < 2; j++) {
	  int tmp2;
	  if (j)
		tmp2 = tmp1 + c;
	  else
		tmp2 = tmp1 - c;
	  if (tmp2 + d == 7) {
		cout << input[0] << op[i] << input[1] << op[j] << input[2] << '+' << input[3] << "=7" << endl;
		return 0;
	  } else if (tmp2 - d == 7) {
		cout << input[0] << op[i] << input[1] << op[j] << input[2] << '-' << input[3] << "=7" << endl;
		return 0;
	  }
	  
	}
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}

int main() {

	ll x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << endl;

	return 0;
}


Measured memory_bytes: 888
#include <iostream>
 #include <cstdlib>
using namespace std;
int h[1000000]; long long  table[1000000];
    long long  a[1000000];int j;long long m;
int main()
{int n,k;
cin >> n>>k;
 for(int i=0;i<n;i++)
        cin>>h[i];



    for(int i=0;i<n;i++){
    if(i==0) table[i]=0;
    else if(i==1) table[i]=abs(h[i]-h[i-1]);
    else {
        m=abs(h[i]-h[i-1])+table[i-1];
        j=max(0,i-k);
        for(;j<i;j++){
            m=min(m,abs(h[i]-h[j])+table[j]);
        }

    table[i]=m;
    }}




        cout << table[n-1] << endl;
        return 0;
    }


Measured memory_bytes: 6400
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var bi = ai.Select((x, i) => x - (i + 1)).ToArray();
            Array.Sort(bi);
            var b = n % 2 == 0 ? bi[n / 2 - 1] : bi[n / 2];
            var answer = ai.Select((x, i) => Math.Abs(x - (b + i + 1))).Sum();
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 38660
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    char ch=s1[0];
    int m=0;
    s1.erase(0,1);
    while(1)
    {
        if(ch=='a')
        {
            if(s1.length() == 0)
            {
                m=1;
                break;
            }
            ch=s1[0];
            s1.erase(0,1);
        }
        else if(ch=='b')
        {
            if(s2.length() == 0)
            {
                m=2;
                break;
            }
            ch=s2[0];
            s2.erase(0,1);

        }
        else if(ch=='c')
        {
            if(s3.length() == 0)
            {
                m=3;
                break;
            }
            ch=s3[0];
            s3.erase(0,1);

        }
    }
    if(m==1)
        cout<<'A';
    if(m==2)
        cout<<'B';
    if(m==3)
        cout<<'C';
    return 0;
}


Measured memory_bytes: 256
N,D=map(int, input().split())
X = [ list(map(int,input().split(" "))) for i in range(N)]
count = 0
for i1 in range(N):
  for i2 in range(i1+1,N):
    sos = 0
    for k in range(D):
      sos = sos + (X[i1][k]-X[i2][k])**2
    if sos**0.5 % 1 == 0:
      count = count + 1
print(count)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
vector<int> primeFactors(int n) {
    vector<int> v;
    int i = 2;
    while (i * i <= n) {
        if (n % i == 0) {
            v.push_back(i);
            n /= i;
        } else {
            i++;
        }
    }
    if(n != 1)v.push_back(n);
    return v;
}
int MOD =1000000000+7;

class modcomb {
public:
    int maxn,MOD;
    vector<int>fac,finv,inv;
    modcomb(int _maxn,int _mod) : maxn(_maxn),MOD(_mod),fac(_maxn),finv(_maxn),inv(_maxn){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < maxn; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    };
    int modComb(int n,int k){
        if (n < k) return 0LL;
        if (n < 0 || k < 0) return 0LL;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
};
signed main(){
    int n,m; cin  >>  n >> m;
    vector<ll> primes = primeFactors(m);
    map<ll,ll>Map; for(auto e:primes)Map[e]++;
    int ans = 1LL;
    auto manager = modcomb(500000,MOD);
    for(auto itr:Map){
        ans *= manager.modComb(itr.second + n - 1,n - 1);
        ans %= MOD;
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 12032
import collections

N = int(input())
A = [int(_) for _ in input().split()]
count = collections.defaultdict(int)
for x in A:
    count[x] += 1
if len(count) == 1:
    a = list(count.keys())[0]
    if a == 0:
        print('Yes')
        exit()
elif len(count) == 2:
    a, b = sorted(count.keys())
    if a == 0 and count[b] == count[a] * 2:
        print('Yes')
        exit()
elif len(count) == 3:
    a, b, c = count.keys()
    if a ^ b == c and count[a] == count[b] == count[c]:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 14468
import fractions
N, M = list(map(int, input().split()))
S = input()
T = input()

L = int(N * M / fractions.gcd(N, M))
LN = int(L / N)
LM = int(L / M)

count = 0
dic1 = {LN*n:S[n] for n in range(N)}
dic2 = {LM*n:T[n] for n in range(M)}

for k in dic1.keys():
    if k in dic2 and dic1[k] != dic2[k]:
        count += 1
        print(-1)
        break

if count == 0:
    print(L)

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

void solve(long long N, long long A, long long B){
    cout << min(N * A, B) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
# ABC081B - Shift only
def main():
    n = int(input())
    A = set(map(int, input().split()))
    ans = 0
    while all(i % 2 == 0 for i in A):
        A = {i // 2 for i in A}
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int r0, w0, c, r; cin >> r0 >> w0 >> c >> r;
    if (r0 == 0) break;
    int res = (max(w0 * c - r0, 0) + r - 1) / r;
    cout << res << '\n';
  }
}


Measured memory_bytes: 3132
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    while (op != '?') {
        int c;
        if (op == '+') c = a + b;
        if (op == '-') c = a - b;
        if (op == '*') c = a * b;
        if (op == '/') c = a / b;
        cout << c << endl;
        cin >> a >> op >> b;
    }
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
#include<string>
#include<vector>
#include<map>
int main() {
	int p,q;
	string s;
	cin>>s>>p>>q;
	int dir=0;//0:x,1;y
	vector<int> x,y;
	x.push_back(0);
//	int first=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='T'){
			dir=dir*-1+1;
			if(dir){
				y.push_back(0);
			}else{
				x.push_back(0);
			}
		}else{
			if(dir){
				y.back()++;
			}else{
				x.back()++;
			}
		}
	}
	int goal;
	int flag=1;
	map<int,int> m,nextm;;
	vector<int>::iterator itr,itrend;
	map<int,int>::iterator itrm;
	for(int i=0;i<2;i++){
//		cout<<'u';
//		for(int j=0;j<16001;j++) c[j]=0;
		m.clear();
		if(i){
			goal=q;
			itr=y.begin();
			itrend=y.end();
			m[0]=1;
		}else{
			goal=p;
			itr=x.begin();
			m[*itr]=1;
			itr++;
			itrend=x.end();
		}
		while(itr!=itrend){
//			cout<<*itr<<endl;
			for(itrm=m.begin();itrm!=m.end();itrm++){
//					m.erase((*itrm).first);
//				m.erase(0);
					nextm[(*itrm).first+*itr]=1;
					nextm[(*itrm).first-*itr]=1;

			}
			m=nextm;
			nextm.clear();
			itr++;
		}
//		for(itrm=m.begin();itrm!=m.end();itrm++){
//				cout<<(*itrm).first<<' '<<(*itrm).second<<endl;
//		}
//		cout<<m[goal]<<endl;
		if(m[goal]==0){
			flag=0;
		}

	}



//	int c[16001];
//	int goal;
//	int flag=1;
//
//	vector<int>::iterator itr,itrend;
//	for(int i=0;i<2;i++){
////		cout<<'u';
//		for(int j=0;j<16001;j++) c[j]=0;
//
//		if(i){
//			goal=q;
//			itr=y.begin();
//			itrend=y.end();
//			c[8000]=1;
//		}else{
//			goal=p;
//			itr=x.begin();
//			c[8000+*itr]=1;
//			itr++;
//			itrend=x.end();
//		}
//		while(itr!=itrend){
////			cout<<*itr<<endl;
//			for(int k=0;k<16001;k++){
//				if(c[k]){
//					c[k]=0;
//					c[k+*itr]=1;
//					c[k-*itr]=1;
//				}
//			}
//			itr++;
//		}
//		if(c[goal+8000]==0){
//			flag=0;
//		}
//
//	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    // k 個のブロックの中に１を入れて左右に広げていく
    // 1 が入っているブロックが端にある場合

    var flag = false
    for (i in 0..k - 1) {
        if (inputs[i] == 1) {
            flag = true
        }
    }
    for (i in n - k until n) {
        if (inputs[i] == 1) {
            flag = true
        }
    }

    if (flag) {
        // WA: ceil を使わず実装して間違えていたので注意
        println(Math.ceil((n.toDouble() - k) / (k - 1)).toInt() + 1)
        return
    }

    // 1 が入っているブロックが内部にある場合
    // -> そこで配列を２つに分割してそれぞれを端から塗っていく場合を考える
    var index = 0
    for (i in 0 until n) {
        if (inputs[i] == 1) {
            index = i
        }
    }


    // 左側残りをまず塗る( １はブロック内の右端に寄せると仮定）
    // WA: 寄せずに真ん中配置の方が１の配置によってはブロック数を減らせる場合がある
    // -> 左端，右端，中心ケースをすべて求める？？

    var min = Int.MAX_VALUE

    // 右端ケース
    var restL = (index + 1 - k)
    var restR = n - (index + 1)
    var ans = (Math.ceil(restL.toDouble() / (k - 1)) + Math.ceil(restR.toDouble() / (k - 1))).toInt() + 1
    min = Math.min(ans, min)

    // 左端ケース
    restL = (index + 1 - 1)
    restR = n - (index + k)
    ans = (Math.ceil(restL.toDouble() / (k - 1)) + Math.ceil(restR.toDouble() / (k - 1))).toInt() + 1
    min = Math.min(ans, min)

    // 中央ケース
    restL = (index + 1 - Math.ceil(k.toDouble()/2).toInt())
    restR = n - (index + Math.ceil(k.toDouble()/2).toInt())
    ans = (Math.ceil(restL.toDouble() / (k - 1)) + Math.ceil(restR.toDouble() / (k - 1))).toInt() + 1
    min = Math.min(ans, min)

    println(min)
}

Measured memory_bytes: 47860
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n,k;
    int ans=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        ans=fmin(ans*2,ans+k);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
from heapq import*
X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]
for _ in[0]*N:A.append([int(e)for e in input().split()])
A.sort(key=lambda a:a[0]-a[1])
for i in range(N):
	L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];heappush(q2,A[N-1-i][0]-A[N-1-i][2])
	if i>=Y:L[i+1]-=heappop(q1)
	if i>=X:R[i+1]-=heappop(q2)
print(max(L[i]+R[N-i] for i in range(Y,N-X+1)))

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, M;

  void init() {
    scanf("%lld %lld", &N, &M);
  }

  void solve() {
    if(N<=M) printf("unsafe\n");
    else printf("safe\n");
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>

using namespace std;

int main(int argc,char **argv)
{
  std::string line;
  cin >> line;

  const char *p = line.c_str();
  int a = p[0] - '0'; 
  int b = p[1] - '0'; 
  int c = p[2] - '0'; 
  int d = p[3] - '0'; 

  for(int i=0;i<2*2*2;i++)
  {
    bool s1 = (i & 1) == 1;
    bool s2 = (i & 2) == 2;
    bool s3 = (i & 4) == 4;
    int res1 = s1 ? a + b : a - b;
    int res2 = s2 ? res1 + c : res1 - c;
    int res3 = s3 ? res2  + d: res2 - d;
    if(res3 == 7)
    {
      cout << a << (s1 ? "+" : "-") << b << (s2 ? "+" : "-") << c << (s3 ? "+" : "-") << d << "=7" << endl; 
      return 0;
    }

  }

}


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

// 下から index 番目（0から数えて）のビットが 1 である
constexpr bool hasBit(long long n, int index) {
	return ((n >> index) & 1) != 0;
}

constexpr bool isOdd(long long n) {
	return n % 2 == 1;
}

int main() {
	long long A, B;
	std::cin >> A >> B;

	long long result = 0;
	// 0桁目だけ特別
	if(((B - A + 1) % 4 == 1 && isOdd(A)) || (B - A + 1) % 4 == 2 || ((B - A + 1) % 4 == 3 && !isOdd(A))) {
		result += 1ll;
	}
	for(int i = 1; i < 40; i++) {
		bool bit = false;
		const long long v = std::pow<long long>(2, i);
		const long long bottom = v - (A % v);
		if(isOdd(bottom) && hasBit(A, i)) {
			bit = !bit;
		}
		const long long top = B % v + 1;
		if(isOdd(top) && hasBit(B, i)) {
			bit = !bit;
		}

		if(bit) {
			result += v;
		}
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int N,M;
struct node
{
    int l;
    int r;
} a[100005];
bool cmp(node a,node b)
{
    return a.r<b.r;
}
int main()
{
    scanf("%d%d",&N,&M);
    for(int i=0; i<M; i++)
        scanf("%d%d",&a[i].l,&a[i].r);
    sort(a,a+M,cmp);
    int flag=a[0].r;
    int ans=1;
    for(int i=1; i<M; i++)
    {
        if(a[i].l>=flag)
        {
            flag=a[i].r;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n+1, 0));
    rep(i, 2){
        rep(j, n){
            cin >> a.at(i).at(j+1);
        }
    }
    //累積和
    rep(i, 2){
        rep(j, n){
            a.at(i).at(j+1) += a.at(i).at(j);
        }
    }
    //最大値を求める
    int max = 0;
    //1行目0からi-1まで、i、2行目i+1からnの区間の総和
    rep(i, n){
        int sum = 0;
        sum += a.at(0).at(i+1);
        sum += a.at(1).at(n) - a.at(1).at(i);
        if (sum > max) max = sum;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

int main()
{
    ll x; cin >> x;
    ll m = 100L;
    int y = 0;

    while (m < x) {
        m *= 1.01;
        ++y;
    }

    cout << y << endl;

    return 0;
}

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


main()
{
	set<int>s;
	set<int>::iterator it;
	int a;
	cin >> a;
	for(int i=0;i<a;i++)
	{
		int b;
		scanf("%d",&b);
		it=s.find(b);
		if(*it != b)
			s.insert(b);
		else
			s.erase(it);
	}
	cout << s.size();
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    map<int,int> mp;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        ++mp[A];
    }

    vector<int> cnt;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        cnt.push_back(itr->second);
    }
    if(cnt.size() <= K) {
        cout << 0 << endl;
    } else {
        sort(cnt.begin(), cnt.end());
        partial_sum(cnt.begin(), cnt.end(), cnt.begin());
        cout << cnt[cnt.size()-K-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 10748
#include<iostream>
using namespace std;
static const int MAX = 100;
int main()
{
    int n;
    char S[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> S[i];
    for (int i = 0; i < n; i++)
    {
        if (S[i] == 'Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  long long N = s.size();
  int Q = t.size();
  vector<vector<int>> ne(26,vector<int> (N,0));
  int c = s[0] - 'a';
  for (int i=N-2; i>=0; i--) {
    for (int j=0; j<26; j++) {
      if (s[i+1]-'a' == j) {
        ne[j][i] = i+1;
      }
      else {
        ne[j][i] = ne[j][i+1];
      }
    }
  }
  long long tt = -1;
  long long now = N-1;
  int su;
  for (int i=0; i<Q; i++) {
    su = t[i] - 'a';
    if (ne[su][now] != 0) {
      now = ne[su][now];
      continue;
    }
    if (su == c) {
      tt++;
      now = 0;
      continue;
    }
    if (ne[su][0] == 0) {
      cout << -1 << endl;
      return 0;
    }
    tt++;
    now = ne[su][0];
  }
  
  cout << tt * N + now + 1ll << endl;
      
  return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string s;
	scan(s);
	int N=s.size();
	ll Astock=0,BCstock=0;
	ll ans=0;
	rep(i,N-1){
		if(s[i]=='A'){
			Astock++;
		}
		else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=Astock;
			i++;
		}
		else{
			Astock=0,BCstock=0;
		}
	}
	prin(ans);
	return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N,D;
	cin >> N>>D;
	int cnt = 0;
	for(int i = 0; i<N;i++)
	{
		ll x,y;
		cin >>x>>y;
		if(x*x + y*y <= D*D)
			cnt++;
	}
	cout <<cnt<<endl;
}


Measured memory_bytes: 3580
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(input())

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

restaurants.sort(key=itemgetter(2), reverse=True)
restaurants.sort(key=itemgetter(1))

for i in range(n):
    print(restaurants[i][0])

Measured memory_bytes: 3064
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}



Measured memory_bytes: 1996
import java.util.Scanner;

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


Measured memory_bytes: 26288