akhauriyash/Code-Regression huggingface dataset:
// 2_abc141_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, s.length()){
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	
	int ans = 0;
	for(auto& c : S) ans += (c == '1');
	Cout(ans);
}


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

int main(){
	int N,cnt=0,max_p=0,max_i=0;
	cin>>N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin>>d.at(i);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if(max_p<d.at(j))
              	max_p=d.at(j);
				max_i=j;
		}
		if(max_p==0)
			break;
	    else
   			cnt++;
		for (int j = 0; j < N; j++) {
			if(max_p==d.at(j))
				d.at(j)=0;
		}
		max_p=0;
		max_i=0;
	}
	cout << cnt << endl;
}

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

using namespace std;
#define ll long long

void init();
void solve();

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int L;
vector<vector<pair<int, int> > > v(30);
vector<int> memo;
int fi;
int l;

void init()
{
	cin >> L;
	int t = L;
	v[0].PB(MP(1, 0)); // v 1 cost 0
	v[0].PB(MP(1, 1));
	while (t != 2) {
		if (t & 1) {
			memo.PB(1);
			t--;
		}
		else {
			memo.PB(2);
			t /= 2;
		}
	}
	fi = 1;
	reverse(all(memo));
	l = 2;
}

void solve()
{
	int N = 2, M = 2;
	for (int x : memo) {
		if (x == 1) {
			l++;
			v[0].PB(MP(fi, l-1));
			M++;
		} else {
			l *= 2;
			rep(i, fi) {
				for (auto& p : v[i]) {
					p.second *= 2;
				}
			}
			v[fi].PB(MP(fi+1, 0));
			v[fi].PB(MP(fi+1, 1));
			fi++;
			N++;
			M+=2;
		}
	}
	cout << N << " " << M << endl;
	rep(i, fi) {
		for (auto p : v[i]) {
			cout << i+1 << " " << p.first+1 << " " << p.second << endl;
		}
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w=MI()
dp=[[-1]*w for i in range(h)]
Q=deque([])
for i in range(h):
    s=SI()
    for j in range(w):
        if s[j]=="#":
            dp[i][j]=0
            Q.append((i,j))
step=[(-1,0),(1,0),(0,1),(0,-1)]
while Q:
    x,y=Q.popleft()
    for i,j in step:
        if not(0<=x+i<h and 0<=y+j<w):
            continue
        if dp[x+i][y+j]<0:
            Q.append((x+i,y+j))
            dp[x+i][y+j]=dp[x][y]+1
ans=-inf
#print(dp)
for i in range(h):
    for j in range(w):
        ans=max(ans,dp[i][j])
print(ans)
            
    
        

    
        


            
        
        
            
    
            
            

    
    
            
            



Measured memory_bytes: 109640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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


// エラトステネスの篩
// O(n log log n) 競プロで使うようなサイズに対しては、大体 nの線形時間

const int MAX_N = 10000000;
int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N+1]; // is_prime[i]がtrueならiは素数

// n以下の素数の数を返す
int sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i<= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2*i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return p;
}

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

  sieve(MAX_N);
  for (int i = x; i < MAX_N; ++i) {
    if (is_prime[i]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979323846
#define pb push_back
#define po pop_back()
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007 
using namespace std;
bool isPowerofTwo(ll n){
	return n&(n-1)==0;
}
void solution(){
	ll n;
	cin>>n;
	ll a[n],sum=0;
	unordered_map<ll,ll> m;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		m[a[i]]++;
		sum+=a[i];
	}
	ll q;
	cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		if(m.find(b)!=m.end()){
			sum-=m[b]*b;
			sum+=m[b]*c;
			m[c]+=m[b];
			m[b]=0;
		}
		cout<<sum<<"\n";
	}
}
int main()
{
	hello;
	/*int t;
	cin>>t;
	while(t--){
		solution();
		cout<<"\n";
	}*/
	solution();
	return 0;
}


Measured memory_bytes: 7600
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C,x;
set<int>S1;
vector<int>V;
int main(){
#ifdef LOCAL
	freopen("C.in","r",stdin);//freopen("C.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&x);
		if(S1.find(x)!=S1.end())S1.erase(x),V.pb(x);
		else S1.insert(x);
	}
	sort(V.begin(),V.end());
	reverse(V.begin(),V.end());
	if(SZ(V)<2)puts("0");
	else printf("%lld\n",1ll*V[0]*V[1]);
	return 0;
}


