akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>

using ll = unsigned long long;
using namespace std;

int main(void) {

    int n, m;
    string *s, *t;

    cin >> n;
    
    s = new string[n];

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

    cin >> m;

    t = new string[m];

    for(int j = 0; j < m; ++j) {
        cin >> t[j];
    }

    // sol
    unordered_map<string, int> red, blue;
    for(int i = 0; i < n; ++i) {
        red[s[i]] += 1;
    }

    for(int j = 0; j < m; ++j) {
        blue[t[j]] += -1;
    }

    unordered_set<string> keys;
    for(auto r : red) {
        keys.insert(r.first);
    }

    for(auto b : blue) {
        keys.insert(b.first);
    }

    vector<int> res;
    for(auto k : keys) {
        res.push_back(red[k]+blue[k]);
    }

    int max = *max_element(res.begin(), res.end());
    
    cout << std::max(max,0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, T, A, H;
    cin >> N;
    cin >> T >> A;
    T *= 1000;
    A *= 1000;
    int best_sc = 1 << 30;
    int best_i = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> H;
        int deg = T - H * 6;
        int sc = abs(A - deg);
        if (best_sc > sc) {
            best_sc = sc;
            best_i = i;
        }
    }
    cout << best_i << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int a[3];
    for(int i = 0; i < 3; i++) {
        std::cin >> a[i];
    }

  	if(a[0]*a[1] < a[2]){
        std::cout << (a[0]*a[1]) << std::endl;
    }else{
        std::cout << a[2] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> p(n);
	rep (i, m) {
		int a, b;
		cin >> a >> b;
		p[a - 1]++;
		p[b - 1]++;
	}
	bool ok = true;
	rep (i, n) if (p[i] % 2 != 0) ok = false;
	cout << (ok ? "YES" : "NO") << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int S, W;
	cin >> S >> W;
	if (S > W) {
		cout << "safe" << endl;
	}
	else {
		cout << "unsafe" << endl;
	}
	
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll n, capacity;
ll price[105], weight[105];
ll dp[105][MAX];

ll solve(){
    memset(dp, 0, sizeof(dp));

    for(int item=0; item<=n; item++){
        for(int w=0; w<=capacity; w++){
            if(item == 0|| w==0){
                dp[item][w]=0;
            }
            else if(w>=weight[item-1]){
                dp[item][w] = max(price[item-1]+dp[item-1][w-weight[item-1]], dp[item-1][w]);
            }
            else dp[item][w] = dp[item-1][w];
        }
    }
    return dp[n][capacity];
}

int main(){
    cin>>n>>capacity;
    for(int i=0; i<n; i++){
        cin>>weight[i]>>price[i];
    }
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int ar[1000005],cnt[1000005];
int main()
{
    int n,k,i,a,c1=0,c2=0;
    string s,s1,s2;
    s1="AC";s2="WA";
    cin>>n>>k;
    for(i=0;i<k;i++)
    {
        cin>>a>>s;
        if(ar[a]==0&&s==s1)
        {
            ar[a]=1;
            c1++;
            c2+=cnt[a];
        }
        else
            cnt[a]++;
    }
    cout<<c1<<" "<<c2<<endl;
}


Measured memory_bytes: 4736
s = input()
fir = int(s[:2])
sec = int(s[2:])
b = (1<=fir<=12)
c = (1<=sec<=12)
if b and c:
  t = "AMBIGUOUS"
elif b:
  t = "MMYY"
elif c:
  t = "YYMM"
else:
  t = "NA"
print(t)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> B;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    B = fetch_vec<int>(N-1);
}

void solve(){
    input();
    vector<int> A(N,0);
    A[0] = B[0];
    for(int i=0;i<N-1;i++){
        A[i+1] = min(B[i+1],B[i]);
    }
    A[N-1] = B[N-2];
    cout << accumulate(ALL(A),0) << endl;

}

int main()
{
    solve();
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	char ng[60][60], mg[60][60];
	for (int i = 0; i < n; i++)cin >> ng[i];
	for (int i = 0; i < m; i++)cin >> mg[i];

	int ans = 0;
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			int flg = 1;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (ng[i + k][j + l] != mg[k][l]) {
						flg = 0;
					}
				}
			}
			if(flg)ans = 1;
		}
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char s[100001];
  int a[100000];
  int i;
  scanf("%s", s);
  int lastRL=-1;
  int even;
  int odd;
  i=0;
  while(s[i]){
    a[i]=0;
    i++;
  }
  int n=i;
  for(i=0;i<n;i++){
    if(s[i]=='R' && s[i+1]=='L'){
      even=0;
      odd=0;
      while(lastRL<i){
        lastRL++;
        if((i-lastRL)%2) odd++; else even++;
      }
      a[i]+=even;
      a[i+1]+=odd;
      a[i+1]++; //for s[i+1]
      lastRL++;
      i++;
    }else if(s[i]=='L'){
      if((i-lastRL)%2){
        a[lastRL-1]++;
      }else{
        a[lastRL]++;
      }
      if(s[i+1]=='R'){
        lastRL=i;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a[200009];
long long s;

bool fun(int cur) {
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		int tmp = a[i] / cur;
		if (a[i] % cur == 0) tmp--;
		cnt += tmp;
	}
	return cnt <= k;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i] - 1;
	}
	sort(a, a + n);
	if (k >= s) {
		cout << 1 << E;
	}
	else {
		int l = 1, r = a[n - 1];
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			if (fun(mid)) r = mid;
			else l = mid;
		}
		cout << r << E;
	}
	//system("pause");
	return 0;
}

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

