akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;




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

	int N; cin >> N;
	vector<int>v;
	multiset<int>rem;
	REP(i, (1 << N)) {
		int x; cin >> x;
		v.pb(x);
		rem.insert(x);
	}
	//print(*rem.end());
	auto itr = rem.end(); itr--;
	multiset<int>used;
	used.insert(*itr);
	rem.erase(itr);
	int cnt = 1;
	int c = 0;
	REP(i, N) {
		auto itr = used.end();
		itr--;
		vector<int>err;
		auto itr_rem = rem.end();
		REP(j, used.size()) {
			bool done = false;
			int irr;
			while (!done) {
				if (itr_rem == rem.begin()) {
					print("No"); return 0;
				}
				itr_rem--;
				if (*itr_rem < *itr) {
					//print(c); c++;
					//pe(*itr); print(*itr_rem);
					done = true;
					itr--;
					err.pb(*itr_rem);
				}
				else {
					if (itr_rem == rem.begin()) {
						print("No");
						return 0;
					}
				}
			}
		}
		
		
		//pe(i)print(err.size());
		
		for (auto x : err) {
			//rem.erase(x);
			auto itr2 = rem.find(x);
			rem.erase(itr2);
			used.insert(x);
		}
		//for (auto x : used)pe(x); cout << endl;
		//for (auto x : rem)pe(x); cout << endl; cout << endl;
	}
	print("Yes");
}

Measured memory_bytes: 14580
import sys

def initialize(N):
    i = 1
    while i < N:
        i *= 2
    return [0] * (2 * i - 1), i

def add(i, x, L, d):
    K = i + d - 1
    L[K] += x
    while K > 0:
        K = (K-1)//2
        L[K] += x

