akhauriyash/Code-Regression huggingface dataset:
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<int> accum(n+1); //累積和
    vector<int> w(n);

    accum[0] = 0;
    rep(i,n) cin >> w.at(i);

    for(int i=1; i<n+1; i++){
        accum.at(i) = accum.at(i-1) + w.at(i-1);
    }
    

    int ans = 1e9;
    rep(i,n){
        ans = min(ans,abs(accum.at(n) - 2*accum.at(i)));
    }
    cout << ans << endl;


}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int i,j,k;
	long long x,y;
	scanf("%lld%lld",&x,&y);
	if(abs(x-y)<=1) printf("Brown\n");
	else printf("Alice\n");
	return 0;
}


Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int w, h, x, y, r; cin >> w >> h >> x >> y >> r;

	bool inX = (x - r) >= 0 && (x + r) <= w;
	bool inY = (y - r) >= 0 && (y + r) <= h;

	bool in = inX&&inY;

	if (in) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;

int n;
ll a = -1, b = 2;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll c = a + b;
		a = b; b = c;
	}
	cout << b << endl;
	return 0;
}

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

int n ,  x , y , a , b , c;
main( ) {
	cin >> x >> y >> a >> b >> c;
	priority_queue<int> r, g, rg;
	rep( i , a ) {
		cin >> n; r.push( n );
	}
	rep( i , b) {
		cin >> n; g.push( n );
	}
	rep( i , c ) {
		cin >> n; rg.push( n );
	}
	rep( i , x ) {
		rg.push( r.top( ) ); r.pop( );
	}
	rep( i , y ) {
		rg.push( g.top( ) ); g.pop( );
	}
	long long ans= 0;
	rep(i, x + y ) {
		ans += rg.top( ); rg.pop( );
	}
	cout << ans;
}





Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
typedef long double ld;
using namespace std;
 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);

    ld a,b,H,M;cin>>a>>b>>H>>M;
    ld ang1 = (H*2*PI)/12 + (M*2*PI/60)/12;
    ld ang2 = (M*2*PI)/60;

    ld ang = ang1-ang2;
    ld ans = 0;
    //cout<<"ang = "<<(ang1*360)/(2*PI)<<"\n";
    //cout<<"ang = "<<(ang*360)/(2*PI)<<"\n";

    if(ans == 0){
        ans = sqrtl((a*a)+(b*b)-2*a*b*cosl(ang));
    }
    cout<<setprecision(10)<<ans<<"\n";
    //printf("%20.20Lf\n",ans);
    return 0;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N,l=0,r=0,L=0,R=0;
  string S;
  cin>>N>>S;
  for(ll i=0;i<N;i++){
    if(S[i]=='(') l++;
    else if(S[i]==')'){
      if(l==0) L++;
      else{
        r++;
        l--;
      }
    }
  }
  for(ll i=0;i<L;i++) cout<<"(";
  cout<<S;
  for(ll i=0;i<l;i++) cout<<")";
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+9;
const int mod=1e9+7;
int n;
string s;
ll dp[2][13];
int main(){
  cin>>s;n=s.size();s=" "+s;
  dp[0][0]=1;
  for(int i=1,j=1;i<=n;i++,j^=1){
    for(int k=0;k<13;k++)dp[j][k]=0;
    if(s[i]!='?')
      for(int k=0;k<13;k++)dp[j][(k*10+s[i]-'0')%13]=(dp[j][(k*10+s[i]-'0')%13]+dp[j^1][k])%mod;
    else
      for(int t=0;t<10;t++)
         for(int k=0;k<13;k++)dp[j][(k*10+t)%13]=(dp[j][(k*10+t)%13]+dp[j^1][k])%mod;
  }
  cout<<dp[n%2][5]<<endl;
  return 0;
}


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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  string s;cin>>s;
  rep(i,s.size()){
    int tmp = s[i] - 'A';
    tmp += n;
    tmp %= 26;
    s[i] = char('A'+tmp);
  }
  print(s);
  return 0;
}

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

int main(){
  int x;
  cin >> x;
  
  while (1){
    bool ok=true;
    for (int i=2;i<x;++i){
      if (x%i==0) {
        ok=false;
        break;
      }
    }
      if (ok) break;
      ++x;
  }
      cout << x << endl;
      return 0;
}


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