Measured memory_bytes: 4992
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String fst = br.readLine();
		int n = Integer.parseInt(fst);
		double[] x = new double[n]; 
		double[] y = new double[n]; 
		String[] linex = (br.readLine()).split(" ");
		String[] liney = (br.readLine()).split(" ");
		for (int i = 0; i<n ; i++ ) {
			x[i] = Double.parseDouble(linex[i]);
			y[i] = Double.parseDouble(liney[i]);
		}
		Double sum = 0.0;
		double p = 1;
		for (int i =0; i<n ;i++ ) {
			sum += Math.pow(Math.abs(x[i]-y[i]),p);
		}

		Double d = Math.pow(sum,(1/p));
		System.out.printf("%.6f\n",d);

		sum = 0.0;
		p = 2;
		for (int i =0; i<n ;i++ ) {
			sum += Math.pow(Math.abs(x[i]-y[i]),p);
		}

		d = Math.pow(sum,(1/p));
		System.out.printf("%.6f\n",d);

		sum = 0.0;
		p = 3;
		for (int i =0; i<n ;i++ ) {
			sum += Math.pow(Math.abs(x[i]-y[i]),p);
		}

		d = Math.pow(sum,(1/p));
		System.out.printf("%.6f\n",d);

		double max = 0.0;
		for (int i =0; i<n ;i++ ) {
			max = Math.max(max,Math.abs(x[i]-y[i]));
		}
		System.out.printf("%.6f\n",max);
	}
}

Measured memory_bytes: 24800
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> h(N);
  REP(i, N) cin >> h[i];

  vector<int> dp(N, INF);
  dp[0] = 0;

  REP(i, N){
    REP(j, K){
      if(i+j+1 < N) chmin(dp[i+j+1], dp[i]+abs(h[i+j+1]-h[i]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define F(i,j,k) for(int i=(j);i<=(k);++i)
using namespace std;
int n,x,num;
int main(){
	//freopen("txt.in","r",stdin);freopen("txt.out","w",stdout);
	scanf("%d\n",&n);
	F(i,1,n){scanf("%d",&x);if(x&1)num^=1;}
	if(num&&n>1)printf("NO\n");
	else printf("YES\n");
	return 0;
}

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++)

const int inf = 1'000'000'000;

int main(){
  int n;
  cin >> n;
  printf("%.12f\n", (double)n*n*n/27);
}



Measured memory_bytes: 3740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

ll dp[51][5010];

int main(){
  itn n,a; cin >> n >> a;
  vector<int> x(n);
  rep(i,n){
    cin >> x[i];
    x[i]-=a;
  }
  dp[0][2500]=1;
  rep(i,n)rep(j,5010){
    dp[i+1][j+x[i]]+=dp[i][j];
    dp[i+1][j]+=dp[i][j];
  }
  cout << dp[n][2500]-1 << endl;
}

Measured memory_bytes: 5540
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n;
   cin>>n;
   ll sum=0;
   for(ll i=1;i<=n;i++){
       for(ll j=1;j<=n;j++){
           for(ll k=1;k<=n;k++){
               sum+=__gcd(__gcd(i,j),k);
           }
       }
   }
   cout<<sum<<endl;

}

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

struct Application{
  int i, j, w;
  Application(int i, int j, int w):
    i(i), j(j), w(w) {}
};

bool operator<(const Application& a, const Application& b){
  return a.j != b.j ? a.j < b.j : a.i != b.i ? a.i < b.i : a.w < b.w;
}

int main(){
  int n;
  while(cin >> n, n){
    int s, e, w;
    vector<Application> V(n,Application(0,0,0));
    for(int i = 0; i < n; ++i){
      cin >> s >> e >> w;
      V[i] = Application(s,e,w);
    }
    sort(V.begin(), V.end());
    int y = 366;
    vector< vector<int> > DP(y,vector<int>(y,0));

    for(int i = 0; i < n; ++i){
      vector< vector<int> > DP_(y,vector<int>(y,0));
      int s = V[i].i, e = V[i].j, w = V[i].w;
      for(int j = 0; j < y; ++j){
        for(int k = 0; k < y; ++k){
          DP_[j][k] = max(DP[j][k], DP_[j][k]);
          if(j < s) DP_[e][k] = max(DP_[e][k], DP[j][k] + w);
          if(k < s) DP_[j][e] = max(DP_[j][e], DP[j][k] + w);
          if(j > 0) DP_[j][k] = max(DP_[j][k], DP_[j-1][k]);
          if(k > 0) DP_[j][k] = max(DP_[j][k], DP_[j][k-1]);
        }
      }
      DP = DP_;
      /*
      cout << "----------------------------------" << endl;
      for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 4; ++j){
          printf("%02d ", DP[i][j]);
        }cout << endl;
      }
      */
    }
    cout << DP[y-1][y-1] << endl;

      
  }
  return 0;
}



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

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

using namespace std;

using graph=vector<vector<int>>;

int main(){
	int n,m;
	string s; cin>>n>>m>>s;
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
		if(u!=v) G[v].emplace_back(u);
	}

	vector<vector<int>> deg(2,vector<int>(n));
	rep(u,n) for(int v:G[u]) deg[s[v]-'A'][u]++;

	vector<bool> del(n);
	queue<int> Q;
	rep(u,n) if(deg[0][u]==0 || deg[1][u]==0) {
		del[u]=true;
		Q.emplace(u);
	}
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		for(int v:G[u]) if(!del[v]) {
			deg[s[u]-'A'][v]--;
			if(deg[0][v]==0 || deg[1][v]==0){
				del[v]=true;
				Q.emplace(v);
			}
		}
	}

	puts(count(del.begin(),del.end(),false)>0?"Yes":"No");

	return 0;
}