def getSum(s, t, index, l, r, L): 
    if r <= s or t <= l: return 0
    elif s <= l and r <= t: return L[index]
    else:
        sumL = getSum(s, t, 2 * index + 1, l, (l+r)//2, L)
        sumR = getSum(s, t, 2 * index + 2, (l+r)//2, r, L)
        return sumL + sumR

F = sys.stdin
N, Q = map(int, F.readline().strip("\n").split(" "))
SegTree, d = initialize(N)
for _ in range(Q):
    com, x, y = map(int, F.readline().strip("\n").split(" "))
    if com == 0: add(x-1, y, SegTree, d)
    elif com == 1:
        print(getSum(x-1, y, 0, 0, d, SegTree))


Measured memory_bytes: 10968
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int dist(int x, int y, int x2, int y2)
{
    return abs(x - x2) + abs(y - y2);
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, pair<int, int>>> info;
    while (n--)
    {
        int x, y, h;
        cin >> x >> y >> h;
        info.push_back({h, {x, y}});
    }
    sort(info.rbegin(), info.rend());
    /*
    for (int k = 0; k < info.size(); k++)
        cout<<info[k].second.first<<" "<<info[k].second.second<<" "<<info[k].first<<endl;
    return 0;
    */
    int ansx = -1, ansy = -1;
    int height;
    for (int i = 0; (i < 101) && (ansx == -1); i++)
    {
        for (int j = 0; (j < 101) && (ansx == -1); j++)
        {
            for (int k = 0; k < info.size(); k++)
            {
                if (k == 0)
                {
                    height = dist(i, j, info[k].second.first, info[k].second.second) + info[k].first;
                }
                else
                {
                    if (info[k].first != 0)
                    {
                        if (height != dist(i, j, info[k].second.first, info[k].second.second) + info[k].first)
                            break;
                    }
                    else
                    {
                        if (height > dist(i, j, info[k].second.first, info[k].second.second))
                            break;
                    }
                }
                if (k == info.size() - 1)
                {
                    ansx = i;
                    ansy = j;
                }
            }
        }
    }
    cout << ansx << " " << ansy << " " << height << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, k) = input_tuple();
    let c = n * (n - 1) / 2 - (n - 1);
    if k > c {
        println!("-1");
        return;
    }
    println!("{}", n - 1 + c - k);
    for i in 2..(n+1) {
        println!("1 {}", i);
    }
    let mut count = 0;
    for i in 2..n {
        for j in (i+1)..(n+1) {
            if count == c - k {
                break;
            }
            println!("{} {}", i, j);
            count += 1;
        }
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 21:16:53 2019

@author: yuta
"""

AB = list(map(int,input().split()))

def main(ab):
    a = ab[0]
    b = ab[1]
    if a == b:
        print(2*a)
    else:
        max_ab = max(ab)
        print(2*max_ab-1)
main(AB)

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
vector<int> a;

int main()
{
	IOS;
	cin >> n;
	a.resize(n);
	for (auto &i : a)
		cin >> i;
	sort(a.begin(),a.end());
	cout << a[n/2] - a[n/2-1] << endl;
	return 0;
}



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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int main() {
    int n = read(), k = read();
    printf("%d\n", n - k + 1);
    return 0;
}

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

int main() {
	ll n,max=0;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		
	}
	ll cnt=0;
	for(ll i=0;i<n-1;i++)
	{
		if(arr[i]<arr[i+1])
		cnt=0;
		else
		++cnt;
		if(cnt>max)
		max=cnt;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m, x;
    cin>>n>>m>>x;
    int c[n], a[n][m];
    for(int i=0; i<n; i++) {
        cin>>c[i];
        for(int j=0; j<m; j++) {
            cin>>a[i][j];
        }
    }
    int mn=1<<30;
    for(int i=0; i<(1<<n); i++) {
        int cost=0;
        int b[m];
        memset(b, 0, sizeof(b));
        for(int j=0; j<n; j++) {
            if((i>>j)&1) {
                cost+=c[j];
                for(int k=0; k<m; k++) {
                    b[k]+=a[j][k];
                }
            }
        }
        bool ok=1;
        for(int j=0; j<m; j++) {
            if(b[j]<x) ok=0;
        }
        if(ok) mn=min(mn, cost);
    }
    if(mn==(1<<30)) mn=-1;
    cout<<mn<<"\n";
    return 0;
}

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

int main()
{
    int N, K;
    int p[1000] = {};
    std::cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        std::cin >> p[i];
    }
    std::sort(p, p + N);
    int s = 0;
    for (int i = 0; i < K; ++i)
    {
        s += p[i];
    }
    std::cout << s;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	ld arr[n], ans = 0.0;
	fo(i, 0, n)
	cin >> arr[i];
	fo(i, 0, n)
	ans += 1 / arr[i];
	cout << fixed << setprecision(10) << 1 / ans;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;



int main() {

 
  string S;
  cin >> S;
  int cnt1=0, cnt0=0;

  REP(i, S.length()){
    if(S[i]=='0')cnt0++;
    else cnt1++;
  }

  cout << 2*min(cnt0, cnt1) << endl;
}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main(){
	long long s,n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		cout << "Case " << i+1 << ":\n";
		for(int k=0; k<10; k++){
			s = s*s;
			s /= 100;
			s %= 10000;
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

multiset<string> se;
string mast = "";
string manumst = "";
int manum = 0;

int main()
{
	string str;
	
	while( cin >> str, !cin.eof())
	{
		
		if( mast.size() < str.size() )
			mast = str;
		
		se.insert(str);
		if( se.count(str) > manum )
		{
			manum = se.count(str);
			manumst = str;
		}
	}
	
	cout << manumst << " " << mast << endl;
	
	
	return 0;
}

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

int main(int argc, char const* argv[]) {
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	printf("%d\n", max(A * B, C * D));
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    sort(ALL(s));
    if(s[1]== s[2] || s[0] != s[1] || s[2] != s[3]) ans = "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
l = []

def main(n):
  global l
  i = 1
  while True:
    tmp = i*(i+1)//2
    if tmp >= n:
      l.append(i)
      if n-i == 0:
        return l
      else:
        return main(n-i)
    i += 1
    
sys.setrecursionlimit(10000)
li = main(N)
for n in li:
  print(n)

Measured memory_bytes: 12732
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			q[i] = sc.nextInt();
		}

		System.out.println(Math.abs(searchCount(p) - searchCount(q)));
		sc.close();
	}

	public static int searchCount(int[] orderArr) {

		int len = orderArr.length;
		ArrayList<Integer> usedList = new ArrayList<Integer>();
		int count = 0;

		for (int i = 1; i <= len; i++) { // 桁数
			for (int j = 1; j <= len; j++) { // 注目している桁の値
				if ((orderArr[i - 1] > j) && (!usedList.contains(j))) {
					count += factorial(len - i);
				} else if (orderArr[i - 1] == j) {
					usedList.add(j); // 使った値を記録しておく
				}
			}
		}
		return count + 1;
	}

	public static int factorial(int n) {
		if (n == 0) {
			return 1;
		}
		return n * factorial(n - 1);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

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

    double l;
    cin>>l;
    printf("%.10f\n", (l * l * l) / 27.0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef tuple<pii,pii,int> T;
int M[51][51],dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
	int a,b,x,y,X,Y,i,j;
	for(;scanf("%d%d",&a,&b),a;){
		map<pair<pii,pii>,int>m;
		scanf("%d%d%d%d",&x,&y,&X,&Y);x--,y--,X--,Y--;
		for(j=0;j<b;j++)for(i=0;i<a;i++)scanf("%d",M[i]+j);
		queue<T>q;
		m[make_pair(make_pair(x,y),make_pair(X,Y))]=1;
		for(q.push(make_tuple(make_pair(x,y),make_pair(X,Y),0));!q.empty();){
			T z=q.front();q.pop();
			if(get<0>(z)==get<1>(z)){printf("%d\n",get<2>(z));goto OK;}
			if(get<2>(z)>=99)continue;
			for(i=0;i<4;i++){
				pii c1=make_pair(get<0>(z).first+dx[i],get<0>(z).second+dy[i]);
				if(!(0<=c1.first&&c1.first<a&&0<=c1.second&&c1.second<b&&!M[c1.first][c1.second]))c1=get<0>(z);
				pii c2=make_pair(get<1>(z).first+dx[(i+2)%4],get<1>(z).second+dy[(i+2)%4]);
				if(!(0<=c2.first&&c2.first<a&&0<=c2.second&&c2.second<b&&!M[c2.first][c2.second]))c2=get<1>(z);
				if((c1!=get<0>(z)||c2!=get<1>(z))&&!m[make_pair(c1,c2)]){
					q.push(make_tuple(c1,c2,get<2>(z)+1));
					m[make_pair(c1,c2)]=1;
				}
			}
		}
		puts("NA");
		OK:;
	}
}

Measured memory_bytes: 12136
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int n, m, D;
    cin >> n >> m >> D;

    vector<vector<pair<int,int>>> pos(D);
    vector<vector<int>> A(n, vector<int>(m, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x;
            cin >> x;
            A[i][j] = x;
            pos[(x - 1) % D].emplace_back(i, j);
        }
    }

    auto cmp = [&](const pair<int,int>& l, const pair<int,int>& r) {
        return A[l.first][l.second] < A[r.first][r.second];
    };

    for (auto& V : pos) {
        sort(V.begin(), V.end(), cmp);
    }

    vector<vector<long long>> dis(D);

    for (int i = 0; i < D; ++i) {
        auto& P = pos[i];
        int n = P.size();
        auto& R = dis[i];
        for (int j = 0; j < n; ++j) {
            int d = 0;
            if (j - 1 >= 0) {
                d = abs(P[j].first - P[j - 1].first) + abs(P[j].second - P[j - 1].second);
                d += R.back();
            }
            // cout << i << " " << j << " " << d << endl;
            R.push_back(d);
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;

        int d = (l - 1) % D;
        l = (l - 1) / D;
        r = (r - 1) / D;
        // cout << d << " " << l << " " << r << endl;
        cout << dis[d][r] - dis[d][l] << '\n';            
    }

    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int MX = 100005;
 
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  int ans = 0;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  rep(is, 1<<h)rep(js,1<<w){
    int cnt = 0;
    rep(i,h)rep(j,w){
      if(is>>i&1) continue;
      if(js>>j&1) continue;
      if(s[i][j] == '#') cnt++;
    }
    if(cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)
#define sz(v) v.size()
#define pb(e) push_back(e)

using namespace std;

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

void shuffle ( vector<int> &v, int k )
{
	vector<int> a(v);
	
	int vlen = sz(v);

	rep (i, k)
	{
		v[vlen-k+i] = a[i];
	}

	rep2 (i, k, vlen)
	{
		v[i-k] = a[i];
	}
}

void shuffle ( vector<int> &v )
{
	vector<int> a(v);

	int vlen_half = sz(v) / 2;

	rep (i, vlen_half)
	{
		v[i*2] = a[i];
		v[i*2+1] = a[vlen_half+i];
	}
}

int main ( void )
{
	int n;

	while (cin >> n)
	{
		vector<int> v(2*n);
		int m;

		cin >> m;

		rep (i, 2*n) { v[i] = i + 1; }

		rep (i, m)
		{
			int k;

			cin >> k;

			if (k)
			{
				shuffle(v, k);
			}
			else
			{
				shuffle(v);
			}
		}

		rep (i, 2*n)
		{
			cout << v[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)
		cout << k;
	else if (k <= (a + b))
		cout << a;
	else cout << a - (k - a - b);
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    ll k;
    cin >> s >> k;
    string t = s+s;
    ll count = 1;
    ll ans = 0;
    ll l,r;
    l = r = 0;
    if(s[0] == s[s.size()-1]){
        while(s[0] == s[r]){
            r++;
        }
        while(s[s.size()-1] == s[s.size()-1-l]){
            l++;
        }
    }

    if(r == l && r == s.size()){
        cout << r*k/2 << endl;
    }else{
        //cout << r << l << endl;
        for(int i = r;i < s.size()-l-1;i++){
            if(s[i] == s[i+1])count++;
            else{
                ans += count/2;
                count = 1;
            }
        }
        ans += count/2;
        ans *= k;
        //cout << ans << endl;
        ans += (r+l)/2*(k-1) + r/2 + l/2;
        cout << ans << endl;
    }
    //cin >> k;  
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
  
{
int a,b,c,i;
  
  scanf("%d",&a);
  scanf("%d",&b);
  c=b-1;
  for(i=1;i<a;i++)
    b=b*c;
  
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ll ret=(ar+(br-ar)%b*moddiv(1,a,b)%b*a)%(a*b);
  return ret;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1+val0*val1;
        ll ans1=garner2(val0,val1,0,1)-1+val0*val1;
        ans0%=val0*val1;
        ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


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

Measured memory_bytes: 7056
#include <iostream>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

int main(){
    long double a,b,x;
    long double PI = acos(-1);
    cin >> a >> b >> x;
    long double ans;
    if(a*a*b/2 < x){
        ans = atan( (a*a*b-x)*2/(a*a*a) );
    }else{
        ans = atan( (a*b*b) / (2*x));
    }

    cout << fixed << setprecision(10) << ans * 180.0 / PI << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe";
	}	else {
		cout << "safe";
	}
}


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

int n;
vector<int> v;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    v.resize(n);
    vector<int> dp(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        dp[i] = 0;
        if(i){
            dp[i] = dp[i-1]+abs(v[i-1]-v[i]);
        }
        if(i > 1){
            dp[i] = min(dp[i], dp[i-2]+abs(v[i-2]-v[i]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
k, q = map(int, input().split())
d = list(map(int, input().split()))
for i in range(q):
    n, x, m = map(int, input().split())
    d2 = [d[i] % m for i in range(k)]
    sum_d = [0] * (k + 1)
    count_d = [0] * (k + 1)
    for i in range(k):
        sum_d[i + 1] = sum_d[i] + d2[i]
        if d2[i] == 0:
            count_d[i + 1] = count_d[i] + 1
        else:
            count_d[i + 1] = count_d[i]
    a = (n - 1) // k
    b = (n - 1) % k
    c = (x + sum_d[k] * a + sum_d[b]) // m - (x // m)
    print(n - 1 - c - count_d[k] * a - count_d[b])

Measured memory_bytes: 83932
#include <iostream>
#include <cstring>
#define MAX_N 2246912

using namespace std;

int N, num_prime[MAX_N + 1];
bool is_prime[MAX_N + 1];

void Init()
{
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = is_prime[1] = false;
  int cnt = 0;
  for (int i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) {
      cnt++;
      for (int j = i * 2; j <= MAX_N; j += i) {
        is_prime[j] = false;
      }
    }

    num_prime[i] = cnt;
  }
}

int main()
{

  Init();

  while (cin >> N && N) {
    cout << num_prime[2 * N] - num_prime[N] << endl;
  }

}

Measured memory_bytes: 11000
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a, a+5, greater<int>());
	cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int v1[27],v2[27];
int main() {
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++)
        v2[s[i]-'a'+1]++;
    int mmax=0,ss=0;
    for(int i=0;i<n;i++){
        v1[s[i]-'a'+1]++;
        v2[s[i]-'a'+1]--;
        if(v1[s[i]-'a'+1]==1&&v2[s[i]-'a'+1]>0)
            ss++;
        if(v2[s[i]-'a'+1]==0&&v1[s[i]-'a'+1]>1)
            ss--;
        mmax=ss>mmax?ss:mmax;
    }
    cout<<mmax<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		HashMap<Integer,Integer> hs=new HashMap<>();
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			if(!hs.containsKey(a)){
				hs.put(a, 1);
			}else {
				hs.put(a, hs.get(a)+1);
			}
		}
		int ans=0;
		for(Integer key:hs.keySet()) {
			int num=hs.get(key);
			if(key==num||num==0){
			}else if(num>key) {
				ans+=num-key;
			}else {
				ans+=num;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 63408
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, m; cin >> n >> m;
  vector <int> g[n + 1];
  vector <int> h(n + 1);
  for(int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  while(m--) {
    int u, v; read(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    bool okay = 1;
    for(auto x : g[i]) {
      if(h[i] <= h[x]) okay = 0;
    }
    ans += okay;
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 8776
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N, M;
    cin >> N;

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

    cin >> M;
    vector<string> t(M);
    for(int i = 0; i < M; i++){
        cin >> t[i];
    }

    ll ans = 0;
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        string c = s[i];
        cnt = 0;
        for(int j = 0; j < N; j++){
            if(c == s[j]) cnt++;
        }

        for(int j = 0; j < M; j++){
            if(c == t[j]) cnt--;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;



}

Measured memory_bytes: 256
#dame datta....
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = sorted(A)
    a = Counter(A)
    l = [0] * (10**6+1)
    v = [0] * (10**6+1)
    for i in B:
        if v[i] == 1 or l[i] == 1:
            continue
        else:
            v[i] = 1
        t = 2*i
        while t < 10**6 + 1:
            l[t] = 1
            t += i
    r = 0
    for i in A:
        if l[i] == 0 and a[i] == 1:
            r += 1
    return r
print(main())


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

int main() {
  long long w, h;
  cin >> h >> w;
  long long ans = 0;
  if (h == 1 || w == 1) {
    ans = 1;
  }
  else {
    ans = h * w;
    ans = (ans + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3544
// In the name of Allah 
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9+7, MAX = 2e5+5;

long long n, a, b;
			
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	cin >> n >> a >> b;
	if (n==1 && a!=b) return cout << 0 << endl, 0;
	if (a > b) return cout << 0 << endl, 0;
	if (a == b) return cout << 1 << endl, 0;
	cout << b*n-b+a - (a*n-a+b)+1 << endl;
	return 0;
}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  int H, W, M, ans = 0, phase = 0, Hi = 1, Wd = 1 ;
  cin >> H >> W >> M ;
  if(H <= W * M){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  

  return 0 ;
}  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    char c;
    cin >> c;
    cout << ++c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using namespace std;
int main(){
  long n,l,ii,minPos,minVal,val,sum;
  cin >> n >> l;
  minPos = -1;
  minVal = LONG_MAX;

  for(ii=0;ii<n;ii++){
    val = l+(ii+1) - 1;
    //cout << val <<  endl;
    if(abs(val) < minVal){
      minVal = abs(val);
      minPos = ii;

    }
  }
  sum = 0;
  for(ii=0;ii<n;ii++){
    if(ii != minPos){
      sum += l+(ii+1)-1;
    }
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int main(){
  cin >> n;
  m = 2;
  cout << n << ":";
  while(n >= m * m){
    if(n % m == 0){
      printf(" %lld",m);
      n /= m;
    }else{
      m++;
    }
  }
  printf(" %lld\n",n);
  return 0;
}


Measured memory_bytes: 3292
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  long long tmp=1,ans=0;
  for(int i=1;i<n;i++){
    if(s[i-1]!=s[i]){
      ans+=tmp*(tmp-1)/2;
      tmp=1;
    }else {
      tmp++;
    }
  }
  cout << ans+tmp*(tmp-1)/2 << endl;
}

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

int main(){
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  if(A+B>C+D){
    cout << "Left" << endl;
  }
  else if(A+B==C+D){
    cout << "Balanced"<<endl;
  }
  else cout << "Right"<<endl;
} 
  

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

bool primecheck(int);

int main(){

    int x;
    cin>>x;
    while(!primecheck(x)) x++;
    cout<<x<<endl;
    return 0;
}

bool primecheck(int x){
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

Measured memory_bytes: 256
A,P=map(int,input().split())
ans,maru,kakera = 0,0,0
def is_even(num):
    return num % 2 == 0
maru=(3*A)//2
if P==0:
    kakera=0
else:
    if is_even(A) == False and is_even(P) == False:
        kakera = P//2+1
    else:
        kakera = P//2
ans=maru+kakera
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vip in(m);
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			b--;c--;
			in[i]=pip(a,pii(b,c));
		}
		sort(all(in));
		UnionFind uf(n);
		rep(i,m){
			if(uf.root(in[i].second.first)==uf.root(0))uf.unionSet(in[i].second.first,in[i].second.second);
		}
		cout<<uf.size(0)<<endl;
	}
}

Measured memory_bytes: 1516
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
ll binom_two(ll n){
  if(n%2==0) return n/2*(n-1);
  else return (n-1)/2*n;
}
 
int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(),s.end());
  int h=0;
  vector<int> rec(N);
  rec[0]++;
  for(int i=1; i<N; i++){
    if(s[i]!=s[i-1]){
      h++;
      rec[h]++;
    }
    else rec[h]++;
  }
  ll ans=0;
  for(int i=0; i<=h; i++){
    ans+=binom_two(rec[i]);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 7680
n,a,b= map(int,input().split())

##nの各桁の和を求める

def digitSum(s):
    x1 = s//10**4
    x2 = (s-x1*10**4)//10**3
    x3 = (s-x2*10**3-x1*10**4)//10**2
    x4 = (s-x3*10**2-x2*10**3-x1*10**4)//10
    x5 = (s-x4*10-x3*10**2-x2*10**3-x1*10**4)
    # print(x1,x2,x3,x4,x5)
    return x1+x2+x3+x4+x5
    

count = 0
for i in range(1,n+1):
    u = digitSum(i)
    if ((u >= a) and (u<= b)):
        # print(u)
        count += i


print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

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

int n ;
int arr[500005] ;
string str ;

void solve()
{
    int x ;
    cin >> x ;
    if(x)
        cout << 0 ;
    else
        cout << 1 ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3612
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> dictionary = new HashSet<>();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			String command = sc.next();
			String word = sc.next();

			if (command.equals("insert")) {
				dictionary.add(word);
			} else if (command.equals("find")) {
				if (dictionary.contains(word)) {
					sb.append("yes\n");
				} else {
					sb.append("no\n");
				}
			}
		}
		sc.close();
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 232828
#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>

#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>

using namespace std;

int main(void) {
	string str = "";
	cin >> str;
	bool suki = false;
	if (str.length() < 4) cout << "No" << endl;
	else
	{
		string subst = str.substr(0, 4);
		if (subst == "YAKI") suki = true;
		if (suki) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,a,b,c,d;cin >> n >> a >> b >> c >> d;
	string s;cin >> s;
	a--;b--;c--;d--;
	auto check = [&](int l,int r){
		vector<int> dp(r-l+5);
		dp[0] = 1;
		for(int i = l;i <= r;i++){
			if(s[i] == '#')continue;
			if(i+1 - l < r-l+2)dp[i+1-l] |= dp[i-l];
			if(i+2 - l < r-l+2)dp[i+2-l] |=dp[i-l];
		}
		//rep(i,r-l+5)trace(i,dp[i],s[i+l]);
		return dp[r-l];
	};
	auto three = [&](int l,int r){
		int mxng = 0,mxok = 0;
		r++;
		for(int i = l,j;i < r; i = j){
			int k;
			for(k = i;k < r && s[k] == '#';k++);
			int lenng = k-i;
			mxng = max(mxng,lenng);
			if(i == r)break;
			for(j = k;j < r && s[j] != '#';j++);
			int lenok = j-k;
			mxok = max(mxok,lenok);
		}
		return(mxok >= 3 && mxng < 2); 
	};
	if(c < a || d < b){
		cout << "No" << endl;
		return 0;
	}
	//a - c,b - d
	if(d < c){
		swap(c,d);
		swap(a,b);
	}
	//b a c d
	
	if(b < a){
		if(three(a-1,c+1) && check(b,d))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	//a b c d
	else if(b < c){
		if(check(b,d)&& check(a,c))cout << "Yes" << endl;
		else cout << "No" << endl;

	}
	//a c b d
	else{
		if(check(a,c)&&check(b,d))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	
	return 0;
}


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

int main(){
	int n;
	while(cin >> n , n){
		long long int time[10010];
		long long int total[10010]={0};
		for(int i=0;i<n;i++){
			cin >> time[i];
		}
		sort(time,time+n);
		long long int ans = 0;
		for(int i=0;i<n;i++){
			total[i+1] = time[i] + total[i];
			ans += total[i];
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

vector< vector<int> > to = {
  {2},
  {2, 5},
  {0, 1, 3, 6},
  {2, 7},
  {5},
  {1, 4, 6, 9},
  {2, 5, 7, 10},
  {3, 6, 8, 11},
  {7},
  {5, 10},
  {6, 9, 11, 12},
  {7, 10},
  {10}
};

vector<int> ans = {0,1,2,3,4,5,6,7,8,9,10,11,0};

vector<int> x = {2,1,2,3,0,1,2,3,4,1,2,3,2};
vector<int> y = {0,1,1,1,2,2,2,2,2,3,3,3,4};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int p;
  while(cin >> p, ~p) {
    vector<int> pzl; pzl.push_back(p);
    rep(i, 12) cin >> p, pzl.push_back(p);
    map<vector<int>, int> d;
    queue< vector<int> > que;
    que.push(pzl);
    d[pzl] = 0;
    bool flag = false;
    while(!que.empty() && !flag) {
      auto v = que.front(); que.pop();
      int e = 0;
      rep(i, v.size()) if(v[i]) {
	e += abs(x[i]-x[v[i]]) + abs(y[i]-y[v[i]]);
      }
      if(e == 0) {
	cout << d[v] << endl;
	flag = true;
	break;
      }
      if(e + d[v] > 20) continue;
      rep(i, v.size()) {
	if(v[i]) continue;
	rep(j, to[i].size()) {
	  int c = d[v];
	  swap(v[i], v[to[i][j]]);
	  if(!d.count(v)) {
	    que.push(v);
	    d[v] = c + 1;
	  }
	  swap(v[i], v[to[i][j]]);
	}
      }
    }
    if(!flag) cout << "NA" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5468
n = gets.to_i
s = gets.split("").map(&:to_s)
alphabets = "abcdefghijklmnopqrstuvwxyz"
alphabets_ary = alphabets.split("").map(&:to_s)
alphabets_counts = []
alphabets_ary.each do |alphabet|
  alphabets_counts.push(s.count(alphabet))
end
options = 1
alphabets_counts.each do |alphabets_count|
  options *= (alphabets_count + 1)
end
options -= 1
puts options % (10 ** 9 + 7)

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

int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double n,x,y,d;
    cin>>n>>d;
    ll c=0;
    for(ll i=0;i<n;i++)
    {	cin>>x>>y;
    	double l=sqrt(pow(x,2)+pow(y,2));
    	if(l<=d)
        c++;
   }
   cout<<c<<endl;
   return 0;



}

Measured memory_bytes: 3760