akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define mod 1000000007
#define ll long long
int main()
{
	int a,b;cin>>a>>b;
	if(a<=0 and b>=0) 
	{
		puts("Zero");return 0;
	}
	if(a>0 or abs(a-b+1)%2==0)
	{
		puts("Positive");return 0;
	}
	puts("Negative");
	return 0;
} 


Measured memory_bytes: 256
N=int(input())
m=len(input())
mod=10**9+7

dp=[[0 for j in range(i+2)] for i in range(N+1)]
dp[N][m]=1
for i in range(N-1,-1,-1):
    for j in range(1,i+2):
        dp[i][j]=(2*dp[i+1][j-1]+dp[i+1][j+1])%mod
    dp[i][0]=(dp[i+1][0]+dp[i+1][1])%mod

print(dp[0][0])


Measured memory_bytes: 139272
# -*- coding: utf-8 -*-

s = int(input())

q, r = divmod(s, 10 ** 9)
if r != 0:
    x = 10 ** 9 - r
    y = q + 1
else:
    x = r
    y = q

xy = [0, 0, 10 ** 9, 1, x, y]
print(*xy)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
using namespace std;
const int Max_N = 1e2+10;

const int Max_value = 1e3+10;
long long v[Max_value];
int w[Max_N];
long long dp[Max_N][Max_value*Max_N];

int main() {
    int N;
    cin >> N;
    int W;
    cin >> W;
    
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    dp[0][0]=0;
    for (int i = 1; i <= (Max_N*Max_value); i++) {
        dp[0][i] = 1e9+10;
    }
    
    
    for (int i = 1; i <= N; i++) {
        for (int j = 0 ; j < (Max_value*Max_N); j++) {
            if (j >= v[i]) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
            
            
        }
        
    }
    int ans = 0;
    for (int i = 1; i < (Max_N*Max_value) ; i++) {
        if(dp[N][i] <= W){
            ans = max(ans,i);
        }
    }
    cout << ans <<  endl;
    
    return 0;
}


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

int dp[2][10100][110];