Measured memory_bytes: 12420
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var N = int.Parse(Console.ReadLine());
        Console.WriteLine(N/3);
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  Vector x(n),y(n);
  Vector xary,yary;

  rep(i,n){
      cin >> x[i] >> y[i];
      xary.pb(x[i]);
      yary.pb(y[i]);
  }
  usort(xary);
  usort(yary);

  ll ans = (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);
  rep(xi,n)repl(xj,xi+1,n-1)rep(yi,n)repl(yj,yi+1,n-1){
    ll num = 0;
    ll lx = xary[xi],rx = xary[xj];
    ll by = yary[yi],uy = yary[yj];

    rep(i,n)if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy)num++;
    if(num >= k)ans = mmin(ans, (rx - lx) * (uy - by));
  }

  cout << ans << endl;
}


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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
from itertools import count, cycle, repeat     # count(start[,step]), cycle(iter), repeat(elm[,n])
from itertools import groupby                  # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
from itertools import starmap                  # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    s, t = input().split()
    ans = ''
    for i in range(n):
        ans += s[i]
        ans += t[i]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from collections import Counter

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

cou = sorted(Counter(A).items(), key=lambda x:x[1], reverse=True)
ans = [cou[i][1] for i in range(K, len(cou))]
print(sum(ans))

Measured memory_bytes: 39312
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


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


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


# 累積最大値で逆から見ていく
N = read_a_int()
P = read_ints()

# from itertools import accumulate

# P_accum = list(accumulate(P, func=max))
# print(P_accum)
# ans = 0
# for i in range(N - 1, 0, -1):
#     print(i, P[i], P_accum[i - 1])
#     if P[i] <= P_accum[i - 1]:
#         ans += 1
# print(ans)
ans = 0
MIN = P[0]
for p in P:
    if MIN >= p:
        MIN = p
        ans += 1

print(ans)


