akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 500
#define MOD 1000000007
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define endl "\n"
#define eps 1e-9
#define PI 3.141592653589793
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
#define debug(x) cout<<#x<<"="<<x<<endl;
int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
	string a;
	cin>>a;
	string b="";
	REP(0,a.length())if(a[i]!='x')b+=a[i];
	string c=b;
	reverse(all(c));
	if(c!=b){
        cout<<"-1";
        return 0;
	}
	lo in,jo;
	if(b.length()%2==0){
        lo j=-1;
        REP(0,a.length()){
            if(a[i]!='x')j++;
            if(j==b.length()/2-1){
                in=i;
                break;
            }
        }
        j=b.length();
        IREP(a.length()-1,0){
            if(a[i]!='x')j--;
            if(j==b.length()/2){
                jo=i;
                break;
            }
        }
	}
	else{
        lo j=-1;
        REP(0,a.length()){
            if(a[i]!='x')j++;
            if(j==b.length()/2){
                in=i;
                jo=i;
                break;
            }
        }
	}
	lo i=in;
	lo ans=0;
	lo j=jo;
	while(i>=0 and j<a.length()){
        if(a[i]=='x' and a[j]!='x'){
            ans++;
            i--;
        }
        else if(a[j]=='x' and a[i]!='x'){
            ans++;
            j++;
        }
        else{
            i--;
            j++;
        }
	}
	if(i>=0)ans+=(i+1);
	if(j<a.length())ans+=a.length()-j;
	cout<<ans<<endl;
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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;
};

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d2 > d1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q, n;
  cin >> q >> n;
  vector<vector<int>> wt(n, vector<int>(2 * n, 0));
  for (int _ = 0; _ < q; _++) {
    int i, j;
    cin >> i >> j;
    i %= 2 * n;
    int par = i / n;
    i %= n;
    j %= 2 * n;
    char clr;
    cin >> clr;
    if (clr == 'B' ^ par) {
      wt[i][j]++;
    } else {
      wt[i][j]--;
    }
  }
  vector<vector<int>> ac(n + 1, vector<int>(2 * n + 1, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 2 * n; j++) {
      ac[i][j] = ac[i - 1][j] + ac[i][j - 1] - ac[i - 1][j - 1] + wt[i - 1][j - 1];
    }
  }
  int ans = 0;
  for (int di = 0; di < n; di++) {
    for (int dj = 0; dj < n; dj++) {
      int tmp = ac[n][2 * n] - 2 * ac[n][dj + n] + 2 * ac[n][dj]
      -2 * ac[di][2 * n] + 4 * ac[di][dj + n] - 4 * ac[di][dj];
      ans = max(ans, abs(tmp));
    }
  }
  ans = (ans + q) / 2;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

using T = tuple<ll, ll, ll>;

