akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
 
int main(){
	int q,c,x;
	cin >> q;
	set<int> se;
	while(q--){
		cin >> c >> x;
		if(c==1){
			cout << se.count(x) << endl;
		}else if(c==0){
			se.insert(x);
			cout << se.size() << endl;
		}else if(c==2){
			se.erase(x);
		}else if(c==3){
			int L = x;
			int R; cin >> R;
			auto it = se.lower_bound(L);
			auto end = se.upper_bound(R);
			for(;it!=end;it++){
				cout << (*it) << endl;
			}
		}
	}
}


Measured memory_bytes: 12448
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int dp[110000];

int DP(int n)
{
  if(n==0) return 0;
  if(dp[n]!=-1) return dp[n];
  
  int res = n;
  
  for(int i=1; i<=n; i*=6) res = min(res, DP(n-i)+1);
  for(int i=1; i<=n; i*=9) res = min(res, DP(n-i)+1);
  
  return dp[n] = res;
}

int main()
{
  int n;
  cin >> n;
  REP(i,110000) dp[i] = -1;
  cout << DP(n) << endl;
  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

int main(void){
    int N,cnt=0;
    cin>>N;
    VI p(N),cp(N);
    rep(i,N){
        cin>>p[i];
        cp[i]=p[i];
    }
    sort(cp.begin(),cp.end());
    rep(i,N){
        if(p[i]!=cp[i])cnt++;
    }
    if(cnt>2)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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 ll INF=1000000000000;

ll h,n;
ll a[1005],b[1005];
ll dp[10005];

void solve(){
    for(int i=0;i<h;i++) dp[i]=INF;
    for(int i=h;i>=0;i--){
        for(int j=0;j<n;j++){
            if(i==h||(i<h&&dp[i]<INF)){
                if(i-a[j]>0){
                    dp[i-a[j]]=min(dp[i-a[j]],dp[i]+b[j]);
                }else{
                    dp[0]=min(dp[0],dp[i]+b[j]);
                }
            }
        }
    }
    cout<<dp[0]<<endl;
}

int main(){
    cin>>h>>n;
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    solve();
}

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

int main() {
    int N;
    long long sum=0;
    long long A[300001];
    cin >> N;
    for (int i=0;i<3*N;i++) cin >> A[i];
    sort(A,A+3*N, greater<int>());
    for (int i=1;i<2*N;i+=2) sum += A[i];
    cout << sum << '\n';
}


Measured memory_bytes: 2560
a, b = map(int, raw_input().split())
towers = [0] * 1000
for i in range(999):
	towers[i + 1] = towers[i] + 1 + i
diffs = [0] * 1000
for i in reversed(range(999)):
	diffs[i] = towers[i + 1] - towers[i]
target_idx = diffs.index(b - a)
print towers[target_idx] - a




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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;

int ans;
bool visited[N];

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

    int a[n];
    map<int,int>m;

    rep(i,0,n)
    {
        cin>>a[i];
        m[a[i]]++;
    }

    
    sort(a,a+n);
    
        rep(i,0,n)
        {
            if(!visited[a[i]]&&m[a[i]]==1)
        {  // cout<<a[i]<<endl;
            ans++;}
            
            if(!visited[a[i]]){
            rep(j,1,1000001)
            {   
                if(a[i]*j>1000001)
                break;
                visited[a[i]*j]=true;
            }
            }
        }
        cout<<ans;
    
return 0;
}

Measured memory_bytes: 14628
n = int(input())

dp = [[0 for i in range(3)]]
for i in range(1,n+1):
    a,b,c = map(int, input().split())
    x = max(dp[i-1][1] + a, dp[i-1][2] + a)
    y = max(dp[i-1][2] + b, dp[i-1][0] + b)
    z = max(dp[i-1][0] + c, dp[i-1][1] + c)
    dp.append([x,y,z])
print(max(dp[n]))


Measured memory_bytes: 22752
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
const int nax = 2e5 + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int&a , int b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int sum = 15 ; 
for(int i = 0 ; i<5 ; i++){
	int k ; cin >> k ; 
	sum -=k;
}
	cout<<sum<<endl;

	
}

Measured memory_bytes: 3636
#include <stdio.h>
 