Measured memory_bytes: 25568
#include <stdio.h>
#include <ctype.h>
int main()
{
	int c, ch;
	while(1){
		c=getchar();
		if(c=='\n'){
			break;
		} else if(islower(c)){
			ch=toupper(c);
		} else {
			ch=tolower(c);
		}
		printf("%c", ch);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
int main() {
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int ans=0;
    if(a+b>n) ans=a+b-n;
    printf("%d %d\n",std::min(a,b),ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>

using int64 = long long;

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

    int N;
    std::cin >> N;

    int64 exor = 0;
    std::map<int64, int> counter;

    for (int i = 0; i < N; i++) {
        int64 a;
        std::cin >> a;
        exor ^= a;

        counter[a ^ (a - 1)]++;
    }
    // std::cerr << std::bitset<8>(exor) << std::endl;
    // 

    int ans = 0;
    for (int i = 30; i >= 0; i--) {
        if ((exor >> i) & 1) {
            if (counter[(1LL << (i + 1)) - 1] == 0) {
                std::cout << -1 << std::endl;
                return 0;
            }
            exor ^= (1LL << (i + 1)) - 1;
            ans++;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_SIZE = 600;
int H, W;
long long a[MAX_SIZE][MAX_SIZE];
int proc[MAX_SIZE*MAX_SIZE][4];

int main(int argc, char **argv) {
    std::cin >> H >> W;

    long long N = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            std::cin >> a[i][j];
        }
    }

    for (int i = 1; i <= H - 1; i++) {
        for (int j = 1; j <= W; j++) {
            if (a[i][j] % 2 == 1) {
                a[i  ][j] -= 1;
                a[i+1][j] += 1;
                proc[N][0] = i; proc[N][1] = j; proc[N][2] = i + 1; proc[N][3] = j;
                N++;
            }
        }
    }

    for (int j = 1; j <= W - 1; j++) {
        if (a[H][j] % 2 == 1) {
            a[H][j] -= 1;
            a[H][j+1] += 1;
            proc[N][0] = H; proc[N][1] = j; proc[N][2] = H; proc[N][3] = j + 1;
            N++;
        }
    }

    std::cout << N << std::endl;

    for (int i = 0; i < N; i++) {
        std::cout << proc[i][0] << " " << proc[i][1] << " " << proc[i][2] << " " << proc[i][3] << std::endl;
    }

    return 0;

}

Measured memory_bytes: 8192
let inline charToInt c = int c - int '0'

let ints = stdin.ReadLine().Split(' ') |> Array.map int
let n = ints.[0]
let a = ints.[1]
let b = ints.[2]

seq { 1..n } |> Seq.sumBy (fun x ->
    let sum = x |> (string >> Seq.sumBy charToInt)
    if a <= sum && sum <= b then
        x
    else
        0
    ) |> printfn "%A"


Measured memory_bytes: 15964
import java.util.*;

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

		Scanner stdIn = new Scanner(System.in);

		while(true){
			int n = stdIn.nextInt();
			if(n == 0)
				break;

			int[] s = new int[n];
			double sum = 0;

			for (int i=0; i<n; i++) {
				sum += s[i] = stdIn.nextInt();
			}

			double m = sum/n;
			sum = 0;

			for (int i=0; i<n; i++) {
				sum += Math.pow(s[i]-m,2);
			}
			System.out.printf("%.5f\n",Math.pow((double)sum/n,0.5));
		}
	}
}

Measured memory_bytes: 23956
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7, maxn = 202;  
const long double PI = acos(-1);


int solve(string s, int n){
    int w = 0, r = 0, nw = 0, nr = 0, ans;
    for (int i=0; i<n; i++){
        if (s[i] == 'W') w++;
        else r++;
    }

    ans = min(r, w);
    for (int i=1; i<=n; i++){
        if (s[i-1] == 'W') nw++, w--;
        else nr++, r--;
        int cost = nw + r - min(nw, r);
        ans = min(ans, cost);
    }

    return ans;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    int ans = solve(s, n);

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

Measured memory_bytes: 3852
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] P = new int[M];
    String[] S = new String[M];
    for (int i = 0; i < M; i++) {
      P[i] = sc.nextInt();    
      S[i] = sc.next();    
    }
    sc.close();
 
    boolean[] ac = new boolean[N];
    int[] pe = new int[N];
    for (int i = 0; i < M; i++) {
      int p = P[i] - 1;
      if (ac[p]) continue;
      String s = S[i];
      if ("WA".equals(s)) {
        pe[p]++;
      } else if ("AC".equals(s)) {
        ac[p] = true;
      }
    }
    
    long ans1 = 0;
    long ans2 = 0;
    for (int i = 0; i < N; i++) {
      if (ac[i]) {
        ans1++;
        ans2 += pe[i];
      }
    }
    System.out.println(ans1 + " " + ans2);
  }
}