int main() {
    ll n;
    cin >> n;
    vector<T> xyh;
    ll idx;
    for (ll i = 0, x, y, h; i < n; i++) {
        cin >> x >> y >> h;
        xyh.push_back(T(x, y, h));
        if (h > 0) idx = i;
    }
    for (ll i = 0; i <= 100; i++) {
        for (ll j = 0; j <= 100; j++) {
            ll h = get<2>(xyh[idx]) + abs(get<0>(xyh[idx]) - i) + abs(get<1>(xyh[idx]) - j);
            bool flag = true;
            for (ll k = 0; k < n; k++) {
                ll tmp = h - abs(get<0>(xyh[k]) - i) - abs(get<1>(xyh[k]) - j);
                tmp = max(tmp, 0LL);
                if (tmp != get<2>(xyh[k])) flag = false;
            }
            if (flag) {
                cout << i << ' ' << j << ' ' << h << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b+c)
    cout<<"Yes"<<endl;
  else if(b==a+c)
    cout<<"Yes"<<endl;
  else if(c==a+b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
use proconio::{input, marker::Usize1};
use std::mem::MaybeUninit;

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    let mut sq = Vec::new();
    let mut dfs = unsafe { MaybeUninit::uninit().assume_init() };
    let rec = &mut dfs as *mut dyn FnMut() -> u64;
    dfs = || {
        if sq.len() == n {
            qs.iter()
                .map(|&(a, b, c, d)| if sq[b] - sq[a] == c { d } else { 0 })
                .sum()
        } else {
            let last = *sq.last().unwrap_or(&1);
            (last..=m)
                .map(|x| {
                    sq.push(x);
                    let ret = unsafe { (*rec)() };
                    sq.pop();
                    ret
                })
                .max()
                .unwrap()
        }
    };
    println!("{}", dfs());
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define repUp(i, n) for(int i = 0; i <= n; i ++)
#define vpair(d)	vector<pair<d, d> >
#define pair(d)		pair<d,d >

using namespace std;


int main(){
	int n;
	cin >> n;
	
	if(n%4 == 0 || n%7 == 0)
		cout << "Yes" << endl;
	else{
		for(int i = 0; i < n; i ++){
			for(int j = 0; j<n; j++){
				if(i*4 + j * 7 == n){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
A.sort()
z=N//2
if not N%2==0:
    An=sum(A[z+2:])*2 - sum(A[:z-1])*2 - A[z-1] + A[z+1] + max(-A[z-1]+A[z], -A[z] + A[z+1])
else:
    An=sum(A[z+1:])*2-sum(A[:z-1])*2-A[z-1]+A[z]
print(An)

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

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double n, x, t;
  cin >> n >> x >> t;
  cout << (int)(ceil(n/x) * t) << endl;
}


Measured memory_bytes: 3736
// AC - C - A x B + C

#include <bits/stdc++.h>
using namespace std;

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

    int n,r,i,j,d,s = 0; cin >> n;
    r = sqrt(n);

    for(i = 1; i <= n; i++)
        for(j = 1; j <= (n/i); j++){
            d = n - (i*j);
            if(d > 0) s = s + 1;
        }
    cout << s <<"\n";
    return 0;
}

Measured memory_bytes: 3692
// atcoder/abc169/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int a, b;
  while (cin >> a >> b) {
    cout << a * b << endl;
  }

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],n;
ll f[N][2];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i);
	f[0][1]=-linf;
	rep(i,1,n){
		f[i][0]=f[i-1][0]+(a[i]>>1);
		if(a[i]>1) getmax(f[i][0],f[i-1][1]+((a[i]-1)>>1));
		if(!a[i]){
			f[i][1]=-linf;
			continue;
		}
		--a[i];
		f[i][1]=f[i-1][0]+(a[i]>>1)+1;
		if(a[i]>1) getmax(f[i][1],f[i-1][1]+((a[i]-1)>>1)+1); 
	}
	printf("%lld\n",f[n][0]); 
	return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  int count = 0;
  
  for ( int i = 0; i < N -2; i++){
    if ( S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 200005;
  const int INF = 1e16;
  const double PI = acos(-1);


int ans = 0;

int arr1[N],arr2[N],arr3[N];


int32_t main()
{
       

    IOS


    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;



    for(int i = 1; i <= a; i++)
    {
      cin >> arr1[i];
    }

    for(int i = 1; i <= b; i++)
    {
      cin >> arr2[i];
    }

    for(int i = 1; i <= c; i++)
    {
      cin >> arr3[i];
    }

    sort(arr1+1,arr1+a+1,greater<int>());
    sort(arr2+1,arr2+b+1,greater<int>());
    sort(arr3+1,arr3+c+1,greater<int>());


    vector<int> v;


     for(int i = 1; i <= x; i++)v.PB(arr1[i]);




     for(int i = 1; i <= y; i++)v.PB(arr2[i]);




    sort(all(v));

    int ans = 0;

    int j = 1;

    //cout << v.size() << endl;

    for(int i = 0; i < v.size(); i++)
    {
      if(v[i] < arr3[j] and j <= c)
      {
        v[i] = arr3[j++];
      }
    }
    for(int i = 0; i < v.size(); i++)
    {
      ans += v[i];
    }

    cout << ans;
  return 0;
} 

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

using namespace std;

int main()
{
/*string s;
string t;

cin>>s;
cin>>t;
int contador=0;
for(int i=0;i<3;i++)
{
	if(s[i]==t[i])
	{
		contador=contador+1;
	}
	
	
}
cout<<contador;*/
/*string s;
cin>>s;
sort(s.begin(),s.end());

if((s[0]==s[1])&&(s[2]==s[3])&&(s[0]!=s[3]))
{
	cout<<"Yes"<<endl;
	
}
else
{
	cout<<"No"<<endl;
}*/

/*
int n,k;
string s;
cin>>n;
cin>>k;
cin>>s;
tolower(s[k-1]);

cout<<s<<endl;*/
/* string s;

cin>>s;
int contador1=0;
int contador2=0;
int total=s.size();
for(int i=0;i<total;i++)
{
	if(isupper(s[i]))
	{
		contador1=contador1+1;
	}
	else
	{
		contador2=contador2+1;
	}

}


	if(contador1<=contador2)
	{
		
		for(int i=0;i<total;i++)
		{
			
			cout<<char(tolower(s[i]));
		}
	}
	else
	{
		for(int i=0;i<total;i++)
		{
			cout<<char(toupper(s[i]));
		}
	}
*/




/*int n;
string s;
cin>>n;
for(int i=0;i<n;i++)
		{
			cin>>s;
			
			int total=s.size();
			if(total>10)
			{
				cout<<s[0]<<total-2<<s[total-1];
				
				
				
			}
			else
			{
				cout<<s;
			}
			
			
		}*/
		
/*		int n;
		string s;
		cin>> n;
		cin>>s;
		int total=s.size();
		for(int i=0;i<total;i++)
		{
			s[i]=s[i]+n;
			
		}
		int valor =int('Z');
		int valor2 =int('Z'-'A');
		for(int i=0;i<total;i++)
		{
			if(s[i]>valor)
			{
				s[i]=s[i]-valor2-1;
			}
			
		}
		cout<<s<<endl;*/
		int a,b;
		string s;
		
		cin>>a;
		cin>>b;
		cin>>s;
		s[b-1]=tolower(s[b-1]);
		cout<<s;
return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

const int N = 81;
const int MAXDIFF = 2 * N * N;

bitset<2 * MAXDIFF> dp[N][N];

int a[N][N];

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < 2 * MAXDIFF; k++) {
				dp[i][j][k] = 0;
			}
		}
	}

	dp[0][0][0] = 1;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int x;
			cin >> x;
			a[i][j] += x;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int x;
			cin >> x;
			a[i][j] -= x;
		}
	}
	dp[0][0][MAXDIFF + a[0][0]] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i + 1 < n) {
				dp[i + 1][j] |= (dp[i][j] >> abs(a[i + 1][j]));
				dp[i + 1][j] |= (dp[i][j] << abs(a[i + 1][j]));	
			}  
			if (j + 1 < m) {
				dp[i][j + 1] |= (dp[i][j] >> abs(a[i][j + 1]));
				dp[i][j + 1] |= (dp[i][j] << abs(a[i][j + 1]));	
			}
		}
	}
	int ans = 2 * MAXDIFF;
	for (int i = 0; i < 2 * MAXDIFF; i++) {
		if (dp[n - 1][m - 1][i]) {
			ans = min(ans, abs(i - MAXDIFF));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 21376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] L = new int[M];
        int[] R = new int[M];
        
        int resL = 1;
        int resR = N;
        
        for(int i = 0; i < M; i++){
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
            
            resL = Math.max(resL, L[i]);
            resR = Math.min(resR, R[i]);
        }

        System.out.println( Math.max(resR - resL + 1, 0) );

    }
}


