akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
int main() {
	int N;
	cin>>N;
	string S;
	cin>>S;

	int ket[SIZE]={};	//[:0, ]:1
	bool odd=0;
	for(int i=1;i<2*N;i++){
		if(S[i]=='B')
			ket[i]=!odd;
		else
			ket[i]=odd;
		odd=!odd;
	}
	ll ans=1;
	ll count=0;
	for(int i=0;i<2*N;i++){
		if(ket[i]==0)
			count++;
		else{
			if(count==0){
				cout<<0<<endl;
				return 0;
			}
			(ans*=count)%=MOD;
			count--;
		}
	}
	if(count){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<=N;i++)
		(ans*=i)%=MOD;

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

Measured memory_bytes: 1412
#include<iostream>
#include<string>
using namespace std;
int main()
{
string commands;
  cin>>commands;
string output="";
  for(int i=0;i<commands.length();i++)
  {
    if(commands[i]!='B')
      output.push_back(commands[i]);
    else
    {  if(!output.empty())
      	output.pop_back();
       else
         continue;
    }
  }
 cout<<output;
  return 0;
 
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int s, t, info, math, sci, en;

    scanf("%d%d%d%d", &info, &math, &sci, &en);
    s = info + math + sci + en;
    scanf("%d%d%d%d", &info, &math, &sci, &en);
    t = info + math + sci + en;

    if(s>t) {
        printf("%d\n", s);
    } else {
        printf("%d\n", t);
    }

    return (0);
}

Measured memory_bytes: 592
#include<iostream>
using namespace std;
#define MAX_NUM 100000

int main(){
    int N,K,h[MAX_NUM],can_ride = 0; cin>>N>>K;
    for(int i=0;i<N;i++)
        cin>>h[i];
    
    for(int i=0;i<N;i++){
        if(h[i]>=K)
            can_ride++;
    }
    cout<<can_ride<<endl;
    return 0;
}

Measured memory_bytes: 640
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,m=n1()
LR=n3(m)

m=0
M=10**10
for l,r in LR:
    m=max(m,l)
    M=min(M,r)

p0(M>=m,M-m+1,0)

Measured memory_bytes: 60192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
ll x,ans=0,mon=100;
cin>>x;
while (mon<x)
{
    mon*=1.01;
    ans++;
}
cout<<ans<<endl;
    return 0;
}

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

int n, A[30];

int solve( int i, int m){
	if( m == 0 ) return 1;
	if( i >= n ) return 0;
	int res = solve( i + 1, m ) || solve( i + 1, m - A[i] );
	return res;
}

int main(){
	int q;
	int M[210];

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	cin >> q;
	for(int j = 0; j < q; j++){
		cin >> M[j];
	}
	for(int j = 0; j < q; j++){
		if( solve(0, M[j]) ) cout << "yes" << endl;
		else{ cout << "no" << endl;}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void)
{
	int nyuu[4];
	int ans[2];
	int ta;
	int i;
	scanf("%d",&nyuu[0]);
	scanf("%d",&nyuu[1]);
	scanf("%d",&nyuu[2]);
	scanf("%d",&nyuu[3]);
		ta=nyuu[0]+nyuu[1]+nyuu[2]+nyuu[3];
	ans[0]=ta/60;
	ans[1]=ta%60;
	printf("%d\n",ans[0]);
	printf("%d\n",ans[1]);
}


Measured memory_bytes: 2084
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a=0,n,t=0;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	sort(all(vec));
	while (a+1 < n && vec[a] + vec[a + 1] < 0) {
		vec[a] *= -1;
		vec[a + 1] *= -1;
		a += 2;
	}
	rep(i, n) {
		t += vec[i];
	}
	cout << t << endl;
}


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

using namespace std;

typedef long long ll;

