akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n;
    while(cin >> n){
        if(n == 0) break;
        vi w(n);
        vvi dp(n, vi(n));
        rep(i,n) cin >> w[i];
        REP(W,2,n+1){
            rep(i,n){
                int j = i+W-1;
                if(j >= n) continue;
                if(dp[i+1][j-1] == W-2 && abs(w[i] - w[j]) <= 1) dp[i][j] = W;
                REP(k,i,j){
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
                }
            }
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int res = 0;

    if(n < 10){
        res += n;
        cout<<res<<endl;
        return 0;
    }
    if(n >= 10){
        res += 9;
    }

    if(n >= 100 && n<1000){
        res += (n-100+1);
        cout<<res<<endl;
        return 0;
    }
    if(n>=1000){
        res += 900;
    }

    if(n >= 10000 && n < 100000){
        res += (n-10000+1);
        cout<<res<<endl;
        return 0;
    }
    if(n == 100000){
        res += 90000;
    }
    cout<<res<<endl;
    return 0;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
ll INF = 1e18;
using namespace std;

int main(){
  cout<<fixed<<setprecision(10);

  ll N, M;
  cin >> N >> M;
  
  multimap<double,ll> A;
  vector<ll> AA;
  vector<ll> as(N);
  rep(i,N){
    double a;
    cin >> a;
    AA.push_back(a);
    A.insert(make_pair(a/2, i));
  }
  rep(i,M){
    auto end = A.end();
    end--;
    ll a = end->second;
    double val = end->first;
    as[a]++;
    A.erase(end);
    A.insert(make_pair(val/2,a));
    
    
  }
  
  ll ans = 0;
  rep(i,N){
    ll c = as[i];
    ans += AA[i] / (pow(2,c));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8052
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){

int i,j;
int n,x,t;
scanf("%d %d %d",&n,&x,&t);

  int a = n % x;
  int b = n / x;
  
  int c;
  if(a==0){
   c = b*t; 
  }else c = (b+1) * t;
  
  
printf("%d\n",c);

return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;

   ll i,j;
   ll a[n];
   mll m;
   ll sum=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       m[a[i]]++;
       sum+=a[i];
   }
   ll q;
   cin>>q;
   while(q--)
   {
       ll x,y;
       cin>>x>>y;
       ll no = m[x];
       ll dif = y-x;
       m[x]=0;
       m[y]+=no;
       sum+=no*dif;
       cout<<sum<<"\n";

   }
    



}
 

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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 10224
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
      if(a==1){a = 14;}
      if(b==1){b = 14;}
      
      if(a>b){System.out.print("Alice");}
      if(a<b){System.out.print("Bob");}
      if(a==b){System.out.print("Draw");}
       
    }
      
    }

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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<int> divisor(int n)
{
	vector<int> res;

	for(int i = 1; i * i <= n; i++)
	{
		if (n % i==0)
		{
			res.push_back(i);
			if (i != n / i)
			{
				res.push_back(n / i);
			}
		}
	}

	return res;
}


int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> div = divisor(m);

	if(n == 1){
		cout << m << endl;
		return 0;
	}

	sort(all(div));
	int l = div.size();

	for(int i = l-1; i >= 0; i--){
		if(m / div[i] >= n){
			cout << div[i] << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

const int MAX_S = 1e5;
char s[MAX_S + 1];
vector<int> v;

int main() {
    scanf("%s", s);
    int n = strlen(s);
    int ans = n;
    int a = n / 2;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            v.push_back((i <= a) ? n - i : i); 
        }
    }
    
    sort(v.begin(), v.end());
    printf("%d\n", (v.empty()) ? n : v[0]);
    return 0;
}


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

bitset<40> rec(ll N, bitset<40> ans) {
    if (N == 0) return ans;

    ll sum = 0;
    if (N > 0) {
        int i = 0;
        while (true) {
            ll p = pow(2, i);
            sum += p;
            if (sum >= N) {
                N -= p;
                break;
            }
            i += 2;
        }
        ans[i] = 1;
        return rec(N, ans);
    } else {
        int i = 1;
        while (true) {
            ll p = pow(-2, i);
            sum += p;
            if (sum <= N) {
                N -= p;
                break;
            }
            i += 2;
        }
        ans[i] = 1;
        return rec(N, ans);
    }
}