string fixedNum( string a )
{
    if( a.size() == 1 )
        return a;
    for( int i = 0; i < a.size(); i++ )
        if( '1'<= a[i] && a[i] <= '9' )
            return a.substr( i, a.size() );
    return "0";
}

string calcAddition( string a, string b )
{
    a = fixedNum(a); b = fixedNum(b);
    int as = a.size(), bs = b.size(), d = as > bs ? as - bs : bs - as;
    string s = "0", t = "0";
    for( int i = 0; i < d; i++ )
        as > bs ? t += "0" : s += "0";
    s += a; t += b;

    for( int i = s.size() - 1; i >= 1; i-- )
    {
        s[i] += t[i] - '0';
        if( s[i] > '9' )
        {
            s[i] -= 10;
            s[i-1]++;
        }
    }
    return s[0] == '0' ? s.substr( 1, s.size() ) : s;
}

string calcSubtraction( string a, string b )
{
    int as = a.size(), bs = b.size(), d = as - bs;
    string s = "", t = "";
    for( int i = 0; i < d; i++ )
        t += "0";

    s += a;
    t += b;

    for( int i = s.size() - 1; i >= 0; i-- )
    {
        if( s[i] < t[i] )
        {
            s[i] += 10;
            if( s[i-1] >= '1' )
                s[i-1]--;
            else
            {
                int j = i - 1;
                while( s[j] == '0' )
                    s[j--] += 9;
                s[j]--;
            }
        }
        s[i] -= ( t[i] - '0' );
    }

    if( s.size() == 1 )
        return s;

    for( int i = 0; i < s.size(); i++ )
    {
        if( '1' <= s[i] && s[i] <= '9' )
            return s.substr( i, s.size() );
    }
    return "0";
}