Measured memory_bytes: 69592
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int ans=m+1;
    for(int i=0;i<=n-m;i++){
        int co=0;
        rep(j,0,m)
        if(t[j]!=s[i+j])
            co++;
        ans=min(ans,co);
    }
    cout<<ans<<endl;


    }



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, W;
    cin >> n >> W;
    vector<ll> dp(W+1, 0);
    ll wn, vn;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> wn >> vn;
        for(ll w = W; w >= 0; w--) {
            if (w-wn >= 0) {
                dp[w] = max(dp[w], dp[w-wn]+vn);
                ans = max(ans, dp[w]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int m = sc.nextInt();

		for (int i=0; i<m; i++){
			n -= sc.nextInt();
		}

		if (n >= 0){
			System.out.println(n);
		} else {
			System.out.println("-1");
		}
	}
}

Measured memory_bytes: 37856
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;

typedef long long signed int ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N, M;

int Bcount(int bit,int n) {
	int count=0;
	REP(i, n) {
		if (bit & (1 << i)) {
			count++;
		}
	}
	return count;
}

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);



	cin >> N >> M;	
	int Mask[10] = {0};
	int P[10];
	int num;
	REP(i, M) {
		cin >> num;
		REP(j, num) {
			int tmp;
			cin >> tmp;
			Mask[i] += (1 << tmp-1);
		}
	}
	REP(i, M) {
		cin >> P[i];
	}
	int ans = 0;
	for (int bit = 0; bit < (1<<N); ++bit){
		ans++;
		REP(i, M) {
			int tmp = (Mask[i] & bit);
			if  (Bcount(tmp, N)% 2 != P[i]) {
				ans--;
				break;
			}
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
  	function get_max_keta($a,$b){
  		if($a<=$b){
          return strlen((string)($b));
        }else{
          return strlen((string)($b));
        }
	}


  	fscanf(STDIN,"%d",$n);
	$min = PHP_INT_MAX;

	for($i=1;$i*$i<=$n;$i++){
      if($n%$i==0){
        $new = get_max_keta($i,$n/$i);
        $min = min($new,$min);
      }
    }
	
	echo $min;

Measured memory_bytes: 16180
// AOJ 0564: Bug Party
// 2018.1.27 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef struct { int a, b; } T;
T tbl[300002];
long long sa[300002];
int n;

#define MAX 300002
int que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void max_heapify(int i)
{
	int l, r, max;
	int qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l] > que[i]) max = l; else max = i;
	if (r < qsize && que[r] > que[max]) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

int deq()
{
	int t;

	if (qsize == 0) return 0;
	t = que[0];
	que[0] = que[--qsize];
	max_heapify(0);
	return t;
}

void enq(int t)
{
	int i, max;
	int qt;

	i = qsize++;
	que[i] = t;
	while (i > 0 && que[max = PARENT(i)] < que[i]) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { return b->b - a->b; }

int check(int k)
{
	int i;
	long long s;
	
	if (!k) return 1;
	s = 0, qsize = 0;
	for (i = 0; i < k-1; i++) s += tbl[i].a, enq(tbl[i].a);
	for ( ; i < n; i++) {
		if (s + tbl[i].a <= (long long)k*tbl[i].b) return 1;
		s += tbl[i].a, enq(tbl[i].a);
		s -= deq();
	}
	return 0;
}
	
int main()
{
	int i, lo, hi, m;
	
	n = in();
	for (i = 0; i < n; i++) tbl[i].a = in(), tbl[i].b = in();
	qsort(tbl, n, sizeof(T), cmp);

	lo = 0, hi = n+1;
	while (lo + 1 < hi) {
		m = (lo + hi) >> 1;
		if (check(m)) lo = m; else hi = m;
	}
	printf("%d\n", lo);
	return 0;
}



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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n;
    cin >> n;

    int a[n], sum = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i], sum += a[i];
    
    for (int i = 0; i < n; i++)
        if (a[i] >= sum - a[i]) {
            cout << "No\n";
            return 0;
        }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
// #define mod 998244353
#define mod 1000000007
#define MAXN  1000001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



void solve()
{
    int n;
    cin>>n;
    vl a(n,0);
    ll ans = 1;
    ll maxv = pow(10,18);
    for(int i = 0 ; i < n ; i++)
    cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0] == 0)
    {
        cout<<0<<endl;
        return;
    }
    ld log_val = 0.000;
    for(int i = 0 ; i < n ; i++)
    log_val += log10(1.00*a[i]);
    if(log_val > 18.1)
    {
        cout<<-1<<endl;
        return;
    }
    for(int i = 0 ; i < n ; i++)
    {
        ans *= 1ll*a[i];
        if(ans > maxv)
        {
            cout<<-1<<endl;
            return;
        }    
    }
    cout<<ans<<endl;
}