int main(void) {
	int a, b, c, temp;
	scanf("%d%d%d", &a, &b, &c);
	if (a>b) {
		temp=a;
		a=b;
		b=temp;
	} 
	if (b>c) {
		temp=b;
		b=c;
		c=temp;
	}
	if (a>b) {
		temp=a;
		a=b;
		b=temp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int A, B;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> A >> B;
    cout << "100 100" << endl;
    for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2){
				cout << '#';
			} else{
				if(j % 2 and A-- > 1) cout << '.';
				else cout << '#';
			}
		}
		cout << endl;
    }
    for(int i = 0; i < 50; i++){
		for(int j = 0; j < 100; j++){
			if(i % 2 == 0){
				cout << '.';
			} else{
				if(j % 2 and B-- > 1) cout << '#';
				else cout << '.';
			}
		}
		cout << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << (p / 2);
}
#endif


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int minv=numeric_limits<int>::max();
    for(int i=-100;i<=100;++i){
        int cost=0;
        rep(j,n)cost+=(int)pow(a[j]-i,2);
        chmin(minv,cost);
    }
    cout<<minv<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

class Node {
	int id;
	int jisu;
	int parent = -1;
	int[] childs = new int[0];
	int depth;

	public String getChildsStr() {
		StringJoiner sj = new StringJoiner(", ");
		for(int child : this.childs) {
			sj.add(String.valueOf(child));
		}

		return "[" + sj.toString() + "]";
	}
}

class Main {
	public static void main(String[] args) {

		int n = 0;
		Node[] nodes = null;

		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			n = Integer.parseInt(br.readLine());
			nodes = new Node[n];

			for (int i = 0; i < n; i++) {
				nodes[i] = new Node();
			}

			for (int i = 0; i < n; i++) {

				String[] infos = br.readLine().split(" ");

				int nowId = Integer.parseInt(infos[0]);
				Node now = nodes[nowId];

				now.id = nowId;
				now.jisu = Integer.parseInt(infos[1]);

				now.childs = new int[now.jisu];

				if (now.jisu == 0) continue;

				for (int j = 0; j < now.jisu; j++) {
					int child = Integer.parseInt(infos[2+j]);

					now.childs[j] = child;
					nodes[child].parent = now.id;
				}

			}

		} catch (IOException e) {
			e.printStackTrace();
		}

		Node root = null;
		for(Node node : nodes) {
			if (node.parent == -1) {
				root = node;
				break;
			}
		}
		root.depth = 0;

		setDepth(root, nodes);

		for(Node node : nodes) {
			String kind;
			if (node.parent == -1) {
				kind = "root";
			} else if (node.jisu == 0) {
				kind = "leaf";
			} else {
				kind = "internal node";
			}

			String info = String.format("node %d: parent = %d, depth = %d, %s, %s",
					node.id,
					node.parent,
					node.depth,
					kind,
					node.getChildsStr());

			System.out.println(info);

		}

	}

	private static void setDepth(Node node, Node[] nodes) {

		if (node.jisu == 0) return;

		for(int child : node.childs) {
			nodes[child].depth = node.depth + 1;
			setDepth(nodes[child], nodes);
		}
	}
}

Measured memory_bytes: 194388
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
csf = [tuple(map(int, readline().split())) for _ in range(n-1)]