int main() {
  vector<int>A(9);
  vector<int>B(10);
  int N;
  for(int i =0; i<9; i++){
    cin >> A.at(i);
  }
  
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  
  string ans = "No";
  
  for(int i=0; i<9; i++){
    for(int j=0; j<N; j++){
      if(A.at(i)==B.at(j)){
        A.at(i) = 0;
      }
    }
  }
  
  if(A.at(0) == 0 && A.at(1) ==0 && A.at(2) == 0){ans = "Yes";}
  if(A.at(3) == 0 && A.at(4) ==0 && A.at(5) == 0){ans = "Yes";}
  if(A.at(6) == 0 && A.at(7) ==0 && A.at(8) == 0){ans = "Yes";}
  
  if(A.at(0) == 0 && A.at(3) ==0 && A.at(6) == 0){ans = "Yes";}
  if(A.at(1) == 0 && A.at(4) ==0 && A.at(7) == 0){ans = "Yes";}
  if(A.at(2) == 0 && A.at(5) ==0 && A.at(8) == 0){ans = "Yes";}
  
  if(A.at(0) == 0 && A.at(4) ==0 && A.at(8) == 0){ans = "Yes";}
  if(A.at(2) == 0 && A.at(4) ==0 && A.at(6) == 0){ans = "Yes";}
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3596
#pが素数の時、p未満の数の積xについてx^(p-1)=1(mod p) <=> x^(p-2)=1/x(mod p) (オイラの小定理)
#ここでpは素数なので、p以下の数a,b,nにおいてcmb(n,a)≡n!/((n-a)!*a!)≡((n-a+1)*…*n)/(a!)≡((n-a+1)*…*n)(a!)^(p-2) (mod p)
#あとは((n-a+1)*…*n)(a!)^(p-2) (mod p)を繰り返し2乗法でO(log(p))で求められる…らしいが普通にpow(n,r,mod)つよそう

def modcmb(n,r,mod):
    upper=1
    for i in range(n-r+1,n+1,1):
        upper=(upper*i)%mod
    rfrac=1
    for i in range(1,r+1,1):
        rfrac=(rfrac*i)%mod
    pwrfrac=pow(rfrac,mod-2,mod)
    return (upper*pwrfrac)%mod

n,a,b=map(int,input().split())
p = 10 ** 9 + 7

print((pow(2,n,p)-1-modcmb(n,a,p)-modcmb(n,b,p))%p)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 1;i<=n;i++)
long long int N,C;
long long int x[100002];
long long int v[100001];
long long int vposi[100001];
long long int vnega[100001];
long long int vrposi[100001];
long long int vrnega[100001];
int main(){
  cin >> N >> C;
  x[0]=0;
  x[N+1]=C;
  v[0]=0;
  vposi[0]=0;
  vnega[0]=0;
  rep(i,N){
    cin >> x[i] >> v[i];
    vposi[i] = vposi[i-1]+v[i];
  }
  rep(i,N){
    vnega[i] = vnega[i-1]+v[N-i+1];
  }
  vrposi[0]=vrnega[0]=0;
  rep(i,N){
    vrposi[i]= max(vrposi[i-1],vposi[i]-x[i]);
  }
  rep(i,N){
    vrnega[i]= max(vrnega[i-1],vnega[i]-(C-x[N-i+1]));
  }
  long long int ans = 0;
  rep(i,N){
    ans = max(ans,max(vposi[i]-2*x[i]+vrnega[N-i],vposi[i]-x[i]));
  }
  rep(i,N){
    ans = max(ans,max(vnega[i]-2*(C-x[N-i+1])+vrposi[N-i],vnega[i]-(C-x[N-i+1])));
  }
  cout << ans << endl;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back

int n,k,sum;
int w[100100];
pair<int,int> v[100100];

int compute(int x)
{
    int i;
    for(i=1; i<=n; ++i)
        v[i].s=w[i],
        v[i].f=v[i].s - (v[i].s/x*x);
    sort(v+1,v+n+1);
    i = 1;
    int j = n;
    int cnt = 0;
    while(i<j)
    {
        int p = min(v[i].s- v[i].s/x*x, (v[j].s/x+1)*x-v[j].s);
        cnt+=p;
        if(cnt>k)
            return 0;
        v[i].s-=p;
        v[j].s+=p;
        if(v[i].s%x==0)
            ++i;
        if(v[j].s%x==0)
            --j;
    }
    return 1;
}


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

    cin>>n>>k;
    int i;
    for(i=1; i<=n; ++i)
    {
        cin>>w[i];
        sum+=w[i];
    }

    int ans = 0;

    int lim = sqrt(sum);

    for(i=1; i<=sum; i++)
        if(sum%i==0)
        {
            if(compute(i))
                ans=max(ans,i);
            if(compute(sum/i))
                ans=max(ans,sum/i);
        }
    cout<<ans;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

	public class Main {
		static FastScanner sc;
		static PrintWriter out;
		public static void main(String[] args){
			sc = new FastScanner();
			out = new PrintWriter(System.out);
			out.println(solve());
			out.flush();
		}

		static String solve(){
			char[] S = sc.next().toCharArray();
			char[] T = sc.next().toCharArray();
			int[] repS = new int[26];
			int[] repT = new int[26];
			Arrays.fill(repS, -1);
			Arrays.fill(repT, -1);
			for(int i=0;i<S.length;i++){
				int tmpS = S[i]- 'a';
				int tmpT = T[i]- 'a';
				if(repS[tmpS]==-1 && repT[tmpT]==-1){
					repS[tmpS] = tmpT;
					repT[tmpT] = tmpS;
				}else if(tmpS == repT[tmpT] && tmpT == repS[tmpS]) continue;
				else return "No";
			}
			return "Yes";
		}
	}

	class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			}else{
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
			return (int) nl;
		}
		public double nextDouble() { return Double.parseDouble(next());}
	}

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