int main()
{
    string a, b, c, sum = "0", cnt = "1";
    bool j1 = false;
    cin >> a >> b;

    if( a == "0" )
    {
        cout << 0 << endl;
        return 0;
    }
    else if( a[0] == '-' && b[0] == '-' )
    {
        a = a.substr( 1, a.size() );
        b = b.substr( 1, b.size() );
    }
    else if( a[0] == '-' )
    {
        j1 = true;
        a = a.substr( 1, a.size() );
    }
    else if( b[0] == '-' )
    {
        j1 = true;
        b = b.substr( 1, b.size() );
    }
    else;

    c = b;
    int as = a.size(), bs = b.size(), cs, d = as - bs;
    for( int i = 0; i < d - 1; i++ )
    {
        c += "0";
        cnt += "0";
    }
    cs = c.size();

    bool j2 = false;
    while( c != b )
    {
        while( as > cs || as == cs && a >= c )
        {
            j2 = true;
            a = calcSubtraction( a, c );
            as = a.size();
            sum = calcAddition( sum, cnt );
        }
        c = c.substr( 0, c.size() - 1 );
        cnt = cnt.substr( 0, cnt.size() - 1 );
        cs = c.size();
    }

    while( as > bs || as == bs && a >= b )
    {
        j2 = true;
        a = calcSubtraction( a, b );
        sum = calcAddition( sum, cnt );
        as = a.size();
    }

    if( j1 && j2 )
        cout << '-';
    cout << sum << endl;

    return 0;
}



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

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

    int N;
    cin >> N;
    vector<ll> d(N);

    rep(i, N) { cin >> d[i]; }

    sort(all(d));
    ll left = d[N / 2 - 1], right = d[N / 2];

    cout << right - left << endl;
}

Measured memory_bytes: 1024
module solution;
import std.algorithm, std.array, std.conv, std.stdio;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		int res = 0;
		foreach (c; a)
		{
			while (c % 2 == 0)
			{
				res += 1;
				c /= 2;
			}
		}
		writeln (res);
	}
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int N,T,A;
  cin >> N >> T >> A;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  T *= 1000;
  A *= 1000;
  int ans = -1;
  ll min_diff = 99999999;
  for (int i = 0; i < N; i++) {
    ll t = T - (H[i] * 6);
    if (abs(A - t) < min_diff) {
      min_diff = abs(A - t);
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  int ans = 0;
  
  for(int i = 0; i < N - 1; i++){
    if(A.at(i) > A.at(i + 1)) ans += (A.at(i) - A.at(i + 1));
  }
  ans += A.at(N - 1);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i(a);i<=(b);++i)

typedef long long ll;

#define gc getchar()
inline int read(){char c,p=0;int w;
	while(!isdigit(c=gc))if(c=='-')p=1;w=c&15;
	while(isdigit(c=gc))w=w*10+(c&15);return p?-w:w;
}

template<typename T,typename U>inline bool smin(T&x,const U&y){return y<x?x=y,1:0;}
template<typename T,typename U>inline bool smax(T&x,const U&y){return x<y?x=y,1:0;}

const int N=5e5+5;
int n,a[N],m,len;
struct node{int l,r,v;}q[N];
int top;
bool check(int ans){
	q[top=1]=(node){1,a[1],1};
	REP(i,2,n){
		int x=a[i];
		int l=1,r=top;
		while(l<r){
			int mid=l+r+1>>1;
			if(q[mid].l<=x)l=mid;else r=mid-1;
		}
		if(q[l].r<x){
			if(q[l].v==1)q[l].r=x;
			else q[++top]=(node){q[l].r+1,x,1};
		}else{
			q[top=l].r=x;
			while(top&&q[top].v==ans)--top;
			if(!top)return 0;
			int v=q[top].v,p=q[top].r;
			if(--q[top].r<q[top].l)--top;
			if(!top||v+1!=q[top].v)q[++top]=(node){p,p,v+1};else q[top].r=p;
			if(p<x)q[++top]=(node){p+1,x,1};
		}
	}
	return 1;
}
int main(){
	n=read();
	REP(i,1,n)a[i]=read();
	int l=1,r=1e9;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid))r=mid;else l=mid+1;
	}
	std::cout<<l;
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
    int n,k;
    cin>>n>>k;
    int cnt[n+1]={0};
    rep(i,0,k)
    {
        int d;
        cin>>d;
        rep(i,0,d)
        {
            int s;
            cin>>s;
            cnt[s]++;
        }
    }
    int res=0;
    repA(i,1,n)
    {
        if(cnt[i]==0)
            res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int MAXN = 1000*100 + 1  ;
const int INF = INT_MAX;
int main (){
	fast_io();
	int n ;
	cin >> n ;
	set<string>s ; 	
	for(int i = 0 ; i < n ;++i )
	{	string x ;
		cin >> x ;
		s.insert(x);
		
		
	}
	
	cout << ((int)s.size()) , br 


	//misunderstood problem nvm :( whoami
 	 
	return 0 ;

}
 


Measured memory_bytes: 19216
#include <cstdio>
#include <cctype>

int n, a[100010], tot;

int read() {
    int ret, fl = 1;
    char ch;
    while(!isdigit(ch = getchar()))
        (ch == '-') && (fl = -1);
    ret = ch - '0';
    while(isdigit(ch = getchar()))
        ret *= 10, ret += ch - '0';
    return ret * fl;
}

void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int abs(int x) {
    return x > 0 ? x : -x;
}

int main() {
    n = read();
    for(int i = 1; i <= n; ++i)
        a[i] = read(), tot += abs(a[i] - a[i - 1]);
    tot += abs(a[n]);
    for(int i = 1; i <= n; ++i) {
        int ans;
        if(a[i] > a[i - 1]) {
            if(a[i + 1] > a[i]) ans = tot;
            else {
                if(a[i + 1] > a[i - 1]) ans = tot + a[i + 1] * 2 - a[i] * 2;
                else ans = tot + a[i - 1] * 2 - a[i] * 2;
            }
        }
        else {
            if(a[i + 1] < a[i]) ans = tot;
            else {
                if(a[i + 1] > a[i - 1]) ans = tot + a[i] * 2 - a[i - 1] * 2;
                else ans = tot + a[i] * 2 - a[i + 1] * 2;
            }
        }
        print(ans), putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int H[N], l=0, maxl=0;

  rep(i,N) {
    cin >> H[i];
    if (i==0) continue;
    if (H[i]<=H[i-1]) l++;

    if (i==N-1 || H[i]>H[i-1]) {
      maxl = max(maxl, l);
      l = 0;
    }

  }
  
  cout << maxl << endl;


  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 640
using System;

namespace abc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力、大文字変換
            string[] input = Console.ReadLine().Split(' ');
            string a = input[0].ToUpper();
            string b = input[1].ToUpper();
            string c = input[2].ToUpper();
            //出力
            Console.WriteLine($"{a[0]}{b[0]}{c[0]}");

        }
    }
}