int main() {
    ll N;
    cin >> N;

    if (N == 0) {
        cout << 0 << endl;
        return 0;
    } else {
        string b = rec(N, 0).to_string();
        int top = b.find("1");
        cout << b.substr(top) << endl;
    }
}

Measured memory_bytes: 512
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  string[] s; int[] p; readC(n, s, p);

  struct R { string s; int p, i; }
  auto r = new R[](n);
  foreach (i; 0..n) r[i] = R(s[i], p[i], i+1);

  r.sort!"a.s == b.s ? a.p > b.p : a.s < b.s";

  foreach (ri; r) writeln(ri.i);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<queue>

int main(){
	long long N;
	std::cin >> N;
	if(N == 1){
		std::cout << 0 << std::endl;
		return 0;
	}

	// 素因数分解
	long long n = N;
	std::priority_queue<long long, std::vector<long long>, std::greater<long long>> prime;

	for(long long i=2; i*i<=n; i++){
		if(n%i != 0) continue;
		//std::cout << "n: " << n << ", i: " << i << std::endl;
		long long a = 1;
		while(n%i == 0){
			a *= i;
			//std::cout << a << std::endl;
			prime.push(a);
			n /= i;
		}
	}
	if(n!=1){
		prime.push(n);
	}
	if(n == N){
		std::cout << 1 << std::endl;
		return 0;
	}

	long long ans = 0;
	long long z = prime.top();
	prime.pop();	
	while(z <= N){
		if(N%z == 0) {
			//std::cout << "z: " << z << std::endl;
			N /= z;
			ans++;
		}
		z = prime.top();
		prime.pop();
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int f(int x)
{
	int cnt =0;
	for(;x>0;x/=10)
		cnt += (x % 10);
	return cnt;
}
int main()
{
	int n;
	cin >> n;
	int ans = 1e9;
	for(int i = 1; i < n; i ++)
	{
		int k1 = i, k2 = n - i;
		int foo = f(k1);
		int hoo = f(k2);
		foo += hoo;
		umin(ans, foo);
	}
	cout << ans;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val str_len = io.StdIn.readInt
    val Array(str1, str2) = io.StdIn.readLine.split(" ")
    var ans_str = ""

    (0 until str_len).foreach{ i =>
      ans_str += str1(i).toString + str2(i)
    }
    println(ans_str)
  }
}

Measured memory_bytes: 25404
n,m = map(int,input().split())
a = [0 for i in range(m+1)]

for i in range(n):
    x= list(map(int,input().split()))
    for k in range(1,x[0]+1):
        a[x[k]] += 1
ans = 0
for i in range(m+1):
    if a[i] == n:
        ans += 1

print(ans)


Measured memory_bytes: 38384
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int f(int n) {
    if (n % 2 == 0) return n / 2;
    return 3 * n + 1;
}

void main() {
    int s = readint;

    int[int] d;
    d[s] = 1;
    int prev = s;
    for (int i = 2; ; i++) {
        int x = f(prev);
        if (x in d) {
            writeln(i);
            break;
        }
        else {
            d[x] = i;
            prev = x;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m,d;
    char map[100][100];
    bool x=true;
    cin>>n>>m>>d;
    for (int i=0; i<n; i++) {
        for(int j=0;j<m;j++){
            cin>>map[i][j];
        }
    }
    
    int ans=0;
    for (int i=0; i<n; i++) {
        for(int j=0;j<m;j++){
            if(map[i][j]=='#')continue;
            if(m>=j+d){
                x=true;
                for (int k=j; k<j+d; k++) {
                    if(map[i][k]=='#'){
                        x=false;
                        break;
                    }
                }
                if(x)ans++;
            }
            if(n>=i+d){
                x=true;
                for(int k=i;k<i+d;k++){
                    if(map[k][j]=='#'){
                        x=false;
                        break;
                    }
                }
                if(x)ans++;
            }
            map[i][j]='#';
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
	int n, tmp;
	double money = 100000;
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		money = money + money*0.05;
		tmp = (int)(money+999)/1000;
		money = (double)(tmp*1000);
	}
	
	tmp = (int)money;
	printf("%d\n", tmp);
	
	return 0;
}

Measured memory_bytes: 592
h,w = map(int,input().split())
grid = [['.']*(w+2)] + [['.'] + [s for s in input()] + ['.'] for i in range(h)] + [['.']*(w+2)]
#print(grid)
ans = [[0]*w for i in range(h)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j] == '.':
            for dx in range(-1,2):
                for dy in range(-1,2):
                    if grid[i+dx][j+dy] == '#':
                        ans[i-1][j-1] += 1
        else:
            ans[i-1][j-1] = '#'

for i in range(h):
    for j in range(w):
        ans[i][j] = str(ans[i][j])

for i in range(h):
    ans[i] = ''.join(ans[i])

for i in range(h):
    print(ans[i])


Measured memory_bytes: 41456
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef enum {
  WHITE,
  GRAY,
  BLACK,
} color_t;

#define MINIMUM_SPANNING_TREE_GRAPH_SIZE 100
extern bool minimum_spannig_tree(int32_t graph[][MINIMUM_SPANNING_TREE_GRAPH_SIZE], size_t size, size_t *weight);
typedef void(single_source_shortest_path_callback_t)(uint32_t index, int32_t weight);
extern bool single_source_shortest_path(int32_t graph[][MINIMUM_SPANNING_TREE_GRAPH_SIZE], size_t size,
                                        single_source_shortest_path_callback_t callback);


static int32_t weights[MINIMUM_SPANNING_TREE_GRAPH_SIZE];
static color_t colors[MINIMUM_SPANNING_TREE_GRAPH_SIZE];

bool single_source_shortest_path(int32_t graph[][MINIMUM_SPANNING_TREE_GRAPH_SIZE], size_t size,
                                 single_source_shortest_path_callback_t callback)
{
  if ((graph == NULL) || (size == 0)) return false;

  uint32_t i;
  for (i = 0; i < size; i++) {
    weights[i] = INT32_MAX;
    colors[i] = WHITE;
  }

  weights[0] = 0;

  while (true) {
    int32_t mincost = INT32_MAX;
    uint32_t min_idx;
    for (i = 0; i < size; i++) {
      if ((colors[i] != BLACK) && (weights[i] < mincost)) {
        mincost = weights[i];
        min_idx = i;
      }
    }

    if (mincost == INT32_MAX) break;
    callback(min_idx, mincost);
    colors[min_idx] = BLACK;

    for (i = 0; i < size; i++) {
      if ((colors[i] != BLACK) && (graph[min_idx][i] != INT32_MAX)) {
        int32_t new_weight = weights[min_idx] + graph[min_idx][i];
        if (new_weight < weights[i]) {
          weights[i] = new_weight;
          colors[i] = GRAY;
        }
      }
    }
  }
  return true;
}

#if !defined(TEST)
#include <stdio.h>
int32_t graph[MINIMUM_SPANNING_TREE_GRAPH_SIZE][MINIMUM_SPANNING_TREE_GRAPH_SIZE];
int32_t lengths[MINIMUM_SPANNING_TREE_GRAPH_SIZE];

static void callback(uint32_t index, int32_t weight)
{
  lengths[index] = weight;
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  uint32_t i, j;

  for (i = 0; i < num; i++) {
    for (j = 0; j < num; j++) {
      graph[i][j] = INT32_MAX;
    }
  }

  for (i = 0; i < num; i++) {
    int32_t index, len;
    scanf("%d %d", &index, &len);

    for (j = 0; j < len; j++) {
      int32_t v, c;
      scanf("%d %d", &v, &c);
      graph[index][v] = c;
    }
  }

  single_source_shortest_path(graph, num, callback);

  for (i = 0; i < num; i++) {
    printf("%d %d\n", i, lengths[i]);
  }

  return 0;
}

#endif

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair

const int N = 3000005;
const int mod = 1e9 + 7;

char s[N+1];

int cnt = 2,sz[N],freq[N],n;
vector<int> g[N];
vector< pii > E;

void addEdge(int u , int v){
	E.pb(mp(u,v));
	g[u].pb(v);
	g[v].pb(u);
}
void dfs(int u , int p){
	sz[u] = 1;
	for(auto v : g[u]){
		if(v==p)continue;
		dfs(v,u);
		sz[u] += sz[v];
	}
	if(p != -1){
		freq[sz[u]] = 1;
		freq[n-sz[u]] = 1;
	}
}

int main(){
	scanf("%s",s);
	n = strlen(s);
	for(int i = n ;i >= 1 ; --i)
		s[i] = s[i-1];
	if(s[n]=='1' || s[1]=='0'){
		puts("-1");
		return 0;
	}
	for(int i = 1; i <= n/2 ; ++i){
		int cm = n-i;
		if(s[i] != s[cm]){
			puts("-1");
			return 0;
		}
	}
	int last = 1,lsSize = 1;
	for(int i = 2 ; i <= n/2 ; ++i){
		if(s[i]=='1'){
			int rem = i-lsSize-1;
			int me = cnt++;
			while(rem--){
				addEdge(cnt++,me);
			}
			addEdge(me,last);
			last = me;
			lsSize = i;
		}
	}
	if(cnt <= n){
		int here = cnt++;
		addEdge(last,here);
		while(cnt <= n){
			addEdge(here,cnt++);
		}
	}
	dfs(1,-1);
	for(int i = 1;  i <= n ; ++i){
		if(freq[i] != s[i]-'0'){
			puts("-1");
			return 0;
		}
	}
	for(int i =0 ; i < E.size();++i){
		printf("%d %d\n",E[i].first,E[i].second );
	}
	return 0;
}

Measured memory_bytes: 84340
import sys
from collections import defaultdict

input = sys.stdin.readline
P = 998244353


def main():
    N = int(input())
    D = list(map(int, input().split()))

    count = defaultdict(int)
    for d in D:
        count[d] += 1

    if not(D[0] == 0 and count[0] == 1):
        print(0)
        exit()

    max_depth = max(count.keys())
    ans = 1
    for d in range(max_depth):
        ans = (ans * pow(count[d], count[d + 1], mod=P)) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24460
#include <iostream>
#include <cstdio>
#include <queue>
#define N 10005
#define PI pair<int, int>
#define F first
#define S second
using namespace std;

int n, m, s, num, a[N], b[15][15], mn[15];
bool v[15];
priority_queue<PI> qu;
void f(int p, int q) {
	if (v[p]) return;
	qu.push(PI(q, p));
}
int main()
{
	int i, j;
	PI t;
	cin >> n >> m;
	for (i =0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			scanf ("%d", &b[i][j]);
		}
	}
	f(1, 0);
	while (!qu.empty()) {
		t = qu.top(); qu.pop();
		if (v[t.S]) continue;
		v[t.S] = true;
		mn[t.S] = -t.F;
		for (i = 0; i < 10; i++) {
			f(i, t.F - b[i][t.S]);
		}
	}
	for (i = 0; i < n; i++) {
		for (j =0; j <m; j++) {
			scanf ("%d", &num);
			if (num == -1) continue;
			s += mn[num];
		}
	}
	cout << s;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{   
    string s, t;
    cin >> s  >> t;
    int n = s.length();
    rep(i,n){
        if(s[i] != t[i]){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
				
		if(W >= S) {
			System.out.println("unsafe");
		}else{
			System.out.println("safe");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 35836
#include <stdio.h>

int main(){
  int n,A[100],i,j,x,temp,c=0;

  scanf("%d",&n);

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

  for(i=0 ; i<n-1 ; i++){
     x=i;
    for(j=i ; j<n ; j++){
      if(A[j] < A[x])x=j;
    }
    if(x!=i){
      temp=A[i];
      A[i]=A[x];
      A[x]=temp;
      c++;
    }
  }

  for(i=0 ; i<n ; i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }

  printf("\n");
  printf("%d\n",c);
  
  return 0;
}

  

Measured memory_bytes: 604
//-----------------------
// author : xyqkoala
// time : 2020-09-14
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


LL qp(LL m,LL n){
	LL rs = 1ll;
	while(n){
		if(n&1){
			rs = (rs*m)%MOD;
		}
		n>>=1;
		m = (m*m)%MOD;
	}
	return rs;
}


void solve(){
	int n;
	cin>>n;
	LL res = qp(10,n);
	res = (res-(2*qp(9,n)%MOD))%MOD;
	res = (res+qp(8,n))%MOD;
	res = (res+MOD)%MOD;
	cout<<res<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Dice {
  vi face;
  void init() {
    face.resize(6);
  }
  void rolll() {
    vi newface = {face[4], face[1], face[0], face[3], face[5], face[2]};
    swap(face, newface);
  }
  void rollr() {
    vi newface = {face[2], face[1], face[5], face[3], face[0], face[4]};
    swap(face, newface);
  }
  void rollu() {
    vi newface = {face[1], face[5], face[2], face[0], face[4], face[3]};
    swap(face, newface);
  }
  void rolld() {
    vi newface = {face[3], face[0], face[2], face[5], face[4], face[1]};
    swap(face, newface);
  }
  void rotl() {
    vi newface = {face[0], face[2], face[3], face[4], face[1], face[5]};
    swap(face, newface);
  }
  void rotr() {
    vi newface = {face[0], face[4], face[1], face[2], face[3], face[5]};
    swap(face, newface);
  }
};
bool operator==(Dice d1, Dice d2) {
  return d1.face == d2.face;
}
bool operator<(Dice d1, Dice d2) {
  return d1.face < d2.face;
}
struct Elm {
  Dice dice;
  int r, c;
  int pos;
  int d;
};
bool operator<(Elm e1, Elm e2) {
  return make_tuple(e1.d, e1.r, e1.c, e1.dice, e1.pos) < make_tuple(e2.d, e2.r, e2.c, e2.dice, e2.pos);
}
vi dr = {0, 0, -1, 1};
vi dc = {-1, 1, 0, 0};
bool solve() {
  vi a(6);
  vi b(6);
  for(int i=0;i<(6);++i) {
    cin >> a[i];
  }
  for(int i=0;i<(6);++i) {
    cin >> b[i];
  }
  Dice dice;
  dice.face = {a[0], a[1], a[3], a[4], a[2], a[5]};
  Dice dice2;
  dice2.face = {b[0], b[1], b[3], b[4], b[2], b[5]};
  bool ok = false;
  for(int k=0;k<(2);++k) {
    for(int i=0;i<(4);++i) {
      for(int j=0;j<(4);++j) {
        ok |= dice.face == dice2.face;
        dice.rolll();
      }
      dice.rolld();
    }
    dice.rotl();
  }
  cout << (ok ? "Yes" : "No") << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using ULL=unsigned long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    REP( i, N )
    {
        cin >> T[i];
    }
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    REP( i, M )
    {
        cin >> P[i] >> X[i];
    }
    REP( i, M ){
        int res{};
        REP( j, N )
        {
            if( P[i] == j+1 )
            {
                res += X[i];
            
            }else{
                res += T[j];
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; ++i)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry)
            return;
        if (rank[ry] > rank[rx])
            par[rx] = ry;
        else
            par[ry] = rx;
        if (rank[rx] == rank[ry])
            rank[rx]++;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
};

vector<ll> fac, inv, finv;

void initcom()
{
    fac = inv = finv = vector<ll>(1e6);
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i < 1e6; ++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;
    }
}

ll com(int n, int k)
{
    if (n < 0 || k < 0)
        return 0;
    if (n < k)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}
ll mopow(ll a, ll x, ll mod)
{
    ll res = 1;
    while (x > 0)
    {
        if (x & 1)
            res = res * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return res;
}

int main(){
    ll n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i],--a[i];
    vector<bool> used(n,false);
    deque<int> cycle;
    int cur=0;
    while(true){
        if(used[cur]){
            while(cycle[0]!=cur){
                --k;
                cycle.pop_front();

                if(k==0){
                    cout<<cycle[0]+1<<endl;
                    return 0;
                }
            }
            break;
        }
        cycle.push_back(cur);
        used[cur]=true;
        cur=a[cur];
    }
    cout<<cycle[k%(int)cycle.size()]+1<<endl;
    return 0;
}

Measured memory_bytes: 4436
import java.util.Scanner;

public class Main {
	
	static class State {
		int a, b, w;
		public State(int a, int b, int w) {
			this.a = a;
			this.b = b;
			this.w = w;
		}
	}
	
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int V = sc.nextInt();
			int E = sc.nextInt();
			int r = sc.nextInt();
			int MAX = 2000001;
			State[] edge = new State[E];
			for(int i=0; i<E; i++) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				int d = sc.nextInt();
				edge[i] = new State(s, t, d);
			}
			int[] dis = new int[V];
			for(int i=0; i<V; i++) {
				dis[i] = MAX;
			}
			dis[r] = 0;
			for(int i=1; ; i++) {
				boolean update = false;
				for(int j=0; j<E; j++) {
					int s = edge[j].a;
					int t = edge[j].b;
					int d = edge[j].w;
					if(dis[s] < MAX && dis[t] > dis[s] + d) {
						dis[t] = dis[s]+d;
						update = true;
					}
				}
				if(i == V && update) {
					System.out.println("NEGATIVE CYCLE");
					return;
				}
				else if(! update) {
					break;
				}
			}
			for(int i=0; i<V; i++) {
				if(dis[i] >= MAX) {
					System.out.println("INF");
				}
				else {
					System.out.println(dis[i]);
				}
			}
		}
	}

}




Measured memory_bytes: 38100
N = int(input())
B = list(map(int, input().split()))
sum=B[0]
for i in range(1,N):
    if i<N-1 and B[i]<=B[i-1]:
        sum=sum+B[i]
    elif i<N-1 and B[i-1]<=B[i]:
        sum=sum+B[i-1]
    else:
        sum=sum+B[N-2]
print(sum)

Measured memory_bytes: 9116
s,t = raw_input(),raw_input()
m = len(t)

def f(s,t):
	if len(s) < len(t):
		return +float('inf')
	c = 0
	for u,v in zip(s,t):
		if u != v:
			c+=1
	return c
for i in range(len(s)):
	m = min(m,f(s[i:i+len(t)],t))
print m

Measured memory_bytes: 77924
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  cout << (N - 1) / 2 << endl;
  ;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

struct FiniteField {
  int64 x;
  FiniteField(int64 input_x) : x(input_x) {}
  inline FiniteField operator+ (FiniteField o) {
    return *this + o.x;
  }
  inline FiniteField operator+ (int64 o) {
    return FiniteField((x + o) % P);
  }
  inline FiniteField operator* (FiniteField o) {
    return *this * o.x;
  }
  inline FiniteField operator* (int64 o) {
    return FiniteField((x * o) % P);
  }
  inline void operator*= (FiniteField o) {
    *this *= o.x;
  }
  inline void operator*= (int64 o) {
    x = (x * o) % P;
  }
};

struct Edge {
  int from, to;
  Edge(int input_from, int input_to) : from(input_from), to(input_to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].emplace_back(v1, v2);
    graph[v2].emplace_back(v2, v1);
  }
  return graph;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<Edge>> graph = ReadUndirectedGraph(n, n - 1, true);

  std::function<FiniteField(int, int, int)> solve =
      [k, &graph, &solve](int v, int parent, int depth) {
    int numChildren = graph[v].size() - (depth > 0 ? 1 : 0);
    if (numChildren == 0) return FiniteField(1);
    int numColors = k - 1 - (depth > 0 ? 1 : 0);
    if (numColors < numChildren) return FiniteField(0);
    FiniteField ans = FiniteField(1);
    for (int i = 0; i < numChildren; i++) {
      ans *= numColors - i;
    }
    for (const auto& e : graph[v]) {
      if (e.to == parent) continue;
      ans *= solve(e.to, v, depth + 1);
    }
    return ans;
  };
  auto solution = solve(0, -1, 0) * k;
  cout << solution.x << endl;
}

Measured memory_bytes: 12800
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, int k) {
    int answer = k;
    for (int i = 1; i < n; i++) {
      answer *= k - 1;
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    out.println(solve(n, k));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21332
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	min := 1000
	for i := 0; i < len(s)-2; i++ {
		n, _ := strconv.Atoi(s[i : i+3])
		d := abs(n - 753)
		if d < min {
			min = d
		}
	}
	fmt.Println(min)
}

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


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

vector<vector<int> > b;

int get_depth(int x) {
  int sz = (int)b[x].size();
  if (sz == 0) {
    return 0;
  }

  vector<int> ret(sz);
  rep (i, sz) {
    ret[i] = get_depth(b[x][i]);
  }
  sort(all(ret), std::greater<int>());
  rep (i, sz) {
    ret[i] += (i+1);
  }
  sort(all(ret), std::greater<int>());
  return ret[0];
}

int main() {
  int n;
  scanf("%d", &n);
  vi a(n+1, 0);
  b.resize(n+1);
  FOR (i, 2, n+1) {
    scanf("%d", &a[i]);
    b[a[i]].push_back(i);
  }

  int ans = get_depth(1);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int64_t sum = 0;
  for (int i = 0; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0)
      sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec)
    is >> x;  // for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}

double distcalc(pair<ll,ll>p1, pair<ll,ll>p2){
    return sqrt(pow( (p1.first - p2.first) , 2) + pow((p1.second-p2.second),2) );
}


double route(vector<ll> pushed,vector<ll> &list,vector<pair<ll,ll>> &dist,double distsum,ll lastid){
    // cerr << lastid << ",";
    double ans = 0;
    if (pushed.size()==list.size()){
        // cerr << "::" << distsum << endl;;
        return distsum;
    }

    for(auto l : list){
        if (find(pushed.begin(),pushed.end(),l) ==pushed.end() ){
            pushed.push_back(l);
            double tmp = 0;
            if (lastid != -1)tmp = distsum + distcalc( dist[l],dist[lastid] );
            ans+=route(pushed,list,dist,tmp,l);
            pushed.pop_back();
        }
    }

    // cerr << endl;
    
    return ans;

}




int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<pair<ll,ll>> pos(n);
  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    pos[i] = make_pair(x[i],y[i]);
  }

    vector<ll> list;
  double nb = 1;
  for (ll i = 1; i <= n; i++) {
    nb *= i;
    list.push_back(i-1);
  }

    double ans = route(vector<ll>(),list,pos,0,-1);
    ans /= nb;


    cout<< setprecision(7)<< fixed << ans <<endl;


}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>
 
 
//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;
 
//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)
 
typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;
 
//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
//今回の変数
 
//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}
 
 
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	REPS(i, n) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
}

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

int main() {
	int n;cin>>n;
	vector< pair<int,int> > d(n);
	for(int i=0;i<n;++i) cin>>d[i].first>>d[i].second;

	sort(d.begin(),d.end(), [](auto &d1, auto &d2){
			if(d1.first==d2.first) return d1.second < d2.second;
			return d1.first < d2.first;
		});

	for(auto &&di: d){
		cout<<di.first<<" "<<di.second<<endl;
	}
  return 0;
}



Measured memory_bytes: 3580
S = input()
N = len(S)

D = [0 for i in range(26)]
for i in range(N):
    D[ord(S[i]) - 97] = 1

if N != 26:
    for i in range(26):
        if D[i] == 0:
            s = chr(97 + i)
            break
    print(S + s)

else:
    if S == "abcdefghijklmnopqrstuvwxyz"[::-1]:
        print(-1)
    else:
        c = 2
        for i in range(N):
            if ord(S[-2 - i]) - ord(S[-1 - i]) >= 1:
                c += 1
            else:
                break
        s = sorted(list(S[26 - c:]))
        for i in s:
            if ord(i) > ord(S[-c]):
                key = i
                break

        print(S[:26 - c] + key)


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    vector<int> a(n), b(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }
    a[0] = b[0];
    a.back() = b.back();
    for (int i = 1; i < n - 1; ++i) {
        a[i] = min(b[i - 1], b[i]);
    }
    cout << accumulate(all(a), 0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N); repp(i,0,N) cin >> A[i];
    int sum = 0; repp(i,0,N) sum += A[i];
    int count = 0;
    repp(i,0,N) {
        if (A[i] * 4 * M < sum) continue;
        ++count;
    }
    if (M <= count) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
// you can use includes, for example:
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <sstream>
#include <set>
#include <cassert>
#include <map>

using namespace std;

constexpr int64_t kMod = 1e9 + 7;

int main(void) {
  ios_base::sync_with_stdio(0);
  string s, t;
  cin >> s >> t;

  std::vector<pair<int, int>> cnt_s(s.size());
  std::vector<pair<int, int>> cnt_t(t.size());
  {
    for (int i = 0; i < s.size(); i++) {
      if (i) {
        cnt_s[i].first += cnt_s[i - 1].first;
        cnt_s[i].second += cnt_s[i - 1].second;
      }
      cnt_s[i].first += s[i] == 'A';
      cnt_s[i].second += s[i] == 'B';
    }

    for (int i = 0; i < t.size(); i++) {
      if (i) {
        cnt_t[i].first += cnt_t[i - 1].first;
        cnt_t[i].second += cnt_t[i - 1].second;
      }
      cnt_t[i].first += t[i] == 'A';
      cnt_t[i].second += t[i] == 'B';
    }
  }

  auto get_ab = [](int l, int r, const std::vector<pair<int, int>>& cnts) {
    assert(l <= r);
    if (l == 0) {
      return cnts[r];
    }
    auto cur = cnts[r];
    cur.first -= cnts[l - 1].first;
    cur.second -= cnts[l - 1].second;
    return cur;
  };

  int m;
  cin >> m;

  while (m-->0) {
    int sl, sr, tl, tr;
    cin >> sl >> sr >> tl >> tr;
    sl--;
    sr--;
    tl--;
    tr--;
    auto s_ab = get_ab(sl, sr, cnt_s);
    auto t_ab = get_ab(tl, tr, cnt_t);
    int s_mod = (s_ab.first * 2 + s_ab.second) % 3;
    int t_mod = (t_ab.first * 2 + t_ab.second) % 3;
    if (s_mod == t_mod) {
      cout << "YES" << "\n";
      continue;
    }
    s_mod = (s_ab.first + s_ab.second * 2) % 3;
    t_mod = (t_ab.first + t_ab.second * 2) % 3;
    if (s_mod == t_mod) {
      cout << "YES" << "\n";
      continue;
    } else {
      cout << "NO" << "\n";
    }
  }

}


Measured memory_bytes: 2512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type AB struct {
	a int
	b int
}

type ABS []AB

func (abs ABS) Len() int {
	return len(abs)
}

func (abs ABS) Swap(i, j int) {
	abs[i], abs[j] = abs[j], abs[i]
}

func (abs ABS) Less(i, j int) bool {
	return abs[i].a < abs[j].a
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	ab := make([]AB, n)
	cd := make([]AB, n)

	for i := 0; i < n; i++ {
		ab[i].a, ab[i].b = nextInt(), nextInt()
	}

	for i := 0; i < n; i++ {
		cd[i].a, cd[i].b = nextInt(), nextInt()
	}

	// sort.Sort(ab)
	// sort.Sort(ByB{ab})

	sort.Sort(ABS(ab))
	sort.Sort(ABS(cd))

	// fmt.Println(ab)
	// fmt.Println(cd)
	used := make([]bool, len(cd))
	ans := 0
	for i := 0; i < n; i++ {
		B := cd[i]
		index := -1
		maxv := -1
		for j := 0; j < n; j++ {
			if !used[j] && ab[j].a < B.a && ab[j].b < B.b && maxv < ab[j].b {
				index = j
				maxv = max(maxv, ab[j].b)
			}
		}
		if index != -1 {
			ans++
			used[index] = true
		}
	}
	fmt.Println(ans)

}

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


Measured memory_bytes: 640
from copy import copy
S = list(input())
n = len(S)

total = int("".join(S))
siki = set()
for i in range(2 ** (n - 1)):
    S_ = copy(S)
    plus_count = 0
    for j in range(n - 1):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            S_.insert(plus_count + j + 1, "+")  # フラグが立っていたら bag に果物を詰める
            plus_count += 1
            siki.add("".join(S_))  # 買い物累計額にも加算
for s in list(siki):
    total += eval(s)
print(total)


Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
const int N=105;
pair<pair<string,int>,int>a[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first.first>>a[i].first.second;
		a[i].first.second=-a[i].first.second;
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		cout<<a[i].second<<endl;
	return 0;
}


Measured memory_bytes: 256