int main(){
    int n;
    cin>>n;
    long long a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int cnt=0;
    for(int i=0;i<n;i++){
        int p=lower_bound(b,b+n,a[i])-b;
        if(i%2!=p%2) cnt++;
    }
    cout<<cnt/2;

}

Measured memory_bytes: 1792
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

int A[505][505];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max(max(a, b), c);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define f(i,a,b) for(int i = a;i < b;i++)
#define ff(i,a,b)  for(int i = a-1;i>=b;i--)
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;

int32_t main()
{
   IOS;
   int n;
   cin>>n;
   int ans = 0;
   f(i,1,n+1)
   {
    if(i%3 == 0 or i%5 == 0 or i%15==0)
      continue;
    ans += i;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p=1;
    while (p<=10)
    {

        if (p*1000>=n)
        {
                    cout<<p*1000-n<<endl;
                    break;

        }
        p++;
    }

    return 0;
}


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

const int N=200001;
int main(){
    int n;
    cin>>n;
    int m=0;
    for(int i=1; i<n; i++){
        for(int j=1; j<n; j++){
            if(i*j>=n){
                break;
            }
            m++;
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3620
//Name: A Piece of Cake
//Level: 2
//Category: 数学
//Note:

/**
 * cを全て合計すると、1種類のケーキはちょうど(K-1)回だけ足されたことになる。
 * したがって、ΣcをK-1で割ればよい。
 *
 * オーダーは O(K^2)。
 */
#include <iostream>

using namespace std;

bool solve() {
    int K;
    if(!(cin >> K)) return false;
    if(!K) return false;

    int sum = 0;
    for(int i = 0; i < K*(K-1)/2; ++i) {
        int c;
        cin >> c;
        sum += c;
    }
    cout << sum / (K-1) << endl;
    return true;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

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

using namespace std;

const int N = 505;

int dist[N][N], a[N][N];
int p[N * N];

const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, -1, 0, 1};

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n * n; ++i) {
    scanf("%d", p+i);
    --p[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      dist[i][j] = min(min(i+1, n-i), min(j+1, n-j));
      a[i][j] = 1;
    }
  }
  int nn = n * n;
  int ans = 0;
  for (int i = 0; i < nn; ++i) {
    int v = p[i];
    queue<int> que;
    int r = v / n, c = v % n;
    --dist[r][c];
    a[r][c] = 0;
    ans += dist[r][c];
    que.emplace(v);
    while (!que.empty()) {
      v = que.front();
      que.pop();
      r = v / n, c = v  % n;
      for (int j = 0; j < 4; ++j) {
        int x = r + dr[j], y = c + dc[j];
        if (min(x, y) < 0 || max(x, y) >= n) continue;
        if (dist[x][y] > dist[r][c] + a[x][y]) {
          dist[x][y] = dist[r][c] + a[x][y];
          que.emplace(x * n + y);
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6724
import java.util.*;

public class Main {

	boolean[] can;
	int N, a, b;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt(); a = in.nextInt(); b = in.nextInt();
			if(N==0 && a==0 && b==0) return ;
			System.out.println(solve());
		}
	}

	int solve(){
		can = new boolean[N+1];
		can[0] = true;
		for(int i=0; i<=N; i++)if(can[i]){
			if(i+a<=N) can[i+a] = true;
			if(i+b<=N) can[i+b] = true;
		}
		int ret = 0;
		for(int i=0; i<=N; i++)if(!can[i]) ret++;
		return ret;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include<cstdio>
char s[11];int a,b,c,now,ans=1<<30;
main()
{
	scanf("%s",s);
	a=s[0]-'0';b=s[1]-'0';
	for(register int i=2;s[i]!='\0';++i)
	{
		c=s[i]-'0';
		now=a*100+b*10+c-753;if(now<0)now=-now;
		if(now<ans)ans=now;
		a=b;b=c;
	}
	printf("%d",ans);
}/**/

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  s=S()

  c=0
  f=''
  e=''
  
  for x in s:
    if x=='(':
      c+=1
    else:
      c-=1

    if c<0:
      f+='('*abs(c)
      c=0

  if c<0:
    f+='('*abs(c)
  else:
    e+=')'*c

  return f+s+e

print(main())


Measured memory_bytes: 6812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			System.out.println(180*(N - 2));
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}

Measured memory_bytes: 21460
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B, C;
	in >> A >> B >> C;
	out << C - std::min(A - B, C) << std::endl;
}


Measured memory_bytes: 256
//abc061_b.cpp
//Tue Oct 30 21:54:14 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int road[n];
	fill(road,road+n,0);

	for (int i=0;i<m;i++){
		int city1,city2;
		cin >> city1 >> city2;
		road[city1-1]++;
		road[city2-1]++;
	}

	for (int i=0;i<n;i++){
		cout << road[i] << endl;
	}

}

Measured memory_bytes: 256
# 木上の累積和

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


from collections import defaultdict

N, Q = read_ints()
tree = defaultdict(lambda: [])
for _ in range(N - 1):
    a, b = read_ints()
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
cnt = [0] * N
for _ in ra(Q):
    q, x = read_ints()
    cnt[q - 1] += x

# dfsでcntに木に沿った累積和をsetしていく


def dfs(c, u, p):  # uは現在のノード、pは親のノード、cはuは含まない累積のスコア
    cnt[u] += c
    for nv in tree[u]:
        if nv == p:
            continue
        dfs(cnt[u], nv, u)


dfs(0, 0, -1)

print(*cnt)


Measured memory_bytes: 241604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}// 改行付き出力



double dp[330][330][330];
bool flag[330][330][330];
int n;
 
double recurse(int i, int j, int k)
{
    if (abs(dp[i][j][k] + 1) > 1e-9)
        return dp[i][j][k];
    
    double ret = 0;
    ret += (double)n / (double)(i + j + k);
 
    if (i > 0)
        ret += (double)i / (double)(i + j + k) * recurse(i - 1, j, k);
    if (j > 0)
        ret += (double)j / (double)(i + j + k) * recurse(i + 1, j - 1, k);
    if (k > 0)
        ret += (double)k / (double)(i + j + k) * recurse(i, j + 1, k - 1);
    dp[i][j][k] = ret;
 
    return ret;
}
// TODO: write
int main() {
  cin>>n;
  int c[4] = {0};
  rep(i,n){
    int a;cin>>a;
    c[a]++;
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  print(recurse(c[1],c[2],c[3]));
  return 0;
}

Measured memory_bytes: 284588
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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 long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll a=0;
  FOR(i,0,1000000000000000){
    a++;
  }
  co(3*n*n)
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,K,x,y,kk,ans,tot,opt,head[N];
struct Tree{int nxt,to,from;}e[N];
inline void link(int x,int y){e[++kk].nxt=head[x];e[kk].from=x;e[kk].to=y;head[x]=kk;}
void dfs(int u,int fa,int dep){
	if (dep>K) return;tot++;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (v==fa) continue;
		dfs(v,u,dep+1);
	}
}
inline void solve(int x){
	tot=0;
	dfs(x,-1,0);
	ans=min(ans,n-tot);
}
inline void solve1(int x){
	tot=0;dfs(e[x].to,e[x].from,0);
	dfs(e[x].from,e[x].to,0);
	ans=min(ans,n-tot);
}
int main(){
	scanf("%d%d",&n,&K);
	int opt=(K&1);
	if (K%2==0) K/=2;
	else K=(K-1)/2;
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		link(x,y);link(y,x);
	}
	ans=1e9;
	if (!opt) for (int i=1;i<=n;i++) solve(i);
	if (opt) for (int i=1;i<=kk;i+=2) solve1(i);
	printf("%d\n",ans);
	return 0;
}

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

#define endl '\n'
using namespace std;
using ll = long long;

const int N = 100005;
const ll MOD = 1e9+7;
const int BLACK = 0, WHITE = 1;

int n;
vector<int> tree[N];
ll dp[2][N];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void mul_self(ll &lhs, ll rhs)
{
    lhs *= rhs;
    lhs %= MOD;
}

void dfs(int v, int p)
{
    // count subtree result
    for(auto c:tree[v])
    {
        if(c == p) continue;
        dfs(c, v);
        mul_self(dp[BLACK][v], dp[WHITE][c]);
        mul_self(dp[WHITE][v], dp[BLACK][c]+dp[WHITE][c]);
    }
}

void init()
{
    cin >> n;
    for(int i = 1; i <= n; i++) dp[0][i] = dp[1][i] = 1;
    for(int i = 1; i < n; i++)
    {
        int x, y; cin >> x >> y;
        tree[x].emplace_back(y);
        tree[y].emplace_back(x);
    }
}

void process()
{
    dfs(1, 1);
    cout << (dp[BLACK][1] + dp[WHITE][1])%MOD << endl;
}



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

int main() {
  ll K, N;
  cin >> N >> K;
  N = N % K;
  if (N < 0) {
    N += K;
  }
  cout << min(N, K - N) << endl;

  return 0;
}


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

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] u = new int[n];
		int[] v = new int[n];
		for (int i = 0; i < n; i++) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		sc.close();

		long[] dp = new long[100001];
		for (int j = 1; j < dp.length; j++) {
			dp[j] = 1000000000000000L;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 100000; j >= v[i]; j--) {
				dp[j] = Math.min(dp[j], dp[j - v[i]] + u[i]);
			}
		}

		for (int j = 100000; j >= 0; j--) {
			if (dp[j] <= w) {
				System.out.println(j);
				return;
			}
		}
	}
}