Measured memory_bytes: 13140
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int s;
    cin>>s;
    vec a(10000000);
    a[s]=1;
    int count=2;
    while(true){
        if(s%2==0) s=s/2;
        else s=s*3+1;
        // debug(s);

        if(a[s]==0){
            a[s]=count;
            count++;
        }
        else if(a[s]!=0){
            cout<<count<<endl;
            break;
        }
    }
    
}

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

int main(){
    int H, W;
    cin >> H >> W;
    
    int h, w;
    cin >> h >> w;
    
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int b[n];
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    int ans[3][3];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(b[i]==a[j][k])
                {
                    ans[j][k]=1;
                }
            }
        }
    }
    bool p=false;
    for(int i=0;i<3;i++)
    {
        if(ans[i][0]==ans[i][1] && ans[i][1]==ans[i][2] && ans[i][2]==1)
        {
            p=true;
        }
        else if(ans[0][i]==ans[1][i] && ans[1][i]==ans[2][i] && ans[2][i]==1)
        {
            p=true;
        }
    }
    if(ans[0][0]==ans[1][1] && ans[1][1]==ans[2][2] && ans[2][2]==1)
    {
        p=true;
    }
    if(ans[0][2]==ans[1][1] && ans[1][1]==ans[2][0] && ans[2][0]==1)
    {
        p=true;
    }
    if(p)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    /*for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}







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

#define Uni All right
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;--i)
#define LREP(i,a) for(int i=Head[a];i;i=Next[i])
#define LL long long
#define Mod 1000000007 
 
static const int M=200004;
int n,A[M],F[M],Lt[M];
int main(){
	scanf("%d",&n);
	F[0]=1;
	REP(i,1,n+1){
		int x;
		scanf("%d",&x);
		if(Lt[x] && Lt[x]!=i-1)
			F[i]=(F[i-1]+F[Lt[x]])%Mod;
		else F[i]=F[i-1];
		Lt[x]=i;
	}
	printf("%d\n",F[n]);
	
	return 0;
}

Measured memory_bytes: 1792
// AtCoder Beginner Contest 164 - Problem B: Battle (https://atcoder.jp/contests/abc164/tasks/abc164_b)
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int next = 0;

    while (A > 0 and C > 0)
    {
        switch (next) {
        case 0:
            C -= B;
            break;

        default:
            A -= D;
            break;
        }

        next = 1 - next;
    }

    cout << (next ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,d,ans=0;
    cin>>n>>a>>b>>c>>d;
    string t;
    cin>>t;
    string s='#'+t+'#';
    if(c>d)
    {
        for(int i=b;i<=d;i++)
        {
            if(s[i-1]=='.'&&s[i+1]=='.'&&s[i]=='.') ans++;
        }
        if(ans==0)
        {
            cout<<"No";
            return 0;
        }
    }
    for(int i=b;i<d;i++)
    {
        if(s[i]=='#'&&s[i+1]=='#')
        {
            cout<<"No";
            return 0;
        }
    }
    for(int i=a;i<c;i++)
    {
        if(s[i]=='#'&&s[i+1]=='#')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3840
N, M= (int(i) for i in input().split())

L_max = 1
R_min = N

for i in range(M):
    L, R = map(int, input().split())
    L_max = max(L_max,L)
    R_min = min(R_min,R)

ans = set(range(L_max,R_min+1))

print(len(ans))


Measured memory_bytes: 11884
// abc046_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    REP(i, N) cin >> T[i] >> A[i];

    ll t=T[0], a=A[0];
    REPN(i, 1, N){
//        print(t, a);
//        ll x = T[i];
//        ll y = A[i];
//        while (not (t <= x && a <=y)){
//            x += T[i];
//            y += A[i];
//        }
        ll x = ((t + T[i] - 1) / T[i]);
        ll y = ((a + A[i] - 1) / A[i]);
        ll z = max(x, y);

        t = T[i] * z;
        a = A[i] * z;
    }
    ll ans = t + a;
    print(ans);


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(void)
{
	int a,b,d,r;



	double x,y,f;


	cin>>a>>b;

	
	d=a/b;

	r=a%b;

	x=a;
	
	y=b;

	f=x/y;
	


	
	cout<<fixed;

	cout<<d<<" "<<r<<" "<<setprecision(6)<<f<<endl;
	return 0;
}



Measured memory_bytes: 3260
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder st = new StringBuilder();
        
        String[] ary = new String[3];
        int count = 0;
        
        ary = br.readLine().split(" ");
        int a = Integer.parseInt(ary[0]);
        int b = Integer.parseInt(ary[1]);
        int c = Integer.parseInt(ary[2]);
        
        for(int i = a; i <= b; i++){
            if(c % i == 0){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 24416
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int d[n][2];
  int dis;
  d[0][0] = d[0][1] = 0;
  for(int i=1;i<n;i++){
    cin >> dis;
    d[i][0] = dis;
  }
  for(int i=1;i<n;i++) d[i][1] = d[i-1][1] + d[i][0];
  //for(int i=0;i<n;i++) cout << d[i][1] << ' ';
  //cout << endl;
  int ans = 0;
  int a,mema=0;
  for(int i=0;i<m;i++){
    cin >> a;
    if(a>0) ans += d[mema+a][1] - d[mema][1];
    else ans += d[mema][1] - d[mema+a][1];
    ans %= 100000;
    mema += a;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
const int maxn = 50 + 5;

int n, m, q, A[maxn], a[maxn], b[maxn], c[maxn], d[maxn];
int res;

void dfs(int dep, int pre) {
    if (dep == n + 1) {
        int ans = 0;
        for (int i = 1; i <= q; i++) if (A[b[i]] - A[a[i]] == c[i]) {
            ans += d[i];
        }
        res = max(res, ans);
        return;
    }

    for (int i = pre; i <= m; i++) {
        A[dep] = i;
        dfs(dep + 1, i);
    }
}

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 1; i <= q; i++) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
    dfs(1, 1);
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 3780
//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 <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++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 n; cin >> n;
	vector<int> d(n);

	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	int ans = d[n / 2] - d[n / 2 - 1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

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

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int a[101]={0};
        rep(i,n){
            cin >> a[i];
        }

        int ans=0;
        rep(i,n){
            rep(i,n-1){
                if(a[i]>a[i+1]){
                    swap(a[i],a[i+1]);
                    ans++;
                }
            }
        }

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

ll gcd (ll x, ll y){
    if(x % y == 0) return y ;
    ll r = x % y ;
    return gcd(y, r) ;
}

int main () {
    ll a, b, c, d ;
    cin >> a >> b >> c >> d ;
    ll tot = b - a + 1 ; 
    ll div1 = b / c - a / c ;
    ll div2 = b / d - a / d ; 
    if(a % c == 0){
        div1++ ; 
    }
    if(a % d == 0){
        div2++ ;
    }
    ll gd = gcd(c, d) ;
    gd = gd * (c / gd) * (d / gd) ; 
    ll div3 = b / gd - a / gd ; 
    if(a % gd == 0){
        div3++ ; 
    }
    ll de = div1 + div2 - div3 ;
    cout << tot - de << endl ; 
}



Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define cle(a) memset(a,0,sizeof(a))
#define maxn 1000005

using namespace std;
typedef long long ll;
//N 表示
int a[100005];
long long dp[100005];
int main()
{
    int n;
    while(cin>>n)
    {
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=n;i++)
           {
               cin>>a[i];
           }


        sort(a,a+n+1);
        for(int i=1;i<=n;i++)
            dp[i]=dp[i-1]+a[i];
           // cout<<"---"<<endl;
       int flag=1;
        for(int i=n-1;i>=1;i--)
        {
            if(dp[i]*2>=a[i+1])flag++;
            else break;
//            int temp=0;
//            for(int j=i;j<=n;j++)
//             {
//                 if(dp[j]*2>=a[j+1])temp++;
//
//             }
//             if(temp==n-i)flag++;

        }
cout<<flag<<endl;
    }

    return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
itl = lambda: list(map(int, input().strip().split()))


def solve():
    N = int(input())
    nums = itl()
    S = input().strip()

    basis = []
    for i in range(N - 1, -1, -1):
        v = nums[i]
        for b in basis:
            v = min(v, v ^ b)
        if v:
            if S[i] == '1':
                return 1
            basis.append(v)
    return 0    


T = int(input())
for _ in range(T):
    print(solve())

Measured memory_bytes: 68932
#include <stdio.h>

int main() {
    int alpha[27] = {0};
    char check;
    char input;
    
    while(scanf("%c", &input) != EOF){
        if('a' <= input && input <= 'z'){
            alpha[input - 'a']++;
        } else if('A' <= input && input <= 'Z'){
            alpha[input - 'A']++;
        }
    }
    
    for(check = 'a'; check <= 'z'; check++){
        printf("%c : %d\n",check,alpha[check - 'a']);
    }
    
    return 0;
}


Measured memory_bytes: 2060
x, k, d = map(int, input().split())

if abs(x) - (d * k) >= 0:
    print(abs(x) - (d * k))
elif (k - (abs(x) // d)) % 2 == 0:
    print(abs(x) % d)
else:
    print(abs(abs(x) % d - d))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll ans = N + N * N + N * N * N;
  ANS;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int X; cin>>X;
    ll ans=0;
    int k=X/500;
    ans+=1000LL*k;
    X-=k*500;
    ans+=5LL*(X/5);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));

if ($n === 2)
{
	echo abs($a[0] - $a[1]);
}
else
{
	$total = array_sum($a);
	$ans = abs($total - 2 * $a[0]);
	$x = 0;
	for ($i = 0; $i < $n-1; $i++)
	{
                $x += $a[$i];
		$ans = min($ans, abs($total - 2 * $x));
	}
	echo $ans;
}

Measured memory_bytes: 39796
S=input()
def bit_sum(list):
    if len(list)==1:
        return int(list[0])
    else:
        n=len(list)
        s=0
        for i in range(1,n):
            s+=(bit_sum(list[:i])+int(list[i:])*2**(i-1))
        s+=int(list)
        return s

print(bit_sum(S))


Measured memory_bytes: 2940
main :: IO ()
main = do
  [n, a, b] <- getInts
  xs <- getInts
  print $ solve xs a b

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

solve :: [Int] -> Int -> Int -> Int
solve xs a b = go xs (0, 0) 
  where
    go :: [Int] -> (Int, Int) -> Int 
    go (y:ys) (n, m)
     | null ys = n*a + b*m
     | otherwise = if (head ys - y) * a > b
                   then go ys (n, m+1)
                   else go ys (n+(head ys - y), m)

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


int main()
{
   ll n;string s;
   cin>>n;
   map<string , ll>m;
   for(ll i=0;i<n;i++){
        cin>>s;
    if(m.count(s)){
        m[s]++;
    }
    else{
        m[s]=1;
    }


   }
cout<<m.size();
    return 0;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0, co = 0;
  char bf;
  rep(i, s.size()){
    if(i == 0){
      bf = s.at(i);
      co++;
      continue;
    }
    if(bf != s.at(i)){
      ans += co-1;
      bf = s.at(i);
      co = 0;
    }
    co++;
  }
  ans += co-1;
  // cerr << ans << endl;
  ans = min(n-1, ans+2*k);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
def main():
    k=int(input())
    a,b=map(int,input().split())
    d=a//k
    tmp=k*d
    while tmp<=b:
        if tmp>=a and tmp<=b:
            print('OK')
            exit()
        tmp+=k
    print('NG')

if __name__=='__main__':
    main()

Measured memory_bytes: 9116
#include <iostream>
using namespace std;
#define ll long long
#include <algorithm>

int main(){

    int n;
    cin >> n;
    ll int a[n],ans=0;
    for(int i=0;i<n;i++) cin >> a[i];

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans = max(ans,abs(a[i]-a[j]));
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int H, W;
  cin >> H >> W;
  long long int sum = H * W;
  if(H==1||W==1){
    cout <<1<< endl;
  }else{
    if(sum%2==0){
      cout << sum / 2 << endl;
    }else{
      cout << sum / 2 + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  int ans,tmp;
  ans=0;
  tmp=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='G'||s.at(i)=='C'){
      tmp++;
    }
    else{
      if(tmp>ans){
        ans=tmp;
      }
    tmp=0;
    }
  }
  if(tmp>ans){
    ans=tmp;
  }
  cout << ans << endl;
}
  

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

bool is_prime(long long N) {
    if (N == 1)
        return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0)
            return false;
    }
    return true;
}

int main() {
    int Q;
    cin >> Q;
    int MAX = pow(10, 5);
    vector<int> sum(MAX, 0);
    for (int i = 1; i <= MAX; i += 2) {
        if (is_prime(i) && is_prime((i + 1) / 2))
            sum[i] = 1;
    }

    for (int i = 0; i < MAX - 1; i++) {
        sum[i + 1] += sum[i];
    }

    rep(i, Q) {
        int a, b;
        cin >> a >> b;
        a--;
        cout << sum[b] - sum[a] << endl;
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x =sc.nextInt();
    int y =sc.nextInt();
    if(y%2==1){
      System.out.println("No");
    }else if(y>=2*x && y<=4*x){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for(int i=0; i<n; i++) {
    b[i] = i+1;
  }
  
  int count = 0;
  for(int i=0; i<n; i++) {
    if(a[i] != b[i]) count++;
  }
  if(count == 0 || count == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	N, K, q, r int
)

func readVariables() {
	N, K = nextInt(), nextInt()
}

func main() {
	readVariables()
	answer := 0
	for N > 0 {
		answer++
		N /= K
	}
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	char c_fes[13];
	scanf("%s",c_fes);
	int i=0;
	for(i=0;i<12;i++){
		if(i==4){
			printf(" ");
		}
		printf("%c",c_fes[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){
  int64_t A , B, C;
  int N;
  cin >> N;
  A=2;
  B=1;
  C=0;
  if(N==1)
    cout << 1 << endl;
  else{
  for(int i=0;i<N-1;i++){
    C=A+B;
    A=B;
    B=C;
  }
  cout << C << endl;
  }
}


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

int a[5010], n, k;;
bool dp1[5010][5010], dp2[5010][5010];
int solve(int mid){
	if(a[mid] >= k)return 1;
	int dp[5010] = {};
	/*printf("%lld: ", a[mid]);
	for(int i = 1;i <= k;i++)printf("%lld ",dp1[mid-1][i]);
	printf("\n");*/
	for(int i = 1;i <= k;i++)dp[i] = dp2[n-mid][i];
	for(int i = 1;i <= k;i++){
		if(dp1[mid-1][i] == 0)continue;
		int x = i;
		for(int j = k;j >= 1;j--){
			if(j-x >= 0)dp[j] += dp2[n-mid][j-x];
			dp[j] = !!dp[j];
		}
	}
	for(int i = k;i >= 1;i--)dp[i] += dp[i+1];
	if(dp[k-a[mid]] > 0)return 1;
	return 0;
}