int main(void)
{
    int n;
    
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if ((i) % 2 == 1) ans++;
    }
    double a = (double)ans / (double)n;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    set<string> st;
    for (int i = 0; i+m-1 < n; ++i) {
        bool ok = true;
        rep(j, m) {
            if (s[i+j] == '?') continue;
            if (s[i+j] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            string ans = s.substr(0, i) + t + s.substr(i+m, n-m-i); 
            rep(j, n) if (ans[j] == '?') ans[j] = 'a';
            st.insert(ans);
        }
    }
    if (st.size() > 0) cout << *st.begin() << endl;
    else cout << "UNRESTORABLE" << endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

// [1, n]
int bit[200020];

// return a_1 + ... + a_i
int sum(int i) {
  int s = 0;
  while (0 < i) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

// a_i += x
void add(int i, int x) {
  while (i <= 200020) {
    bit[i] += x;
    i += i & -i;
  }
}

int main() {
  int n;
  ll k;
  cin >> n >> k;
  ll a[n];
  REP(i, n) cin >> a[i];
  ll b[n + 1];
  b[0] = 0;
  for (int i = 1; i <= n; ++i) {
    b[i] = b[i - 1] + a[i - 1] - k;
  }
  vector<P> vc;
  for (int i = 0; i <= n; ++i) {
    vc.push_back(P(b[i], i));
  }
  sort(ALL(vc));
  int c[n + 1];
  for (int i = 0; i <= n; ++i) {
    auto it = lower_bound(ALL(vc), vc[i]);
    c[it->second] = it - vc.begin() + 1;
  }
  ll ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans += sum(c[i]);
    add(c[i], 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vector<pair<int,int>> v(m);
  rep(i,m){
    int a,b; cin >> a >> b;
    v[i] = {--b,--a};
  }
  sort(all(v));
  int ans = 0, r = v[0].first;
  rep(i,m){
    if(r <= v[i].second){
      ans++;
      r = v[i].first;
    }
  }
  cout << ans+1;
  return 0;
}


Measured memory_bytes: 3980
//************************************************************************//
//*Author : Handsome How                                                 *//
//************************************************************************//
//#pragma comment(linker, "/STA    CK:1024000000,1024000000")
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define foreach(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define fur(i,a,b) for(int i=(a);i<=(b);i++)
#define furr(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#ifdef HandsomeHow
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define debug(...)
#define dbg(x)
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★
//-----------------------------------------------------------------
set<pii>st;
ll H,W,N;
ll ans[11];

int check(int x, int y){
	int ret = 0;
	fur(i,-1,1)fur(j,-1,1) if(st.count(make_pair(x+i,y+j))) ret++;
	return ret;
}

int main(){
#ifdef HandsomeHow
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    time_t beginttt = clock();
#endif
	gn(H);gn(W);gn(N);
	ans[0] = (H-2)*(W-2);
	fur(i,1,9) ans[i]=0;
	while(N--){
		int x,y;
		gn(x);gn(y);
		st.insert(make_pair(x,y));
		fur(dx,-1,1)fur(dy,-1,1){
			if(x+dx<=1 || x+dx >H-1 || y+dy<=1 || y+dy>W-1) continue;
			int has = check(x+dx,y+dy);
			ans[has]++;
			ans[has-1]--;
		}		
	}
	fur(i,0,9) cout<<ans[i]<<endl;

#ifdef HandsomeHow
	time_t endttt = clock();
    debug("time: %d\n",(int)(endttt - beginttt));
#endif
	return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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

auto mpow = [](auto x, i64 y){
 auto z = x;
 decltype(x) val = y & 1 ? x : decltype(x)(1);
 while(z *= z, y >>= 1)
  if(y & 1)
   val *= z;
 return val;
};

template <typename T>
struct Matrix{
    int h, w;
    vector<T> v;

    Matrix() : h(1), w(1), v(1, 1){}
    Matrix(int n){*this = makeUnit(n);}
    Matrix(int h, int w) : h(h), w(w), v(h * w, 0){}

    Matrix(vector<vector<T>> v_) : h(v_.size()), w(v_[0].size()), v(h * w){
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
                v[i * w + j] = v_[i][j];
    }

    static Matrix makeUnit(int n){
        Matrix mat(n, n);
        for(int i = 0; i < n; ++i)
            mat.at(i, i) = 1;
        return mat;
    }

    T& at(int i, int j){
        assert(0 <= i && i <= h && 0 <= j && j < w);
        return v[i * w + j];
    };

    Matrix pow(i64 x){
        assert(h == w);
        auto mat = x & 1 ? *this : makeUnit(h);
        auto u = *this;
        while(u = u * u, x >>= 1)
            if(x & 1)
                mat *= u;
        return mat;
    }

    Matrix& operator+=(const Matrix& mat){
        assert(h == mat.h && w == mat.w);
        for(int i = 0; i < h * w; ++i)
            v[i] += mat.v[i];
        return *this;
    }

    Matrix& operator-=(const Matrix& mat){
        assert(h == mat.h && w == mat.w);
        for(int i = 0; i < h * w; ++i)
            v[i] -= mat.v[i];
        return *this;
    }

    Matrix& operator%=(const T mod){
        for(int i = 0; i < h * w; ++i)
            v[i] %= mod;
        return *this;
    }

    Matrix operator*(const Matrix& mat){
        assert(w == mat.h);
        Matrix ret(h, mat.w);
        for(int i = 0; i < h; ++i)
            for(int k = 0; k < w; ++k)
                for(int j = 0; j < mat.w; ++j)
                    ret.v[i * mat.w + j] += v[i * w + k] * mat.v[k * mat.w + j];
        return ret;
    }

    Matrix operator+(const Matrix& mat){return Matrix(*this) += mat;}
    Matrix operator-(const Matrix& mat){return Matrix(*this) -= mat;}
    Matrix operator%(const T mod){return Matrix(*this) %= mod;}
    Matrix& operator*=(const Matrix& mat){return *this = *this * mat;}
};

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    i64 n, a, b;
    cin >> n >> a >> b;

    vector<vector<i64>> elm{{1, -1}, {1, 0}};
    vector<vector<i64>> res{{a}, {b}};
    Matrix<i64> mat(elm);
    Matrix<i64> mat2(res);
    mat = mat.pow(n / 2);

    auto ans = mat * mat2;
    if(n % 2 == 1){
        ans.at(0, 0) -= ans.at(1, 0);
    }
    cout << ans.at(0, 0) << " " << ans.at(1, 0) << endl;
}



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

int main() {
	string s;
	cin>>s;
	set<string> w;
	for(int i=0;i<s.length();i++){
		w.insert(s.substr(i,1));
	}
	if(w.size()==s.length()){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}

	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long i,N,S,a,ans=0;
  cin>>N>>S;
  vector<int> v(S+1,0);
  while(N--){
    cin>>a;
    ++v[0];
    if(S>=a)(ans+=v[S-a]*(N+1))%=998244353;
    for(i=S;i>=a;i--)(v[i]+=v[i-a])%=998244353;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from datetime import date
while True:
    m,d = map(int,raw_input().split(" "))
    
    if m ==0:
        break
        
    w = date(2004,m,d).isoweekday()

    if w==1:
        print 'Monday'
    elif w==2:
        print 'Tuesday'
    elif w==3:
        print 'Wednesday'
    elif w==4:
        print 'Thursday'
    elif w==5:
        print 'Friday'
    elif w==6:
        print 'Saturday'
    elif w==7:
        print 'Sunday'

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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll s,w;
    cin >> s >> w;

    if(w>=s)
        cout << "unsafe";
    else
        cout << "safe";

    return 0;
}


Measured memory_bytes: 3652
var main = (standardInput) => {
    var lengthList = standardInput.split(' ');
	var n = Number.parseInt(lengthList[0]);
	var a = Number.parseInt(lengthList[1])
    var b = Number.parseInt(lengthList[2])
    
    if ( n*a >= b){
 	 console.log(b);
	} else {
  	 console.log(n*a)
 	}
    	
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll h,w;
  cin >> h >> w;
  vvll a(h,vll(w)),b(h,vll(w)),c(h,vll(w));
  rep(i,0,h){
   rep(j,0,w) cin >> a[i][j];
  }
  rep(i,0,h){
   rep(j,0,w) {
     cin >> b[i][j];
    c[i][j]=abs(a[i][j]-b[i][j]);
  }
  }
 
    
    
  
  vector<vector<vb>> dp(h,vector<vb>(w,vb(20000,false)));
  dp[0][0][c[0][0]]=true;
  rep(i,0,h){
   rep(j,0,w) {
     rep(k,0,15000){
       if(j+1<w){
        dp[i][j+1][k+c[i][j+1]]=(dp[i][j+1][k+c[i][j+1]]||dp[i][j][k]);
        dp[i][j+1][abs(k-c[i][j+1])]=(dp[i][j+1][abs(k-c[i][j+1])]||dp[i][j][k]);
       }
      if(i+1<h){
        dp[i+1][j][k+c[i+1][j]]=(dp[i+1][j][k+c[i+1][j]]||dp[i][j][k]);
        dp[i+1][j][abs(k-c[i+1][j])]=(dp[i+1][j][abs(k-c[i+1][j])]||dp[i][j][k]);
      }  
       
     }
   }
  }                
  
  rep(i,0,15000) if(dp[h-1][w-1][i]) {
    cout << i << endl;
    return 0;
  }
}


Measured memory_bytes: 18688
#include <stdio.h>
#include <math.h>
int main(){
    long i, k, n, ans=0;
    scanf("%ld", &n);
    for(i=1; i<=n; i++){
        k = floor(n/i);
        ans += k * (k+1) * i / 2;
    }
    printf("%ld", ans);
    return 0;
}


Measured memory_bytes: 1696
W, H, N = map(int, input().split())

L = [ list(map(int, input().split())) for i in range(N) ]

dp = [[0] * W for i in range(H)]

for i in range(N):
    if L[i][2] == 1:
        for y in range(H):
            for x in range(L[i][0]):
                dp[y][x] = 1
                
    elif L[i][2] == 2:
        for y in range(H):
            for x in range(L[i][0], W):
                dp[y][x] = 1
                
    elif L[i][2] == 3:
        for y in range(L[i][1]):
            for x in range(W):
                dp[y][x] = 1
                
    else:
        for y in range(L[i][1], H):
            for x in range(W):
                dp[y][x] = 1
                

res = 0

for x in range(W):
    for y in range(H):
        if dp[y][x] == 0:
            res += 1
        
print(res)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
struct edge{//辺の情報
  int to,cost;
};
int V,E;//頂点の数、辺の数
vector<edge> g[100010];
int d[100010];//d[u]は始点から頂点uへの最短距離

void add_directed_edge(int from,int to,int cost){//有向グラフを作成
  g[from].push_back((edge){to,cost});
}

void dijkstra(int s){//始点sからのダイクストラ
  priority_queue<pi,vector<pi>,greater<pi> > q;//pair(コスト、頂点)としてコストの小さい順に並ぶ
  rep(i,V){
    d[i]=INF;//初期化
  }
  d[s]=0;
  q.push(pi(0,s));
  while(!q.empty()){
    pi p = q.top();q.pop();
    int w=p.second;//最新の確定した頂点
    if(d[w]<p.first) continue;//取り出した頂点のコストが最短コストより長かったら破棄
    for(int i=0;i<g[w].size();i++){//取り出した頂点と隣接した頂点を調べる
      int t=g[w][i].to,c=g[w][i].cost;
      if(d[t]>d[w]+c){//頂点tまでの暫定最短距離よりwまでの最短距離+w→tのコストが小さければ更新
	d[t]=d[w]+c;
	q.push(pi(d[t],t));
      }
     }
  }
}

int main(){
  int n;cin>>n;
  V=n;
  int a[100010];
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n){
    add_directed_edge(i,a[i],1);
  }
  dijkstra(0);
  if(d[1]!=INF) prin(d[1]);
  else prin(-1);
  
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,l;
    cin >> n >> l;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    stack<ll> ans;
    ll f = -1;
    for(i = 0;i < n-1;++i){
        if(a.at(i) + a.at(i+1) >= l){
            ans.push(i+1);
            f = i+1;
            break;
        }
    }
    if(f == -1){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(i = f+1;i < n;++i){
        ans.push(i);
    }
    for(i = f-1;i >= 1;--i){
        ans.push(i);
    }
    while(!ans.empty()){
        ll t = ans.top();
        ans.pop();
        cout << t << endl;
    }


    return 0;
}

Measured memory_bytes: 2332
#include<stdio.h>
#include<stdlib.h>

int main() {
	int n,i,H[251];
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++) {
		scanf("%d",&H[i]);
	}
	
	for(i=1;i<=n;i++) {
		printf("node %d: key = %d, ",i,H[i]);
		if(i!=1) printf("parent key = %d, ",H[i/2]);
		if(2*i<=n)
		printf("left key = %d, ",H[2*i]);
		if((2*i+1)<=n)
		printf("right key = %d, ",H[2*i+1]);
		printf("\n");
	}
	return 0;
}



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

using namespace std;

int n, m;
int a[100][100];

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

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

    if(n >= 2 && m >= 2)
    {
        long long rez = 0;
        if(n >= 2 && m >= 2)
        {
            rez += 1LL * (n - 2) * (m - 2);
        }

        cout << rez << "\n";
    }

    else
    {
        int mx = max(n, m);

        if(mx == 1)
            cout << 1 << "\n";

        else
            cout << mx - 2 << "\n";

    }

    return 0;
}


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

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

using namespace std;

const int INF = 1e9 + 5;
const int N = 1e4;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);

double to_rad(double x) {
    return x * PI / 180;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double x = (360. * h / 12.0 + m / 2.0), y = (360. * m / 60.0);
    double ang = abs(x - y);
    ang = min(ang, 360 - ang);
    ang = to_rad(ang);
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(ang));
    cout << setprecision(11) << fixed << ans;
}

Measured memory_bytes: 4244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>

#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))

using namespace std;

void print_func(int *array, int size){
    for (int j = 0; j < size; ++j) {
        cout << ( j ? " " : "" ) << array[j];
    }
    cout << endl;
}

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

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

    int tmp, minj, cnt=0;
    bool flag;
    for (int i = 0; i < N; ++i) {
        minj = i;
        flag = false;
        for (int j = i; j < N; ++j) {
            if (A[j] < A[minj]) {
                minj = j;
                flag = true;
            }
        }

        if (flag) {
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            cnt++;
        }
    }

    print_func(A, GET_ARRAY_SIZE(A));
    cout << cnt << endl;

}

