akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
//	doin();
	ll n, m;
	cin >> n >> m;
	vpi a;
	getv(a, n);
	sort(all(a));
	ll ans = 0, i = 0;
	while(m) {
		ll t = min(m, a[i].second);
		m -= t;
		ans += t*a[i].first;
		i++;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 1792
//A Summ of Two Integers
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin>>n;
  if(n%2==0)
  {
    cout<<n/2-1<<endl;
  }
  else
  {
    cout<<(n-1)/2<<endl;
  }
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split())
A = []
b = []
for i in range(n):
    A += [map(int, raw_input().split())]
for i in range(m):
    b += [input()]
for i in range(n):
    C = 0
    for j in range(m):
        C += A[i][j] * b[j]
    print C

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

using namespace std;

int main(){
    int W, H, N;
    int x[100], y[100], a[100];
    int A[100][100];

    cin >> W >> H >> N;
    for (int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    for (int i = 0; i < W; i++){
        for (int j = 0; j < H; j++){
            A[i][j] = 0;
        }
    }

    for (int t = 0; t < N; t++){
        switch(a[t]){
        case 1:
            for(int i = 0; i < x[t]; i++){
                for (int j = 0; j < H; j++){
                A[i][j] = 1;
                }
            }
            break;
        case 2:
            for(int i = x[t]; i < W; i++){
                for (int j = 0; j < H; j++){
                A[i][j] = 1;
                }
            }
            break;
        case 3:
            for(int i = 0; i < W; i++){
                for (int j = 0; j < y[t]; j++){
                A[i][j] = 1;
                }
            }
            break;
        case 4:
            for(int i = 0; i < W; i++){
                for (int j = y[t]; j < H; j++){
                A[i][j] = 1;
                }
            }
            break;
        }
    }
    int num = 0;
    for (int i = 0; i < W; i++){
        for (int j = 0; j < H; j++){
            if(A[i][j] == 0) num += 1;
        }
    }
    cout << num << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);

  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  auto f = [](ll x, ll y) {
    return (x ? y : -y);
  };

  ll ans = 0;
  REP(i, 1 << 3) {
    vector<ll> cal;
    REP(j, n) {
      ll t = f(i & (1 << 0), a[j]) + f(i & (1 << 1), b[j]) + f(i & (1 << 2), c[j]);
      cal.push_back(t);
    }
    sort(cal.begin(), cal.end(), greater<ll>());
    ll sum = 0;
    REP(j, m) sum += cal[j];
    ans = max(ans, sum);
  }

  cout << ans << endl;
}


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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