int main(){
    int N,C;
    cin >> N >> C;
    vector<int> a(N),b(N),c(N);
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i=0; i<2; i++){
        for(int j=0; j<10100; j++){
            for(int k=0; k<110; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<10100; j++){
            for(int k=0; k<=C; k++){
                if(dp[i%2][j][k] == -1) continue;
                dp[(i+1)%2][j][k] = max(dp[(i+1)%2][j][k],dp[i%2][j][k]);
                if(k + c[i] > C) continue;
                int now = dp[i%2][j][k];
                int nxt = min(10010,j+b[i]);
                dp[(i+1)%2][nxt][k+c[i]] = max(dp[(i+1)%2][nxt][k+c[i]],now+a[i]);
                if(j+a[i] > now+b[i]){
                    int nxt2 = min(10010,now+b[i]);
                    dp[(i+1)%2][nxt2][k+c[i]] = max(dp[(i+1)%2][nxt2][k+c[i]],j+a[i]);
                }else{
                    int nxt2 = min(10010,j+a[i]);
                    dp[(i+1)%2][nxt2][k+c[i]] = max(dp[(i+1)%2][nxt2][k+c[i]],now+b[i]);
                }
                dp[i%2][j][k] = -1;
            }
        }
    }
    int ans = -1;
    for(int j=0; j<10010; j++){
        for(int k=0; k<=C; k++){
            if(dp[N%2][j][k] != -1){
                ans = max(ans,j);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int n, t;
  cin >> n;
  int trees[n] = {};
  for (int i = 1; i <= n - 1; ++i) {
    cin >> t;
    trees[t - 1]++;
  }
  for (int i = 0; i < n; ++i) cout << trees[i] << '\n';
  return 0;
}


Measured memory_bytes: 4380
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int[] map = new int[26];
		for (char c: S.toCharArray()) {
			map[c-'a']++;
			if (map[c-'a'] > 1) {
				System.out.println("no");
				return;
			}
		}
		
		System.out.println("yes");
	}
}


Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}
		sc.close();

		long sum = 0;
		int size = list.size();
		for (int i = 0; i < size - 1; i++) {
			long li = list.get(i);
			for (int j = i + 1; j < size; j++) {
				long lj = list.get(j);
				sum = sum + li * lj;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23252
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    string s; cin >> s;
    vector<int> cnt(26);
    for(int i=0; i<N; i++) {
        cnt[ s[i] - 'a' ]++;
    }

    int ans = 1;
    for(int i=0; i<26; i++) {
        (ans *= cnt[i] + 1) %= MOD;
    }
    cout << (ans - 1 + MOD) % MOD << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

ll X, A, B;

int main()
{
	cin >> X >> A >> B;

	if (A - B >= 0) {
		cout << "delicious" << endl;
	}
	else if (A - B + X >= 0) {
		cout << "safe" << endl;
	}
	else
		cout << "dangerous" << endl;
	return	0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

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 long long INF = 1LL << 60;

int main(){
    long long A;
    long long h[100010];
    long long dp[100010];
    for(int i = 0; i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;

    cin >> A;

    for(int i = 0; i < A; ++i) cin >> h[i];

    for(int i = 0; i < A; ++i)
    {
        chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[A - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,n;
    cin >> x >> n;
    vector<int> a(102);
    rep(i,102){
        a[i]=0;
    }
    rep(i,n){
        int m;
        cin >> m;
        a[m]=1;
    }
    if(n==0){
        cout << x;
        return 0;
    }
    int ans = 0;
    int l = x;
    for(int i=0;i<102;i++){
        if(a[i]==0){
            if(l>abs(i-x)){
                ans=i;
                l = abs(i-x);
            }
        }

    }
    cout << ans;
    // cout << m;


    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll  n;
    cin>>n;
    ll  arr[n];
    for(ll  i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll c=0;
    ll  l=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>l)
        l=arr[i];
        else
        {
            c+=l-arr[i];
            
        }
    }
    cout<<c<<endl;
    
}

Measured memory_bytes: 5168
#include<stdio.h>
#include<iostream>
#include<string>

#define MAX 500000

struct node {
	int key;
	int parent, left, right;
} T[MAX];
int root;

void PrePrint(int t) {
	if (t == -1) return;
	printf(" %d", T[t].key);
	PrePrint(T[t].left);
	PrePrint(T[t].right);
}

void InPrint(int t) {
	if (t == -1) return;
	InPrint(T[t].left);
	printf(" %d", T[t].key);
	InPrint(T[t].right);
}

void initNode(int n) {
	root = -1;
	for (int i = 0; i < n; i++) {
		T[i].key = -1;
		T[i].parent = -1;
		T[i].left = -1;
		T[i].right = -1;
	}
}

void insert(int z) {
	int y = -1; // xの親
	int x = root;
	while (x != -1) {
		y = x;
		if (T[z].key < T[x].key) x = T[x].left;
		else x = T[x].right;
	}
	T[z].parent = y;

	if (y == -1) root = z;
	else if (T[z].key < T[y].key) T[y].left = z;
	else T[y].right = z;
	T[z].right = -1;
	T[z].left = -1;
}

bool find(int k) {
	int x = root;
	while (x != -1) {
		if (T[x].key == k) return true;
		if (T[x].key < k) x = T[x].right;
		else x = T[x].left;
	}
	return false;
}

int getMin(int x) {
	if (T[x].left == -1) return x;
	else return getMin(T[x].left);
}

int successer(int x) {
	if (T[x].right != -1) {
		return getMin(T[x].right);
	}
	else {
		return T[x].parent;
	}
}

void delchil(int x) {
	int parent = T[x].parent;
	bool isLeft = T[parent].left == x;
	if (T[x].left == -1 && T[x].right == -1) {
		if (isLeft) T[parent].left = -1;
		else T[parent].right = -1;
		return;
	}
	if (T[x].left == -1) {
		int chil = T[x].right;
		if (isLeft) T[parent].left = chil;
		else T[parent].right = chil;
		T[chil].parent = parent;
		return;
	}
	if (T[x].right == -1) {
		int chil = T[x].left;
		if (isLeft) T[parent].left = chil;
		else T[parent].right = chil;
		T[chil].parent = parent;
		return;
	}
	else {
		int chil = successer(x);
		T[x].key = T[chil].key;
		delchil(chil);
		return;
	}
}
void del(int k) {
	int x = root;
	while (x != -1) {
		if (T[x].key == k) break;
		if (T[x].key < k) x = T[x].right;
		else x = T[x].left;
	}
	if (x == -1) printf("%d is not exist!", k);

	delchil(x);
}

int main() {
	int n = 0;
	scanf("%d", &n);
	initNode(n);
	for (int i = 0; i < n; i++) {
		std::string com;
		std::cin >> com;
		if (com[0] == 'i') {
			int k = 0;
			scanf("%d", &k);
			T[i].key = k;
			insert(i);
		}
		else if (com[0] == 'p') {
			InPrint(root);
			printf("\n");
			PrePrint(root);
			printf("\n");
		}
		else if (com[0] == 'f') {
			int k = 0;
			scanf("%d", &k);
			if (find(k)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
		else if (com[0] == 'd') {
			int k = 0;
			scanf("%d", &k);
			del(k);
		}
	}
}



Measured memory_bytes: 11144
#include<bits/stdc++.h>
 
using namespace std;
int main(){
int a=0,b=0,c=0,d=0;
scanf("%d %d %d",&a,&b,&c);
if (a > c){
   swap(a,c);}
if (a > b){
   swap(a,b);}
if (b > c){
   swap(b,c);}
   printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {data.assign(n, -1);}
	int find(int x) {return (data[x] < 0) ? x : data[x] = find(data[x]);}
	void unite(int a, int b) {
		a = find(a), b = find(b);
		if (a != b) {
			if (data[a] < data[b]) swap(a, b);
			data[a] += data[b], data[b] = a;
		}
	}
	bool same(int a, int b) {return find(a) == find(b);}
	int size(int x) {return -data[x];}
	vector<int> data;
};

char board[410][410];
ll wb[410 * 410][2];

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,h)rep(j,w) cin >> board[i][j];

	Union_find uf(h * w);

	rep(i,h)rep(j,w){
		if(i + 1 < h and board[i][j] != board[i + 1][j]){
			uf.unite(i * w + j, (i + 1) * w + j);
		}
		if(j + 1 < w and board[i][j] != board[i][j + 1]){
			uf.unite(i * w + j, i * w + j + 1);
		}
	}

	rep(i,h)rep(j,w){
		const int idx = uf.find(i * w + j);
		wb[idx][board[i][j] == '#']++;
	}

	ll ans = 0LL;
	rep(i,h*w) ans += 1LL * wb[i][0] * wb[i][1];
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a,b,c,d;
	int ans;
	cin>>a>>b>>c>>d;
	while(true){
		c-=b;
		if(c<=0){
			ans=1;
			break;
		}

		a-=d;
		if(a<=0){
			ans=0;
			break;
		}

	}
	if(ans==0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3588
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn main() {
    let s = read_vec_char();
    let w = read::<usize>();
    for i in 0..(s.len()-1)/w+1 {
        print!("{}",s[i*w]);
    }
    print!("\n");
}


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	nums := make([]int, 210)
	var (
		isOdd bool
		count int
		n int
	)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	for {
		for _, num := range nums {
			if num % 2 == 1 {
				isOdd = true
			}
		}

		if isOdd {
			break
		}
		
		for i := range nums {
			nums[i] /= 2
		}

		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main ()
{
    char d[10];
    int i,j,l,k;
    gets(d);
    for(j=0;j<10;j++)
    {
        if(j==3)
        {
        d[j]='8';
        }
    }
     for(j=0;j<10;j++)
     {
         printf("%c",d[j]);
     }
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ba(n);
  for(int i = 0; i < n; i++) {
    cin >> ba.at(i).second >> ba.at(i).first;
  }
  sort(ba.begin(), ba.end());
  int nt = 0;
  for(int i = 0; i < n; i++) {
    if((nt += ba.at(i).second) > ba.at(i).first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
import sys
import numpy

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver():
    N,D = LI()

    ans = 0
    for _ in range(N):
        X,Y = LI()
        if( numpy.sqrt(X*X+Y*Y) <= D ):
            ans = ans + 1

    print(ans)

def main():

    #N,D = LI()
    #A = LI()

    solver()

if __name__ == '__main__':
    main()


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

#define pb push_back
#define ff first
#define ss second

const int MAXN = 2e5 + 21, LG = 61;

int n, m;
long long k;
long long a[MAXN], d[MAXN], p[MAXN][LG];
vector <long long> res;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;

    for (int i = 1; i <= n; i++) 
        cin >> a[i];
    res.pb(a[1]);
    
    cin >> m >> k;

    for (int i = 1; i < n; i++) {
        d[i] = a[i + 1] - a[i];
        p[i][0] = i;
    }

    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        swap(p[x - 1][0], p[x][0]);
    }

    for (int i = 1; i < LG; i++)
        for (int j = 1; j < n; j++) {
            p[j][i] = p[p[j][i - 1]][i - 1];
        }
    
    
    for (int i = 1; i < n; i++) {
        int cur = i;
        
        for (int i = LG - 1; ~i; i--)
            if (k & (1LL << i))
                cur = p[cur][i];
        res.pb(res.back() + d[cur]);
    }

    for (auto y: res)    
        cout << y << '\n';
    return 0;
}



Measured memory_bytes: 55412
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int time = scan.nextInt();
        int h, m, s;
        h = time/3600;
        m = time%3600/60;
        s = time%3600%60;
        System.out.printf("%d:%d:%d\n", h, m, s);
        scan.close();
    }
}


Measured memory_bytes: 26436
#include <iostream>
#include <vector>
#include<iomanip>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
        ans += 1 / (1.0 * a[i]);
    }

    std::cout << std::fixed << std::setprecision(15) << 1 / ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, a, p[7];
int main() {
	while (true) {
		scanf("%d", &n);
		if (n == 0) break;
		for (int i = 0; i < 7; i++) p[i] = 0;
		for (int i = 0; i < n; i++) scanf("%d", &a), p[a < 60 ? a / 10: 6]++;
		for (int i = 0; i < 7; i++) printf("%d\n", p[i]);
	}
	return 0;
}

Measured memory_bytes: 2604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> 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 dp[105][1000005];

int main(void){
  ll n,w; cin >> n >> w;
  ll weight[n],value[n];
  rep(i,n) cin >> weight[i] >> value[i];
  rep(i,n){
    rep(j,w){
      dp[i][j] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= w; j++){
      if(j-weight[i] >= 0)chmax(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1) {
  	if (B == 2) {
     cout << 3 << endl;
    }
    else {
     cout << 2 << endl;
    }
  }
  if (A == 2) {
  	if (B == 1) {
     cout << 3 << endl;
    }
    else {
     cout << 1 << endl;
    }
  }
  if (A == 3) {
   if (B == 1) {
    cout << 2 << endl;
   }
   else {
    cout << 1 << endl;
   }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

int main(){
	long long a,b,c;
	cin >> a >> b >> c;
	if(a+b+c>=22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}

}


Measured memory_bytes: 3620
N, Q = map(int, input().split())
S = input()
d = [0, 0]
for i in range(N - 1):
    if S[i] + S[i + 1] == "AC":
        d.append(d[-1] + 1)
    else:
         d.append(d[-1])

for _ in range(Q):
    l, r = map(int, input().split())
    print(d[r] - d[l])
    

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<vector<int>> X(N,vector<int>(2));
  for(int i=0;i<N;i++){
  int x,y;
    cin>>x>>y;
    X.at(i).at(0)=x;
    X.at(i).at(1)=y;
  }
  
  double sum=0;
  for(int i=0;i<N-1;i++){
  for(int j=i+1;j<N;j++){
  sum+=pow(pow(X.at(i).at(0)-X.at(j).at(0),2)+pow(X.at(i).at(1)-X.at(j).at(1),2),0.5);
  
  }
    
  }
    sum*=2;
    sum/=N;
    cout<<fixed<<setprecision(8)<<sum<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

Days = int(input())
C = list(map(int, input().split())) # 満足度低下
Ss = [list(map(int, input().split())) for _ in range(Days)]
# Ss[d][i]: d日目にiを開催したときの満足度

INF = 10**18

def outputToScore(T):
    last = [0]*26

    satisfied = 0
    for d, t in enumerate(T):
        t -= 1; d += 1
        satisfied += Ss[d-1][t]
        last[t] = d
        for i, c in enumerate(C):
            satisfied -= c*(d-last[i])
        print(satisfied)

def greedy():
    last = [0]*26
    for d in range(Days):
        satisfied_max = -INF
        selected = -1
        for t in range(26):
            score_t = Ss[d][t]
            for j, c in enumerate(C):
                if t != j:
                    score_t -= c*(d+1-last[j])
            if score_t > satisfied_max:
                satisfied_max = score_t
                selected = t
        print(selected+1)
        last[selected] = d+1

greedy()


Measured memory_bytes: 68964
N,Y=map(int,input().split())
for x in range(N + 1):
    n = N - x
    for y in range(n+1):
        z = n - y
        if 10000*x + 5000*y + 1000*z == Y:
            print(x,y,z)
            break
        elif x == N:
            print(-1,-1,-1)
            break
    else:
        continue
    break


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

int main(){
	int a[]={500,100,50,10,5,1};
	int n;
	while(cin>>n,n){
		n=1000-n;
		int ans=0;
		rep(i,6){
			while(1){
				if(n<a[i]) break;
				else{
					ans++;
					n-=a[i];
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

namespace Atcoder_program_test_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            //標準入力
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if ((A + B) % 2 == 0)
            {
                Console.WriteLine((A + B) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}

Measured memory_bytes: 13140
/*************************************************************************
    > File Name: b.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2019年12月22日 星期日 21时08分16秒
 ************************************************************************/

#include <cstdio>
#include <cstring>

char s[105], t[105];

int main(){
    int n;
    scanf("%d%s%s", &n, s, t);
    for(int i = 0; i < n; i++){
        putchar(s[i]);
        putchar(t[i]);
    }
    return 0;
}



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

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        vector<int> a(n);
        for (int &ai: a) cin >> ai;
        int sum = 0;
        for (int i = 0; i < k; i++) sum += a[i];
        int ma = sum;
        for (int i = k; i < n; i++) {
            sum += -a[i - k] + a[i];
            ma = max(ma, sum);
        }
        cout << ma << endl;
    }
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int l = a + b;
  int r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  } else if (l == r) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String strk = sc.next();
        
        int k = 9999;
        if(strk.length() < 3) k = Integer.parseInt(strk);
        String[] arr = n.split("");
        
        //1文字の時
        if(arr.length == 1)System.out.println(n);
        else{
            //2文字以上の時
            boolean flag = true;
            int count = 0;
            int leng = arr.length;
            for(int i = 0; i < leng; i++){
                //前から1が何個続くか
                if(flag && arr[i].equals("1")) count++;
                else flag = false;
                
            }
            
            if(count < k)System.out.println(arr[count]);
            else System.out.println(1);
        }
        
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 998244353
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll


signed main() {
	fast;

	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];

	int m = 1000, s = 0;
	for(int i=1;i<n;i++) {
		if(v[i]>v[i-1]) {
			int cnt = m/v[i-1];
			m += (v[i]-v[i-1])*cnt;
		}
		else {

		}
	}
	cout<<m;
}

Measured memory_bytes: 3652
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
	const int INF=1<<29;
	for(int n;scanf("%d",&n),n;){
		vector<pair<int,int> >v(n+1);
		vector<vector<int> >m(n+1);
		for(int i=0;i<=n;i++){
			if(i)scanf("%d%d",&v[i].first,&v[i].second);
			m[i].resize(4),fill(m[i].begin(),m[i].end(),INF);
		}
		m[0][0]=0;
		int i=0;
		for(;i<n;i++){
			int x=0;
			for(int j=0;j<4;j++)if(m[i][j]<INF){
				int dist=abs(v[i+1].first-v[i].first),dt=v[i+1].second-v[i].second;
				if(j<3&&dist*(j+1)<=dt)x=m[i+1][j+1]=min(m[i+1][j+1],m[i][j]+dist);
				if(v[i+1].first+v[i].first*(j+1)<=dt)x=m[i+1][1]=min(m[i+1][1],m[i][j]+v[i+1].first+v[i].first);
			}
			if(!x)break;
		}
		if(i<n){
			printf("NG %d\n",i+1);
		}else{
			int r=INF;
			for(int i=0;i<4;i++)r=min(r,m[n][i]+v[n].first);
			printf("OK %d\n",r);
		}
	}
}

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

int main()
{
	int a,b;
	cin >> a >> b;
	for(int i = 1;;i++)
	{
		if(i*8/100==a&&i/10==b)
		{
			cout<<i<<endl;
			return 0;
		}
		if(i*8/100>a&&i/10>b)
		{
			cout<<-1<<endl;
			return 0;
		}
		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-9
#define MOD	1000000007
#define int	long long
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;


#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]" << " ";
	err(++it, args...);
}


int32_t main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	int x = b/c - (a-1)/c;
	int y = b/d - (a-1)/d;
	int temp = c*d/__gcd(c,d);
	int xy = b/temp - (a-1)/temp;
	cout << (b - a + 1 - x - y + xy);
	
	return 0;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
A.sort()
positive=[x for x in A if x >=0]
negative=[x for x in A if x <0]
ans=[]



if len(negative)>0 and len(positive)>0:
    y=negative[0]
    for i in positive[1:]:
        ans.append([y,i])
        y-=i
        
    x=positive[0]
    for i in negative[1:]:
        ans.append([x,i])
        x-=i

    M=x-y
    ans.append([x,y])

elif len(negative)==0:
    x=positive[N-1]
    y=positive[0]
    for i in positive[1:N-1]:
        ans.append([y,i])
        y-=i
    M=x-y
    ans.append([x,y])

elif len(positive)==0:
    negative.reverse()
    y=negative[N-1]
    x=negative[0]
    for i in negative[1:N-1]:
        ans.append([x,i])
        x-=i
    M=x-y
    ans.append([x,y])
    
print(M)
for i in ans:
    print(i[0],i[1])

Measured memory_bytes: 69436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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 int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    int n, m, cnt = 0;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int d;
        cin >> d;
        mp[d]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int t;
        cin >> t;
        if(!mp[t]){
            cout << "NO" << endl;
            return 0;
        }
        mp[t]--;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; i++) cin >> S[i];
  ll numM=0, numA=0, numR=0, numC=0, numH=0;
  for (int i=0; i<N; i++) {
    if (S[i][0]=='M') numM++;
    else if (S[i][0]=='A') numA++;
    else if (S[i][0]=='R') numR++;
    else if (S[i][0]=='C') numC++;
    else if (S[i][0]=='H') numH++;
  }
  ll ans = numM*numA*(numR+numC+numH) + numM*numR*(numC+numH) + numM*numC*numH;
  ans += numA*numR*(numC+numH) + numA*numC*numH + numR*numC*numH;
  cout << ans << endl;
}

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

typedef long long ll;
const int N = 200010;

int n, m, f[N], g[N], st[N], top;
char s[N];
struct Node {int v, id;};
deque<Node>q;

int main() {
    memset(g, -1, sizeof(g));
    memset(f, 0x3f, sizeof(f));
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    f[0] = 0; q.push_back({f[0], 0});
    for(int i = 1; i <= n; ++i) {
        while(!q.empty() && i - q.front().id > m) q.pop_front();
        if(s[i] == '1') continue;
        if(!q.empty()) f[i] = q.front().v + 1, g[i] = q.front().id;
        while(!q.empty() && q.back().v > f[i]) q.pop_back();
        if(f[i] != 0x3f3f3f3f) q.push_back({f[i], i});
    }
    if(g[n] == -1) return puts("-1"), 0;
    int now = n;
    while(g[now] != -1) {st[++top] = now - g[now], now = g[now];}
    while(top) printf("%d ", st[top--]);
    puts("");
}

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


int main(){
  long n,k;
  cin >> n >> k;
  long p[n],c[n];
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n)cin >> c[i];
  long ans = -INF;
  long flag[n][n];
  rep(i,n)rep(j,n)flag[i][j] = 0;
  long tmp_score[n];
  rep(i,n)tmp_score[i] = 0;
  rep(i,n){
    long tmp_max = -INF, tmp = 0, now = i, iter = 0;
    while(1){
      if(flag[i][now]==1 || iter >= k)break;
      flag[i][now] = 1;
      now = p[now];
      tmp += c[now];
      tmp_score[iter] = tmp;
      if(tmp > tmp_max)tmp_max = tmp;
      iter++;
    }
    if(tmp_max > ans)ans = tmp_max;
    if(tmp > 0 && iter < k){
      rep(j,iter){
        long score = tmp_score[j] + tmp*(k/iter - 1);
        if(k%iter >= j+1)score += tmp;
        if(ans < score)ans = score;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 199000
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    const int M = 3;
    vi R(M); for(auto& e : R) cin >> e;
    vi a(n);
    {
        string in; cin >> in;
        map<char, int> dic;
        dic['r'] = 0, dic['s'] = 1, dic['p'] = 2;
        rep(i, n) a[i] = dic[in[i]];
    }

    int res = 0;
    vi log(n, -1);
    rep(i, n){
        int cur = (a[i] - 1 + M) % M;
        if(i - K >= 0 and log[i - K] == cur){
            continue;
        }
        res += R[cur];
        log[i] = cur;
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int comp[22][22];
int dp[1 << 21];
int main()
{
    IOS
    int n;
    cin >> n;
    REP(i, n)
        REP(j,n)
            cin >> comp[i][j];
    
    dp[0] = 1;
    FOR(i, 0, (1 << n), 1)
    {
        int a = __builtin_popcount(i);
        REP(b, n)
        {
            if(comp[a][b] && ! (i & (1<<b)))
            {
                int m2 = i ^ (1<<b);
                dp[m2] = (dp[i]+dp[m2])%MOD;
            }
        }
    }   
    if(dp[(1<<n)-1] < 0)
        dp[(1<<n)-1]+=MOD;
    cout << dp[(1<<n)-1] << "\n";
    
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    if (n%2!=0){
        cout << "No\n";
        return 0;
    }
    string s1 = s.substr(0,n/2);
    string s2 = s.substr(n/2, n/2);
    if (s1==s2){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
	return 0;
}


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

using namespace std;

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

	int ans = 1;
	for (int i = 0; i < N; i++) {
		ans = min(ans * 2, ans + K);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int SOD(int n){
	int sum = 0;
	while(n > 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(a <= SOD(i) && SOD(i) <= b) ans += i;
	}
	cout << ans << endl;
}

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

using namespace std;



int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    for (int a = 1; a < n; a++)
    {
        for (int b = 0; b < a; b++)
        {
            int r  = upper_bound(l.begin(), l.end(), l[a]-l[b]) - l.begin();
            int dist = b - r;
            sum += max(dist,0);
        }
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main()
{
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  char S[5];
  scanf("%s",S);
  int i;
  for(i=0;i<3;i++){
    if(S[i] == S[i+1]){
      puts("Bad");
      return 0;
    }
  }
  puts("Good");
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	if (n<1200) printf("ABC\n");
	else if (n<2800) printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  if(a<=b){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
}

Measured memory_bytes: 3636
# Square869120Contest #4 B - Buildings are Colorful!　
# 全探探索　ver

import sys

N, K = map(int, sys.stdin.readline().strip().split())
a = list(map(int, sys.stdin.readline().strip().split()))

ans = float('inf')
for i in range(2 ** (N - 1)):
    bit = [(i >> j) & 1 for j in range(N - 1)]  # 左から2番目以降で見えるようにするビルを選択

    can_see = 0
    cost = 0
    height = a[0]
    for j, b in enumerate(bit):
        if (b == 1) & (height >= a[j + 1]):
            cost += height - a[j + 1] + 1
            height = height + 1
            can_see += 1
        elif (b == 1):
            height = a[j + 1]
            can_see += 1
        elif height < a[j + 1]:
            can_see += 1
            height = a[j + 1]

    if can_see >= K - 1:
        ans = min(ans, cost)

print(ans)







Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

bool dfs(vector<vector<int>> &g, int now, int goal, int prev, vector<int> &route) {
    route.push_back(now);
    if (now == goal) return true;

    for (int to : g[now]) {
        if (to == prev) continue;
        bool ok = dfs(g, to, goal, now, route);
        if (ok) return true;
    }

    route.pop_back();
    return false;
}

P make_edge(int a, int b) {
    if (a < b) return P(a, b);
    return P(b, a);
}

ll calc(int m, vector<vector<P>> &use_edges_p, int i) {
//    vector<P> use_edges;
    set<P> use_edges;
    rep(j, m) {
        bool use = (i >> j) & 1;
        if (!use) continue;

        for (P p : use_edges_p[j]) {
            use_edges.insert(p);
        }
    }
//    sort(use_edges.begin(), use_edges.end());
//    use_edges.erase(unique(use_edges.begin(), use_edges.end()), use_edges.end());
    return use_edges.size();
}

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

    vector<P> v(n - 1);
    for (P &p : v) cin >> p.first >> p.second, p.first--, p.second--;

    for (P p : v) if (p.first > p.second) swap(p.first, p.second);

    vector<vector<int>> g(n);
    for (P p : v) g[p.first].push_back(p.second);
    for (P p : v) g[p.second].push_back(p.first);

    int m;
    cin >> m;
    vector<P> u(m);
    for (P &p : u) cin >> p.first >> p.second, p.first--, p.second--;


    vector<vector<int>> use_edges(m);
    rep(i, m) dfs(g, u[i].first, u[i].second, -1, use_edges[i]);

    vector<vector<P>> use_edges_p(m);
    rep(i, m) {
        rep(j, use_edges[i].size() - 1) {
            use_edges_p[i].push_back(make_edge(use_edges[i][j], use_edges[i][j + 1]));
        }
    }

    ll ans = 0;
    rep(i, 1 << m) {
        int method = __builtin_popcount(i) % 2;
        if (method == 0) {
            // またはを引く
            ll k = calc(m, use_edges_p, i);
            ll now = ((1ll << k) - 1) * (1ll << (n - 1 - k));
            ans -= now;
        } else {
            // またはを足す
            ll k = calc(m, use_edges_p, i);
            ll now = ((1ll << k) - 1) * (1ll << (n - 1 - k));
            ans += now;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	long  h[100000];
		int a[100000];
	int d, e,l = 0;

	for (int i = 0; i < N; i++) {
		cin >> h[i];
		a[i] = 1;
	}

	for (int i = 0; i < M; i++) {
		cin >> d >> e;
		if (h[d - 1] > h[e - 1] ) {
			if (a[e - 1] != 0) {
				a[e - 1] = 0;
			}
		}if(h[d - 1] < h[e - 1]){
				if (a[d-1] != 0) {
					a[d-1] = 0;
				}
			
			}

		if (h[d - 1] == h[e - 1]) {
			a[d - 1] = 0;
			a[e - 1] = 0;
		}

		}

	for (int j = 0; j < N; j++) {
		l = l + a[j];

	}

	cout << l;

}

Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  pll p[n];
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    p[i].second=2*(x-y)+1;
    p[i].first=2*(x+y)-1;
  }
  sort(p,p+n);
  ll ans=0,t=-longinf;
  rep(i,n){
    if(t<p[i].second){
      ans++;
      t=p[i].first;
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1792
out = []

def out.higher?(v)
  return true if self.size < 3
  self.each do |h|
    return true if v > h
  end
  return false
end

def out.push(v)
  if self.size < 3
    self << v
    return
  end
  min = 10000
  min_i = 3
  self.each_with_index do |h, i|
    min, min_i = h, i if min > h
  end
  self[min_i] = v
end

def out.puts_desc
  order = []
  3.times do
    max = 0
    max_i = 3
    self.each_with_index do |h, i|
      max, max_i = h, i if max < h
    end
    order << max
    self.delete_at(max_i)
  end
  order.each do |v|
    puts v
  end
end

10.times do |count|
  num = readline.to_i
  if out.higher? num
    out.push num
  end
end

out.puts_desc

Measured memory_bytes: 6100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

"""
Nが奇数個の場合、
    Aiに奇数の数字があったらNG
    0の数は1つだけ
    2^(N//2)通り

偶数個の場合
    Aiに偶数の数字があったらNG
    0は0個
    2^((N-1)/2)通り→2^(N//2)でOK

同じ数字は2個ある
"""

from collections import Counter
c = Counter(A)

def ng():
    print(0)
    exit()

# 奇数
if N%2 == 1:
    for k, v in c.items():
        if k % 2 == 1:
            ng()

        if k != 0:
            if v != 2:
                ng()

    if c[0] != 1:
            ng()

else:
    for k, v in c.items():
        if k % 2 == 0:
            ng()

        if k != 0:
            if v != 2:
                ng()

    if c[0] != 0:
            ng()

print( 2**(N//2) % MOD)


Measured memory_bytes: 14628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int N; cin >> N;

    vector<pair<ll, ll> > pairs(N);

    for (int i = 0; i < N; i++) {
        ll x, l;
        cin >> x >> l;
        pairs[i] = make_pair(x + l, x - l);
    }

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

    ll tail = -1000000000;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (pairs[i].second >= tail) {
            tail = pairs[i].first;
            cnt++;
        }
    }

    cout << cnt << '\n';
    return 0;

}



Measured memory_bytes: 1792