akhauriyash/Code-Regression huggingface dataset:
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L;
ll A[300005] = {};
ll B[300005] = {};
ll C[300005] = {};
bool f, ff;
string S,T;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;
multiset<ll> llmset;


/*
struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
bool fl[30] = {};



string ss, sss;


int main() {


	cin >> N;

	for (int i = 0; i < 3*N; i++) {
		cin >> A[i];
		vll.push_back(A[i]);
	}

	sort(vll.begin(), vll.end());

	reverse(vll.begin(), vll.end());

	e = 0;

	for (int i = 0; i < N; i++) {
		e += vll[i * 2 + 1];
	}

	cout << e << endl;
	return 0;

}


Measured memory_bytes: 13296
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

// set<ll> st[1000001];

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll sp = a[0];
  for (int i = 0; i < n; ++i) {
    sp = gcd(sp, a[i]);
  }
  bool setwise = (sp == 1ll);
  vector<int> map(1000001);
  bool pairwise = true;
  for (int i = 0; i < n; ++i) {
    ll val = a[i];
    for (ll j = 2; j * j <= val; ++j) {
      int cnt = 0;
      while (val % j == 0) {
        cnt++;
        val /= j;
        if (map[j]) {
          pairwise = false;
        }
      }
      map[j] = cnt;
    }
    if (val != 1ll) {
      if (map[val]) {
        pairwise = false;
      }
      map[val] = 1;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << '\n';
  } else if (setwise) {
    cout << "setwise coprime" << '\n';
  } else {
    cout << "not coprime" << '\n';
  }
  return 0;
}

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

int main() {
    int n, a[105],ans=0, num=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i]-num>=0) ans += a[i]-num;
        num=a[i];
    }
    cout << ans;
}

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

int main()
{
    string s;
    cin>>s;
    ll n = s.length(),i,ctr=0;
    string prev ="", tmp = "";
    for(i=0;i<n;i++)
    {
        tmp+=s[i];
        if(tmp!=prev)
        {
            ctr++;
            prev = tmp;
            tmp ="";
        }
    }
    cout<<ctr;
    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

signed main() {
  uint64_t n;
  cin >> n;
  
  int64_t min = 1000000;
  int64_t max = -1000000;
  int64_t sum = 0;
  
  int64_t val = 0;
  for(uint64_t i=0;i<n;i++){
      cin >> val;
      if(val<min) min = val;
      if(val>max) max = val;
      sum += val;
  }
  
  cout << min << " " << max << " " << sum << endl;;
  return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N;
    cin >> N;
    vector<int> d;
    rep(i, 0, N) {
        int a;
        cin >> a;
        d.push_back(a);
    }
    sort(d.begin(), d.end());
    if(d[N / 2] == d[N / 2 - 1]) {
        cout << 0 << endl;
    } else {
        cout << d[N / 2] - d[N / 2 - 1] << endl;
    }
}

Measured memory_bytes: 892
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int [] Ls = new int [N];
		int sum = 0;
		for(int i=0; i<N; i++) {
			Ls[i] = sc.nextInt();
			sum += Ls[i];
		}
		Arrays.sort(Ls);
		if(Ls[N-1] < (sum - Ls[N-1]) ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 23380
import java.util.Scanner;

//TETORIS
public class Main{

//	static void p(boolean[][] m){
//		System.out.println();
//		for(int i=10;i>=0;i--){
//			for(int j=0;j<5;j++){
//				System.out.print(m[i][j]?"1":"0");
//			}
//			System.out.println();
//		}
//	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			boolean[][] m = new boolean[5000][5];
			while(n--!=0){
				int d = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt()-1;
				if(d==2){
					int k = 4999;
					while(k>=0&&!m[k][q])k--;
					k++;
					for(int i=k;i<k+p;i++)m[i][q]=true;
				}
				else{
					int k = 4999;
					while(true){
						boolean f = true;
						if(k>=0){
							for(int j=q;j<q+p;j++){
								if(m[k][j])f = false;
							}
						}
						if(!f||k==-1){
							k++;
							for(int j=q;j<q+p;j++)m[k][j]=true;
							break;
						}
						k--;
					}
				}
				boolean con = true;
				int k = 0;
				while(k<5000&&con){
					con = false;
					boolean t = true;
					for(int j=0;j<5;j++){
						if(m[k][j])con = true;
						else t = false;
					}
					if(t){
						boolean f = true;
						int i = k;
						while(i<5000&&f){
							f = false;
							for(int j=0;j<5;j++){
								if(m[i][j])f = true;
							}
							if(f){
								for(int j=0;j<5;j++){
									m[i][j] = m[i+1][j];
								}
							}
							i++;
						}
					}
					else k++;
				}
//				p(m);
			}
			int s = 0;
			for(int i=0;i<5000;i++)for(int j=0;j<5;j++)s+=m[i][j]?1:0;
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 13000
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	if(n>9 ||m>9){
		cout<<-1;
		return 0;
	}
	cout<<n*m;
    return 0;
}
//.........

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

#define N 26

const int INF = 1 << 30;

int c[N];
int s[365][N];
int last[N];
std::chrono::time_point<std::chrono::steady_clock> start, endt;

struct ContestInfo {
	int D;
	long score;
	vector<int> t;
	set<int> held[N];
	ContestInfo(int dd) : D(dd), score(0) {
		t.resize(D, -1);
		for (int i = 0; i < N; i++) {
			held[i].insert(-1);
			held[i].insert(D);
			score -= c[i] * D * (D + 1) / 2;
		}
	}

	void add(int dd, int qq) {
		if (t[dd] != -1) {
			cout << "Add faild!" << endl;
			exit(1);
		}

		t[dd] = qq;
		score += s[dd][qq];
		held[qq].insert(dd);
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score -= c[qq] * range(*litr, *ritr);
		score += c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
	}

	void erase(int dd) {
		if (t[dd] == -1) {
			cout << "Erase faild!" << endl;
			exit(1);
		}
		int qq = t[dd];
		t[dd] = -1;
		score -= s[dd][qq];
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score += c[qq] * range(*litr, *ritr);
		score -= c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
		held[qq].erase(itr);
	}

	void change(int dd, int qq) {
		erase(dd);
		add(dd, qq);
	}

	void output() {
		for (int i = 0; i < D; i++)
			cout << t[i] + 1 << endl;
	}
};

void tic() {
	start = std::chrono::steady_clock::now();
}

double toc() {
	endt = std::chrono::steady_clock::now();
	std::chrono::duration<double> elapsed_seconds = endt - start;
	return elapsed_seconds.count();
}

int main() {
	tic();
	int d;
	cin >> d;
	for (int i = 0; i < N; i++)
		cin >> c[i];
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < N; j++) {
			cin >> s[i][j];
		}
	}

	int t;
	ContestInfo ci(d);
	for (int i = 0; i < d; i++) {
		t = rand() % N;
		ci.add(i, t);
	}

	int current_score = ci.score;

	int dd, qq;
	while (toc() < 1.9) {
		dd = rand() % d;
		qq = rand() % N;
		int old_q = ci.t[dd];
		ci.change(dd, qq);
		long new_score = ci.score;
		current_score = new_score;
		if (new_score < current_score)
			ci.change(dd, old_q);
		else
			current_score = new_score;
	}
	ci.output();
	// cout << ci.score << endl;
}

Measured memory_bytes: 3704
package main

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

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	lines, _ := scanLongIntSlices(1, 10000000)
	logs := lines[0]

	lower := 0
	upper := 1000000000

	for upper > lower+1 {
		mid := (lower + upper) / 2
		if isCuttable(logs, k, mid) {
			upper = mid
		} else {
			lower = mid
		}
	}

	fmt.Printf("%d\n", upper)
}

func isCuttable(logs []int, limit, longest int) bool {
	cut := 0
	for _, log := range logs {
		cut += ((log + longest - 1) / longest) - 1
	}
	return cut <= limit
}

func scanLongIntSlices(lines int, maxBufSize int) ([][]int, error) {

	res := [][]int{}

	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, bufio.MaxScanTokenSize)
	sc.Buffer(buf, maxBufSize)

	for sc.Scan() {
		line := sc.Text()
		strs := strings.Split(line, " ")
		ints := make([]int, len(strs))
		for i, c := range strs {
			n, err := strconv.Atoi(c)
			if err != nil {
				return nil, err
			}
			ints[i] = n
		}
		res = append(res, ints)
	}

	if err := sc.Err(); err != nil {
		return nil, err
	}

	return res, nil
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;
int N;
ll mo=998244353;
int memo[10100][10100];

const int NUM_=1000005;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
int base;

ll dfs(int same,int dif) {
	if(dif==0) {
		ll c=fact[base]*factr[same]%mo*factr[base-same]%mo;
		return fact[same]*fact[same]%mo*c%mo;
	}
	if(memo[same][dif]==-1) {
		ll ret=0;
		if(same) (ret+=dif*same*dfs(same-1,dif))%=mo;
		(ret+=dif*dif*dfs(same,dif-1))%=mo;
		memo[same][dif]=ret;
	}
	return memo[same][dif];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	N=S.size();
	int same=0,dif=0;
	FOR(i,N) if(S[i]=='1') {
		if(T[i]=='1') same++;
		else dif++;
	}
	base=same+dif;
	
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	MINUS(memo);
	cout<<dfs(same,dif)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

struct Py {
  int id;
  int pref;
  int year;
  int cnt;
};

bool yearAsc(const Py &py1, const Py &py2) {
  return py1.year < py2.year;
}

bool idAsc(const Py &py1, const Py &py2) {
  return py1.id < py2.id;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<Py> py(m);
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    py.at(i) = {i, p, y};
  }
  sort(py.begin(), py.end(), yearAsc);
  map<int, int> mp; // prefごとの数
  for (int i = 0; i < py.size(); i++) {
    Py &p = py.at(i);
    p.cnt = ++mp[p.pref];
  }
  sort(py.begin(), py.end(), idAsc);
  for (int i = 0; i < py.size(); i++) {
    Py v = py.at(i);
    cout << right << setw(6) << setfill('0') << v.pref;
    cout << right << setw(6) << setfill('0') << v.cnt << endl;
  }
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputData = Console.ReadLine().Trim().Split(' ');

            int num1 = int.Parse(inputData[0]);
            int num2 = int.Parse(inputData[1]);

            if (num2 % num1 == 0)
            {
                Console.WriteLine(num2 + num1);
            }
            else
            {
                Console.WriteLine(num2 - num1);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
#define mod (ll)(1e9+7)

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

    ll n,k;
    cin >> n >> k;
    ll res=0;
    n++;
    for(ll i=k;i<=n;i++)
    {
        ll mi=(i*(i+1))/2;
        ll ma=n*i-mi+i;
        res=(res+ma-mi+1)%mod;
    }
    db(res)

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    double x,ans=0;
    while(n--)
    {
        cin>>x>>s;
        if(s=="JPY")
        {
            ans+=x;
        }
        else{
            ans+=(x*380000);
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

const ll INF = 2e18;

pll get(ll ai, ll bi){
	ll g = __gcd(ai, bi);
	g = abs(g);
	if(bi < 0)
		ai = -ai, bi = -bi;
	return {ai / g, bi / g};
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	vpll v(n);
	map<pll, int> cnts;
	int rem = n;
	int ans = 0;
	map<pll, pll> related;
	map<pll, int> seen;
	pll p1 = {0, 0}, p2 = {INF, INF};
	related[p1] = p2, related[p2] = p1;
	int tot = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i].F >> v[i].S;
		if(v[i].F == 0 && v[i].S == 0){
			tot++;
			rem--;
			continue;
		}
		if(v[i].F == 0){
			cnts[p1]++;
			continue;
		}
		if(v[i].S == 0){
			cnts[p2]++;
			continue;
		}
		pll pa = get(v[i].F, v[i].S), pb = get(-v[i].S, v[i].F);
		related[pa] = pb, related[pb] = pa;
		cnts[pa]++;
	}
	ans = 1;
	for(auto i : cnts){
		if(seen[i.F]) continue;
		int x = i.S;
		pll pb = related[i.F];
		int y = cnts[pb];
		seen[i.F] = seen[pb] = 1;
		int c = power(2, x);
		c = add(c, power(2, y));
		c = sub(c, 1);
		ans = mul(ans, c);
	}
	ans = sub(ans, 1);
	ans = add(ans, tot);
	cout << ans << endl;

}

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

int main(){

	int a, b;
	cin >> a >> b;

	if (a > b)
		cout << "a > b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else if (a == b)
		cout << "a == b" << endl;

	return 0;
}

Measured memory_bytes: 3084
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if j-a[i]>=0:
            dp[i+1][j]=dp[i][j]*2+dp[i][j-a[i]]
        else:
            dp[i+1][j]=dp[i][j]*2
        dp[i+1][j]%=mod
print(dp[n][s])

Measured memory_bytes: 132404
#[allow(dead_code)]
fn main() {
    let mut s = i::s();
    s.reverse();
    let mut i = 0;
    'all: loop {
        if s.len() >= 7 + i {
            let mut a = true;
            for j in 0..7 {
                if s[i + j] != "remaerd".chars().collect::<Vec<char>>()[j] {
                    a = false;
                }
            }
            if a {
                i += 7;
                continue 'all;
            }
        }

        if s.len() >= 6 + i {
            let mut a = true;
            for j in 0..6 {
                if s[i + j] != "resare".chars().collect::<Vec<char>>()[j] {
                    a = false;
                }
            }
            if a {
                i += 6;
                continue 'all;
            }
        }

        if s.len() >= 5 + i {
            let mut a = true;
            for j in 0..5 {
                if s[i + j] != "maerd".chars().collect::<Vec<char>>()[j] {
                    a = false;
                }
            }
            if a {
                i += 5;
                continue 'all;
            }
            let mut a = true;
            for j in 0..5 {
                if s[i + j] != "esare".chars().collect::<Vec<char>>()[j] {
                    a = false;
                }
            }
            if a {
                i += 5;
                continue 'all;
            }
        }
        if s.len() == i {
            break;
        }

        //    dbg!(i);
        println!("{}", "NO");
        return;
    }
    println!("{}", "YES");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename T>
void printvec(vector<T> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int>> ar(h, vector<int>(w));
    rep(i,h){
        string s; cin >> s;
        rep(j,w){
            if (s[j] == '.') ar[i][j] = 0;
            else ar[i][j] = 1;
        }
    }
    vector<vector<int>> ans(h, vector<int>(w,0));
    vector<int> dx = {0,1,1,1,0,-1,-1,-1};
    vector<int> dy = {1,1,0,-1,-1,-1,0,1};
    rep(i,h){
        rep(j,w){
            if (ar[i][j] == 1){
                rep(k,8){
                    if (range(0,h,i+dx[k]) && range(0,w,j+dy[k])){
                        ans[i+dx[k]][j+dy[k]] += 1;
                    }
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if (ar[i][j] == 0) cout << ans[i][j];
            else cout << '#';
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	vector<vector<int> > a(100, vector<int>(2, 0));
	for(int i=0;i<100;i++){
		a[i][0] = i;
	}
	int n;
	while(cin>>n){
		a[n-1][1]++;
	}
	for(int i=0;i<100-1;i++){
		for(int j=i;j<100;j++){
			if(a[i][1] < a[j][1]){
				swap(a[i][0],a[j][0]);
				swap(a[i][1],a[j][1]);
			}
		}
	}
	int hoge=0;
	while(1){
		cout<< a[hoge][0]+1<< endl;
		if(a[hoge][1]!=a[hoge+1][1] || hoge==99) break;
		hoge++;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1212
from itertools import accumulate


def main():
    n, k = map(int, input().split())
    s = list(input())
    l = []
    if s[0] == "0":
        l.append(["1", 0])
    l.append([s[0], 1])
    for i in range(1, n):
        if s[i] == l[-1][0]:
            l[-1][1] += 1
        else:
            l.append([s[i], 1])
    if s[-1] == "0":
        l.append(["1", 0])
    count = []
    for standing, c in l:
        count.append(c)
    count = list(accumulate(count))
    count = [0] + count
    answer = 0
    for i in range(0, len(count), 2):
        j = i + 2 * k + 1
        if j >= len(count):
            j = len(count) - 1
        answer = max(answer, count[j] - count[i])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 23312
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	int n;
	int i;
	scanf("%d", &n);

	int *a = (int*)malloc(n * sizeof(int));
	int *b = (int*)malloc(n * sizeof(int));
	b[0] = 1;

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

	int bsize = 1;
	int k = 0;
	int count = 1;
	int ans = -1;

	while (bsize < n) {
		int d = a[k];
		if (d == 2) {
			ans = 0;
			break;
		}
		else {
			for (int j = 0; j < bsize; j++) {
				if (d == b[j]) {
					ans = -1;
					break;
				}
			}
			b[bsize] = d;
		}
		k = d - 1;
		count++;
		bsize++;
	}

	if (ans == 0)printf("%d\n", count);
	else printf("%d\n", -1);
	return 0;
}

Measured memory_bytes: 896
def main():
    import sys
    input = sys.stdin.readline
    #重み付きUnion-Find

    #xの根を求める
    def find(x):
        if par[x] < 0:
            return x
        else:
            px = find(par[x])
            wei[x] += wei[par[x]]
            par[x] = px
            return px

    #xの根から距離
    def weight(x):
        find(x)
        return wei[x]


    #w[y]=w[x]+wとなるようにxとyを併合
    def unite(x,y,w):
        w += wei[x]-wei[y]
        x = find(x)
        y = find(y)
        
        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if par[x] > par[y]:
                x,y = y,x
                w = -w
            par[x] += par[y]
            par[y] = x
            wei[y] = w
            return True

    #xとyが同じ集合に属するかの判定
    def same(x,y):
        return find(x) == find(y)

    #xが属する集合の個数
    def size(x):
        return -par[find(x)]

    #x,yが同じ集合に属するときのwei[y]-wei[x]
    def diff(x,y):
        return weight(y)-weight(x)

    n,m = map(int,input().split())

    #初期化
    #par:根なら-size,子なら親の頂点
    #wei:親からの距離,根なら0
    par = [-1]*n
    wei = [0]*n

    for i in range(m):
        l,r,d = map(int,input().split())
        l,r = l-1,r-1
        if same(l,r):
            if d != diff(l,r):
                print('No')
                exit()
        else:
            unite(l,r,d)
    print('Yes')
            
if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector< vector<int> > k(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        k[a].push_back(b);
    }
    vector< vector<int> > odp(n, vector<int>(n, 0));
    vector<int> ile_kon(n, 0);
    for (int i = n - 1; i >= 0; --i)
    {
        for (int j = 0; j < k[i].size(); ++j)
            ++ile_kon[k[i][j]];
        for (int j = i; j < n; ++j)
        {
            odp[i][j] = ile_kon[j];
            if (j != i)
                odp[i][j] += odp[i][j - 1];
        }
    }
    for (int i = 0; i < q; ++i)
    {
        int a, b;
        cin >> a >> b;
        cout << odp[a - 1][b - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

// pow
//int power(int a, int b){
	//int result = 1;
	//while(b>0){
		//if(b%2) result *= a;
		//a*=a;
		//b/=2;
	//}
	//return result;
//}

// rotate vector
//rotate(a.begin(),a.begin()+offset,a.end());

// next permutation - returns true if next permutation is lexigraphically greater else false
//while(next_permutation(all(s))) ans.insert(s);

// bitset way to simulate all subsets
// assume we have int a[n];
//for(int i = 0; i < 1<<n; ++i){
		 //bit set way to simulate every possible set
		//forn(j,0,n) if(i>>j&1) then a[j] is in cur set

// iota		
// int p[8];
// iota(p,p+8,0) --> {0,1,2,3,4,5,6,7}

// * note lowerbound is the same as upperbound but inclusive
// lower_bound finds value >= to given value
// to find a lowerbound/upper bound in unsorted list use set<pair<int,int>> 
// where the second element is the index
//auto itr = s.lower_bound({-t,0});
//if(itr == s.end()) cout << "-1\n";

// values in set are stored in increased order by default

// fast subarray sum using map
//void solve(){
	//int n,x; cin >> n >> x;
	//ll s = 0;
	//map<ll,int> mp;
	//++mp[0];
	//ll ans = 0;
	//forn(i,0,n){
		//int v; cin >> v;
		//s+=v;
		//ans+=mp[s-x];
		//++mp[s];
	//}
	//cout << ans;
//}

// 0-1 knapsack
//void solve(){
	 //x is maximum capacity, n is number of items
	//int n, x;
	//cin >> n >> x;
	//vector<int> weight(n), value(n);
	//forn(i,0,n) cin >> weight[i];
	//forn(i,0,n) cin >> value[i];
	//vector<vector<int>> dp(n+1,vector<int>(x+1,0));
	//forn(i,1,n+1){
		//forn(j,0,x+1){
			//dp[i][j] = dp[i-1][j];
			//int space = j-weight[i-1];
			//if(space >= 0) dp[i][j] = max(dp[i][j], dp[i-1][space]+value[i-1]);
		//}
	//}
	//cout << dp[n][x] << endl;
//}
 
 

 

void solve(){
	string s,t; cin >> s >> t;
	int ans = 0;
	forn(i,0,s.size()){
		if(s[i] != t[i]) ++ans;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

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

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

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

int main(){
    int u, k, v;

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



Measured memory_bytes: 3104
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool ret = false;
  for(int i=1; i<=B; i++)
    if((A * i) % B == C) {
      ret = true;
      break;
    }
  if(ret)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ');
                var n = int.Parse(inputs[0]);
                var x = int.Parse(inputs[1]);
                if ((n == 0) && (x == 0)) return;
                var permutation = 0;

                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        for (int k = 1; k <= n; k++)
                        {
                            if (i == j || i == k || j == k) continue;
                            if ((i + j + k) == x) permutation++;
                        }
                    }
                }
                Console.WriteLine(permutation / 3 / 2);
            }
        }
    }
}

Measured memory_bytes: 5612
input = input()
acgt = ['A', 'C', 'G', 'T']

input_len = len(input)
cnt = 0
max_cnt = 0
for i,s in enumerate(input):
    if s in acgt:
        cnt += 1
    elif cnt > max_cnt:
        max_cnt = cnt
        cnt = 0
    else:
        cnt = 0

    if i == input_len - 1 and cnt > max_cnt:
        max_cnt = cnt

print(max_cnt)
        


Measured memory_bytes: 3060
H = {}
120.times {|i| H[n=i**5] = i; H[-n] = -i}
X = gets.to_i
F =->(b,y) { a=H[X+y] and puts([a,b]*' ') || exit }
120.times {|b| y = b**5; F[b,y]; F[-b,-y]}

Measured memory_bytes: 14380
c = [list(map(int,input().split())) for _  in range(3)]
d = set()
e = set()
for i in range(3):
    d.add(c[i][0] - c[i][1])
    e.add(c[i][1] - c[i][2])
print("Yes" if len(d) == len(e) == 1 else "No")

Measured memory_bytes: 9100
W, H, x, y, r = map(int,input().split())

right =  x + abs(r)
left = x - abs(r)
top = y + abs(r)
bottom = y - abs(r)

if right <= W and left >= 0 and top <= H  and bottom >= 0:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 5596
A, B, K = map(int, input().split())

if A + K - 1 >=  B - K + 1:
    for item in range(A, B + 1):
        print(item)
else:
    for item in range(A, A + K):
        print(item)
    for item in range(B - K + 1, B + 1):
        print(item)

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

#include <atcoder/all>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;
typedef long long ll;

const ll MX = 300005;
ll op(ll a, ll b) { return max(a, b); }
ll e() { return 0; }

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  segtree<ll, op, e> dp(MX);
  rep(i, n)
      dp.set(a[i], dp.prod(max(0ll, a[i] - k), min(MX, a[i] + k + 1)) + 1);
  ans = dp.prod(0ll, MX);

  cout << ans << endl;
  return 0;
}

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

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

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

// 0-indexed
// componenet_size(k): return the size of the component which include k
class union_find_tree {
	std::vector<int> data;

	public:
	union_find_tree(const size_t && N)
		: data(N, -1) {}
	const bool unite(size_t x, size_t y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) std::swap(x, y);
		
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	const size_t find(size_t k) {
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	const size_t component_size(const size_t && k) {
		return -data[find(k)];
	}
	const bool same(const size_t && x, const size_t && y) {
		return find(x) == find(y);
	}
	
	void clear() { data.assign(size(), -1); }
	const size_t size() const { return data.size(); }
};

int main() {
	int h, w; scanf("%d%d", &h, &w); h++; w++; std::vector<int> p(h - 1), q(w - 1);
	for(int i = 0; i < h - 1; i++) scanf("%d", &p[i]);
	for(int i = 0; i < w - 1; i++) scanf("%d", &q[i]);
	
	std::vector<std::pair<int, std::pair<int, int>>> vec;
	for(int i = 0; i < h - 1; i++) vec.push_back({p[i], {i, 0}});
	for(int i = 0; i < w - 1; i++) vec.push_back({q[i], {i, 1}});
	sort(begin(vec), end(vec));

	i64 ans = 0, a = h, b = w;
	union_find_tree A(h), B(w);
	for(auto elm: vec) {
		i64 val = elm.first, id = elm.second.first, d = elm.second.second;
		
		if(d == 0) {
			A.unite(id, id + 1);
			ans += val * b;
			a--;
		} else {
			B.unite(id, id + 1);
			ans += val * a;
			b--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5620
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>



#define ll long long


/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;




int main()
{
	int s, w;
	cin >> s >> w;
	if (s <= w) {
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}
}



Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	fmt.Println(smaller(n%k, k-n%k))
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<Pll> p;
    for (ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        p.push_back(make_pair(a, b));
    }

    sort(p.begin(), p.end());

    ll ans = 0;
    ll i = 0;
    while (M > 0) {
        if (M - p[i].second < 0) {
            ans += M*p[i].first;
            break;
        }
        ans += p[i].first*p[i].second;
        M -= p[i].second;
        i++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  string s; 
  cin >> s;
  vector<int>vec(3);
  vec[0]=s[1]-'0';
  vec[1]=s[2]-'0';
  vec[2]=s[3]-'0';
  for(int bit=0;bit<(1<<3);bit++){
    int sum=s[0]-'0';
    vector<char>p(3);
    rep(i,3){
      if(bit&(1<<i)){
        sum+=vec[i];
        p[i]='+';
      }
      else{
        sum-=vec[i];
        p[i]='-';
      }
    }
    if(sum==7){
      cout << s[0]-'0' << p[0]<< s[1]-'0'<< p[1]<< s[2]-'0'<< p[2]<< s[3]-'0'<<"=7"<<endl;
      return 0;
    }
  }


}


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

int main()
{
    int res;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    res = a[2]*10 + a[1] + a[0];
    cout << res << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  ll ans=n*(n-1)/2;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
def s():
 import sys
 r=sys.stdin.readline
 I=float('inf')
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  F=[[I]*-~n for _ in[0]*-~n]
  for i in range(1,n+1):F[i][i]=0
  for _ in[0]*k:
   f=r();g=map(int,f[2:].split())
   if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
   else:
    c,d,e=g
    if e<F[c][d]:
     for i in range(2,n+1):
      for j in range(1,i):
       F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])
if'__main__'==__name__:s()


Measured memory_bytes: 6248
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 120000;
void no(const char* s){
	cout << s;
	exit(0);
}
int p[maxn], A[maxn], B[maxn], C[maxn];
int fp(int u){
	return u == p[u] ? u : p[u] = fp(p[u]);
}
int main(){
	ios::sync_with_stdio(false);
	LL N, M, Q;
	cin >> N >> M >> Q;
	for(int i = 1; i <= Q; i += 1) cin >> A[i] >> B[i] >> C[i];
	if(M == N - 1){
		for(int i = 1; i <= Q; i += 1) if(C[i]) no("No");
		no("Yes");
	}
	for(int i = 1; i <= N; i += 1) p[i] = i;
	LL cc = N; 
	for(int i = 1; i <= Q; i += 1) if(not C[i]){
		int u = fp(A[i]), v = fp(B[i]);
		if(u != v) cc -= 1;
		p[u] = v;
	}
	if(cc == 2) no("No");
	for(int i = 1; i <= Q; i += 1) if(C[i])
		if(fp(A[i]) == fp(B[i])) no("No");
	if(M <= N - 1 + cc * (cc - 1) / 2 - cc + 1) no("Yes");
	no("No");
}

Measured memory_bytes: 1920
# N = 10
# ARR = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#
#
# N = 3
# ARR = [2, 2, 2]
#
# N = 3
# ARR = [2, 1, 2]
#
# N = 1
# ARR = [1]

N = int(input())
ARR = list(map(int,input().split()))

def calculate(n,arr):
    currentSearchIndexs = []
    currentSearch = 1
    for i in range(n):
        if arr[i] == currentSearch:
            if len(currentSearchIndexs) < currentSearch:
                currentSearchIndexs.append(i)
            else:
                currentSearchIndexs[currentSearch-1] = i

            currentSearch = currentSearch  + 1



    if len(currentSearchIndexs) == 0:
        print(-1)
        return

    print(n - len(currentSearchIndexs))

calculate(N,ARR)

Measured memory_bytes: 26012
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n;
    ll a[n] = {0}, dp[n];
    for(i=0;i<n;i++)cin>>a[i];	
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(i=2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),(dp[i-2] + abs(a[i] - a[i-2])));
	}
	cout<<dp[n-1];
}    
	

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10],ans=0;

    cin >> a >> b >> c >> d;

    for(i=0;i<a;i++){
        if(i==b){
            ans += (a-b)*d;
            break;
        }
        ans += c;
    }
  
    cout << ans;
    return 0;
}

Measured memory_bytes: 256