Measured memory_bytes: 3108
N=int(input())
V=map(float, input().split())
sortedV=sorted(V,reverse=True)

summax=0.0
for i in range(N-1):
    summax=summax+sortedV[i]/pow(2.0,i+1)
summax=summax+sortedV[N-1]/pow(2.0,N-1)

print(summax)







Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		if(n==0&&m==0)break;
		vector<pair<string,int > > check;
		string kuji;
		ll sum = 0;
		for(int i =0;i <n;i++){
			string tmp;
			int k;
			cin>>tmp>>k;
			check.push_back(mp(tmp,k));
		}
		/*rep(i, check.size()){
			rep(j, check[i].first.length()){
				cout <<check[i].first[j]<<endl;
			}
		}*/
		for(int i =0;i <m;i++){
			cin>>kuji;
			for(int j =0;j <n;j++){
				bool ok =true;
				for(int k =0;k <8;k++){
					if(check[j].first[k]=='*')continue;
					if(check[j].first[k]!=kuji[k]){
						ok =false;
						break;
					}
				}
				if(ok){
					sum +=check[j].second;
				}
			}
		}
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a < b); 
} 

void solve()
{
	char c;
	cin>>c;
	if(c-'a'<=26&& c-'a'>=0)cout<<"a";
	else cout<<"A";

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sci3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define scs(s) scanf("%s",s)
#ifndef GET_MACRO

#define GET_MACRO(__1,__2,__3,NAME,...) NAME

#endif // GET_MACRO

#define sci(...) GET_MACRO(__VA_ARGS__,sci3,sci2,sci1)(__VA_ARGS__)
#define ll long long
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
#define LSB(i) ((i)&(-i))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define infl 0x7ffffffffffffff
#define infi  0x7fffffff
#define fill_(a,b) fill(a.begin(),a.end(),b)
#define pb push_back
#define xx first
#define yy second
int main(){
    int n,i,tmp;
    sci(n);
    vector<int> vct(n+1,-1);
    for(i=0;i<n;i++){
        sci(tmp);
        if(vct[tmp-1]==-1){
            vct[tmp]=1;
        }
        else{
            vct[tmp]=vct[tmp-1]+1;
        }
    }
    cout<<n-*max_element(vct.begin(),vct.end())<<endl;
}


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

typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll a,b;
	cin >> a >> b;
	cout << (a * b/__gcd(a,b)) << '\n';
}