int main()
{
    fast;
    int t;
    t = 1;
    // cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int W,a,b;
	cin>>W>>a>>b;
	if(W+a<b){
		ce(b-a-W)
	}else if(W+b<a){
		ce(a-b-W)
	}else{
		ce('0')
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <math.h>
#define ll long long
#define MIN(a, b) ((a > b) ? b : a)
using namespace std;

typedef struct process {
    string name;
    int t;
} process;


int main(void){
    ll n, q, t, elapsed;
    string name;
    queue<process> Q;
    
    cin >> n >> q;
    
    for (int i = 0; i < n; i++) {
        cin >> name >> t;
        process p;
        p.name = name;
        p.t = t;
        Q.push(p);
    }
    
    elapsed = 0;
    while (!Q.empty()) {
        process p = Q.front(); Q.pop();
        elapsed += MIN(q, p.t);
        p.t -= q;
        if (p.t <= 0) {
            cout << p.name << ' ' << elapsed << endl;
        }
        else {
            Q.push(p);
        }
    }
}



Measured memory_bytes: 6188
C[1<<20];F[1<<20];n,x,p;main(i){for(;++i<1e6;)for(p=i;p+i<=1e6;)C[p+=i]=1;for(;scanf("%d%d",&n,&x),p=n;printf(x?"%d\n":"NA\n",x)){for(memset(F,0,4e6),*F=1;n--;)for(scanf("%d",&p),i=p;i<=x;i++)F[i]|=F[i-p];for(;!F[x]|C[x];x--);}}

Measured memory_bytes: 8228
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    cout<<(n+1)/2;




}

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

int main() {
	int b[3]={1,0,0},i;
	char x,y;
	while(scanf("%c,%c",&x,&y)!=EOF) { swap(b[x-'A'],b[y-'A']); getchar(); }
	for (i=0;i<3;i++) if (b[i]==1) cout << (char)('A'+i) << '\n';
 return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    ll ca = 0, cb = 0, cc = 0;
    ll pa = a[0], pb = b[0], pc = c[0];
    for (int i = 1; i < n; ++i) {
        ca = max(pb, pc) + a[i];
        cb = max(pa, pc) + b[i];
        cc = max(pa, pb) + c[i];
        pa = ca, pb = cb, pc = cc;
    }
    cout << max(pa, max(pb, pc)) << endl;
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, W) = Read2Longs();
            // as 1-index
            var w = new long[N + 1];
            var v = new long[N + 1];

            for (var i = 1; i <= N; i++)
            {
                (w[i], v[i]) = Read2Longs();
            }

            var vSumMax = v.Sum();
            // i番目までの品物の中からvSumを達成するように選んだ場合の重さの最小値
            var dp = new long[N + 1, vSumMax + 1];

            // 初期化
            for (int i = 0; i <= N; i++)
            {
                for (int sumv = 0; sumv <= vSumMax; sumv++)
                {
                    dp[i, sumv] = int.MaxValue;
                }
            }

            dp[0, 0] = 0;

            for (int i = 1; i <= N; i++)
            {
                for (int j = 0; j <= vSumMax; j++)
                {
                    var notChoiceWeight = dp[i - 1, j];
                    if (j - v[i] >= 0)
                    {
                        var choiceWight = dp[i - 1, j - v[i]] + w[i];
                        dp[i, j] = Math.Min(choiceWight, notChoiceWeight);
                    }
                    else // sumV < v[i]
                    {
                        // v[i] 品物を選ぶことができない場合
                        dp[i, j] = notChoiceWeight;
                    }
                }
            }

            for (var val = vSumMax; val >= 0; val--)
            {
                if (dp[N, val] <= W) return val;
            }

            return null;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 106812
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;

int main(){
  int a, b, max;

  cin >> a >> b;
  max = a + b;

  if (max < a - b){
    max = a - b;
  }
  if (max < (a * b)){
    max = (a * b);
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256