Measured memory_bytes: 23380
#include <stdio.h>
#include <math.h>

int main() {
  int number_a, number_b;
  scanf("%d %d", &number_a, &number_b);
  double ave = (number_a + number_b) / 2.0;
  printf("%d\n", (int)ceil(ave));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n;
	ll ans=0;
	cin >>n;
	if (n<600)ans=8;
	else if (n<800) ans=7;
	else if (n<1000) ans=6;
	else if (n<1200) ans=5;
	else if (n<1400) ans=4;
	else if (n<1600) ans=3;
	else if (n<1800) ans=2;
	else if (n<2000) ans=1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int H,W; cin >> H >> W;
    char c[100][100];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
            cout << c[(i)/2][j];
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		sc.close();

		if (N < 10) {
			System.out.println(R + 100 * (10 - N));
		} else {
			System.out.println(R);
		}
	}

}


Measured memory_bytes: 23380
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> se(n+1);
    vector<int> sw(n+1);
    se[0] = 0;
    sw[0] = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'E') {
            se[i+1] = se[i]+1;
            sw[i+1] = sw[i];
        }
        else {
            sw[i+1] = sw[i]+1;
            se[i+1] = se[i];
        }
    }
    int MIN = INF;
    for (int i = 0; i < n; ++i) {
        int ans = sw[i]+(se[n]-se[i+1]);
        MIN = min(MIN, ans);
    }
    cout << MIN << std::endl;
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    if (N % 2) {
        cout << "No" << endl;
        return 0;
    } else {
        for (int i = 0; i < N / 2; i++) {
            if (S[i] != S[i + N / 2]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
maxer = sum(p[:k])
cnt = maxer
st = 0
for i in range(n-k):
    cnt = cnt - p[i] + p[i+k]
    if cnt >= maxer:
        maxer = cnt
        st = i+1
ans = 0
for i in range(st,st+k):
    if p[i]%2 == 0:
        ans += (p[i]//2+0.5)
    else:
        ans += (p[i]//2 + 1)
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int x;
	int answer;

	cin >> N >> x;

	vector<int> a(N);

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

	sort(a.begin(), a.end()); // 昇順にソート

	answer = 0;
	while ( x >= a.at(answer) ) {
		x -= a.at(answer);
		answer++;

		if (answer == N){
			if (x > 0) answer--;
			break;
		}
	} 

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main(){
	ll N;
	cin>>N;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	//sup[i][j]=A[i]をj回4倍したときにそれ以降(自身を含む)を単調非減少にするために必要な4倍の回数
	ll sup[SIZE][20]={};
	for(int i=0;i<16;i++)
		sup[N-1][i]=i;
	for(int i=N-2;i>=0;i--){
		//A[i]をj回4倍する
		for(int j=0;j<16;j++){
			ll a=(A[i]<<(2*j));
			//A[i+1]をb回4倍したらa以上になる
			ll b=0;
			for(int k=0;k<32;k++){
				if(a<=(A[i+1]<<(2*k))){
					b=k;
					break;
				}
			}
			//bが15以上のとき
			if(b>15){
				sup[i][j]=sup[i+1][15]+j+(b-15)*(N-1-i);
			}
			else{
				sup[i][j]=sup[i+1][b]+j;
			}
		}
	}
	//pre[i][j]=A[i]をj回4倍したときにそれ以前(自身を含む)を単調非減少にするために必要な4倍の回数
	ll pre[SIZE][20]={};
	for(int i=0;i<16;i++)
		pre[0][i]=i;
	for(int i=1;i<N;i++){
		//A[i]をj回4倍する
		for(int j=0;j<16;j++){
			ll a=(A[i]<<(2*j));
			//A[i-1]をb回4倍したらa以上になる
			ll b=0;
			for(int k=0;k<32;k++){
				if(a<=(A[i-1]<<(2*k))){
					b=k;
					break;
				}
			}
			//bが15以上のとき
			if(b>15){
				pre[i][j]=pre[i-1][15]+j+(b-15)*(i);
			}
			else{
				pre[i][j]=pre[i-1][b]+j;
			}
		}
	}
	ll ans=min(sup[0][0]*2,pre[N-1][0]*2+N);
	for(int i=1;i<N;i++){
		ans=min(ans,pre[i-1][0]*2+i+sup[i][0]*2);
	}
	/*
	for(int i=0;i<N;i++){
		for(int j=0;j<16;j++)
			cout<<pre[i][j]<<" ";
		cout<<endl;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<16;j++)
			cout<<sup[i][j]<<" ";
		cout<<endl;
	}
	*/
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 64496
#include<iostream>
#include<vector>
#include<string>
using namespace std;
struct moji{
  string st;
  bool is_t;
};
void create_st(string& s,vector<moji>& sv){
    for(int i=0;i<s.size();i++){
      if(s[i]!='"') {
        string tmp(1,s[i]);
        moji add={tmp,false};
        sv.push_back(add);
      }else{
        string tmp="";
        int j=i+1;
        while(s[j]!='"'){
          tmp+=s[j];
          j++;
        }
        moji add={tmp,true};
        sv.push_back(add);
        i=j;
      }
    }
}
int main(){
  string s,t;
  cin >> s >> t;
  while(true){
    vector<moji> sv,tv;
    create_st(s,sv);
    create_st(t,tv);
    if(sv.size()!=tv.size()){
      cout <<"DIFFERENT\n";
    }else{
      int cnt=0;
      for(int i=0;i<sv.size();i++){
        if(sv[i].st!=tv[i].st){
          if(sv[i].is_t==false||tv[i].is_t==false)cnt+=2;
          else cnt++;
        }else if(sv[i].is_t!=tv[i].is_t) cnt+=2;
        if(cnt>=2) break;
      }
      if(cnt==0) cout <<"IDENTICAL\n";
      else if(cnt==1) cout <<"CLOSE\n";
      else cout <<"DIFFERENT\n";
    }
    cin>>s;
    if(s.size()==1&&s[0]=='.')break;
    cin >> t;
  }
}



Measured memory_bytes: 3252
#include <stdio.h>
#include <math.h>

int isprime(int x){
  if(x==2) return 1;
  if(x<2||x%2==0) return 0;
  int i;
  for(i=3;i<=sqrt(x);i+=2)
    if(x%i==0)
      return 0;
  return 1;  
}

int main(void){

  int n,x,i;

  for(;;){

    scanf("%d",&n);
    if(n==0)break;

    int num=0;
    for(i=n+1;i<=2*n;i++)
      if(isprime(i))num++;
    
    printf("%d\n",num);
    
  }

  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
       cin >> a.at(i);
    }
    vector<int> b = a;
    sort(b.begin(), b.end());
    for (int i=0; i<n; i++) {
        if (a.at(i) < b.at(n/2)) {
            cout << b.at(n/2) << endl;
        }
        else {
            cout << b.at(n/2-1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    int A,B; cin >> A >> B;
    if (A>=10 || B>=10){
        cout << -1;
    }else{
        cout << A*B;
    }
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B, K = sc.nextLong()

    val (a, b) = if (K <= A) {
      (A - K, B)
    } else {
      (0, (B - (K - A) max 0))
    }
    println(s"$a $b")
  }

}

Measured memory_bytes: 27716
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int lens=s.length();
	if(s[0]==s[lens-1])
	{
		if(lens%2==1) cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
	else
	{
		if(lens%2==1) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	return 0;
}

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

using namespace std;

struct request_t {
  int a;
  int b;

  constexpr request_t(int a_, int b_) : a(a_), b(b_) {}
  request_t() {}

  explicit operator bool() const noexcept { return a < b; }
  bool operator!() const noexcept { return !static_cast<bool>(*this); }
};

request_t operator&(const request_t& t1, const request_t& t2) {
  request_t ret;
  ret.a = std::max(t1.a, t2.a);
  ret.b = std::min(t1.b, t2.b);
  return ret;
}

int calc(std::vector<request_t>& rs, int n) {
  if (n <= 2) {
    return 1;
  }
  if (rs.size() <= 1) {
    return rs.size();
  }
  std::sort(rs.begin(), rs.end(),
            [](auto& lhs, auto& rhs) { return lhs.a < rhs.a; });
  int ret = 0;
  request_t previous_range(0, 0);
  for (const auto& r : rs) {
    request_t new_range = previous_range & r;
    if (static_cast<bool>(new_range)) {
      previous_range = new_range;
      continue;
    }

    ret++;
    previous_range = r;
  }
  return ret;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<request_t> rs(m);
  for (auto& r : rs) {
    std::cin >> r.a;
    std::cin >> r.b;
  }
  std::cout << calc(rs, n) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import sys
inf = 10**9+7
mod = 10**9+7

n = int(input())
s = input()
judge = [[[True for k in range(10)]for j in range(10)]for i in range(10)]
judge_first = [True for i in range(10)]
judge_second = [[True for j in range(10)] for i in range(10)]
ans = 0
for i in range(n-2):
    fir = int(s[i])
    if judge_first[fir]:
        for j in range(i+1,n-1):
            sec = int(s[j])
            if judge_second[fir][sec]:
                for k in range(j+1,n):
                    thr = int(s[k])
                    if judge[fir][sec][thr]:
                        ans+=1
                        judge[fir][sec][thr] = False
                judge_second[fir][sec] = False
        judge_first[fir] = False
print(ans)

Measured memory_bytes: 42588
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Math.min(A, B) + " " + Math.max(0, A + B - N));
	}
}

Measured memory_bytes: 22612
<?php
// Your code here!
  $input = fscanf(STDIN,"%d %d",$a,$b);
  $array = trim(fgets(STDIN));
  $array = explode(" ", $array);
  $border = 1 /(4 * $b);
  $num = 0;
  foreach($array as $v){
      if($v/array_sum($array) >= $border){
          $num++;
      }
  }
  if($num >= $b){
      echo "Yes";
  }else{
      echo "No";
  }
  
?>


Measured memory_bytes: 4728
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

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

def f(x, c, d):
    r = x
    r -= x // c
    r -= x // d
    r += x // lcm(c, d)
    return r

def f2(n, C, D):
    return n - n//C - n//D + n//lcm(C, D)

def solve():
    a, b, c, d = MI()

    g = lcm(c, d)
    bb = b - (b // c) - (b // d) + (b // g)
    a = a - 1
    aa = a - (a // c) - (a // d) + (a // g)
    print(bb - aa)
    # print(f(b, c, d) - f(a-1, c, d))
    # print(f2(b, c, d) - f2(a-1, c, d))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 5048