Measured memory_bytes: 64352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b; cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int main(){
	string s;
	cin >> s;
	int top = 0;
	if(s[0] == 'o') top++;
	if(s[1] == 'o') top++;
	if(s[2] == 'o') top++;
	int ret = top*100+700;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
//ysh_gpta
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
typedef long long ll;
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}
//void printArray(vi &v){for(int i=0;i<v.size();i++) cout<<v[i]<<endl; cout<<endl; }

vvi dp(105,vi(100005,0));
vvi s(105,vi(100005,0));

int main(){
   FastIO
   ll n,k;
   cin>>n>>k;
   vi v(n);
   for(int i=0;i<n;i++)
   cin>>v[i];
//    sort(v.begin(),v.end());
   vvi dp(105,vi(100005,0));
    vvi s(105,vi(100005,0));

   dp[0][0]=1;
   s[0][0]=1;
   for(int i=1;i<n;i++){
       dp[i][0] = 1;
       s[i][0] = 1;
   }
   ll sum = 0;
   for(int i=0;i<n;i++){
       sum+=v[i];
       ll c=1;
       for(int j=1;j<=k;j++){
           if(i==0 && j<=sum)
           dp[i][j]=1;
           else if(sum==j){
               dp[i][j]=1;
           }else if(j>sum){
               dp[i][j] = 0;
           }
           else{
               dp[i][j] = s[i-1][j];
               if(j-v[i]-1>=0)
               dp[i][j] -= s[i-1][j-v[i]-1];
           }
           dp[i][j] = (dp[i][j]+MOD)%MOD;
           c = (c + dp[i][j])%MOD;
           s[i][j] = c;
       }
   }

//    for(int i=0;i<=n;i++){
//        for(int j=0;j<=k;j++)
//        cout<<dp[i][j]<<" ";
//        cout<<endl;
//    }
//       for(int i=0;i<=n;i++){
//        for(int j=0;j<=k;j++)
//        cout<<s[i][j]<<" ";
//        cout<<endl;
//    }
   cout<<dp[n-1][k];
   return 0;
}

