akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
//using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  string S; cin>>S;
  
  ll ans=0;
  rep(i,N+1){
    set<char> list;
    for(int j=0;j<i;j++){
      list.insert(S[j]);
    }
    vector<int> vec(26,0);
    for(int j=i;j<N;j++){
      if(list.count(S[j])){
        vec[S[j]-'a']++;
      }
    }
    ll sans=0;
    for(auto v:vec) if(v) sans++;
    chmax(ans,sans);
  }
  
  cout<<ans<<'\n';
  
  return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>

int main(void)
{
    int i,N;

    scanf("%d",&N);
    long long a=0;
    for(i=1;i<=N;i++){
        if((i%3!=0)&&(i%5!=0)) a+=i;}
    printf("%lld\n",a);
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    if(s.size()==26){
        string c;
        for(int i=25;i>0;i--){
            c.push_back(s[i]);
            if(s[i]>s[i-1]){
                char post=s[i];
                for(int j=0;j<c.size();j++){
                    if(c[j]>s[i-1]) post=min(post,c[j]);
                }
                c.erase(find(c.begin(),c.end(),post));
                c.push_back(s[i-1]);
                sort(c.begin(),c.end());
                int fr=i-1;
                for(int i=0;i<fr;i++) cout<<s[i];
                cout<<post;
                return 0;
            }
        }
        cout<<-1<<endl;
        return 0;
    }
    else{
        for(char x='a';x<='z';x++){
            for(int i=0;i<s.size();i++){
                if(x==s[i]) break;
                if(i==s.size()-1){
                    cout<<s+x<<endl;
                    return 0;
                }
            }
        }
        
    }
    
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
set<int>appear[26];
int n;
string s;
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n;
  cin >> s;
  for(int i = 0; i < n; i++){
    appear[s[i]-'a'].insert(i);
  }
  int q;
  cin >> q;
  f(i,0,26)appear[i].insert(n);
  while(q--){

    int tp;
    cin >> tp;
    if(tp==1){
      int idx;  cin >> idx; --idx;
      char c; cin >> c;
      appear[s[idx]-'a'].erase(idx);
      s[idx] = c;
      appear[s[idx]-'a'].insert(idx);
    } else {
      int l, r;
      cin >> l >> r;  --l;
      int ans = 0;
      f(i,0,26)ans+=(*appear[i].lower_bound(l) < r);
      cout<<ans<<'\n';
    }
  }

  return 0;
}


Measured memory_bytes: 26244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		long n,m;
		long sum;
		n=cin.nextInt();
		m=cin.nextInt();
		
		if((n==1)||(m==1)) {
			sum=1;
		}
		else {
			if((n*m)%2!=0)
			{
				long x=(n*m)/2;
				sum=x+1;
			}
			else
			{
				sum=(n*m)/2;
			}
		}
		System.out.println(sum);
		cin.close();
	}

}


Measured memory_bytes: 22356
#include <stdio.h>
#include <math.h>

int main(void){
	long int n,d,i;
        long int co=0;
  	scanf("%ld %ld",&n,&d);
 	long int x,y;
    for(i=0;i<n;i++){
      scanf("%ld %ld",&x,&y);
      if(sqrt(x*x+(y*y)) <= (double)d)
        co++;
    }
  	printf("%ld\n",co);
    return 0;
}
        



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

using namespace std;

int n;
int cnt[4];

double dp[303][303][303];
int visited[303][303][303];

double dfs(int a, int b, int c){
    if(a<0 || b<0 || c<0 || a+b+c==0) return 0;
    if(visited[a][b][c]) return dp[a][b][c];
    visited[a][b][c] = 1;
    int s = a+b+c;
    return dp[a][b][c] = (double)n / s + dfs(a-1, b, c) * ((double)a / s) + dfs(a+1, b-1, c) * ((double)b/s) + dfs(a, b+1, c-1) * ((double)c/s);
}

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

    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        cnt[tmp]++;
    }
    cout<<setprecision(30)<<dfs(cnt[1], cnt[2], cnt[3]);


    return 0;
}

