akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

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

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct SegTree {
    int n;
    vll dat;

    SegTree(int _n) {
        int m = 1;
        while(m < _n) m *= 2;
        n = m;
        dat = vll(2 * n - 1, 0);
    }

    void update(int i, ll x) {
        i += n - 1;
        dat[i] += x;
        while(i > 0) {
            i = (i - 1) / 2;
            dat[i] = dat[i * 2 + 1] + dat[i * 2 + 2];
        }
    }

    ll query_sub(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        else {
            ll vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }

    ll query(int a, int b) {
        return query_sub(a, b, 0, 0, n);   // query for [a, b)
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    SegTree st(n);
    vll ans;
    for(ll i = 0; i < q; i++) {
        ll c, x, y;
        cin >> c >> x >> y;
        if(c == 0) {
            st.update(x - 1, y);
        }
        else {
            ans.push_back(st.query(x - 1, y));
        }
    }
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 5528
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
 
for num in b:
  for x in range(3):
    for y in range(3):
      if a[x][y] == num:
        a[x][y] = 0
 
if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int n, a[100];
    int i, b[20][10] = {0};
    char c[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%*c%c %d", &c[i], &a[i]);
        if (c[i] == 'S')
        {
            b[a[i]][1] = 1;
        }
        else if (c[i] == 'H')
        {
            b[a[i]][2] = 1;
        }
        else if (c[i] == 'C')
        {
            b[a[i]][3] = 1;
        }
        else if (c[i] == 'D')
        {
            b[a[i]][4] = 1;
        }
    }

    for (i = 1; i <= 13; i++)
    {
        if (b[i][1] == 0)
        {
            printf("S %d\n", i);
        }
    }
    for (i = 1; i <= 13; i++)
    {
        if (b[i][2] == 0)
        {
            printf("H %d\n", i);
        }
    }
    for (i = 1; i <= 13; i++)
    {
        if (b[i][3] == 0)
        {
            printf("C %d\n", i);
        }
    }
    for (i = 1; i <= 13; i++)
    {
        if (b[i][4] == 0)
        {
            printf("D %d\n", i);
        }
    }

    return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    double ans=0;
    rep(i,n){
        double x; string s;
        cin>>x>>s;
        if(s=="JPY") ans+=x;
        else ans+=x*380000.0;
    }
    cout<<ketasuu(10)<<ans<<endl;
}

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

void solve(long long N, long long M, std::vector<long long> P, std::vector<long long> Y){
	vector<pair<int, int>> ans;
	ans.reserve(M);
	vector<tuple<long long, long long, long long>> gogo;
	long long cnt[200000] = {};
	for(int i = 0; i < M; i++) {
		gogo.push_back(make_tuple(Y[i], P[i], i));
	}
	sort(gogo.begin(), gogo.end());
	for (int i = 0; i < M; ++i) {
		cnt[get<1>(gogo[i])]++;
		ans[get<2>(gogo[i])] = make_pair(get<1>(gogo[i]), cnt[get<1>(gogo[i])]);
	}
	for(int i = 0; i < M; i++) {
		cout << setfill('0') << right << setw(6) << ans[i].first;
		cout << setfill('0') << right << setw(6) << ans[i].second << endl;
	}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> P(m);
  vector<long long> Y(m);
  for(int i = 0; i < m; i++){
    cin >> P[i] >> Y[i];
  }
  solve(n, m, std::move(P), std::move(Y)); 
  return 0;
}

Measured memory_bytes: 8560
#include <stdio.h>
#include<math.h>
int main(void) {
double a,b,c,d;
double e;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
e=(a-c)*(a-c)+(b-d)*(b-d);
e=sqrt(e);
printf("%f",e);
  return 0;
}



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


int main() {
int n;
  cin >> n;
  vector<int> card(n);
  for(int i=0; i<n; ++i){
    cin >> card.at(i);
  }
  bool sinsa = true;
  for(int i =0; i<n; ++i){
    if(card.at(i)%2 == 0){
      if(card.at(i)%3!=0 && card.at(i)%5!=0) sinsa = false;
    }
  }
  if(sinsa) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
      




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int a,n,sum=0,x;
    cin>>a>>n;
    REP(i,n){
        cin>>x;
        sum+=x;
    }
    if(a<=sum) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n;
	cin >> n;
	cout << n * n * n;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;
#define LL long long 

int main()
{
    int n;
	cin>>n;
	LL int a;
	int num1=0,num2=0,num4=0;
	while(n--)
	{
	    cin>>a;
	    if (a%2==1)
	        num1++;
	    else if (a%4==0)
	        num4++;
	    else
	        num2++;
	}
	if ((num4>=num1)||(num2==0&&num1-1<=num4)) 
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
	return 0;
}
	    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    ll a,b,n;cin>>a>>b>>n;
    ll x = min(n, b-1);
    co(a*x/b-a*(x/b));
}

Measured memory_bytes: 3568
#include <iostream>
long long n, s, r;
int main() {
	std::cin>>n;
	r = n % 11;
	if(r==0) s = 0;
	else if(r<7) s = 1;
	else s = 2;
	std::cout << n/11*2 + s;
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int N;
    N = (int)S.size();
    
    string T1 = S.substr(0, N/2);
    reverse(T1.begin(), T1.end());
    if (S.substr(0, (N-1)/2) == T1 && S.substr((N+3)/2-1) == T1) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
nums = list(map(int, input().split()))
N = nums[0]
M = nums[1]
a = []
X = []
Y = []
Z = []
for i in range(N):
    a.append(input())
for i in range(N):
    b = []
    b = a[i].split()
    X.append(b[0])
    Y.append(b[1])
    Z.append(b[2])
x = []
y = []
z = []
lst1 = []
lst2 = []
lst3 = []
lst4 = []
lst5 = []
lst6 = []
lst7 = []
lst8 = []
x = list(map(int, X))
y = list(map(int, Y))
z = list(map(int, Z))
goukeiseiseisei = 0
for i in range(N):
    lst1.append(x[i]+y[i]+z[i])
lst1 = sorted(lst1,reverse=True)
goukeiseiseisei = sum(lst1[:M])
goukeiseiseifu = 0
for i in range(N):
    lst2.append(x[i]+y[i]-z[i])
lst2 = sorted(lst2,reverse=True)
goukeiseiseifu = sum(lst2[:M])
goukeiseifusei = 0
for i in range(N):
    lst3.append(x[i]-y[i]+z[i])
lst3 = sorted(lst3,reverse=True)
goukeiseifusei = sum(lst3[:M])
goukeiseifufu = 0
for i in range(N):
    lst4.append(x[i]-y[i]-z[i])
lst4 = sorted(lst4,reverse=True)
goukeiseifufu = sum(lst4[:M])
goukeifuseisei = 0
for i in range(N):
    lst5.append(-x[i]+y[i]+z[i])
lst5 = sorted(lst5,reverse=True)
goukeifuseisei = sum(lst5[:M])
goukeifuseifu = 0
for i in range(N):
    lst6.append(-x[i]+y[i]-z[i])
lst6 = sorted(lst6,reverse=True)
goukeifuseifu = sum(lst6[:M])
goukeifufusei = 0
for i in range(N):
    lst7.append(-x[i]-y[i]+z[i])
lst7 = sorted(lst7,reverse=True)
goukeifufusei = sum(lst7[:M])
goukeifufufu = 0
for i in range(N):
    lst8.append(-x[i]-y[i]-z[i])
lst8 = sorted(lst8,reverse=True)
goukeifufufu = sum(lst8[:M])
print(max([goukeiseiseisei,goukeiseiseifu,goukeiseifusei,goukeiseifufu,goukeifuseisei,goukeifuseifu,goukeifufusei,goukeifufufu]))

Measured memory_bytes: 3816
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;
 
public class Main{
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        HashSet<String>set = new HashSet<>();
        for(int i = 1; i <= n; i++){
            String s = cin.next();
            String s2 = cin.next();
            if (s.equals("insert")){
                set.add(s2);
            }else{
                System.out.println(set.contains(s2)?"yes":"no");
            }
        }
    }
}


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

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

using namespace std;

int main(){
	int c[3][3];
	rep(i,3) rep(j,3) cin>>c[i][j];

	int a1=0,b1=c[0][0],b2=c[0][1],b3=c[0][2];
	int a2=c[1][0]-b1,a3=c[2][0]-b1;

	if(c[1][1]==a2+b2 && c[1][2]==a2+b3 && c[2][1]==a3+b2 && c[2][2]==a3+b3)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <queue>

using namespace std;

queue<pair<int, int> > q;
int dx[2][6] = {{ 0, 0, 1, -1,  1, 1}, { 0, 0, 1, -1, -1, -1}};
int dy[2][6] = {{-1, 1, 0,  0, -1, 1}, {-1, 1, 0,  0,  1, -1}};
int map[102][102];

int main() {
    int i;
    int w, h;
    int sum = 0;

    scanf("%d %d", &w, &h);
    for (i=0;i<102;i++) {
        int j;
        for (j=0;j<102;j++) {
            map[i][j] = 0;
        }
    }

    for (i=0;i<h;i++) {
        int j;
        for (j=0;j<w;j++) {
            scanf("%d", &map[i+1][j+1]);
        }
    }

    q.push(make_pair(0,0));

    while (!q.empty()) {
        pair<int, int> tmp = q.front();q.pop();
        int x = tmp.first;
        int y = tmp.second;

        if (map[y][x] == 1 || map[y][x] == 2) continue;
        if (map[y][x] == 0) {
            int k;
            map[y][x] = 2;
            for (k=0;k<6;k++) {
                int new_x = x + dx[(y+1)%2][k];
                int new_y = y + dy[(y+1)%2][k];
                if (new_x < 0 || new_y < 0 || new_x >= 102 || new_y >= 102) {
                    continue;
                }
                q.push(make_pair(new_x, new_y));
            }
        }
    }

    for (i=1;i<h+1;i++) {
        int j;
        for (j=1;j<w+1;j++) {
            int k;
            for (k=0;k<6;k++) {
                int new_x = j + dx[(i+1)%2][k];
                int new_y = i + dy[(i+1)%2][k];

                if (map[i][j] == 1 && map[new_y][new_x] == 2) sum++;
            }
        }
    }

    printf("%d\n", sum);
}

Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int A,B,C;
	cin >> A >> B >> C;
	cout << A * B / 2 << endl;

	return 0;
}

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

int main(){
    long long q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    long long qh = min(h, 2 * q);
    long long qhs = min(s, qh * 2);
    cout << min(qhs * n, n / 2 * d + n % 2 * qhs) << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,ans[20000][2];

signed main() {
    cin >> n;
    rep(i,n) ans[i][0] = (i+1)*20000, ans[i][1] = (n-i)*20000;
    rep(i,n) {
        int p;
        cin >> p;--p;
        ans[p][0] += i;
    }
    rep(i,n) cout << ans[i][0] << " ";cout << endl;
    rep(i,n) cout << ans[i][1] << " ";cout << endl;
}




Measured memory_bytes: 896
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int M = one.get(0);
		int D = one.get(1);
		int output = 0;
		for(int i = 1; i <= M; i++){
			for(int j = 22; j <= D; j++){
				int L = j / 10;
				int R = j % 10;
				if(L >= 2 && R >= 2 && L * R == i){
					output++;
				}
			}
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32676
N,M = gets.split(" ").map{|e| e.to_i}
tmp = gets.split(" ").map{|e| e.to_i}
min = tmp[0]
max = tmp[1]
(M-1).times do
  tmp = gets.split(" ").map{|e| e.to_i}
  if min < tmp[0]
    min = tmp[0]
  end
  if max > tmp[1]
    max = tmp[1]
  end
end
puts (min..max).to_a.size

Measured memory_bytes: 2684
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(){
    long long N,T;
    cin>>N>>T;
    int ans=0;
    int d;
    int t;
    cin>>d;
    for(int i=1;i<N;i++){
        cin>>t;
        if(t<d+T){
            ans+=t-d;
            d=t;
        }
        else{
            ans+=T;
            d=t;
        }
    }
    cout<<ans+T;
}


Measured memory_bytes: 256
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, = gi()
print(1000 * (n // 500) + ((n % 500) // 5) * 5)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int ans=2*n;
    for(int i=0;i<n;i++){
        int x=2*n;
        for(int j=0;i+j<n;j++){
            if(s[i+j]==t[j]){
                x--;
            }
            else{
                break;
            }
        }
        ans=min(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n), x, y;
    forn(i, n) cin >> a[i];
    forn(i, n) cin >> b[i];
    x = a, y = b;
    sort(all(a)), sort(all(b));
    int p = 0, q = 0;
    int cur = 0;
    do {
        bool ok1 = 1, ok2 = 1;
        forn(i, n) {
            if (x[i] != a[i]) {
                ok1 = 0;
                break;
            }
        }
        forn(i, n) {
            if (y[i] != a[i]) {
                ok2 = 0;
                break;
            }
        }
        if (ok1) {
            p = cur;
        }
        if (ok2) {
            q = cur;
        }
        cur++;
    } while (next_permutation(all(a)));
    cout << abs(p - q) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf INT_MIN

 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x))%mod;
        }
        x=((x)*(x))%mod;
        y=y/2;
    }
    return res;
}
    

  
int main(){

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

    ll s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";

   
    
  
    return 0;
   
 
  
 
    
 }

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>s(m), c(m);
	rep(i, m) {
		cin >> s[i] >> c[i];
	}
	rep(i, 1000) {
		vector<int>d(1, i % 10);
		bool flag = true;
		int keta = 1;
		int res = i/10;
		while (res > 0) {
			keta++;
			d.push_back(res % 10);
			res /= 10;
		}
		if (keta != n)continue;
		reverse(d.begin(), d.end());
		rep(j, m) {
			if (d[s[j]-1] != c[j])flag=false;
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,k,s; cin >> n >> k >> s;
    vector<int> a(n);
    if(s >= 3){
        rep(i,k) a[i] = s;
        FOR(i, k, n) a[i] = s-1;
    }
    else{
        rep(i,k) a[i] = s;
        FOR(i,k,n) a[i] = 3;
    }
    rep(i,n){
        printf("%d%c", a[i], i == n-1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 1664
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int A, P;

  sc.scan(A, P);

  P += (A * 3);
  writeln(P / 2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int a,b,c,k,flag=0;
	cin>>a>>b>>c>>k;
		while(b<=a)
		{
			b*=2;
			flag++;
		}
		while(c<=b)
		{
			c*=2;
			flag++;
		}
	if(flag<=k)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

int main(){
	int N,P;
	cin >> N >> P;
	int A[N];
	int k = 0;
	for(int i = 0; i < N; i ++){
		int x;
		cin >> x;
		A[i] = x%2;
		if(x%2 == 1){
			k++;
		}
	}

	ll result = 0;

	if(k==0){
		if(P==1){
			cout << 0 << endl;
			return 0;
		}else{
			result = pow(2,N);
			cout << result << endl;
			return 0;
		}
	}else{
		result = pow(2,N-1);
		cout << result << endl;
		return 0;
	}



}


Measured memory_bytes: 512
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	string s;
	cin >> s;
	if(s[0] >= 'a' && s[0] <= 'z'){
		cout<<"a"<<endl;
	}else{
		cout << "A" <<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int H,W,K;
char t[1001][1001];
int J[1001][1001];
int O[1001][1001];
int I[1001][1001];

int main(){
  while(cin>>H>>W>>K){
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
	cin>>t[i][j];
	J[i][j]=(t[i][j]=='J'?1:0)+J[i-1][j]+J[i][j-1]-J[i-1][j-1];
	O[i][j]=(t[i][j]=='O'?1:0)+O[i-1][j]+O[i][j-1]-O[i-1][j-1];
	I[i][j]=(t[i][j]=='I'?1:0)+I[i-1][j]+I[i][j-1]-I[i-1][j-1];
      }
    }
    for(int i=0;i<K;i++){
      int ay,ax,by,bx;
      cin>>ay>>ax>>by>>bx;
      cout<<J[by][bx]-J[ay-1][bx]-J[by][ax-1]+J[ay-1][ax-1]<<' ';
      cout<<O[by][bx]-O[ay-1][bx]-O[by][ax-1]+O[ay-1][ax-1]<<' ';
      cout<<I[by][bx]-I[ay-1][bx]-I[by][ax-1]+I[ay-1][ax-1]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 13876
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define inf 0x3f3f3f3f
#define MAXN 100001
using namespace std;
int n, m;
int uf[MAXN];
int v[MAXN];
int find(int x) {
  if(uf[x] != x) 
    uf[x] = find(uf[x]);
  return uf[x];
}
void bld(int x, int y) {
  int x_ = find(x);
  int y_ = find(y);
  if(x_==y_)
    return;
  uf[x_] = y_;
}
int main() {
  cin>>n>>m; 
  for(int i=1; i<=n; i++) {
    cin >> v[i];
    uf[i] = i;
  }
  for(int i=0; i<m; i++) {
    int x, y;
    cin >> x >> y; 
    bld(x,y);
  }
  int count = 0;
  for(int i=1; i<=n; i++) {
    if(find(i) == find(v[i])) count++; 
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
i = gets.split.map(&:to_i)
a = 0
ii = i.sort
count = 0

n.times do
  if i[a] != ii[a]
	count += 1
  end
  a += 1
end

if count == 0 || count == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
  char s[100];
  scanf("%s",s);
  for(int i=0;s[i]!='\0';i++){
    for(int j=i;s[j]!='\0';j++){
            if(s[i]=='C'&&s[j]=='F') {printf("Yes");return 0;}
        }
  }
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    string s;
    cin >> s;
    Int r, b;
    r = b = 0;
    for (Int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r++;
        }
        else {
            b++;
        }
    }
    dump(r > b ? "Yes" : "No");
    return 0;
}

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

const int MAXN = (int)2e5;

int a[MAXN];

int64_t solve(int n, int k) {
  std::sort(a, a + n);
  int64_t sum = 0;
  for (int i = 0; i < n - k; ++i) {
    sum += a[i];
  }
  return sum;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::cout << solve(n, k) << std::endl;
  return 0;
}


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

typedef long long ll;

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

    int n; cin>>n;
    string s;
    map<string, ll> mp;

    while (n--){
        cin>>s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto item : mp){
        //cout<<item.first<<" "<<item.second<<endl;
        ll res = item.second*(item.second - 1);
        res /= 2;
        //cout<<res<<endl;
        ans += res;
    }

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

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

int main() {
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];
  
  ll fix, ans;
  fix = a[0]; ans = 0;
  
  rep(i, n){
    if(fix >= a[i])
      ans += fix - a[i];
    else
      fix = a[i];
  }
  cout << ans << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    set<int> st;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << (st.size() == n ? "YES" : "NO") << "\n";

    return 0;
}


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

using namespace std;

#define pb push_back
#define mem(a) memset(a,0,sizeof(a))

typedef long long ll;
typedef pair<int,int> pii;

const int mn=2e5+5;

int n;
int a[mn];

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r;
	ll ans=0;
	int now=0;
	for(r=1;r<=n;r++){
		if ((now&a[r])==0) ans+=r-l+1,now^=a[r];//,printf("%d %d\n",l,r);
		else{
			now^=a[l++];
			r--;
			//printf("!%d %d\n",r,now);
		}
	}
	/*r--;
	while(l<=n) {
		//printf("!!!%d %d\n",l,r);
		ans+=r-l+1;
		l++;
	}*/
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
package main

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

var sc *bufio.Scanner

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

const INF = 10000000000

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, _ := nextInt(), nextInt()

	min := INF
	profit := -INF
	ans := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		min = minInt(min, a)
		switch {
		case a-min == profit:
			ans++
		case a-min > profit:
			profit = a - min
			ans = 1
		}
	}
	fmt.Println(ans)
}


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

#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;

int n;
string s;
ll dp[10005][2][100];

ll f(int i,int t,int md,int d) {
	if(i==n) return (md==0);
	if(dp[i][t][md]!=-1) return dp[i][t][md];
	ll ans = 0;
	int ub = t?(s[i]-'0'):9;
	for(int j=0;j<=ub;j++) {
		ans = (ans+f(i+1,t&(ub==j),(md+j)%d,d))%mod;
	}
	return dp[i][t][md] = (ans+mod)%mod;
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>s;
	n = s.length();
	//cout<<n<<endl;
	int d;
	cin>>d;
	memset(dp,-1,sizeof(dp));
	ll ans = f(0,1,0,d);
	ans = (ans-1);
	if(ans<0) ans+=mod;
	ans%=mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 16640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] array = new int[n][3];
        
        int max_i0 = 0;
        int max_i1 = 0;
        int max_idx = -1;
        for (int i = 0; i < n; i++) {
            array[i][0] = sc.nextInt();
            array[i][1] = sc.nextInt();
            array[i][2] = i;
            
            if (array[i][0] > max_i0) {
                max_i0 = array[i][0];
                max_i1 = array[i][1];
                max_idx = i;
                
                if (array[i][0] == max_i0 && array[i][1] >= max_i1) {
                    max_i0 = array[i][0];
                    max_i1 = array[i][1];
                    max_idx = i;
                }
            }
        }
        
        Arrays.sort(array, (a, b) -> Integer.compare(b[1], a[1]));
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (array[i][1] >= max_i0) {
                m -= array[i][1];
                count++;
                
                if (m <= 0) {
                    System.out.println(count);
                    return;
                }
            } else {
                break;
            }
        }
        
        count += (m+max_i0-1) / max_i0;
        System.out.println(count);
    }
}


Measured memory_bytes: 63468
local road={}
local rail={}
local size={}

local function init(n)
    for i=1,n do
        road[i]=i
        rail[i]=i
        size[i]=1
    end
end

local function root(x,list)
    return list[x]==x and x or root(list[x],list)
end

local function same(x,y,list)
    return root(x,list)==root(y,list)
end

local function unite(x,y,list)
    x=root(x,list)
    y=root(y,list)
    if x==y then
        return
    end
    if size[x]>size[y] then
        x,y=y,x
    end
    list[x]=y
    size[y]=size[y]+size[x]
end

local function getsize(x)
    return size[root(x,list)]
end

----------

local n,k,l=io.read("n","n","n")
init(n)

for i=1,k do
    local p,q=io.read("n","n")
    unite(p,q,road)
end

for i=1,l do
    local r,s=io.read("n","n")
    unite(r,s,rail)
end

local counter={}
for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    counter[key]=(counter[key] or 0)+1
end

for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    io.write(counter[key].." ")
end
print()

Measured memory_bytes: 24148
n=int(input())
h=[int(x) for x in input().split()]

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    h1=dp[i-1]+abs(h[i]-h[i-1])
    h2=dp[i-2]+abs(h[i]-h[i-2])
    dp[i]=min(h1,h2)
print(dp[n-1])


Measured memory_bytes: 13980
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int a,b;

int main(){
	cin >> a >> b;
	
	if(a > b){
		for(int i = 0; i < a; i++){
			cout << b;
		}
		cout << endl;
	}
	else{
		for(int i = 0; i < b; i++){
			cout << a;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
def solve():
  N = int(input())
  C = input()  # 'RWRRW...'
  # WR is bad
  # 1. exchange two
  # 2. flip one
  # RRRRWWWWWW
  # max(R) < min(W)
  W = []
  R = []
  for i, c in enumerate(C):
    if c == 'W':
      W.append(i)
    else:
      R.append(i)
  if not W or not R:
    return 0
  #print(W, R)
  for i in range(min(len(W), len(R))):
    if R[-(1+i)] < W[i]:
      return i
  return min(len(W), len(R))
print(solve())


Measured memory_bytes: 17384
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

struct UnionFind {
  vector<int> par;
  vector<ll> count;
  UnionFind(int N) : par(N), count(N) {
    for(int i = 0; i < N; ++i) {
      par[i] = i;
      count[i] = 1;
    }
  }
  int root(int x) {
    if(par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    auto rx = root(x);
    auto ry = root(y);
    if(rx == ry)
      return;
    par[rx] = ry;
    count[ry] += count[rx];
  }
  ll size(int x) { return count[root(x)]; }
  bool isSame(int x, int y) { return root(x) == root(y); }
};

int main() {
  ll N, M;
  cin >> N >> M;
  auto uf = UnionFind(N);
  vector<pair<int, int>> ab(M);
  for(int i = M - 1; i >= 0; --i) {
    cin >> ab[i].first >> ab[i].second;
  }
  vector<ll> anss(M + 1);
  anss[0] = N * (N - 1) / 2;
  int i = 1;
  for(auto v : ab) {
    auto a = v.first - 1;
    auto b = v.second - 1;
    if(uf.isSame(a, b)) {
      anss[i] = anss[i - 1];
    } else {
      anss[i] = anss[i - 1] - (uf.size(a) * uf.size(b));
    }
    uf.unite(a, b);
    i++;
  }
  for(int i = M - 1; i >= 0; --i) {
    cout << anss[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
n=int(input())
flag=1
ct,cx,cy=0,0,0
for i in range(n):
  t,x,y=map(int,input().split())
  if t-ct<abs(x-cx)+abs(y-cy) or (t+x+y)%2!=0:
    flag=0
print("Yes" if flag==1 else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef long long ll;
#define MAXA 200001
int main(){
    pair< ll, ll> A[MAXA];
    for(ll i=0; i<MAXA; i++){
        A[i].first = 0;
        A[i].second = 0;
    }
    ll H, W, D;
    cin >> H >> W >> D;
    ll x, y, tmp_A;
    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            cin >> tmp_A; 
            A[tmp_A].first = i;
            A[tmp_A].second = j;
        }
    }

    ll Q, tmp_L, tmp_R;
    cin >> Q;
    ll d[MAXA];
    for(ll i=1; i<=D; i++){
        d[i] = 0;
        ll E = (H*W+1)/D;
        for(ll j=1; j<=E; j++){
            d[i+j*D] = d[i+(j-1)*D] + abs(A[i+j*D].first-A[i+(j-1)*D].first) + abs(A[i+j*D].second - A[i+(j-1)*D].second);
        }
    }
    for(ll q=0; q<Q; q++){
        cin >> tmp_L >> tmp_R; 
        cout << d[tmp_R]-d[tmp_L] << endl;
    }

}


Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
typedef long double ld;
int compare_int(const void* a, const void* b) {
		return *(int*)a - *(int*)b;
}


int main() {
	int n, a[200005][2], i, max = 0, t=0;
	ll s = 0;
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i][1], &a[i][0]);
		s += a[i][1];
		if (max < a[i][0])max = a[i][0];
	}
	if (s > max) {printf("No"); return 0;}

	qsort(a, n, sizeof(a[0]), compare_int);
	for (i = 0; i < n; i++) {
		t += a[i][1];
		if (t > a[i][0]) {
			printf("No"); return 0;
		}
	}
	printf("Yes"); return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int w,h,x,y,r,flag=0;
  cin>>w>>h>>x>>y>>r;
  if(x+r>w || x-r<0 || y+r>h || y-r<0)flag=1;
  if(flag==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main() {
	int h,w;

	cin >> h >> w;

	vector<string> s;
	
	for (int i = 0; i < h; i++) {
		string str;
		cin >> str;
		s.push_back(str);
	}

	for (int j = 0; j < w + 2; j++) {
		cout << '#';
	}
	cout << endl;
	
	for (int i = 0; i < h; i++) {
		cout << '#' << s[i] << '#' << endl;
	}

	for (int j = 0; j < w + 2; j++) {
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
nums = [int(i) for i in input().split()]

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y):
    return x * y // gcd(x, y)

l = nums[0]
for num in nums:
    l = lcm(num, l)
l -= 1
ans = 0
for num in nums:
    ans += l % num
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int64_t ans(int64_t A ,int64_t B, int64_t N){
  if((B - A)%2 == 0){
    return (B-A)/2;
  }
  else if(A == 1 || B == N){
    return 1 + ans(A,B-1,N);
  }
  else if(A-1 < N-B){
    return A - 1 + ans(1,B - (A - 1),N);
  }
  else{
    return N - B + ans(A + N - B ,N,N);
  }
}
int main() {
  int64_t N,A,B;
  cin >> N >> A >> B;
  cout << int64_t(ans(A , B , N)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int n,m;
char ch[105];
int main(){
	scanf("%d",&n);scanf("%s",ch+1);m=strlen(ch+1);
	for(reg int i=1;i<=min(n,m);i++)putchar(ch[i]);
	if(m>n)puts("...");
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq as q
import math

def solve(N: int, M: int, A: "List[int]"):
    q.heapify(A)
    for _ in range(M):
        Max = q.heappop(A)
        q.heappush(A, math.ceil(Max/2))
    print(-sum(A))


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [-int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15484
#include<bits/stdc++.h>
#define For(i , j , k) for (LL i = (j) , _##end_ = (k) ; i <= _##end_ ; ++ i)
#define Fordown(i , j , k) for (LL i = (j) , _##end_ = (k) ; i >= _##end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define pb push_back
#define INF (0x3f3f3f3f)
#define Mod (1000000007)
#ifdef hany01
#define debug(...) fprLLf(stderr , __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;
typedef long long LL;

inline void file()
{
#ifdef hany01 
	freopen("a1.in" , "r" , stdin);
    freopen("a1.out" , "w" , stdout);
#endif
}

char c_;
LL _ , __;
inline LL read()
{
    for(_=0,__=1,c_=getchar();!isdigit(c_);c_=getchar())if(c_=='-')__=-1;
    for(;isdigit(c_);c_=getchar())_=(_<<1)+(_<<3)+(c_^ 48);
    return _ * __;
}

LL A , B , C , D , E , F , Ans1 , Ans2 , suger , water;
double Maxnd;

int main()
{
	file();
    A = read();
    B = read();
    C = read();
    D = read();
    E = read();
    F = read();
    Maxnd = 0;
    For(i , 0 , 3000)
    {
        if (A * i * 100 > F)
            continue;
        For(j , 0 , 3000)
        {
            water = A * i * 100 + j * B * 100;
            if (water > F)
                break;
            For(k , 0 , 1500)
            {
                if (k * C > water / 100 * E || k * C + water > F)
                    break;
                For(l , 0 , 1500)
                {
                    suger = C * k + D * l;
                    if (suger > water / 100 * E || suger + water > F)
                        break;
                    if (Ans2 * (suger + water) <= Ans1 * suger)
                    {
                        Ans1 = suger + water;
                        Ans2 = suger;
                    }
                }
            }
        }
    }
    cout << Ans1 << ' ' << Ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <utility>
using namespace std;

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

int main(int argc, char const *argv[]) {
  int N,M;
  cin >> N;
  int T[N];
  REP(i,N){
    cin >> T[i];
  }
  cin >> M;
  int P[M];
  int X[M];
  REP(i,M){
    cin >> P[i] >> X[i];
  }
  long sum = 0;
  REP(i,N) sum += T[i];
  REP(i,M){
    cout << (sum - T[P[i]-1] + X[i]) << endl;
  }
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;

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

    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            if(a[i] < a[j]){
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if((i % 2) == 0){
            ans += a[i];
        } else{
            ans -= a[i];
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=200004;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli dp[MaxN];
	lli nel[MaxN];
	void solve(){
		lli N,M,i,j,p;
		cin>>N>>M;
		for(i=0;i<M;i++){
			cin>>p;
			nel[p]=1;
		}
		dp[0]=1;
		for(i=1;i<=N;i++){
			if(!nel[i-1])dp[i]+=dp[i-1];
			if(!nel[i-2]&&i>1)dp[i]+=dp[i-2];
			//cout<<dp[i]<<" "<<i<<"\n";
			dp[i]=dp[i]%mod;
		}
		cout<<dp[N];
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int main() {
    fast_io;

    int n, c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;

        c1 += (s == "AC");
        c2 += (s == "WA");
        c3 += (s == "TLE");
        c4 += (s == "RE");
    }

    cout << "AC x " << c1 << "\n" << "WA x " << c2 << "\n" << "TLE x " << c3 << "\n" << "RE x " << c4 << "\n";
}


Measured memory_bytes: 3656
'use strict'

const main = arg => {
  const str = arg.trim().split("\n")[0].split('');
  const n = str.length - 1;

  const dfs = (i, sum, order) => {
    if (i === n) return eval(order + arg[n]);

    sum += dfs(i + 1, sum, order + arg[i] + '+') + dfs(i + 1, sum, order + arg[i]);

    return sum;
  }

  const ans = dfs(0, 0, '');
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7756