signed main(){
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
	
	sort(a+1,a+n+1);
	dp1[0][0] = dp2[0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < k;j++){
			dp1[i][j] = dp1[i-1][j];
			if(j-a[i] < 0)continue;
			if(dp1[i-1][j-a[i]])dp1[i][j] = 1;
		}
	}
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < k;j++){
			int x = n-i+1;
			dp2[x][j] = dp2[x-1][j];
			if(j-a[i] < 0)continue;
			if(dp2[x-1][j-a[i]])dp2[x][j] = 1;
		}
	}
	
	int lb = 0, ub = n+1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		int res = solve(mid);
		if(res)ub = mid;
		else lb = mid;
	}
	printf("%lld\n", ub-1);
	/*for(int i = 1;i <= n;i++){
		for(int j = 1;j <= k;j++)printf("%d ", dp2[i][j]);
		printf("\n");
	}*/
	return 0;
}

Measured memory_bytes: 49280
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        double radius = input.nextDouble();
        double area = Math.PI * Math.pow(radius, 2);
        double cur = 2*Math.PI*radius;
        System.out.printf("%.6f %.6f",area, cur);
    }
}


Measured memory_bytes: 28228
/*
 * Name        : a
 * Creat       : Fri Jul 12 17:47:54 CST 2019
 * Accept      : Fri Jul 12 17:49:18 CST 2019
 * Author      : landcold7
 * Motivation  : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  string a;
  cin >> a;
  for (int i = 0; i < 9; ++i) {
    string t = string(2, (char)(i + '0'));
    if ((int) a.find(t) != -1) {
      cout << "Bad" << "\n";
      return;
    }
  }
  cout << "Good" << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
//A +-x
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int a,b,sum,dif,pro,n,ans;
  cin>>a>>b;
  sum=a+b;
  dif=a-b;
  pro=a*b;
  n=max(sum,dif);
  ans=max(n,pro);
  cout<<ans<<endl;
}


Measured memory_bytes: 256