Measured memory_bytes: 330224
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ff(i,a,b)for(int i=a,_e=b;i<_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define dot(a,b) ff(k,0,Q)a[k]=(ll)a[k]*b[k]%mo
#define ll long long
using namespace std;
const int N=(1<<14)+5,mo=998244353;
int n,m,ans;
int Q,o,f[2][N],a[N],b[N],h[N],w[N],jc[N],ny[N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
void dft(int *a,int sig){
	ff(i,1,Q)if(h[i]>i)swap(a[i],a[h[i]]);ll A;
	for(int i=1;i<Q;i<<=1)for(int j=0;j<Q;j+=i*2)
		ff(k,0,i)A=(ll)w[i+k]*a[i+j+k],a[i+j+k]=(-A+a[j+k])%mo,a[j+k]=(A+a[j+k])%mo;
	if(sig){
		reverse(a+1,a+Q);
		int y=ksm(Q,mo-2);
		ff(i,0,Q)a[i]=(ll)(a[i]+mo)*y%mo;
	}
}
int main(){
	cin>>n>>m;
	jc[0]=1;
	fo(i,1,n+2)jc[i]=(ll)jc[i-1]*i%mo;
	ny[n+2]=ksm(jc[n+2],mo-2);
	fd(i,0,n+1)ny[i]=(ll)ny[i+1]*(i+1)%mo;
	for(Q=1;Q<=n*2;Q<<=1);
	ff(i,1,Q)h[i]=(h[i>>1]>>1)|(i&1?Q>>1:0);
	for(int i=1;i<Q;i<<=1){
		int g=ksm(3,(mo-1)/(i*2));w[i]=1;
		ff(j,1,i)w[i+j]=(ll)w[i+j-1]*g%mo;
	}
	f[0][0]=1;
	fo(j,1,m){
		o^=1;
		fo(i,0,n){
			a[i]=(ll)f[!o][i]*ny[i]%mo;
			b[i]=i?ny[i+2]:0;
			f[o][i]=(ll)((ll)(i+1)*i/2+1)%mo*f[!o][i]%mo;
		}
		ff(i,n+1,Q)a[i]=b[i]=0;
		dft(a,0);dft(b,0);dot(a,b);dft(a,1);
		fo(i,0,n)f[o][i]=((ll)a[i]*jc[i+2]+f[o][i])%mo;
	}
	fo(i,0,n)ans=((ll)f[o][i]*jc[n]%mo*ny[i]%mo*ny[n-i]+ans)%mo;
	cout<<ans;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

//Janken
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[][] a = new char[N][N];
		for(int i=0;i<N;i++)a[i]=sc.next().toCharArray();
		int min = N+1, cand = 0;
		boolean[] win = new boolean[N];
		for(int S=1;S<1<<N;S++){
			int c = Integer.bitCount(S);
			if(min<=c)continue;
			Arrays.fill(win, false);
			for(int j=0;j<N;j++)if(((S>>j)&1)>0){
				for(int i=0;i<N;i++)win[i]|=a[j][i]!='x';
			}
			boolean ok = true;
			for(boolean v:win)ok&=v;
			if(ok){
				min = c; cand = S;
			}
		}
		List<Integer> use = new ArrayList<Integer>();
		for(int i=0;i<N;i++)if(((cand>>i)&1)>0)use.add(i);
		Random rand = new Random();
		for(int i=0;i<1000;i++){
			int me = use.get(rand.nextInt(use.size()));
			System.out.println(me+1);
			System.out.flush();
			sc.nextInt();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int M = 1000000007;
long long dp[5001][3][5001];

int main() {
    int n, a, b; cin >> n >> a >> b;
    if (a > b) swap(a, b);

    long long ans = 1;
    for (int i = 0; i < n; i++) ans = ans * 2 % M;
    if (a > 1) {
        dp[0][0][1] = 1;
        dp[0][1][1] = 0;
        dp[0][2][1] = 1;
        for (int i = 1; i < n; i++) {
            dp[i][0][1] = accumulate(dp[i-1][2]+1, dp[i-1][2]+b, 0LL) % M;
            for (int j = 2; j < a; j++) dp[i][0][j] = dp[i-1][0][j-1];
            if (i+1 == a) dp[i][1][a] = 1;
            for (int j = a+1; j < b; j++)
                dp[i][1][j] = (dp[i-1][1][j-1] + (i >= a ? dp[i-a][2][j-a] : 0)) % M;
            dp[i][2][1] = accumulate(dp[i-1][0]+1, dp[i-1][0]+a, 0LL) % M;
            for (int j = 2; j < b; j++)
                dp[i][2][j] = (dp[i-1][1][j-1] + dp[i-1][2][j-1]) % M;
        }
        ans -= accumulate(dp[n-1][0]+1, dp[n-1][0]+a, 0LL) % M;
        ans -= accumulate(dp[n-1][1]+1, dp[n-1][1]+b, 0LL) % M;
        ans -= accumulate(dp[n-1][2]+1, dp[n-1][2]+b, 0LL) % M;
    }
    cout << (ans % M + M) % M << endl;
}


Measured memory_bytes: 413676
class Array
	def bubble_sort!(n)
		flag = true
		a = self
		while flag
			flag = false
			(1..n-1).reverse_each{|j|
				if a[j] < a[j-1]
					a[j], a[j-1] = a[j-1], a[j]
					flag = true
					yield if block_given?
				end
			}
		end
		self
	end
end

n = gets.to_i
a = gets.split.map(&:to_i)
cnt = 0
puts a.bubble_sort!(n){cnt+=1}*" "
puts cnt

Measured memory_bytes: 8784
#include<cstdio>
#define min(A,B) ((A)<(B)?(A):(B))

int n;
char a[300005];
int qzh1[300005];
int qzh2[300005];

signed main(){
	scanf("%d%s",&n,a+1);
	for(int i=1;i<=n;i++){
		qzh1[i]=qzh1[i-1];
		if(a[i-1]=='W')
			qzh1[i]++;
	}
	for(int i=n;i;i--){
		qzh2[i]=qzh2[i+1];
		if(a[i+1]=='E')
			qzh2[i]++;
	}
	int ans=1e9;
	for(int i=1;i<=n;i++)
		ans=min(ans,qzh1[i]+qzh2[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2816
package FenwickTree;
sub new{
	return bless[(0)x$_[1]],$_[0];
}
sub add{
	my$self=shift;
	my($p,$x)=@_;
	$p++;
	my$n=@{$self};
	while($p<=$n){
		$self->[$p-1]+=$x;
		$p+=$p&-$p;
	}
}
sub sum{
	my$self=shift;
	return$self->prefixsum($_[1])-$self->prefixsum($_[0]);
}
sub prefixsum{
	my$self=shift;
	my$r=shift;
	my$s=0;
	while($r>0){
		$s+=$self->[$r-1];
		$r-=$r&-$r;
	}
	return$s;
}
package main;
my($N,$Q)=split$",<>;
my$fenwicktree=FenwickTree->new($N);
my@a=split$",<>;
for$i(0..$#a){
	$fenwicktree->add($i,$a[$i]);
}
for(1..$Q){
	my($t,$a,$b)=split$",<>;
	if($t==0){
		$fenwicktree->add($a,$b);
	}
	else{
		print$fenwicktree->sum($a,$b),$/;
	}
}


Measured memory_bytes: 68772
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    sort ALL(a);
    int cnt = 0,ans = 0;

    REP(i,N){
        cnt += a[i];
        if(cnt > x) break;
        ans++;
    }
    if(cnt < x){
        cout << ans - 1 << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>d(n);
  int m;
  int i,j;
  for(i=0;i<n;i++){
    cin >> d[i];
  }
  cin >> m;
  vector<long>t(m);
  for(i=0;i<m;i++){
    cin >> t[i];
  }
  sort(d.begin(),d.end());
  sort(t.begin(),t.end());
  int chk = 1;
  j = 0;
  for(i=0;i<m;i++){
    while(d[j] < t[i])j++;
    if(d[j]==t[i])j++;
    else{
      chk = 0;
      break;
    }
  }
  if(chk == 1)cout << "YES"<<endl;
  else cout << "NO"<<endl;





  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MAX = 333;
Int dp[333][333];
const Int INF = 1e15;

void chmin(Int &x,Int y){if(x>y)x=y;};
void chmax(Int &x,Int y){if(x<y)x=y;};

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> s(n+1);
  for(Int i=0;i<n;i++) s[i+1]=s[i]+a[i];
  
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      dp[i][j]=INF;

  for(Int i=0;i<n;i++) dp[i][i+1]=0;


  auto calc=[&](Int x,Int y){
    Int res=0,c=0;
    while(x||y||c){
      res+=(x%10)*(y%10)+c;
      c=(x%10)+(y%10)+c>=10;
      x/=10;y/=10;
    }
    return res;
  };
  
  for(Int l=2;l<=n;l++){
    for(Int i=0;i+l<=n;i++){
      Int k=i+l;
      for(Int j=i+1;j<k;j++){
	chmin(dp[i][k],dp[i][j]+dp[j][k]+calc(s[j]-s[i],s[k]-s[j]));
      }
    }    
  }

  cout<<dp[0][n]<<endl;
  return 0;
}




Measured memory_bytes: 4040
#include<stdio.h>
int main(){
  int num[2];
  int i,max;

  scanf("%d %d %d",&num[0],&num[1],&num[2]);

  max = num[0];

  for(i = 1; i <= 2; i++){
    if(max < num[i]){
      max = num[i];
    }
  }
  printf("%d",num[0] + num[1] + num[2] - max);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int min=Integer.MAX_VALUE ,max=Integer.MIN_VALUE;
		for(int i = 0; i < N ; i++) {
			if(a[i] < min) min = a[i];
			if(a[i] > max) max = a[i];
		}

		int minSum = Integer.MAX_VALUE;
		for(; min <= max; min++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += Math.pow(a[j]- min, 2);
			}
			if(sum < minSum) {
				minSum = sum;
			}
		}

		System.out.println(minSum);
	}

}


Measured memory_bytes: 9428
#include<stdio.h>
int parent(int a){
return a/2;
}
int left(int a){
 return 2*a;
}
int right(int a){
return 2*a+1;
}


int main(){
  int n, i, x;
  int a[250];
  scanf("%d", &n);

  for ( i = 1; i < n+1; i++ ){
    scanf("%d", &a[i]);
  }

  /*if(n==1)printf("node 1: key = %d, \n",a[1]);
  else  if(n==2)printf("node 1: key = %d, left key = %d, \n",a[1],a[2]);
 else{
 printf("node 1: key = %d, left key = %d, right key = %d, \n",a[1],a[2],a[3]);*/
    
 for ( i = 1; i <= n; i++ ){
   printf("node %d: key = %d, ",i,a[i]);
   if(i!=1) printf("parent key = %d, ",a[parent(i)]);
   if(n>=2*i){
     printf("left key = %d, ",a[left(i)]);
   }
   if(n>=2*i+1){
     printf("right key = %d, ",a[right(i)]);
   }
   printf("\n");
   
 }
 return 0;
}

 



Measured memory_bytes: 2112
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
#define int long long 
int n,k,a[200200],b[200200];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

bool chk(int mid)
{
	int rst=k;
	rep(i,1,n)
	{
		int now=mid/b[i];
		if (a[i]-now>0) 
		{
			int del=a[i]-now;
			if (del<=rst) rst-=del;
			else return 0;
		}
	}
	return 1;
}

signed main()
{
	n=read();k=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n) b[i]=read();
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	ll l=0,r=a[n]*b[n],ans=0;
	reverse(b+1,b+1+n);
	int p=1;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		//cout << l << " " << r << " " << mid << endl;
		if (chk(mid)) {ans=mid;r=mid-1;}
		else l=mid+1;
	}
	cout << ans;
	return 0;
}
	


Measured memory_bytes: 3328
import sys
bbn=1000000007
	
#+++++
		
def main():
	a, b , k = map(int, input().split())
	c=0
	ll=[]
	for i in range(1,200):
		if a% i==0 and b%i==0:
			ll.append(i)
	return ll[-1*k]
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b;
	cin >> a >> b;
	int x = a - b * 2;
	if (x > 0) {cout << x << endl;}
	else if (x <= 0) {cout << 0 << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M2=0;
vector<pair<int,int>> m2(D);
vector<int> a(26);
vector<int> m(D);

rep(i, 26){
    a[i]=0;
}
int M=0;
rep(i, D){
}
vector<int> t(D);

ll score=0;
rep(i, D){
    M=0;
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        if(s[i].at(j)+c[j]*(i+1-a[j])>M){
            M2=M;
            M=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=m[i];
            m[i]=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M2){
            M2=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=j;
        }
    }
    score+=M;
    m2[i].first=M-M2;
    a[m[i]]=i+1;
    t[i]=m[i];
}
rep(j, 100){
rep(i, D){
    calculate(c, s, m2[i].second, i, t, score);
}
rep(i, D){
    calculate(c, s, m[i], i, t, score);
}
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3744
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
char str[100005],tp[100005];
int n,k,r,s,p;
long long ans=0;
char Oppo(char x){
	if(x=='r')return 'p';
	if(x=='p')return 's';
	return 'r';
}
char Change(char x){
	if(x=='r')return 's';
	if(x=='p')return 'r';
	return 'p';
}
int Val(char x){
	if(x=='r')return r;
	if(x=='p')return p;
	return s;
}
int main(){
	cin>>n>>k>>r>>s>>p>>str;
	for(int i=0;i<n;i++){
		if(i<k){
			tp[i]=Oppo(str[i]);
			ans+=Val(tp[i]);
		}
		else if(tp[i-k]==Oppo(str[i])){
			if(i+k>=n)continue;
			tp[i]=(str[i]==Oppo(str[i+k])?Change(str[i]):str[i]);
		}
		else tp[i]=Oppo(str[i]),ans+=Val(tp[i]);
	}
	cout<<ans<<endl;
}

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

int main(){
  int N;cin>>N;ll C;cin>>C;
  vll X, V;
  for (int i=0;i<N;++i){ll x, v;cin>>x>>v;X.push_back(x);V.push_back(v);}
  vll cumsum(N+1);
  cumsum[0]=0;
  for (int i=0;i<N;++i){cumsum[i+1]=cumsum[i]+V[i];}
  vll r_single(N+1);
  vll l_single(N+1);
  vll r_double(N+1);
  vll l_double(N+1);
  r_single[0]=0;l_single[N]=0;r_double[0]=0;l_double[N]=0;
  for (int i=0;i<N;++i){
    r_single[i+1]=max(r_single[i],cumsum[i+1]-X[i]);
    r_double[i+1]=max(r_double[i],cumsum[i+1]-2*X[i]);
  }
  for (int i=N;i>=1;--i){
    l_single[i-1]=max(l_single[i],cumsum[N]-cumsum[i-1]-(C-X[i-1]));
    l_double[i-1]=max(l_double[i], cumsum[N]-cumsum[i-1]-2*(C-X[i-1]));
  }
  ll r_max=0, l_max=0;
  for (int i=0;i<=N;++i){
    r_max=max(r_max, l_single[i]+r_double[i]);
    l_max=max(l_max, r_single[i]+l_double[i]);
  }
  ll ans=max(r_max, l_max);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5996
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007

using namespace std;



int main() {
	int n, t, cnt = 0;
	vector<int> a;
	cin >> n >> t;
	int cmax = -INF, imax = INF;
	REP(i, n) {
		int s;
		cin >> s;
		a.push_back(s);
	}
	REP(i, n) {
		if (imax > a[i])
			imax = a[i];
		if (cmax < a[i] - imax) {
			cmax = a[i] - imax;
			cnt = 1;
		}
		else if (cmax == a[i] - imax) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a=n/100,b=n-a*100;
	bool yymm=false,mmyy=false;
	if(b>0&&b<=12)
	{
		yymm=true;
	}
	if(a>0&&a<=12)
	{
		mmyy=true;
	}
	if(yymm==true&&mmyy==true)
	{
		cout<<"AMBIGUOUS";
		return 0;
	}
	else if(yymm==true)
	{
		cout<<"YYMM";
		return 0;
	}
	else if(mmyy==true)
	{
		cout<<"MMYY";
		return 0;
	}
	else
	{
		cout<<"NA";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

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



int main() {
    vector<int>a(3);
    for(int i=0;i<3;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    if((a.at(2)-a.at(0))%2==(a.at(2)-a.at(1))%2){
        cout<<(2*a.at(2)-a.at(1)-a.at(0))/2<<endl;
        // cout<<"AAA"<<endl;
    }
    else{
        cout<<(2*a.at(2)-a.at(1)-a.at(0))/2+2<<endl;
        // cout<<"BBB"<<endl;
    }








    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int n,m[100][100];
int color[100],d[100],f[100],tt;
int nt[100];
int next(int u){
    for(int v=nt[u]; v<n;v++){
        nt[u]=v+1;
        if(m[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i=0;i<n;i++) nt[i]=0;
    stack<int> s;
    s.push(r);
    color[r]=1;
    d[r]=++tt;
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==0){
                color[v]=1;
                d[v]=++tt;
                s.push(v);
            }
        }else{
            s.pop();
            color[u]=2;
            f[u]=++tt;
        }
    }
}

void dfs(){
    for(int i=0;i<n;i++){
        color[i]=0;
        nt[i]=0;
    }
    tt=0;
    for(int u=0;u<n;u++){
        if(color[u]==0) dfs_visit(u);
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main(){
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            m[u][v]=1;
        }
    }
    dfs();
    return 0;
}



Measured memory_bytes: 3132
n = int(input())
l = [{} for d in range(n)]
for i in range(n):
  s,p = input().split()
  l[i] = {'City': s, 'Point': int(p), 'Number': i+1}
l.sort(key=lambda x: (x['City'],-x['Point']))
for num in l:
  print(num['Number'])

Measured memory_bytes: 8852
#!/usr/bin/env python3
S = input()
n = len(S)
ans = n // 2
pv = S[n // 2]
for i in range(n // 2, n):
    new = [S[n - i - 1], S[i]]
    if set(new) != set(pv):
        break
    ans += 1
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
	pair<int,char> A[5];
	for(int f=0;f!=1;){
		for(int i=0,a,b;i<5;++i){
			cin>>a>>b;
			if(a==0&&b==0){f=1;break;}
			A[i].first=a+b;
			A[i].second=(char)(i+'A');
			if(i==4){
				sort(&A[0],&A[5],greater<pair<int,char> >());
				cout<<A[0].second<<" "<<A[0].first<<endl;
			}
		}
	}
	return 0;
}

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

int main(){
        int n;
        int mo = 100000;

        cin >> n;
        for(; n > 0; n--){
                mo = mo * 1.05;
                if(mo % 1000 != 0)
                        mo = mo - mo % 1000 + 1000;
        }
        cout << mo << endl;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			List<int[]>[] testimony = new List<int[]>[n];
			for (int i = 0; i < n; i++) {
				testimony[i] = new List<int[]>();
				int a = int.Parse(Console.ReadLine());
				for (int j = 0; j < a; j++) {
					int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
					testimony[i].Add(vs);
				}
			}

			//for (int i = 0; i < n; i++) {
			//	System.Diagnostics.Debug.Write($"{i + 1} :");
			//	for (int j = 0; j < testimony[i].Count; j++) {
			//		System.Diagnostics.Debug.Write($" ({testimony[i][j][0]},{testimony[i][j][1]})");
			//	}
			//	System.Diagnostics.Debug.WriteLine("");
			//}

			HashSet<int> hashSet = new HashSet<int>();
			Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
			hashSet.Add(0);
			queue.Enqueue(new KeyValuePair<int, int>((1 << n) - 1, n));
			int ans = 0;
			int[] tmp = new int[n];
			while (queue.Count > 0) {
				var item = queue.Dequeue();
				//System.Diagnostics.Debug.WriteLine($"{item.Value}:{Convert.ToString(item.Key, 2).PadLeft(n, '0')}");
				for (int i = 0; i < n; i++) {
					tmp[i] = ((item.Key & (1 << i)) == 0 ? 0 : 1);
				}

				bool f = true;
				for (int i = 0; i < n; i++) {
					if (tmp[i] == 1) {
						foreach (var j in testimony[i]) {
							int x = j[0] - 1;
							int y = j[1];
							if (tmp[x] != y) {
								f = false;
								break;
							}
						}
					}
					if (!f) {
						break;
					}
				}
				if (f) {
					ans = item.Value;
					break;
				}

				for (int i = 0; i < n; i++) {
					int next = item.Key & ~(1 << i);
					if (!hashSet.Contains(next)) {
						hashSet.Add(next);
						queue.Enqueue(new KeyValuePair<int, int>(next, item.Value - 1));
					}
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}


}


Measured memory_bytes: 14816
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
const int vy[] = {0, 1, 0, -1}, vx[] = {1, 0, -1, 0};
 
 
map< Pi, Pi > futon;
map< Pi, int > head;
 
bool check(const Pi& point)
{
  head[point] = 1;
  head[futon[point]] = -1;
  bool flag = true;
  for(int i = 0; i < 4 && flag; i++) {
    const int nx = point.first + vx[i], ny = point.second + vy[i];
    if(make_pair(nx, ny) == futon[point]) continue;
    if(head.find({nx, ny}) != head.end()) {
      if(head[{nx, ny}] == -1) flag = false;
    } else if(futon.find({nx, ny}) != futon.end()) {
      if(!check({nx, ny})) flag = false;
    }
  }
   
  for(int i = 0; i < 4 && flag; i++) {
    const int nx = futon[point].first + vx[i], ny = futon[point].second + vy[i];
    if(make_pair(nx, ny) == point) continue;
    if(head.find({nx, ny}) != head.end()) {
      if(head[{nx, ny}] == 1) flag = false;
    } else if(futon.find({nx, ny}) != futon.end()) {
      if(!check(futon[{nx, ny}])) flag = false;
    }
  }
  return(flag);
}
 
int main()
{
  int N;
  while(cin >> N, N) {
    while(N--) {
      int x, y;
      char dir;
      cin >> x >> y >> dir;
      if(dir == 'x') {
        futon[{x, y}] = {x + 1, y};
        futon[{x + 1, y}] = {x, y};
      } else {
        futon[{x, y}] = {x, y + 1};
        futon[{x, y + 1}] = {x, y};
      }
    }
    while(!futon.empty()) {
      auto decide = *futon.begin();
      if(head.find(decide.first) == head.end()) {
        if(!check(decide.first)) break;
      }
      futon.erase(futon.begin());
    }
    if(futon.empty()) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    head.clear();
    futon.clear();
  }
}

Measured memory_bytes: 10820
package main

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

func main() {
	N, W := readI(), readI()
	w, v := make([]int, N+1), make([]int, N+1)
	for i := 1; i <= N; i++ {
		w[i], v[i] = readI(), readI()
	}

	// dp[i][j] = i番目までの荷物を容量j以下で選んだ際の価値の最大値
	dp := make([][]int, N+1)
	dp[0] = make([]int, W+1)
	for i := 1; i <= N; i++ {
		dp[i] = make([]int, W+1)
		for j := 1; j <= W; j++ {
			if j-w[i] >= 0 {
				dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j])
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}
	fmt.Println(dp[N][W])

}

func max(a ...int) int {
	m := a[0]
	for i := 1; i < len(a); i++ {
		if m < a[i] {
			m = a[i]
		}
	}
	return m
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 83016
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000009
using namespace std;
map<int,int>ma;
int a[200009],n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(ma[a[i]])
        {
            printf("NO");
            return 0;
        }
        ma[a[i]]=1;
    }
    printf("YES");
    return 0;
}


Measured memory_bytes: 10368