Measured memory_bytes: 325888
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	string S;
	int D; 
	cin >> S >> D; 
	int L = S.size(); 
	int P = 1e9 + 7; 
	int dp[10010][110][2] = {}; // leading zerosを補ってL桁と見る．dp[上からi桁][mod D][未満確定？]．あとで0の分の1個を引くのを忘れるな．
	dp[0][0][0] = 1; 
	for(int i = 0; i < L; i++){
        	for(int j = 0; j < D; j++){
        		for(int k = 0; k <= 1; k++){
				for(int r = 0; r <= (k ? 9 : S.at(i) - '0') ; r++){
					dp[i+1][(j+r) % D][k || (r < S.at(i) - '0')] 
					= (dp[i+1][(j+r) % D][k || (r < S.at(i) - '0')] + dp[i][j][k]) % P; 
				}
			}
		}
	}
	int ans = 1e9 + 6; 
	for(int k = 0; k <= 1; k++){
		ans += dp[L][0][k]; 
		if(ans >= P){ans -= P;}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 8832
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string s;
	int n;
	cin >> n;
	cin >> s;
	vector<int> a(n);
	rep(i, n) {
		if (s[i] == 'R') a[i] = 0;
		if (s[i] == 'G') a[i] = 1;
		if (s[i] == 'B') a[i] = 2;
	}
	vector<ll> cnt(3);
	rep(i, n) cnt[a[i]]++;
	long long total = cnt[0] * cnt[1] * cnt[2];
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int k = 2 * j - i;
			if (k >= n) continue;
			if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
				total--;
			}
		}
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3668
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else 
#define debug(...)
#endif

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	int l , r , d;
	cin >> l >> r >> d;
	int cnt = 0;
	for(int i = l ; i <= r ; i++){
		if(i % d == 0){
			cnt++;
		}
	}
	
	cout << cnt << "\n";
}
int main()
{
	speed;
	int t = 1;
	// cin >> t;
	for(int i = 1 ; i <= t ; i++){
		// cout << "Case #" << i << ": ";
		solve();
	}
    return 0;
}

Measured memory_bytes: 3544
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a, b;
  
  std::cin >> a >> b;

  std::cout << (b < a ? a - 1 : a) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=1000000+9,mod=1e9+7;
ll F[N],IF[N],P2[N];
ll power(ll b,ll p){

  if(p==0) return 1;
  if(p%2==0){
    return power(b*b%mod,p/2);
  }
  else{
    return b*power(b*b%mod,p/2)%mod;
  }
}
ll C(int n,int r){

  return F[n]*IF[n-r]%mod*IF[r]%mod;
}
int main(){
    GO();

    int T;
  //  cin>>T;
    T=1;
    while(T--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"0\n";
            continue;
        }
        F[0]=1;
        P2[0]=1;
        for(int i=1;i<=n;i++) F[i]=(F[i-1]*i)%mod,P2[i]=(P2[i-1]*2)%mod;
        IF[n]=power(F[n],mod-2);

        for(int i=n-1;i>=0;i--){
            IF[i]=(IF[i+1]*(i+1))%mod;
        }
        ll pp=1,ans=0;
        for(int i=0;i<=n-2;i++){

            ll res= C(n,i)*pp%mod*(((P2[n-i]-2)%mod+mod)%mod)%mod;
            ans+=res;
            ans%=mod;
            pp*=8;
            pp%=mod;
        }

        cout<<ans<<"\n";


    }

}





















































































































































































Measured memory_bytes: 27048
# -*- Coding: utf-8 -*-
def sum_benefit(anded):
    summed= 0
    for shop in range(n_shop):
        summed += i_benefit[shop][anded[shop]]
    return summed

n_shop = int(input())
i_schedule = []
i_benefit = []


max_profit = 0

#開店スケジュールを2進数→10進数に変換
for i in range(n_shop):
    i_schedule.append(int(input().replace(" ",""),2))
    
for i in range(n_shop):
    i_benefit.append(list(map(int,input().split())))
    max_profit += min(i_benefit[i])
    
#全パターンの開店スケジューるの作成
#一つ以上の時間帯で店は開店しなければならない

#schedule=[format(i, '010b') for i in range(1,1024)]
schedule = [i for  i in range(1,1024)]

#そこから一致数の計算→リストのcountメソッドを使う
for sch in schedule:
    anded = []
    for j in range(n_shop):
        anded.append(format(sch & i_schedule[j], "b").count("1"))     #一致スケジュールを2進数表記にして，1の数を計算
        
    profit = sum_benefit(anded)
    
    if max_profit <= profit:
        max_profit = profit
    