string f(int a,int b,int c,int d,string op){
    return to_string(a) + op[0]
        +to_string(b) + op[1]
        +to_string(c) + op[2]
        +to_string(d) + "=7";
}
int main(){
    string x;
    cin>>x;
    int A=x[0]-'0';
    int B=x[1]-'0';
    int C=x[2]-'0';
    int D=x[3]-'0';
    
    string ret;
    cin>>A>>B>>C>>D;
    if(A+B+C+D==7)ret=f(A,B,C,D,"+++");
    if(A+B+C-D==7)ret=f(A,B,C,D,"++-");
    if(A+B-C+D==7)ret=f(A,B,C,D,"+-+");
    if(A+B-C-D==7)ret=f(A,B,C,D,"+--");
    if(A-B+C+D==7)ret=f(A,B,C,D,"-++");
    if(A-B+C-D==7)ret=f(A,B,C,D,"-+-");
    if(A-B-C+D==7)ret=f(A,B,C,D,"--+");
    if(A-B-C-D==7)ret=f(A,B,C,D,"---");

    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int d = sc.nextInt(), t = sc.nextInt(), s = sc.nextInt();
		if(t*s >= d) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32808
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

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

  if(k%2 == 0){
    cout << -1 << endl;
    return 0;
  }

  // for(ll a = 1; a <= k; a+=2){
  ll s = 7, i = 1;
  while(true){
    if(i > 10000000){
      i = -1;
      break;
    }
    // cout << "s = " << s << endl;
    s = s % k;
    if(s == 0){
      // cout << a << " : end" << endl;
      break;
    }else{
      
      s = s * 10 + 7;
      i++;
    }
  }

  cout << i << endl;
  // }



  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
bool c[27];
vector<int> a[27];

int main() { // E 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s, t; cin >> s >> t;
	rep(i, (int)s.size()) {
		c[s[i]-'a'] = true;
	}
	rep(i, (int)t.size()) {
		if (!c[t[i] - 'a']) {
			cout << -1 << '\n'; return 0;
		}
	}
	rep(i, (int)s.size()) {
		a[s[i] - 'a'].push_back(i);
	}
	int start = 0;
	ll ans = 0;

	rep(i, (int)t.size()) {
		auto next = lower_bound(a[(t[i] - 'a')].begin(), a[(t[i] - 'a')].end(), start);
		if (next == a[t[i] - 'a'].end()) {
			ans += (ll)((int)s.size() - start);
			ans += (ll)(a[t[i] - 'a'][0] + 1);
			start = a[t[i] - 'a'][0] + 1;
		}
		else {
			ans += (ll)(*next - start + 1);
			start = (*next + 1) % (int)s.size();
		}
	}
	cout << ans << '\n';



}


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

int main(){
    long long N,A,B;
    cin>>N>>A>>B;
    
    long long ans;

    ans=(B*(N-1)+A)-(A*(N-1)+B)+1;
    
    if(A>B)ans=0;
    if(A!=B&&N<2)ans=0;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;



int main() {
    while(true) {
        int n, l, r;
        cin>>n>>l>>r;
        if(n+l+r==0)break;
        vector<int> a(n);
        rep(i,n){
            cin>>a[i];
        }
        int ans=0;
        for(int ye=l;ye<=r;ye++){
            bool t1=true;
            rep(i,n){
                if(ye%a[i]==0){
                    if((i+1)%2){ans++;}
                    t1=false;
                    break;
                }
            }
            if(t1){
                if(n%2==0){
                    ans++;
                }
            }

        }
        cout<<ans<<endl;
    }


    return 0;
}



Measured memory_bytes: 3072
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean flag = false;
    for(int i=0;i<S.length();i++) {
      if(S.substring(i,i+1).equals("7")) flag = true;
    }
    
    if(flag) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35652
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
string s;
cin >> s;
for(int i=0;i<s.length();i+=2)
{
if(s[i]!='0'||s[i+1]!='U')
{
if(s[i]=='0') cout << 'w';
else if(s[i]=='2') cout << 'k';
else if(s[i]=='3') cout << 's';
else if(s[i]=='4') cout << 't';
else if(s[i]=='5') cout << 'n';
else if(s[i]=='6') cout << 'h';
else if(s[i]=='7') cout << 'm';
else if(s[i]=='8') cout << 'y';
else if(s[i]=='9') cout << 'r';
 
if(s[i+1]=='T') cout << 'a';
else if(s[i+1]=='L') cout << 'i'; 
else if(s[i+1]=='U') cout << 'u'; 
else if(s[i+1]=='R') cout << 'e'; 
else if(s[i+1]=='D') cout << 'o'; 
}else cout << "nn";
}
cout << endl;
return 0;
}

Measured memory_bytes: 1180
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		
		List<int>[] wall = new List<int>[W];
		for(int i=0;i<W;i++) wall[i] = new List<int>();
		for(int i=0;i<N;i++){
			wall[Y[i]].Add(X[i]);
		}
		for(int i=0;i<W;i++){
			wall[i].Sort();
			wall[i].Add(H);
		}
		
		
		int[] ptr = new int[W];
		int min = (H - 1) + 1;
		int r = 0, c = 0;
		int taka = 0;
		while(true){
//Console.WriteLine("{0} {1} {2}",r,c,taka);
			while(c < W && wall[c][ptr[c]] <= r) ptr[c]++;
			bool act = false;
			if(wall[c][ptr[c]] > r + 1){
				act = true;
				r++;
				taka++;
				min = Math.Min(min, taka + wall[c][ptr[c]] - r - 1 + 1);
			} else if(wall[c][ptr[c]] == r + 1){
				min = Math.Min(min, taka + wall[c][ptr[c]] - r - 1 + 1);
				break;
			}
			while(c + 1 < W && wall[c + 1][ptr[c + 1]] < r) ptr[c + 1]++;
			if(c + 1 < W && wall[c + 1][ptr[c + 1]] != r){
				c++;
				act = true;
			}
			if(!act) break;
		}
		Console.WriteLine(min);
	}
	
	int H,W;
	int N;
	int[] X,Y;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		N = d[2];
		X = new int[N];
		Y = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			X[i] = d[0] - 1; Y[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 39332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }

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

	vector<int> A(N, 0);
	int n = 0;

	repeat(i, N) {
		cin >> A[i];
		n++;
	}
	
	int result = 0;
	while(n > 0) {
		n -= K;
		result += 1;

		if (n == 0) break;
		n += 1;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int64_t k,ans,x;
  x=7;
  ans=-1;
  cin>>k;
  for(int i=1;i<=1000000;i++)
  {
    if(x%k==0)
    {
      ans=i;
      break;
    }
    x=(x*10+7)%k;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Tmax = 100010;
const int K = 200002;

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

    vector<int> s(Tmax), t(Tmax), c(Tmax), sm(K), tt(K);
    rep(i, n) {
        cin >> s[i] >> t[i] >> c[i];
    }

    for(int i = 1; i <= C; i++) {

        rep(j, K) {
            tt[j] = 0;
        }

        rep(j, n) {
            if(c[j] == i) {
                tt[s[j]*2-1]++;
                tt[t[j]*2]--;
            }
        }

        for(int j = 1; j < K; j++) {
            tt[j] += tt[j-1];
        }

        rep(j, K) {
            if(tt[j] > 0) {
                sm[j]++;
            }
        }
    }

    int mx = 0;
    rep(j, K) {
        if(mx < sm[j]) {
            mx = sm[j];
        }
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int mo=998244353;
const int FFTN=(1<<14);
const int N=FFTN+5;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int fac[N],inv[N];
int W[N],w[N],R[N];
int n,m,f[205][N];
int A[N],B[N];
ull p[N];
void init(){
	fac[0]=inv[0]=inv[1]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) inv[i]=1ll*inv[i-1]*inv[i]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
}
void FFTinit(){
	W[0]=1;
	W[1]=power(3,(mo-1)/FFTN);
	For(i,2,N-1) W[i]=1ll*W[i-1]*W[1]%mo;
}
int FFTinit(int n){
	int L=1;
	for (;L<=n;L<<=1);
	For(i,0,L-1) R[i]=(R[i>>1]>>1)|((i&1)?(L>>1):0);
	return L;
}
void DFT(int *a,int n){
	For(i,0,n-1) p[R[i]]=a[i];
	for (int d=1;d<n;d<<=1){
		int len=FFTN/(d<<1);
		for (int i=0,j=0;i<d;i++,j+=len) w[i]=W[j];
		for (int i=0;i<n;i+=(d<<1))
			for (int j=0;j<d;j++){
				int y=p[i+j+d]*w[j]%mo;
				p[i+j+d]=p[i+j]+mo-y;
				p[i+j]+=y;
			}
	}
	For(i,0,n-1) a[i]=p[i]%mo;
}
void IDFT(int *a,int n){
	For(i,0,n-1) p[R[i]]=a[i];
	for (int d=1;d<n;d<<=1){
		int len=FFTN/(d<<1);
		for (int i=0,j=FFTN;i<d;i++,j-=len) w[i]=W[j];
		for (int i=0;i<n;i+=(d<<1))
			for (int j=0;j<d;j++){
				int y=p[i+j+d]*w[j]%mo;
				p[i+j+d]=p[i+j]+mo-y;
				p[i+j]+=y;
			}
	}
	int val=power(n,mo-2);
	For(i,0,n-1) a[i]=p[i]*val%mo;
}
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	init(); FFTinit();
	scanf("%d%d",&n,&m);
	f[0][0]=1;
	int L=FFTinit(2*n);
	For(i,1,n) B[i]=inv[i+2];
	DFT(B,L);
	For(i,1,m){
		For(j,0,n) f[i][j]=1ll*(j*(j+1)/2+1)*f[i-1][j]%mo;
		int L=FFTinit(2*n);
		For(j,0,L-1) A[j]=0;
		For(j,0,n) A[j]=1ll*f[i-1][j]*inv[j]%mo;
		DFT(A,L);
		For(j,0,L-1) A[j]=1ll*A[j]*B[j]%mo;
		IDFT(A,L);
		For(j,0,n) f[i][j]=(f[i][j]+1ll*A[j]*fac[j+2])%mo;
	}
	int ans=0;
	For(i,0,n) ans=(ans+1ll*f[m][i]*C(n,i))%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 12288
// HE WHO TRAVELS THE FASTEST, TRAVELS ALONE
#include <bits/stdc++.h>
#include <stack>
using namespace std;
#define ORIGAMI ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define INF 1e18LL
#define ll long long int

vector<ll> adj[100000];
vector<bool> vis(100000,false);
ll mod = 998244353;

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

ll po(ll a,ll b)
{
	ll mod = 100;
	a%=mod;
	b%=mod;
	ll res=1;
	while(b>0)
	{
		if(b&1)
			res = (res * a) % mod;
		a = a * a % mod;
		b/=2;
	}
	return res;
}

void dfs(ll x)
{
	vis[x] = true;
	cout<<x<<" ";
	for(auto u:adj[x])
	{
		if(!vis[u])
			dfs(u);
	}
}

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

bool solve(ll x)
{
	ll s=1;
	for(int i=x/2;i>1;i--)
	{
		if(x%i==0)
		{
			s+=i;
		}
	}
	if(s==x)
		return true;
	return false;

}


int main()
{
	ORIGAMI
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ll n;
	cin>>n;
	ll fivehun = n/500;
	//cout<<fivehun<<endl;
	n -= (500 * (fivehun));
	//cout<<n<<endl;
	ll ans = fivehun * 1000 + ceil(n/ 5)*5;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     int n,i;
     cin>>n;
     int a[n];
     for(i=0;i<n;i++)	cin>>a[i];
     	sort(a,a+n);
     cout<<a[n/2]-a[(n/2)-1];
}




Measured memory_bytes: 640
N, M = map(int, input().split())
favorites = [list(map(int, input().split())) for _ in range(N)]

ans_dict = {}

for i in range(N):
    for j in range(1, favorites[i][0] + 1):
        food = favorites[i][j]
        if food in ans_dict:
            ans_dict[food] += 1
        else:
            ans_dict[food] = 1

count = 0
for k, v in ans_dict.items():
    if v == N:
        count += 1

print(count)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

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

  int a[20];
  int b[20], c[19];

  for (int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  for (int i = 0; i < n-1; i++){
    cin >> c[i];
  }

  int s = 0;
  s += b[a[0]];
  for (int i = 1; i < n; i++){
    s += b[a[i]];
    if (a[i] == a[i-1] + 1)
      s += c[a[i - 1]];
  }


  cout << s << endl;



  return 0;
}


Measured memory_bytes: 256
<?php
while(fscanf(STDIN, "%d %d", $n, $r)) {
  if(($n | $r) == 0) break;

  $card = array();
  for($i = 0; $i < $n; $i++) {
    $card[] = $n - $i;
  }

  for($i = 0; $i < $r; $i++) {
    fscanf(STDIN, "%d %d", $p, $c);
    
    $p--;
    
    $tmp = $card;
    $card = array();
    for($j = 0; $j < $n; $j++) {
      if($j < $p) $card[$j + $c] = $tmp[$j];
      else if($p <= $j && $j < $p + $c) $card[$j - $p] = $tmp[$j];
      else $card[$j] = $tmp[$j];
    }
  }

  print $card[0] . "\n";
}

Measured memory_bytes: 6636
#include<bits/stdc++.h>
using namespace std;
long long a[3];
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	for(int i=0;i<3;i++)
	{
		if(a[i]%2==0)
		{
			return puts("0"),0;
		}
	}
	cout<<a[0]*a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    H,W = inputMap()
    
    if H % 3 == 0 or W % 3 == 0:
        print(0)
        sys.exit()
        
    if H <= 2 and W <= 2:
        print(1)
        sys.exit()
        
    a = -(-W // 3)
    b = -(-H // 2)
    s1 = a * H
    s2 = (W-a) * b
    s3 = (W-a) * (H-b)
    ans1 = max(s1,s2,s3)-min(s1,s2,s3)
    
    a -= 1
    s1 = a * H
    s2 = (W-a) * b
    s3 = (W-a) * (H-b)
    ans2 = max(s1,s2,s3)-min(s1,s2,s3)
    
    a += 2
    s1 = a * H
    s2 = (W-a) * b
    s3 = (W-a) * (H-b)
    ans3 = max(s1,s2,s3)-min(s1,s2,s3)
    
    ans = min(ans1,ans2,ans3)
    
    tmp = W // 3
    tmp2 = (W - tmp) // 2
    s1 = tmp * H
    s2 = tmp2 * H
    s3 = (W - tmp- tmp2) * H
    ans1 = max(s1,s2,s3)-min(s1,s2,s3)
    
    tmp += 1
    s1 = tmp * H
    s2 = tmp2 * H
    s3 = (W - tmp- tmp2) * H
    ans2 = max(s1,s2,s3)-min(s1,s2,s3)
    
    tmp -= 2
    s1 = tmp * H
    s2 = tmp2 * H
    s3 = (W - tmp- tmp2) * H
    ans3 = max(s1,s2,s3)-min(s1,s2,s3)
    
    ansans = min(ans,ans1,ans2,ans3)
    
    a = -(-H // 3)
    b = -(-W // 2)
    s1 = a * W
    s2 = (H-a) * b
    s3 = (H-a) * (W-b)
    ans1 = max(s1,s2,s3)-min(s1,s2,s3)
    
    a -= 1
    s1 = a * W
    s2 = (H-a) * b
    s3 = (H-a) * (W-b)
    ans2 = max(s1,s2,s3)-min(s1,s2,s3)
    
    a += 2
    s1 = a * W
    s2 = (H-a) * b
    s3 = (H-a) * (W-b)
    ans3 = max(s1,s2,s3)-min(s1,s2,s3)
    
    ans = min(ans1,ans2,ans3)
    
    tmp = H // 3
    tmp2 = (H - tmp) // 2
    s1 = tmp * W
    s2 = tmp2 * W
    s3 = (H - tmp- tmp2) * W
    ans1 = max(s1,s2,s3)-min(s1,s2,s3)
    
    tmp += 1
    s1 = tmp * W
    s2 = tmp2 * W
    s3 = (H - tmp- tmp2) * W
    ans2 = max(s1,s2,s3)-min(s1,s2,s3)
    
    tmp -= 2
    s1 = tmp * W
    s2 = tmp2 * W
    s3 = (H - tmp- tmp2) * W
    ans3 = max(s1,s2,s3)-min(s1,s2,s3)
    
    print(min(ans,ans1,ans2,ans3,ansans))
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38768
n,k=map(int,input().split())
check = [0 for i in range(n)]

for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        check[a-1] += 1

ans = sum([c == 0 for c in check])
print(ans)

Measured memory_bytes: 9184
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;
void maxHeapify(int[] k, int i)
{
    auto l = 2 * i;
    auto r = 2 * i + 1;
    int largest;
    if (l < k.length && k[l] > k[i])
        largest = l;
    else
        largest = i;
    if (r < k.length && k[r] > k[largest])
        largest = r;
    if (largest != i)
    {
        k[i].swap(k[largest]);
        maxHeapify(k, largest);
    }
}
void main()
{
    auto c = readln.strip.to!int;
    auto k = [0] ~ readln.strip.split(' ').map!(to!int).array;
    for (auto i = c / 2; i >= 1; i--)
        maxHeapify(k, i);
    foreach (i; k.drop(1))
        write(" ", i);
    writeln;
}


Measured memory_bytes: 26064
#include <stdio.h>
 
 
int main(void)
{
   
  int H, W;
  int i, j;
   
  while( scanf("%d %d", &H, &W),  H || W ){
     
    for( i = 0; i < H; i++ ){
      for( j = 0; j < W; j++ ){
         
        if( ( i && j ) && ( i<(H-1) && j<(W-1) ) ) {printf(".");}
        else                                       {printf("#");}
      }
      puts("");
    }
     
    puts("");
  }
   
  return 0;    
  
}       
        



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

int main() {
  ll n;
  scanf("%lld", &n);
  for (int i = 9; i < 100011; i *= 9)
    money.push_back(i);
  for (int i = 6; i < 100011; i *= 6)
    money.push_back(i);
  money.push_back(1);
  sort(money.begin(), money.end());
  int dp[100001];
  fill(dp, dp + 100001, 100001);
  dp[0] = 0;
  for (int i = 0; i < money.size(); i++) {
    for (int j = money[i]; j < 100001; j++) {
      dp[j] = min(dp[j], dp[j - money[i]] + 1);
    }
  }
  printf("%d\n", dp[n]);
}


Measured memory_bytes: 640
sa = str(input())
sb = str(input())
sc = str(input())

sa_len = len(sa)
sb_len = len(sb)
sc_len = len(sc)

sa_turn = 1#順番をきめてる
sb_turn = 0
sc_turn = 0

sa_pl = 0#今何個目を参照しているか
sb_pl = 0
sc_pl = 0






while True:
    if sa_turn == 1:
        if sa_len == sa_pl:
            print("A")
            break
        elif sa[sa_pl] == "a":
            sa_pl += 1
        elif sa[sa_pl] == "b":
            sa_turn = 0
            sb_turn = 1
            sa_pl +=1
        elif sa[sa_pl] == "c":
            sa_turn = 0
            sc_turn = 1
            sa_pl +=1
    
    elif sb_turn == 1:
        if sb_len == sb_pl:
            print("B")
            break
        elif sb[sb_pl] == "b":
            sb_pl += 1
        elif sb[sb_pl] == "a":
            sb_turn = 0
            sa_turn = 1
            sb_pl +=1

        elif sb[sb_pl] == "c":
            sb_turn = 0
            sc_turn = 1
            sb_pl +=1
    
    elif sc_turn == 1:
        if sc_len == sc_pl:
            print("C")
            break
        elif sc[sc_pl] == "c":
            sc_pl += 1
        elif sc[sc_pl] == "b":
            sc_turn = 0
            sb_turn = 1
            sc_pl +=1
        elif sc[sc_pl] == "a":
            sc_turn = 0
            sa_turn = 1
            sc_pl +=1

Measured memory_bytes: 9096
#!/usr/bin/ruby
#encoding: utf-8

a,b,k = gets.split.map(&:to_i)

# a,a+1,a+2,...,a+k-1
c = []
(0..k-1).each do |i|
  if a+i <= b
    c.push(a+i)
  end
end

# b,b-1,b-2,....,b-k+1
d = []
(0..k-1).each do |i|
  if b-i >= a
    d.push(b-i)
  end
end

#p c
#p d
ansAry = (c+d).uniq.sort!
#p ansAry

(0..ansAry.size-1).each do |i|
  puts ansAry[i]
end

Measured memory_bytes: 3836
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    order = {x: i for i, x in enumerate(A)}
    r = []
    for i in range(len(A)):
        r.append(order[i+1]+1)
    return r


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    for i, r in enumerate(ret):
        if i == len(ret) - 1:
            print(r)
        else:
            print('{} '.format(r), end='')


Measured memory_bytes: 22540
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;
 
int main() {
  int N, Alice=0, Bob=0;
  int A[110]={0};
  cin >> N;
  for(int i=1; i<=N; ++i){
  cin >> A[i];
  }
  sort(A, A+110, std::greater<>());
  for(int i=0; i<N; i+=2){
    Alice += A[i];
  }
  for(int i=1; i<N; i+=2){
    Bob += A[i];
  }
  cout << Alice-Bob << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

//AtCoder Beginner Contest 158
//B - Count Balls
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		long A = Long.parseLong(sc.next());
		long B = Long.parseLong(sc.next());
		sc.close();
		long m = N % (A+B);
		long ans = (N / (A+B)) * A;

		if (m > 0) {
			ans += Math.min(m, A);
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e9+7
int main() {
	string s;
	int a, ans = INF;
	cin >> a >> s;
	vector<int> r(a), l(a);
	r[0] = s[0] == 'E';
	l[a-1] = s[a - 1] == 'W';
	for (int i=1;i<a;i++)
	{
		r[i] = r[i - 1] + (s[i] == 'E');
	}
	for (int i = a-2; i >= 0; i--) 
	{
		l[i] = l[i + 1] + (s[i] == 'W');
	}
	rep(i, a)
		ans = min(ans, a - r[i]-l[i]);

	cout << ans;

}


Measured memory_bytes: 2948
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int A,B,N;

int floor_function(int x){
    return floor((double)(A*x/B))-A*floor((double)(x/B));
}

signed main(){
    cin>>A>>B>>N;
    cout<<floor_function(min(B-1,N))<<endl;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> a;
    int ans[n];
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    int max = 0;
    int maxnum = 0;
    rep(i,n){
        if(max<a[i]){
            maxnum = i;
           	max = a[i];
        }
    }
    sort(a.begin(),a.end(),greater<int>());
    rep(i,n){
        if(i!=maxnum){
            ans[i] = a[0];
        }
        else{
            ans[i] =a[1];
        }
    }
    
  
    rep(i,n){
        cout << ans[i] << endl;
    }
    
    return 0;
}


















Measured memory_bytes: 3316
#include"bits/stdc++.h"
    using namespace std;
    using ll = long long ;
    ///PBDS Starting.......

    //#include <ext/pb_ds/assoc_container.hpp>
    //#include <ext/pb_ds/tree_policy.hpp>
    //using namespace __gnu_pbds;
    //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

    ///PBDS_SET
    ///Index of Value - .order_of_key()
    ///Value at Index - .find_by_order()
    ///typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set;
    ///typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset;

    /// PBDS closing......
    #define int long long
    #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
    #define endl '\n'
    ///............Author..................................................................
    ///........... :: .....................................................................
    ///...........(  NOBODY  )................................................................
    ///........... Bangabandhu Sheikh Mujibur Rahman Science and Technlogy University,Gopalganj
    ///........... ( N~76 ) ...................................................................
    ///........... No Copyright .....You can copy and paste my code without any permission.....
    /// !!!!!!!!!!!!!!!........................................................................
    #define pb push_back
    #define esp 0.000000001
    #define pi acos(-1)
    #define N 1000009
    #define ff first
    #define ss second
    #define all(x) x.begin(),x.end()
    /// Code Loading Please wait.............
    /// returning to N~76.
    /// Loading Finished.....................

    int32_t main()
    {
        FAST_IO;
       int n,m,ans=0;
       cin>>n>>m;
       for(int i=0;i<m;i++)
       {
           int x;
           cin>>x;
           ans+=x;
       }
       if(ans>n)cout<<-1<<endl;
       else cout<<n-ans<<endl;
        return 0;
    }



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <iterator>
#include <utility>
using namespace std;

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

int main(void) {
	int n,l,res=0;
	vector<int> v;
	cin >> n;
	REP(i, n) {
		cin >> l;
		v.push_back(l);
	}
	sort(v.begin(), v.end());
	REP(i, n-1) {
		FOR(j, i + 1, n) {
			auto it = lower_bound(v.begin(), v.end(), v[i] + v[j]) - 1;
			int ord=it-v.begin();
			res += max(ord-j,0);
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n;
    cin>>n;
    int three=n/3;
    int five=n/5,sum3=0,sum5=0,sum15=0;
    int threefive=n/15;
     sum3+=(three*(2*3+(three-1)*3))/2;
     sum5+=(five*(2*5+(five-1)*5))/2;
     sum15+=(threefive*(30+(threefive-1)*15))/2;
     int total=(n*(n+1))/2;
     cout<<total-(sum3+sum5-sum15);

}

signed main()
{
		noob
		// #ifndef ONLINE_JUDGE
  //    	freopen("input.txt","r",stdin);
  //    	freopen("output.txt","w",stdout);
  //    	#endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  cout << (a <= x && x <= a + b ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = readLine()?.split(" ")?.map { it.toLong() } ?: return

    val total = aList.sum()
    var sideA = 0L
    var result = Long.MAX_VALUE

    for (i in 0 until aList.lastIndex) { // 最後の要素はsideBが取る必要がある
        sideA += aList[i]
        val sideB = total - sideA
        result = Math.min(result, Math.abs(sideA - sideB))
    }

    println(result)
}

Measured memory_bytes: 82944
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,s,ans=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
		    int i1=s-i-j;
				if(i1<=k&&i1>=0){
					ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*input
1000000000000000000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll dp[64][4];
int main(){
	IOS;
	ll n;
	cin>>n;
	dp[61][0]=1;
	dp[61][1]=dp[61][2]=0;
	for(int d=60;d>=0;d--){
		bool OAO=(n&(1LL<<d));

		for(int i=0;i<=2;i++) for(int j=0;j<=2;j++){
			int tmp=i*2+OAO-j;
			if(tmp<0) continue;
			if(tmp>2) tmp=2;

			dp[d][tmp]+=dp[d+1][i];
			if(dp[d][tmp]>=MOD) dp[d][tmp]-=MOD;
		}
		// cout<<d<<' '<<dp[d][0]<<' '<<dp[d][1]<<' '<<dp[d][2]<<'\n';
	}
	cout<<(dp[0][0]+dp[0][1]+dp[0][2])%MOD<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    ll A, B;
    cin >> A >> B;
    A--;

    ll ans = 0LL;
    for (int i = 1; i < 50; i++) {
        // i bit目が立っているものがいくつあるか
        ll b = 1LL << i;
        ll c = 1LL << (i - 1);
        ll cnt = 0;
        cnt += B / b * c + max(0LL, B % b - c + 1);
        cnt -= A / b * c + max(0LL, A % b - c + 1);
        if (cnt % 2 == 1) ans += c;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k,ans;
int main()
{
	cin>>a>>b>>c>>k;
	ans+=min(a,k);
	k=max((long long)0,k-a);
	k=max((long long)0,k-b);
	ans-=k;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long INF = 100000000000L;

		int N = scn.nextInt(), M = scn.nextInt();
		int NN = (int) Math.pow(2, N);

		long[] DP = new long[NN];
		long[] cost = new long[M];
		int[] keys = new int[M];

		Arrays.fill(DP,INF);
		DP[0] = 0;

		for (int i = 0; i < M; i++) {
			int a = scn.nextInt();
			int b = scn.nextInt();

			cost[i] = a;
			int key = 0;
			for (int j = 0; j < b; j++) {
				int c = scn.nextInt() - 1;
				key += Math.pow(2, c);
			}
			keys[i] = key;
		}
		for (int i = 0; i < M; i++) {
			long c = cost[i];
			int box = keys[i];
			for (int j = 0; j < NN; j++) {
				int tob = j - (j&box);
				DP[j] = Math.min(DP[j], DP[tob] + c);
			}
		}

		System.out.println((DP[NN-1] > INF-1)?-1:DP[NN-1]);
	}

}


Measured memory_bytes: 34468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)
			throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
//		Scanner sc = new Scanner(System.in);
//		sc.useDelimiter(",|\\r\\n");
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		int chohoke = 0;
		int hisi = 0;
//		while (sc.hasNext()) {
//			int a = sc.nextInt();
//			int b = sc.nextInt();
//			int c = sc.nextInt();
//			if (a*a + b*b == c*c) chohoke++;
//			if (a == b) hisi++;
//		}
		for (String str; (str=br.readLine()) != null; /* Nothing to do */) {
			String[] data = str.split(",");
			int a = Integer.parseInt(data[0]);
			int b = Integer.parseInt(data[1]);
			int c = Integer.parseInt(data[2]);
			if (a*a + b*b == c*c) chohoke++;
			if (a == b) hisi++;
		}
		System.out.println(chohoke);
		System.out.println(hisi);
	}

}

Measured memory_bytes: 23908
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    bool ans;
    ans=(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]);
    cout << (ans ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

int op(int a, int b) {
	return max(a, b);
}
int e() {
	return -1ll;
}

int target;
bool f(int a) {
	return a < target;
}

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

signed main(){
	IOS();
	int N, Q;
	cin >> N >> Q;
	vector<int>a(N);
	cin >> a;
	segtree<int, op, e> seg(a);
	REP(i, Q) {
		int t;
		cin >> t;
		if(t == 2) {
			int l, r;
			cin >> l >> r;
			--l;
			out(seg.prod(l, r));
		} else {
			int x, v;
			cin >> x >> v;
			--x;
			if(t == 1) {
				seg.set(x, v);
			} else {
				target = v;
				out(seg.max_right<f>(x) + 1);
			}
		}
	}
}

Measured memory_bytes: 9028
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n,m = ma()

INF=10**15
x = [INF]*n
tree = [[] for i in range(n)]

for i in range(m):
    l,r,d=ma()
    tree[l-1].append((r-1,d))
    tree[r-1].append((l-1,-d))
f=True
def dfs(s):
    stack = collections.deque()
    stack.append((s,0))
    x[s]=0
    ret=True
    while stack:
        pre,c = stack.pop()
        for nex,d in tree[pre]:
            if x[nex]==INF:
                x[nex]=c+d
                stack.append((nex,c+d))
            else:
                if x[nex] !=c+d:
                    # print("pre,nex",pre,nex,x,c,d)
                    ret=False
    return ret
f=True
for i in range(n):
    if x[i]==INF:
        f&=dfs(i)
# print(x)
yn(f)


Measured memory_bytes: 106520
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

LL res;

inline LL go(LL s1, LL s2, LL s3){
    LL mn = min(s1, min(s2, s3));
    LL mx = max(s1, max(s2, s3));
    return mx - mn;
}

void solve(LL H, LL W){
    for(LL i=1; i<W; i++){
        LL s1 = i * H;
        LL w = W - i;
        LL h1 = H / 2;
        LL h2 = H - h1;
        LL w1 = w / 2;
        LL w2 = w - w1;
        res = min(res, go(s1, h1*w, h2*w));
        res = min(res, go(s1, H*w1, H*w2));
    }
}

int main(){
    LL H, W;
    cin >> H >> W;
    res = 1LL<<60;
    solve(H, W);
    solve(W, H);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256