Measured memory_bytes: 256
/*
 * @Author: BilyHurington
 * @Date: 2020-06-13 20:01:30
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-06-13 20:02:11
 */ 
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int main(){
    scanf("%s",s+1);
    printf("%c%c%c",s[1],s[2],s[3]);
    return 0;
}

Measured memory_bytes: 3724
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N, A, B = map(int, input().split())

p = N // (A+B)
mod = N % (A+B)

ans = A * p + min(mod, A)
print (ans)





Measured memory_bytes: 3564
using System;

class Program {
    static void Main (string[] args) {
        string[] S = Console.ReadLine ().Split (' ');
        long ans = 0;
        if (S[1] == "+") {
            ans = long.Parse (S[0]) + long.Parse (S[2]);
        } else {
            ans = long.Parse (S[0]) - long.Parse (S[2]);
        }
        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, T, A;
    cin >>N >> T>> A;
    vi H(N);
    cin >> H;
    
    int mn = INF;
    int ans = 0;
    REP(i, N) {
        if (chmin(mn, abs(A * 1000 - (T * 1000 - H[i] * 6)))) {
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#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 BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int h, w;
int semi[100][100];

int solve(){
	
	int dp[100][100];
	
	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			dp[i][j] = INT_MAX/2;
		}
	}
	
	dp[0][0] = semi[0][0];
	
	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			
			if(!i&&!j)
				continue;
			
			int u = i > 0 ? dp[i-1][j] : INT_MAX/2,
				l = j > 0 ? dp[i][j-1] : INT_MAX/2;
			
			dp[i][j] = semi[i][j] + min( u, l );
		}
	}
	