for i in range(n):
    now = 0
    for c, s, f in csf[i::]:
        if now <= s:
            now = s
        else:
            if now % f == 0:
                pass
            else:
                now = (now // f + 1) * f
        now += c
    print(now)


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

int main(){
  int a, b;cin >> a >> b;
  string s; cin >> s;
  bool ok = true;
  int n = s.size();
  ok &= n == (a + b + 1);
  for(int i = 0; i < n; i++){
    if(i == a) ok &= s[i] == '-';
    else{
      int t = s[i] - '0';
      ok &= (t <= 9) && (t >= 0);
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}
  

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> input(n);
    for (int i = 0; i < n; i++)
        cin >> input[i];
    vector<long long> pref(n);
    pref[0] = input[0];
    for (int i = 1; i < n; i++)
        pref[i] = pref[i - 1] + input[i];
    long long answer = abs(pref[n - 1] - pref[0] - pref[0]);
    for (int i = 0; i < n - 1; i++){
        if (abs(pref[n - 1] - pref[i] - pref[i]) < answer)
            answer = abs(pref[n - 1] - pref[i] - pref[i]);
            //cout << pref[n - 1] - pref[i] << " " << pref[i] << endl;
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
    int n,flag=0;
    cin>>n;
    if(n>=1 && n<=9){
        cout<<"Yes"<<endl;
    }
    else{
        for(int i=9;i>=2;i--){
            if(n%i==0){
                if((n/i)>=1 && (n/i)<=9){
                    cout<<"Yes"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0){
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int S,h,m,s;
    scanf("%d",&S);
    
    h=S%3600;
    s=h%60;
    m=h/60;
    h=S/3600;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


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

int main(){
    ll n,m; cin >> n >> m;
    vl a(m); rep(i,m)cin >> a[i];
    ll sum = 0; rep(i,m)sum += a[i];
    n - sum >= 0 ? cout << n - sum << endl : cout << -1 << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  vector<int> mi,pr;
  rep(i,N) cin >> x[i];
  mi.push_back(0);
  pr.push_back(0);
  //0からの距離を格納
  rep(i,N){
    if(x[i] <= 0) mi.push_back(-x[i]);
    else pr.push_back(x[i]);
  } 
  sort(All(mi));
  sort(All(pr));
  int n = mi.size();
  int m = pr.size();
  int ans = INF * 2;//往復分
  //minus側でi個とって足りない分をplus側でとる
  rep(i,n) {
      int j=K-i;
      if(0<=j && j < m) chmin(ans,mi[i]*2 + pr[j]); 
  }
  //逆
  rep(i,m){
      int j=K-i;
      if(0<=j and j < n) chmin(ans,pr[i]*2 + mi[j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4288
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        ans += (k < ans ? k : ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Integer.parseInt(sc.next());
			y[i] = x[i];
		}
		Arrays.sort(y);
		int cl = y[n / 2 - 1];
		int cr = y[n / 2];
		for (int i = 0; i < n; i++) {
			if (x[i] <= cl)
				System.out.println(cr);
			else
				System.out.println(cl);
		}
	}
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (__builtin_popcount(n) == 1) {
    cout << "No" << "\n";
    return 0;
  }
  auto f = [&](int i) {
    return i;
  };
  auto g = [&](int i) {
    return i + n;
  };
  auto add = [&](int i, int j) {
    cout << i << " " << j << "\n";
  };
  cout << "Yes" << "\n";
  if (n % 4 == 3) {
    for (int i = 1; i < n; ++i) {
      add(f(i), f(i + 1));
      add(g(i), g(i + 1));
    }
    add(f(n), g(1));
  } else if (n % 4 == 1) {
    for (int i = 1; i < n - 2; ++i) {
      add(f(i), f(i + 1));
      add(g(i), g(i + 1));
    }
    add(f(n - 2), g(1));
    add(f(1), f(n - 1));
    add(f(n - 1), f(n));
    add(f(1), g(n));
    add(g(n), g(n - 1));
  } else if (n % 4 == 2) {
    for (int i = 1; i < n - 3; ++i) {
      add(f(i), f(i + 1));
      add(g(i), g(i + 1));
    }
    add(f(n - 3), g(1));
    add(f(1), f(n - 2));
    add(f(n - 2), f(n - 1));
    add(f(1), g(n - 1));
    add(g(n - 1), g(n - 2));
    add(g(n - 1), f(n));
    add(f(2), g(n));
  } else {
    int m = n - 2;
    for (int i = 1; i < m - 3; ++i) {
      add(f(i), f(i + 1));
      add(g(i), g(i + 1));
    }
    add(f(m - 3), g(1));
    add(f(1), f(m - 2));
    add(f(m - 2), f(m - 1));
    add(f(1), g(m - 1));
    add(g(m - 1), g(m - 2));
    add(g(m - 1), f(m));
    add(f(2), g(m));
    add(f(n), f(n - 1));
    add(f(n - 1), f(n ^ (n - 1)));
    add(f(n ^ (n - 1)), g(n));
    add(g(n), g(n - 1));
  }
  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10];
	for(int b=0;b<10;b++)
	cin>>a[b];
	for(int i=0;i<90000000;i++)sort(a,a+10);
	for(int c =9;c>=7;c--)
	cout<<a[c]<<endl;
	}

Measured memory_bytes: 3136
#include <iostream>

using namespace std;
long long f[3001][3001];
long long a[3001];
long long sum=0;
long long rec(long long l,long long r,long long turn)
{
    if(l>r)return 0;
    if(f[l][r]!=1<<30)return f[l][r];
    if(turn==1)
    {
        long long r1=a[l]+rec(l+1,r,1-turn);
        long long r2=a[r]+rec(l,r-1,1-turn);
        long long rf=max(r1,r2);
        f[l][r]=rf;
        return f[l][r];
    }
    else
    {
        long long r1=-a[l]+rec(l+1,r,1-turn);
        long long r2=-a[r]+rec(l,r-1,1-turn);
        long long rf=min(r1,r2);
        f[l][r]=rf;
        return f[l][r];
    }
}
int main()
{
    long long n;
    cin >> n;
    for(long long i=0;i<n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for(long long i=0;i<=3000;i++)
    {
        for(long long j=i;j<=3000;j++)
        {
            f[i][j]=1<<30;
        }
    }
    cout << rec(0,n-1,1);
    return 0;
}


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

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

    int UNNKO = A + B;
    int OSIRI = A - B;
    int OSIKKO = A * B;
    cout << max({UNNKO,OSIRI,OSIKKO}) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b <<  " " << c;
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <iostream>
#include <string>
 
using namespace std;
int main() {
    string inputA,inputB;
    cin >> inputA >> inputB;
    int a = stoi(inputA);
    int b = stoi(inputB);
    if(a <= b){
        cout << a;
    }else{
        cout << a-1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const LL INF = 1e9 + 10;
char st[105];

int main(){
	scanf("%s", st);
	int len = strlen(st);
	st[len - 8] = '\0';
	printf("%s\n", st);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,a;
    while(1){
        int c[10]={0};
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;++i){
            cin>>a;
            c[a]++;
        }
        for(int i=0;i<=9;++i){
            if(c[i]==0){
                cout<<"-"<<endl;
            }
            else{
                for(int j=0;j<c[i];++j){
                    cout<<"*";
                }
                cout<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3008
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Length % 2 == 1)
        {
            Console.WriteLine("No");
            return;
        }
        for (int i = 0; i < s.Length - 1; i += 2)
        {
            if (s[i] != 'h' || s[i + 1] != 'i')
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
   
using namespace std;
   
static const double PI = acos(-1.0);
   
class Vec2
{
public:
    Vec2( double _x, double _y ) : x(_x), y(_y) {}
   
    double length() const { return sqrt(x*x + y*y); }
    double arg() const {
        if ( length() == 0 ) return 0.0;
        return atan2(y, x);
    }
    Vec2 normalize() const {
        if ( length() == 0 ) return *this;
        return Vec2(x/length(), y/length());
    }
   
    Vec2 operator+( const Vec2& rhs ) const { return Vec2(x+rhs.x, y+rhs.y); }
    Vec2 operator-( const Vec2& rhs ) const { return Vec2(x-rhs.x, y-rhs.y); }
    Vec2 operator*( double s ) const { return Vec2(x*s, y*s); }
    double dot( const Vec2& rhs ) const { return x*rhs.x + y*rhs.y; }
    double cross( const Vec2& rhs ) const { return x*rhs.y - y*rhs.x; }
   
private:
    double x;
    double y;
};
   
double DiffAngle( const Vec2& A, const Vec2& B )
{
    double d = fabs(A.arg()-B.arg());
    if ( d > PI ) d = 2*PI-d;
    return d;
}
   
vector<Vec2> IntSegCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> IntPoint;
    Vec2 D = B - A;
    Vec2 DU = D.normalize();
    Vec2 H = A - DU*(A.dot(DU));
    double h = H.length();
    if ( h >= r )
        return vector<Vec2>();
   
    double l = sqrt(r*r - h*h);
    double pa = (A-H).dot(DU), pb = (B-H).dot(DU);
    if ( pa < -l && -l < pb ) {
        IntPoint.push_back(H - DU*l);
    }
    if ( pa < l && l < pb ) {
        IntPoint.push_back(H + DU*l);
    }
    return IntPoint;
}
   
double IntTriCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> Int = IntSegCircle( A, B, r );
    if ( Int.empty() ) {
        return min( 0.5*r*r*DiffAngle(A,B), 0.5*A.length()*B.length()*sin(DiffAngle(A,B)) );
    } else if ( Int.size() == 1 ) {
        double area = 0.0;
        if ( A.length() > r ) {
            area += 0.5*r*r*DiffAngle(A,Int[0]);
        } else {
            area += 0.5*A.length()*r*sin(DiffAngle(A,Int[0]));
        }
        if ( B.length() > r ) {
            area += 0.5*r*r*DiffAngle(B,Int[0]);
        } else {
            area += 0.5*B.length()*r*sin(DiffAngle(B,Int[0]));
        }
        return area;
    } else {
        return 0.5*r*r*(sin(DiffAngle(Int[0],Int[1])) + DiffAngle(A,B) - DiffAngle(Int[0],Int[1]));
    }
}
   
double solve( int R, const vector<Vec2>& Poly )
{
    double area = 0.0;
    for ( size_t i = 0; i < Poly.size()-1; i++ ) {
        double coef = Poly[i].cross(Poly[i+1]) > 0 ? 1.0 : -1.0;
        area += coef * fabs(IntTriCircle(Poly[i], Poly[i+1], R));
    }
    return area;
}
   
int main()
{
    int N, R;
    cin >> N >> R;
   
    vector<Vec2> Poly;
    for ( int i = 0; i < N; i++ ) {
        double x, y;
        cin >> x >> y;
        Poly.push_back( Vec2(x,y) );
    }
    Poly.push_back( Poly.front() );
   
    printf( "%.10f\n", solve( R, Poly ) );
    return 0;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;
int dp[1010][20010];

int main()
{
  long long H;
  scanf("%lld", &H);
  long long N;
  scanf("%lld", &N);
  std::vector<int> A(N);
  std::vector<int> B(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
    scanf("%d", &B[i]);
  }
  for (int i = 0; i < 1010; ++i)
  {
    for (int j = 0; j < 20010; ++j)
      dp[i][j] = INF;
    dp[i][0] = 0;
  }
  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j < 20010; ++j)
    {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (j - A[i] >= 0)
        dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
    }
  }
  int ans = INF;
  for (int i = H; i < 20010; ++i)
    ans = min(ans, dp[N][i]);
  cout << ans << endl;

  return 0;
}


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

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

    queue<ll> q;
    for(int i=1;i<10;i++) q.push(i);

    int count = 0;
    while(!q.empty()){
        ll i = q.front(); q.pop();
        count++;
        if(count==k){
            cout << i << endl;
            return 0;
        }
        int digit = i%10;
        int im = digit-1, ip = digit+1;
        if(0<=im && im<=9) q.push(10*i+im);
        q.push(10*i+digit);
        if(0<=ip && ip<=9) q.push(10*i+ip);

    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
typedef long long ll;

int main() {
	ll a, p; cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    abs_val = sys.maxsize
    flavor = 0
    for i in range(N):
        a = L + i
        flavor += a
        if abs(a) < abs_val:
            abs_val = abs(a)
            index = i
    print(flavor - (L + index))
    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()


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

using namespace std;

int func(int);
int count(void);
void rev(int);

int a[10][10000],r,c;

int main(void){
  
  while(cin >> r >> c,r|c){
    for(int i=0;i<r;i++)
      for(int j=0;j<c;j++)
	cin >> a[i][j];
    
    cout << func(0) << endl;
  }
  
  return 0;
}

int func(int x){
  int res=0;

  if(x+1<r)res=func(x+1);
  res=max(res,count());
  rev(x);
  if(x+1<r)res=max(res,func(x+1));

  return res;
}

int count(void){
  int cnt,res=0;
  
  for(int i=0;i<c;i++){
    cnt=0;
    for(int j=0;j<r;j++){
      cnt+=a[j][i];
    }
    res+=max(r-cnt,cnt);
  }
  return res;
}

void rev(int x){
  for(int i=0;i<c;i++)
    a[x][i]= a[x][i]?0:1;
}

Measured memory_bytes: 1548
//10^N + 8^N - 2*9^N mod 1e9+7
#include <iostream>
using namespace std;
int main() {
    long long n, i = 0,  a = 10, b = 9, c = 8, mod = 1000000007; cin >> n;
    for(; i < n - 1; i++) {
        a *= 10; a %= mod;
        b *= 9;  b %= mod;
        c *= 8;  c %= mod;
    }
    a += c; a %= mod;
    cout << (a - (2 * b) % mod + mod) % mod << endl;
}


Measured memory_bytes: 3544
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> road(N);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        road[a].push_back(b);
        road[b].push_back(a);
    }

    vector<int> d(N, 1e9);
    vector<int> sign(N);
    d[0] = 0;
    // distance, edge(to), edge(from)
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;

    for (int e : road[0])
    {
        q.push(pair<int, int>(1, e));
        d[e] = 1;
        sign[e] = 0;
    }

    while (!q.empty())
    {
        auto t = q.top();
        q.pop();
        if (d[t.second] < t.first)
            continue;
        for (int e : road[t.second])
        {
            //更新可能
            if (d[e] > t.first + 1)
            {
                d[e] = t.first + 1;
                sign[e] = t.second;
                q.push(pair<int, int>(d[e], e));
                //cout << d[e] << " " << e << endl;
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {
        cout << sign[i] + 1 << endl;
    }
}

Measured memory_bytes: 11076
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    int64_t r;
    cin >> r;
    cout << r * r << endl;
}


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

using namespace std;

struct node {
	int v;
	node *next;
} pool[210000] , *g[120000];
int top;
int n;
int a[120000];
int c[120000] , index , ans;
void add ( int u , int v ) {
	node *tmp = &pool[++top];
	tmp -> v = v; tmp -> next = g[u]; g[u] = tmp;
}
void dfs ( int i , int from ) {
	for ( node *j = g[i] ; j ; j = j -> next ) if ( j -> v != from ) {
		dfs ( j -> v , i );
	}
	c[i] = a[++index];
}
void dfs2 ( int i , int from ) {
	for ( node *j = g[i] ; j ; j = j -> next ) if ( j -> v != from ) {
		ans += min ( c[i] , c[j->v] );
		dfs2 ( j -> v , i );
	}
}
void work () {
	int i , u , v;
	scanf ( "%d" , &n );
	for ( i = 1 ; i < n ; i++ ) {
		scanf ( "%d%d" , &u , &v );
		add ( u , v ); add ( v , u );
	}
	for ( i = 1 ; i <= n ; i++ ) scanf ( "%d" , &a[i] );
	sort ( a + 1 , a + 1 + n );
	dfs ( 1 , -1 );
	dfs2 ( 1 , -1 );
	printf ( "%d\n" , ans );
	for ( i = 1 ; i <= n ; i++ ) printf ( "%d " , c[i] );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

inline ll square(ll a){return (a*a)%MOD;}
ll powmod(ll a,ll b){
    if(b==0)return 1;
    if(b==1)return a;
    if(b%2){
        return (square(powmod(a,b/2)%MOD)*a)%MOD;
    }else{
        return square(powmod(a,b/2)%MOD);
    }
}

ll factmod(ll n){
    ll ans=1;
    while(n){
        ans=(ans*n--)%MOD;
    }
    return ans;
}

ll combmod(ll n,ll r){ // nCr
    ll ans=factmod(n)%MOD;
    ans=(ans*powmod(factmod(r),MOD-2))%MOD;
    ans=(ans*powmod(factmod(n-r),MOD-2))%MOD;
    return ans;
}

ll H(ll n,ll r){
    ll ans=factmod(n+r-1)%MOD;
    ans=(ans*powmod(factmod(r),MOD-2))%MOD;
    ans=(ans*powmod(factmod(n-1),MOD-2))%MOD;
    return ans;
}

int main(){
    int n,m;
    cin>>n>>m;
    ll hs[32];
    REP(i,32){
        hs[i]=H(n,i);
    }
    int cnt=0,p=2;

    ll ans=1;
    while(m!=1){ // sqrt(m)
        if(m%p){
            ans*=hs[cnt]; // O(n+r)
            ans%=MOD;
            //<<p<<":"<<cnt<<" "<<ans<<endl;
            cnt=0;
            p+=2-(p==2);
        }else{
            cnt++;
            m/=p;
        }
    }
    if(cnt){
        ans*=hs[cnt];
        ans%=MOD;
        //<<p<<":"<<cnt<<" "<<ans<<endl;
    }
            
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  double ans;
  if(N%2==1){
    ans = N;
    ans = (ans+1)/2/ans;
  }
  else{
    ans = 1.0/2.0;
  }
  cout << fixed << setprecision(7);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
ll pt[N][3];
void solve(){
	int n; 
	cin>>n; 
	int id = -1;
	for(int i=1;i<=n;i++){
		cin>>pt[i][0]>>pt[i][1]>>pt[i][2];
		if(pt[i][2])id = i;
	}
	assert(id>0);
	for(int x=0;x<=100;x++){
		for(int y=0;y<=100;y++){
			int h = max(0ll,pt[id][2]+abs(pt[id][0]-x)+abs(pt[id][1]-y));
			bool can = true;
			for(int i=1;i<=n;i++){
				int hh = max(0ll,h-abs(x-pt[i][0])-abs(pt[i][1]-y));
				if(hh!=pt[i][2])can = false;
			}
			if(can){
				cout<<x<<" "<<y<<" "<<h<<endl;
				return ;
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int func(int x){
  if(x < 10)
    return x;
  return x % 10 + func(x / 10);
}

int main(){
  
  int N;
  scanf("%d",&N);
  
  int s = func(N); //s:Nの各位の和
  
  if(N % s == 0)
    printf("Yes");
  else
    printf("No");
  
  return 0;
  
}

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

using namespace std;

int main()
{
	string grade;

	while (true)
	{
		int m, f, r;
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)
			break;

		if (m == -1 || f == -1 || m + f < 30) {
			grade += "F";
			continue;
		}
		else if (m + f >= 80) {
			grade += "A";
			continue;
		}
		else if (m + f >= 65) {
			grade += "B";
			continue;
		}
		else if (m + f >= 50 || r >= 50) {
			grade += "C";
			continue;
		}
		else if (m + f >= 30) {
			grade += "D";
			continue;
		}
	}

	for (int i = 0; i < grade.size(); ++i)
		cout << grade[i] << endl;

	return 0;
}

Measured memory_bytes: 1188
fn main() {
    let mut reader = acio::Reader::new();
    let a = reader.read::<u64>() - 1;
    let b = reader.read::<u64>();
    let c = reader.read::<u64>();
    let d = reader.read::<u64>();
    let l = acbat::lcm(c, d);
    let f = |x| x - x / c - x / d + 1;
    let k = f(l);
    let ad = f(a % l);
    let bd = f(b % l);
    let ac = (a / l * k) + ad;
    let bc = (b / l * k) + bd;
    //println!("{} / {} + {}, {}", k, l, ad, bd);
    //println!("{} - {} = {}", bc, ac, bc - ac);
    println!("{}", bc - ac);
}

/// Batteries for AtCoder
#[allow(dead_code)]
mod acbat {
    pub fn lcm(v1: u64, v2: u64) -> u64 {
        v1 * v2 / gcd(v1, v2)
    }

    pub fn gcd(v1: u64, v2: u64) -> u64 {
        if v1 == v2 {
            v1
        } else if v1 < v2 {
            gcd(v1, v2 - v1)
        } else {
            gcd(v1 - v2, v1)
        }
    }
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: u64) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            return v;
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            if self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


Measured memory_bytes: 4476
import sys
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = min(a_list) + min(b_list)
for discount in sys.stdin:
    x, y, c = map(int, discount.split())
    ans = min(ans, a_list[x - 1] + b_list[y - 1] - c)
print(ans)


Measured memory_bytes: 18608
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}
 
int main(){
  int m;
  cin >> m;
  cout << 48-m;
  return 0;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split(" ")))
d = list(map(int, input().split(" ")))


def valid(n):
    while n > 0:
        digit = n % 10
        if digit in d:
            return False
        n = int(n / 10)
    return True


for num in range(n, 10 * n):
    if valid(num):
        print(num)
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   double sum=0;
   long long ans=0;
   cin>>n;
   int a[n],i;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       sum=sum+a[i];
   }
   sum=round(sum/n);
   for(i=0;i<n;i++)
   {
       ans=ans+pow((sum-a[i]),2);
   }
   cout<<ans<<endl;
    return 0;
}









Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<int> sort(vector<int> vec) {
    sort(vec.begin(), vec.end());
    return vec;
}
vector<int> resort(vector<int> vec) {
    sort(vec);
    reverse(vec.begin(), vec.end());
    return vec;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    string s,t;
    cin >> s >> t;
  bool ans = false;
    for (int i = 0; i < s.size(); i++) {
        if (s == t) {
            ans = true;
            break;
        }
        s = s.back() + s.substr(0, s.size() - 1);
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;
vector <char> v;
vector<int> num;
string s ;
int table[3][3];
int main(){
  int X,A,B;
  cin >> X>>A>>B;
  cout <<(X-A)%B<< endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),ans=0;
    for(int i=1;i<n;i++){
      for(int j=1;j*i<n;j++){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35692
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    d,t,s = readInt()
    if s*t<d:
        print("No")
    else:
        print("Yes")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9680
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int W,H;
int N;
int p[102];
int pos[2];
int ans;
int main() {
    cin>>W>>H;
    cin>>N;
    rep(i,N) cin>>p[i];
    rep(i,N) {
        pos[p[i]]++;
        if(pos[0]<W) {
            ans+=pos[0]==pos[1];
        }
        else if(pos[0]==W-1) {
            // pass
        }
        else if(pos[0]<W+H-2) {
            ans+=pos[0]==pos[1]+2;
        }
        else if(pos[0]==W+H-2) {
            // pass
        }
        else {
            ans+=pos[0]==pos[1]+4;
        }
        //cout<<i<<": "<<pos[0]<<", "<<pos[1]<<" -> "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_T 50
#define WIDTH 7200
pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH];
vector<vector<int>>X;
int hantei(vector<vector<int>>a) {
	int sum = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			int Num = (a[i][j] + 15) % 16; if (a[i][j] == 0)continue;
			sum += abs(i - (Num / 4)) + abs(j - (Num % 4));
		}
	}
	return sum;
}
int main() {
	for (int i = 0; i < 4; i++) {
		vector<int>FF; for (int j = 0; j < 4; j++) { int p; cin >> p; FF.push_back(p); }
		X.push_back(FF);
	}
	E[0][0] = make_pair(hantei(X), X);
	for (int i = 0; i < MAX_T; i++) {
		int CNT = 0;
		if (E[i][0].first == 0) { cout << i << endl; break; }
		for (int j = 0; j < WIDTH; j++) {
			if (E[i][j].second.size() == 0)break;
			int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
			vector<vector<int>>H = E[i][j].second; int I = E[i][j].first;
			int C = 0;
			for (int k = 0; k < 16; k++) {
				if (H[k / 4][k % 4] == 0) {
					C = k;
				}
			}
			for (int k = 0; k < 4; k++) {
				vector<vector<int>>J = H;
				int Ex = (C / 4) + dx[k], Ey = (C % 4) + dy[k];
				if (Ex < 0 || Ex > 3 || Ey < 0 || Ey > 3)continue;
				swap(J[C / 4][C % 4], J[Ex][Ey]);
				D[CNT] = make_pair(hantei(J), J); CNT++;
			}
		}
		sort(D, D + CNT); E[i + 1][0] = D[0]; int cnt2 = 1;
		for (int k = 1; k < CNT; k++) {
			if (D[k - 1] == D[k])continue;
			E[i + 1][cnt2] = D[k]; cnt2++;
		}
	}
	return 0;
}

Measured memory_bytes: 81424
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int paid = n*800;
        int back = (n/15)*200;

        System.out.println(paid-back);
    }
}


Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    long long n,A[3000],dp[3001][3001]={0};
    cin>>n;
    rep(i,n) cin>>A[i];
    rep(i,n)rep(j,n-i) dp[i+1][j]=max(A[i+j]-dp[i][j],A[j]-dp[i][j+1]);
    cout<<dp[n][0];
}

Measured memory_bytes: 70656
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))


Measured memory_bytes: 61552