print(max_profit)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long k;
    long n;
    ArrayList<Long> a = new ArrayList<Long>();

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        k = sc.nextLong();
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextLong());
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        ArrayList<Long> res = new ArrayList<Long>();
        for (int i = 1; i <= a.size(); i++) {
            if (i == a.size()) {
                res.add((k - a.get(a.size() - 1)) + a.get(0));
            } else {
                res.add(a.get(i) - a.get(i-1));
            }
        }
        res.sort(Comparator.reverseOrder());
        System.out.println(k-res.get(0));
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const LL INF=1e15;

int main()
{
    int n;
    cin>>n;
    vector<PII> a(n+1);
    REP(i,n)
    {
        int s;
        cin>>s;
        a[i]=PII(s,0);
    }

    int sum=0;
    int ans=0;
    bool flag=1;
    for(int k=30;k>=0;k--)
    {
    sort(ALL(a),greater<PII>());
        sum=0;
        for(int i=0;i<a.size();i++)
        {
            sum^=(1<<k)&a[i].first;
            if(a[i+1].first<(1<<k))
            {
                if(sum!=0)
                {
                    if(a[i]==PII(1<<k, 0))
                    {
                        a[i]=PII(a[i].first-1,1);
                        ans++;
                    }
                    else
                    {
                        flag=0;
                    }
                }
                break;
            }
            a[i].first-=(1<<k);
        }
    }

    if(!flag)ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(i%2==0 && s.at(i)=='L') {
            cout << "No";
            return 0;
        }
        else if(i%2==1 && s.at(i)=='R'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string solve()
{
    int N;
    string s;

    std::cin >> N >> s;

    for (int i = 0; i < s.length(); ++i)
    {
        s[i] = s[i] + N % 26;

        if (s[i] > 'Z')
            s[i] -= 26;
    }

    return s;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = k; i < n; i++){
        if(a[i] > a[i-k]){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4044
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return

#B
def B():
    n = I()
    w = LI()
    ans = float("inf")
    for i in range(n):
        m = sum(w[:i])
        l = sum(w[i:])
        ans = min(ans,abs(m-l))
    print(ans)
    return

#C
def C():
    n,m = LI()
    f = [1 for i in range(n+10000)]
    for i in range(m):
        a = I()
        f[a] = 0
    dp = [0 for i in range(n+10000)]
    dp[0] = 1
    for i in range(n):
        if f[i+1]:
            dp[i+1] += dp[i]
            dp[i+1] %= mod
        if f[i+2]:
            dp[i+2] += dp[i]
            dp[i+2] %= mod
    print(dp[n])
    return

#D
def D():
    h,w = LI()
    s = SR(h)
    vi = [[0 for j in range(w)] for i in range(h)]
    ho = [[0 for j in range(w)] for i in range(h)]
    q = deque()
    for y in range(h):
        for x in range(w):
            if s[y][x] == "#":
                l = len(q)
                while q:
                    i,j = q.pop()
                    vi[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            vi[i][j] = l
    for x in range(w):
        for y in range(h):
            if s[y][x] == "#":
                l = len(q)
                while q:
                    i,j = q.pop()
                    ho[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            ho[i][j] = l
    ans = 0
    for y in range(h):
        for x in range(w):
            ans = max(ans,vi[y][x]+ho[y][x]-1)
    print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


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

class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j], f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void move(char ch) {
		if (ch == 'E')for (int i = 0; i < 3; i++)roll_y();
		if (ch == 'W')roll_y();
		if (ch == 'N')roll_x();
		if (ch == 'S')for (int i = 0; i < 3; i++)roll_x();
	}
};

int main() {
	Cube c;
	string com;

	for (int i = 0; i < 6; i++)cin >> c.f[i];
	cin >> com;

	for (int i = 0; i < com.size(); i++)c.move(com[i]);

	cout << c.f[0] << endl;

	return 0;
}

Measured memory_bytes: 3172
r,c=map(int,input().split())
a=[]

for i in range(r):
    a.append(list(map(int,input().split())))
    a[i].append(sum(a[i]))

for i in range(r):
    print(" ".join(list(map(str,a[i]))))
    
b=[]
for j in range(c+1):
    s=0
    for i in range(r):
        s+=a[i][j]
    b.append(s)

print(" ".join(list(map(str,b))))


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

using namespace std;

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

    int n;
    cin >> n;

    char prev = ' ';
    bool ok = true;
    set<string> s;
    for(int i = 0; i < n; i++)
    {
        string w;
        cin >> w;
        if(i > 0)
        {
            if(w[0] != prev || s.count(w))
                ok = false;
        }
        s.insert(w);
        prev = w[w.size() - 1];
    }

    cout << (ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int x, y; cin >> x >> y;
    vector<int> vs({x, y, -x, -y});
    long long d[4][4] = {};
    long long INF = 1LL<<60;
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++) {
            int a = vs[i], b = vs[j];
            if (a == -b) d[i][j] = 1;
            else if (a <= b) d[i][j] = b - a;
            else d[i][j] = INF;
        }
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    cout << d[0][1] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	vector<P> v(n);
	for(int i=0; i<n; i++){
		cin>>v[i].first>>v[i].second;
	}
	sort(v.begin(), v.end());
	v.push_back({(int)(1e9)+7, 0});
	int b[100010];
	b[0]=v[0].second;
	for(int i=1; i<=n; i++){
		b[i]=v[i].second^v[i-1].second;
	}
	int l[200020], r[200020];
	for(int i=0; i<m; i++){
		cin>>l[i]>>r[i]; r[i]++;
		l[i]=lower_bound(v.begin(), v.end(), P(l[i], 0))-v.begin();
		r[i]=lower_bound(v.begin(), v.end(), P(r[i], 0))-v.begin();
	}
	vector<P> g[100010];
	for(int i=0; i<m; i++){
		g[l[i]].push_back({r[i], i});
		g[r[i]].push_back({l[i], i});
	}
	int c[200020]={};
	bool used[100010]={};
	auto dfs=[&](auto dfs, int x)->void{
		used[x]=1;
		for(auto q:g[x]){
			int y=q.first;
			if(used[y]) continue;
			dfs(dfs, y);
			if(b[y]){
				c[q.second]=1;
				b[x]^=1, b[y]^=1;
			}
		}
	};
	for(int i=0; i<=n; i++){
		if(used[i]) continue;
		dfs(dfs, i);
		if(b[i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	vector<int> ans;
	for(int i=0; i<m; i++){
		if(c[i]) ans.push_back(i+1);
	}
	cout<<ans.size()<<endl;
	for(auto x:ans) cout<<x<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 16752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  int p[100001];
  int ans = 0;

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

  for(int i = 1; i < n; i++){
    if(p[i] == i){
      ans++;
      swap(p[i], p[i+1]);  
    }
  }

  if(p[n] == n) ans++;

  cout << ans << endl;

  return 0;
}


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

int main() {

  string S;
  cin >> S;
  if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R') cout << 3;
  else if(S[0] == 'R' && S[1] == 'R' && S[2] == 'S') cout << 2;
  else if(S[0] == 'R' && S[1] == 'S' && S[2] == 'S') cout << 1;
  else if(S[0] == 'S' && S[1] == 'S' && S[2] == 'S') cout << 0;
  else if(S[0] == 'S' && S[1] == 'S' && S[2] == 'R') cout << 1;
  else if(S[0] == 'S' && S[1] == 'R' && S[2] == 'S') cout << 1;
  else if(S[0] == 'R' && S[1] == 'S' && S[2] == 'R') cout << 1;
  else if(S[0] == 'S' && S[1] == 'R' && S[2] == 'R') cout << 2;
 return 0;
}



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

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for (int i = 0; i<n; i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int minstamina = 1e9;
	for (int i = v[0]; i<=v[n-1]; i++){
		int stamina = 0;
		for (int p : v){
			stamina+=(i-p)*(i-p);
		}
		minstamina=min(minstamina,stamina);
	}cout<<minstamina<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val D = listOfLong()
    val Y = LongArray(N) { 0 }
    Y[0] = D.reduceIndexed { n, acc, v -> if (n % 2 == 0) acc + v else acc - v }
    for (n in 0 until N - 1) Y[n + 1] = 2 * D[n] - Y[n]
    println(Y.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0) = listOfString().map { it.toLong() + delta }

Measured memory_bytes: 61316
from sys import stdout
import math
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,z = inm()
if z == a*a*b:
  print(0)
  exit()
u = z/a
if u>=a*b/2:
  t = 2*(a*b-u)/(a*a)
  d = math.degrees(math.atan(t))
else:
  p = math.atan(2*u/(b*b))
  d = 90 - math.degrees(p)
print(d)



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	for(int i=k;i<n;i++) cout << (a.at(i)>a.at(i-k)?"Yes":"No") << endl ;
}

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

using namespace std;

int n, m, p[100005], ans[100005];
vector<pair<int, int>> v[100005];
int ta;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", p + i, &ta);
		v[p[i]].emplace_back(ta, i);
	}
	for (int i = 1; i <= n; i++) {
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j < v[i].size(); j++)
			ans[v[i][j].second] = j + 1;
	}
	for (int i = 0; i < m; i++)
		printf("%06d%06d\n", p[i], ans[i]);
	return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s;
	int a, z;
	cin >> s;
	a = s.find_first_of("A");
	z = s.find_last_of("Z");
	cout << z - a+1 << endl;
	return 0;
}

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

e = [0] * (N+1)

for i in range(2, N+1):
    j = i
    k = 2
    while(j > 1):
        if j % k == 0:
            j //= k
            e[k] += 1
            k = 2
            continue
        k += 1

def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))

print(
num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+(num(3)-2)*num(5)*(num(5)-1)//2
)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int f(string s) {
	vector<int> v(s.size() + 1, 0);
	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		// s[i] - '0'
		int c = 0;
		for (int j = 1; j <= s.size(); j++) {
			if (v[j] == 0)
				c++;
			if (j == s[i] - '0') {
				v[j] = 1;
				c--;
				break;
			}
		}
		int r = 1;
		for (int j = 1; j < s.size() - i; j++)
			r *= j;
		res += r * c;
	}
	// cout << res << endl;
	return res;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s1, s2;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		s1.push_back('0' + t);
	}
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		s2.push_back('0' + t);
	}
	cout << abs(f(s1) - f(s2)) << endl;
}









Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    int kazu[2000][3];
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>kazu[i][j];
        }
    }
    for(int i=0;i<N;i++){
        int ans=0;
        for(int j=0;j<3;j++){
            int dame=0;
            for(int k=0;k<N;k++){
                if(k!=i&&kazu[k][j]==kazu[i][j])dame=1;
            }
            if(dame==0)ans+=kazu[i][j];
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = ll(b) - 1; i >= (a); i--)
#define TR(X)                                                  \
    ({                                                         \
        if (1) cerr << "TR: " << (#X) << " = " << (X) << endl; \
    })
#define LL(name) \
    ll name;           \
    cin >> name;
#define VL(name, num) \
    vl name(num);           \
    FOR(INPUT_VL_I, 0, num) { cin >> name[INPUT_VL_I]; }

int main() { cin.sync_with_stdio(0);
    LL(N); LL(K);
    vl snacks(N);
    FOR(i, 0, K) {
        LL(d);
        VL(A, d);

        for (ll a : A) {
            snacks[a-1]++;
        }
    }

    ll ans = 0;
    for (ll s : snacks) if (s == 0) ans ++;
    cout << ans << endl;
}  // cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

#define reps(i, j, n) for (int i = j; i < (int)n; i++)
#define rep(i, n) reps(i, 0, n)
using int64 = long long;

struct edge {
  int u, v, cost;
};

signed main() {
  int N, M;
  vector<edge> edges;

  cin >> N >> M;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    edges.push_back((edge){a, b, c});
  }

  vector<int64> m(N, -INF);
  m[0] = 0;
  rep(i, 2 * N + 1) {
    for (auto &e : edges) {
      if (m[e.u] + e.cost > m[e.v]) {
        m[e.v] = m[e.u] + e.cost;
        if (i >= N && e.v == N - 1) {
          cout << "inf" << endl;
          return (0);
        }
      }
    }
  }

  cout << m[N - 1] << endl;
}


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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

const int N = 303;

int f[N][N][N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  f[0][1][1] = 1;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    for (int vis = 1; vis <= n; vis++) {
      for (int cap = 1; cap <= n; cap++) {
        int ft = f[i][vis][cap];
        if (ft == 0) {
          continue;
        }
        if (i < m - 1) {
          add(f[i + 1][vis + 1][cap], mul(ft, n - vis));
          add(f[i + 1][vis][vis], mul(ft, cap));
          add(f[i + 1][vis][cap], mul(ft, vis - cap));
        } else {
          if (vis == n) {
            add(ans, mul(ft, cap));
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 54528
N, M = map(int, input().split())

# 約数の全列挙
def divisors(n):
    divisors = []
    R = int(n**(0.5)) + 1
    for i in range(1, R):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

ans = 1
for d in divisors(M):
    if d * N <= M:
        ans = max(ans, d)
print(ans)


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int32_t main(){
sp;
int r ,d,x;
cin>>r>>d>>x;
int a[11];
a[0]=x;
for(int i=1; i<=10; ++i){
    a[i]=1LL*r*a[i-1]-d;
    cout<<a[i]<<"\n";
}

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main(){
    int n,m,ans(0),l;
    cin >> n >> m;
    int a[n],b[n],c[m],d[m];
    rep(i,n)    cin >> a[i] >> b[i];
    rep(i,m)    cin >> c[i] >> d[i];

    rep(i,n){
        l = abs(a[i]-c[0])+abs(b[i]-d[0]);
        ans = 1;
        rep(j,m){
            if(l>abs(a[i]-c[j])+abs(b[i]-d[j])){
                l = abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans = j+1;
            }
        }
        put(ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[1001][1001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  AIN(ll,P,N);
  ll swap = 0;
  REP(i,N){
    if(i+1 != P.at(i))
      swap++;
  }
  if(swap == 0 || swap == 2){
    OUT("YES");
  }
  else{
    OUT("NO");
  }
}



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

int main() {
  vector<int> arr(2);
  for (int i = 0; i < 2; ++i) {
    cin >> arr[i];
  }
  int score = 0;
  for (int i = 0; i < 2; ++i) {
    sort(arr.begin(), arr.end());
    score += arr[1];
    --arr[1];
  }
  cout << score << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll N, W; cin >> N >> W;
    vvll dn(N+1, vll(W+1, 0));
    vll w(N+1), v(N+1);
    for(ll i = 1; i <= N; ++i)
        cin >> w[i] >> v[i];

    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= W; ++j){
            if(j >= w[i]) dn[i][j] = max(dn[i-1][j], dn[i-1][j-w[i]] + v[i]);
            else dn[i][j] = dn[i-1][j];
        }
    }

    cout << dn[N][W] << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 80256
/*ctrl+shift+D =?repeat line
ctrl+x delete a line
*/
#include<iostream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int32_t main()
{
	c_p_c();

	int a, b;

	cin >> a >> b;
	if (b >= a) {
		cout << "unsafe\n";
	}
	else
	{
		cout << "safe\n";
	}

	return 0;



}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	ll n;
	cin >> n;
	vector <ll> arr(n);
	FOR(i,0,n) {
		cin >> arr[i];
	}
	vector <ll> table(n);
	table[0] = 0;
	table[1] = abs(arr[1] - arr[0]);
	FOR(i,2,n) {
		table[i] = min(abs(arr[i] - arr[i-1]) + table[i-1], abs(arr[i] - arr[i-2]) + table[i-2]);
	}
	cout << table[n-1] << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b!=15&&a*b!=15)
		cout<<"x";
	else if(a+b==15)
		cout<<"+";
	else
		cout<<"*";
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i < ll (n); i++)

class DisjointSet{
public:
    vector<ll>Parent, Rank, Size;
    DisjointSet(ll n)
    {
        forn(i,n+1) Parent.push_back(i), Rank.push_back(0), Size.push_back(1);
    }
    ll Find(ll x)
    {
        if(Parent[x]==x) return x;
        else Parent[x]=Find(Parent[x]);
        return Parent[x];
    }
    void Union(ll x, ll y)
    {
        ll u=Find(x);
        ll v=Find(y);
        if(u==v) return;
        if(Rank[u] > Rank[v]) Parent[v]=u, Size[u]+=Size[v];
        else
        {
            Parent[u]=v;
            Size[v]+=Size[u];
            if(Rank[u]==Rank[v]) Rank[u]++;
        }
        return;
    }
};

int main()
{
    ll n,m;
    cin>>n>>m;
    DisjointSet dis(n);
    ll j,k;
    ll ans=1;
    forn(i,m)
    {
        cin>>j>>k;
        dis.Union(j,k);
    }
    forn(i,n)
    {
        ans=max(dis.Size[i+1], ans);
    }
    cout<<ans<<endl;
    return 0;
}


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

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

const ll INF = 1LL << 60;

int N;

vector<ll> dp(200020, 0);

bool is_possible(vector<pair<ll, ll>> T) {
    for (int i = 1; i <= N; i++) {
        if (dp[i - 1] + T[i].second > T[i].first) {
            return false;
        }
        chmax(dp[i], dp[i - 1] + T[i].second);
    }

    return true;
}

int main() {
    cin >> N;
    vector<pair<ll, ll>> T(N + 1);
    T[0].first = 0; T[0].second = 0;
    for (int i = 1; i <= N; i++) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        T[i] = make_pair(b, a);
    }
    sort(T.begin(), T.end());

    if (is_possible(T)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int n;
const int INF = -1e9;
int ans = INF;
int f[105][15];
int p[105][15];
int a[20];


void func() {
  int score = 0;

  for(int i = 0; i < n; i++) {
    int c = 0;
    for(int j = 0; j < 10; j++) {
      if(a[j] == 1 && f[i][j]) c++;
    }
    score += p[i][c];
  }

  bool ok = false;

  for(int i = 0; i < 10; i++) {
    if(a[i]) {
      ok = true;
      break;
    }
  }

  if(!ok) score = INF;

  ans = max(ans,score);
}


void dfs(int pos) {
  if(pos == 10) {
    func();
    return;
  }

  a[pos] = 0;
  dfs(pos + 1);
  a[pos] = 1;
  dfs(pos + 1);
}


int main() {
  cin >> n;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }

  dfs(0);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll C[51][51];

void comb_table(int n){
	rep(i,n+1)rep(j,i+1){
		if(j == 0 || j == i){
			C[i][j] = 1LL;
		}
		else{
			C[i][j] = (C[i-1][j-1] + C[i-1][j]);
		}
	}
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    ll even = 0;
    rep(i,n){
        cin >> a[i];
        a[i] %= 2;
        if(a[i] == 0) ++even;
    }
    comb_table(n);
    ll ans = pow(2, even);
    ll odd = n - even;
    ll mul = 0;
    if(p){
        for(ll i = 1; i <= odd; i+=2){
            mul += C[odd][i];
        }
    }
    else{
        for(ll i = 0; i <= odd; i+=2){
            mul += C[odd][i];
        }
    }
    ans *= mul;
    cout << ans << endl;
	return 0;
}

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

int main(){
    int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  }
  else if (a == c) {
    cout << b << endl;
  }
  else {
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl

signed main(){
    int n, k; cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.begin()+k, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn =50005;
int a,b,x;
int main()
{
   cin>>a>>b>>x;
   if(x<a)cout<<"NO";
   else if((x-a)<=b)cout<<"YES";
   else cout<<"NO";
   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<queue>
int main() {
	int h, w, i, j, l[50][50], numb = 0;
	char s[50][51];
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++) {
		scanf("%s", s[i]);
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#')numb++;
			l[i][j] = 1000000;
		}
	}
	l[0][0] = 1;
	std::queue<std::pair<int, int>> q;
	q.push(std::make_pair(0, 0));
	while (!q.empty()) {
		i = q.front().first;
		j = q.front().second;
		q.pop();
		if (0 < i && s[i - 1][j] == '.' && l[i-1][j]>l[i][j]+1) {
			l[i - 1][j] = l[i][j] + 1;
			q.push(std::make_pair(i - 1, j));
		}
		if (i<h - 1 && s[i + 1][j] == '.' && l[i + 1][j]>l[i][j] + 1) {
			l[i + 1][j] = l[i][j] + 1;
			q.push(std::make_pair(i + 1, j));
		}
		if (0 < j && s[i][j-1] == '.' && l[i][j-1]>l[i][j] + 1) {
			l[i][j-1] = l[i][j] + 1;
			q.push(std::make_pair(i, j-1));
		}
		if (j<w - 1 && s[i][j+1] == '.' && l[i][j+1]>l[i][j] + 1) {
			l[i][j+1] = l[i][j] + 1;
			q.push(std::make_pair(i, j+1));
		}
	}
	if (l[h - 1][w - 1] == 1000000)printf("-1");
	else printf("%d", h*w - l[h - 1][w - 1] - numb);
	return 0;
}

Measured memory_bytes: 256