	return dp[h-1][w-1];
}

int main(){
	
	cin>>h>>w;
		
	for(int i=0; i<h; ++i){
		
		string s;
		cin >> s;
		
		for(int j=0; j<w; ++j){
			semi[i][j] = s[j] - '0';
		}
	}
	
	cout << solve() << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){

    vector<ll>lm;
    map<ll,ll>l;
    int n;
    cin >> n;
    ll len;
    for(int i = 0;i<n;i++){
        cin >> len;
        l[len]++;
        if(l[len] == 2){
            lm.push_back(len);
        }
        else if(l[len] == 4){
            lm.push_back(len);
        }
    }
    sort(lm.begin(),lm.end());
    if(lm.size() <= 1){
        cout << "0";
    }
    else{
        cout << lm[lm.size()-1]*lm[lm.size()-2];
    }
    return 0;
}

Measured memory_bytes: 6528
n=input()
n=int(n)
l=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
    b,f,r,v=input().split()
    b=int(b)
    f=int(f)
    r=int(r)
    v=int(v)
    l[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",l[i][j][k],end="")
        print()
    if i==3:
        break
    print("####################")



Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(void)
{
   int n,W;
   cin>>n>>W;
   struct item{
    int w;int val;
  };
   vector<item>arr(n+1);
   for(int  i = 1;i<=n;i++)
   {
      cin>>arr[i].w>>arr[i].val;
   }
   int maxval = n*1000;
   int dp[n+1][maxval+1];

    // base cases
     dp[1][0] = 0;
     for(int i = 1;i<=maxval;i++)
      dp[1][i] = W+10;
    dp[1][(arr[1].val)] = arr[1].w;

    for(int  i = 2;i<=n;i++)
    {
       for(int  j = 0;j<=maxval;j++)
       {
          dp[i][j] = dp[i-1][j];

          if((j-arr[i].val)>=0)
            dp[i][j] = min(dp[i][j] ,arr[i].w+dp[i-1][(j-arr[i].val)]);
       }
    }

   int ans = 0;
   for(int  i = 0;i<=maxval;i++)
   {
     if(dp[n][i]<=W)
      ans = i;
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1777777777;
int exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}

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


ll in(ll x){
    return exp(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int x;cin >> x;
    //たかだかx秒で行ける→dpするなら2*xだけ配列用意すれば十分だけど…O(logx),O(sqrt(x))くらいで済まさないとなので厳しい
    
    /*1まで：1秒
    2まで：2秒
    3まで：2秒
    4まで：4秒
    
    1+...+tのどれかいくつかのぞいていけるやつ→これがxを超えた時点でそれ返せばよい
    */
    ll ans=0;
    rep(i,x+2){
        ans+=i;
        if(ans>=x){
            cout << i << endl;return 0;
        }
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AGrouping solver = new AGrouping();
        solver.solve(1, in, out);
        out.close();
    }

    static class AGrouping {
        private static final int[] GROUPS = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(GROUPS[in.nextInt()] == GROUPS[in.nextInt()] ? "Yes" : "No");
        }

    }
}



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


int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> l(n);
    for(ll i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    for(ll i = 0; i < n - 2; i++){
        for(ll j = i + 1; j < n - 1; j++){
            for(ll k = j + 1; k < n; k++){
                if(l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}

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


using namespace std;

int ans[900];

int main() {

  int N;
  cin >> N;
  int r,q;
  q = 1;
  int i = 0;
  while(q != 0){
    if (N < 0 && N%-2 != 0){
    r =(N%-2)*(-1);
    q =(N/-2)+1;
    }
    else{
      r = N%(-2);
      q = N/(-2);
    }
    N = q;
    ans[i] = r;
    i++;
    //    cout <<"あまり" <<  r << endl;
    //cout << "しょう" << q << endl;
  }

  for (int k=i-1;k>=0;k--) cout << ans[k];
  cout << endl;

  return 0;

}

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

int main() {
  string date;
  bool MMYY, YYMM;
  int top2, last2;

  cin >> date;
  top2 = atoi(date.substr(0, 2).c_str());
  last2 = atoi(date.substr(2, 4).c_str());
  MMYY = 1 <= top2 && top2 <= 12;
  YYMM = 1 <= last2 && last2 <= 12;
  if (MMYY && YYMM) {
    cout << "AMBIGUOUS" << endl;
  } else if (MMYY) {
    cout << "MMYY" << endl;
  } else if (YYMM) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;

vector<int> tree[200005];

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for(int i = 2; i <= N; ++i) {
        int p;
        cin >> p;
        tree[p].push_back(i);
    }
    for(int i = 1; i <= N; ++i) {
        cout << tree[i].size() << endl;
    }
    return 0;

}



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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
vector<int>road(n,0);
rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    road[a]++;
    road[b]++;
}
rep(i,n)cout<<road[i]<<endl;
return 0;
}

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

int main()
{
  int n,y,z;
  cin >> n >> y >> z;
  
  n -= z;
  int ans = n / (y+z);
  
  cout << ans << endl;
  
  
}

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

using namespace std;

long long solve (long long h) {
    if (h == 1)
        return 1;
    return 1 + solve(h / 2) * 2;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    long long h;
    cin >> h;
    cout << solve(h);
}


Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
        int a,b, avg;
        scanf("%d %d", &a, &b);
        avg = (a+b)/2;
        if((avg*2)==(a+b))
        {
               printf("%d", avg);
         }
         else{
          printf("%d", avg+1);
         }
         return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
str_num = -1
reverse_S = ''

#条件1（Sが回文であるか）
for i in range(-1,-(N+1),-1):
  reverse_S = reverse_S + S[i]

if S == reverse_S:
  condition1 = 'YES'
else:
  condition1 = 'NO'

#条件2
S2 = ''
N2 = int((N-1)/2)
for i in range(N2):
  S2 = S2 + S[i]
  
reverse_S2 = ''
for i in range(-1,-(N2+1),-1):
  reverse_S2 = reverse_S2 + S2[i]

if S2 == reverse_S2:
  condition2 = 'YES'
else:
  condition2 = 'NO'
  
#条件3
S3 = ''
N3 = int((N+3)/2)
for i in range(N3-1,N):
  S3 = S3 + S[i]
  
  
reverse_S3 = ''
for i in range(-1,-(N3-1),-1):
  reverse_S3 = reverse_S3 + S3[i]
  
if S3 == reverse_S3:
  condition3 = 'YES'
else:
  condition3 = 'NO'

if condition1 == condition2 == condition3 == 'YES':
  print('Yes')
else:
  print('No')

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

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

    vector<char> s(n);
    bool P = false,
         W = false,
         G = false,
         Y = false;

    for(int i=0; i<n; i++){
        cin >> s[i];
        if(s[i] == 'P') P = true;
        if(s[i] == 'W') W = true;
        if(s[i] == 'G') G = true;
        if(s[i] == 'Y') Y = true;
    }
    if(P & W & G & Y == 1) cout << "Four" << endl;
    if(P & W & G & Y == 0) cout << "Three" << endl;
    return 0;
}

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

int main() {
    int N, K, S; cin >> N >> K >> S;
    int A[N];
    for (int i = 0; i < N; i++) {
        if (i < K) A[i] = S;
        else {
            if (S < 1000000000) A[i] = S + 1;
            else A[i] = 1;
        }
    }
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include<stdio.h>

int list[100];
int n,t;
int bin_search(int l,int r,int c){
        int m=(l+r)/2;
        if(list[m]==t){
                return c;
        }else if(r<l){
                return c-1;
        }else if(list[m]<t){
                return bin_search(m+1,r,c+1);
        }else if(list[m]>t){
                return bin_search(l,m-1,c+1);
        }
}

int main(){
        int i;
        while(1){
                scanf("%d",&n);
                if(n==0)break;
                for(i=0;i<n;i++){
                        scanf("%d",&list[i]);
                }
                scanf("%d",&t);
                printf("%d\n",bin_search(0,n-1,1));
        }
        return 0;

}

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

int f[30][30];
int w, h, ans;
pair<int,int> sp;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void rec(int,int,int);
bool out(int x, int y){
  return (x < 0 || x >= w || y < 0 || y >= h);
}
bool go(int x, int y, int d, int c){
  while(f[y][x]==0){
    x += dx[d];
    y += dy[d];
    if(out(x,y))return false;
  }
  if(f[y][x] == 3){
    return true;
  }
  else if(f[y][x] == 1){
    f[y][x] = 0;
    rec(x-dx[d],y-dy[d],c+1);
    f[y][x] = 1;
  }

  return false;
}
void rec(int x, int y, int c){
  if(c > 10)return;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(out(nx,ny) || f[ny][nx] == 1)continue;
    if(go(nx,ny,i,c))ans = min(ans, c);
   }
 }
void solve(){
  ans = 1 << 20;
  rec(sp.first, sp.second, 1);
  if(ans == (1 << 20))cout << -1 << endl;
  else cout << ans << endl;
}
int main(){
  while(cin >> w >> h, w||h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> f[i][j];
	if(f[i][j] == 2){f[i][j] = 0; sp.first = j; sp.second = i;}
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <map>
#include <vector>

// lib/prime_factorization.hpp
#ifndef PRIME_FACTORIZATION_HPP
#define PRIME_FACTORIZATION_HPP


namespace tools {
  template <typename T>
  ::std::map<T, T> prime_factorization(T n) {
    ::std::map<T, T> result;

    const T floor_sqrt_n = static_cast<T>(::std::sqrt(n));
    for (T i = static_cast<T>(2); i <= floor_sqrt_n; ++i) {
      while (n % i == static_cast<T>(0)) {
        ++result[i];
        n /= i;
      }
    }

    // if n is a prime
    if (n > static_cast<T>(1)) {
      ++result[n];
    }

    return result;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::map<i64, i64> prime_factors = tools::prime_factorization(N);
  std::cout << std::accumulate(prime_factors.begin(), prime_factors.end(), static_cast<i64>(0), [](const i64& sum, const std::pair<i64, i64>& pair) {
    return sum + static_cast<i64>(std::floor((std::sqrt(8 * pair.second + 1) - 1.0) / 2.0));
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 3776