akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#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 pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5])
    	cout << "Yes";
    else
    	cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct U_F{
    vector<ll> par;
    vector<ll> rank;
private:
    vector<ll> num;
public:
    void init(ll n){
        rep(i,0,n-1){
            par.pb(i);
            rank.pb(0);
            num.pb(1);
        }
    }
    ll find(ll x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(ll x,ll y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(rank[x]<rank[y]){
            par[x]=y;
            num[y]=num[x]+num[y];
        }else if(rank[x]==rank[y]){
            par[y]=x;
            rank[x]++;
            num[x]=num[x]+num[y];
        }else{
            par[y]=x;
            num[x]=num[x]+num[y];
        }
    }
    bool same(ll x,ll y){
        return find(x)==find(y);
    }
    ll g_num(ll x){
        x=find(x);
        return num[x];
    }
};

int main(){fastio
    ll n,m;cin>>n>>m;
    U_F uf;
    uf.init(n);
    rep(i,0,m-1){
        ll a,b;cin>>a>>b;
        b--;a--;
        uf.unite(a,b);
    }
    set<ll> st;
    rep(i,0,n-1){
        ll par=uf.find(i);
        if(st.find(par)==st.end()){
            st.insert(par);
        }
    }
    ll ans=0-1;
    for(auto it=st.begin();it!=st.end();++it){
        ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}





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

def calc_ans(H,W):
    ans = float('inf')
    #ブロックAを横に分割
    halfed_w = W//2
    for h in range(1,H):
        a  = h*W
        #横分け
        b1 = (H-h)//2*W
        c1 = (H-h-(H-h)//2)*W
        #縦で分けた面積
        b2 = (H-h)*halfed_w
        c2 = (H-h)*(W-halfed_w)
        result1 = max(a,b1,c1)-min(a,b1,c1)
        result2 = max(a,b2,c2)-min(a,b2,c2)
        ans = min(ans,result1,result2)
    #ブロックAを縦に分割
    halfed_h = H//2
    for w in range(1,W):
        a = w*H
        #横分け
        b1 = (W-w)//2*H
        c1 = (W-w-(W-w)//2)*H
        #縦分け
        b2 = (W-w)*halfed_h
        c2 = (W-w)*(H-halfed_h)
        result1 = max(a,b1,c1)-min(a,b1,c1)
        result2 = max(a,b2,c2)-min(a,b2,c2)
        ans = min(ans,result1,result2)
    print(ans)

calc_ans(H,W)

Measured memory_bytes: 3064
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int main(){
  ll N,M;
  cin >> N ;
  cout << 180*N-360 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<list>
#include<bitset>
#include<sstream>

#define ln 1e6
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1000000000

#define sortvac(a,b) sort(akash.begin(),akash.end())
#define sortvdc(a,b) sort(akash.begin(),akash.end(),greater<int>())

#define sortaac(a,b) sort(arr,arr+b)
#define sortadc(a,b) sort(arr,arr+b,greater<int>())

#define searchv(data) binary_search(akash.begin(),akash.end(),data)
#define searcha(data) binary_search(arr,arr+b,data)

#define reversev(akash) reverse(akash.begin(),akash.end())
#define reversea(arr) reverse(arr,arr+b)

#define removev(data) remove(akash.begin(),akash.end(),data);
#define removea(data) remove(arr,arr+b,data);

#define maxv(akash) *max_element(akash.begin(),akash.end())
#define maxa(arr) *max_element(arr,arr+b)

#define minv(akash) *min_element(akash.begin(),akash.end())
#define mina(arr) *min_element(arr,arr+b)

#define fori(i,a,b) for(int i=0;i<b;i++)
#define ford(i,a,b) for(int i=b-1;i>=0;i--)

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    
    int flag=0;
    
    for(int i=0;i<s1.size();i++){
        if(s1[i]!=s2[i]){
            flag=1;
            break;
        }
    }
    
    if(flag==0 && (s2.size()-s1.size())==1){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

    return 0;
}







     



Measured memory_bytes: 3040
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG A; string B; cin >> A >> B;
    LLONG tmp = static_cast<int>(B[0] - '0') * 100
        + static_cast<int>(B[2] - '0') * 10
        + static_cast<int>(B[3] - '0') * 1;
    cout << A * tmp / 100 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int a[100000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0||a[i]%5==0)
            {
                continue;
            }
            else
            {
                flag=1;
                break;
            }
        }
    }
    if(flag)
    {
        cout<<"DENIED"<<'\n';
    }
    else
        cout<<"APPROVED"<<'\n';



}


Measured memory_bytes: 256
s = input()
odd = [0,0]
even = [0,0]
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == '0':
            even[0] += 1
        else:
            even[1] += 1
    else:
        if s[i] == '0':
            odd[0] += 1
        else:
            odd[1] += 1
print(min(even[1]+odd[0],even[0]+odd[1]))

Measured memory_bytes: 3188
use std::io;

fn main() {
    let stdin = io::stdin();
    let (x,y) = {
	let mut buf = String::new();
	stdin.read_line(&mut buf).unwrap();
	let mut tmp = buf.split_ascii_whitespace().map(|n| n.parse::<i32>().unwrap());
	(tmp.next().unwrap(), tmp.next().unwrap())
    };

    if solve(x,y) {
	println!("Yes");
    }else{
	println!("No");
    }
}

fn solve(x: i32, y : i32) -> bool{
    let b = y - 2 * x;
    b >= 0 && b % 2 == 0 && x >= (b/2)
}

#[cfg(test)]
mod test{
    use super::*;

    #[test]
    fn on_web(){
	assert!(solve(3,8));
	assert!(!solve(2,100));
	assert!(solve(1,2));
    }
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define int long long

using namespace std;
int solve(int *arr, int *wt,int n,int w)
{
  int **dp= new int*[n+1];
  for(int i=0;i<=n;i++)
  {
      dp[i]= new int[w+1];
  }
  for(int i=0;i<w+1;i++) dp[0][i]=0;
  for(int i=0;i<n+1;i++) dp[i][0]=0;
  
  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<=w;j++)
      {
          dp[i][j]=dp[i-1][j];
          if(wt[i-1]<=j)
          dp[i][j]=max(dp[i][j],arr[i-1]+dp[i-1][j-wt[i-1]]);
      }
  }
  return dp[n][w];
}


int32_t main()
{
        int n,w; cin>>n>>w;
    int arr[n];
    int wt[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>arr[i];
    }
    int ans= solve(arr,wt,n,w);
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a[5], k;
    rep(i, 5) cin >> a[i];
    cin >> k;
    if(abs(a[0]-a[4])>k) out(":(");
    else out("Yay!");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 50005
#define MAXL 50005
int dp[3][MAXL];

int main(){
	int n;
	static bool c[MAX]={true, true};
	for(int i = 2;i < MAX;i++){
		if(!c[i]){
			for(int j = 2;i*j < MAX;j++)c[i*j] = true;
		}
	}
	dp[0][0] = 1;
	for(int k = 0;k < 2;k++){
		for(int i = 0;i < MAXL;i++){
			if(!c[i]){
				for(int j = 0;j < MAXL - i;j++){
					if(i >= j)dp[k+1][j+i] += dp[k][j];
				}
			}
		}
	}
	//for(int i = 0;i < 30;i++)cout << dp[2][i];
	while(cin >> n, n){
		cout << dp[2][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3440
import java.security.AlgorithmParameterGenerator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int R = sc.nextInt();
			boolean[][] use = new boolean[M][1260 - 540 + 1];
			int[] prev = new int[N + 1];
			for (int i = 0; i < R; ++i) {
				int t = sc.nextInt();
				int n = sc.nextInt();
				int m = sc.nextInt();
				int s = sc.nextInt();
				if (s == 0) {
					for (int j = prev[n]; j < t; ++j) {
						use[m - 1][j - 540] = true;
					}
				} else {
					prev[n] = t;
				}
			}
			int Q = sc.nextInt();
			for (int i = 0; i < Q; ++i) {
				int ts = sc.nextInt();
				int te = sc.nextInt();
				int m = sc.nextInt();
				int ans = 0;
				for (int j = ts; j < te; ++j) {
					if (use[m - 1][j - 540]) ++ans;
				}
				System.out.println(ans);
			}
		}
	}

}

Measured memory_bytes: 71152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

ll gcd(ll a, ll b) {
	ll temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

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

	int n;
	cin >> n;
	vi p(n);
	rep(i, n)cin >> p[i];

	int ans = 0;
	repr(i, 1, n - 1) {
		vi t = { p[i - 1],p[i],p[i + 1] };
		sort(all(t));
		
		if (t[0] < t[1] && t[1] < t[2] && t[1]==p[i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
void password(char o[],char e[])
{
    char p[100];
    int l=0,m=0;
    l=strlen(o);
    m=strlen(e);
    for(int i=0,j=0,k=0;i<l+m;i++)
    {
        if(i%2==0)
        {
            p[i]=o[j];
            j++;
        }
        else
        {
            p[i]=e[k];
            k++;
        }
    }
    p[l+m]='\0';
    cout<<p;
}
int main()
{
    char o[50],e[50];
    cin>>o;
    cin>>e;
    password(o,e);
    return 0;
}

Measured memory_bytes: 256
//abc132_c.cpp
//Sat Jun 29 20:41:36 2019

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

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

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

	sort(d,d+n);

	if (d[n/2]==d[n/2-1]){
		cout << 0 << endl;
	}else {
		cout << d[n/2]-d[n/2-1] << endl;
	}
}

Measured memory_bytes: 640
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    VV vec(h, V(w));
    rep(i, h)
    {
        string s;
        cin >> s;
        rep(j, w)
        {
            if (s[j] == '.')
            {
                vec[i][j] = 1;
              //  cout<<i<<" "<<j<<endl;
            }
        }
    }
    ll res = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            if(!vec[i][j]){

                continue;
            }
         //   cout<<i<<" "<<j<<endl;
            VV have(h, V(w));
            VV reg(h, V(w, 0));
            have[i][j] = 1;
            queue<pair<ll, ll>> q;
            q.push({i, j});
            int dx[] = {-1, 0, 1, 0};
            int dy[] = {0, 1, 0, -1};
            while (!q.empty())
            {
                P temp = q.front();
                q.pop();
                ll x = temp.S;
                ll y = temp.F;
             //cout<<x<<" "<<y<<endl;
                rep(f, 4)
                {
                    if (x + dx[f] >= 0 && x + dx[f] < w && y + dy[f] >= 0 && y + dy[f] < h && have[y + dy[f]][x + dx[f]] == 0&&vec[y+dy[f]][x+dx[f]])
                    {
                        q.push({y + dy[f], x + dx[f]});
                        have[y + dy[f]][x + dx[f]] = 1;
                        reg[y + dy[f]][x + dx[f]] = reg[y][x] + 1;
                    //    cout << x + dx[f] << " " << y + dy[f] << " " << reg[x][y] << endl;
                    }
                }
            }
            rep(k,h){
                rep(l,w){
                    chmax(res, reg[k][l]);
              //      cout<<reg[k][l]<<" ";
                }
                //cout<<endl;
            }
            //cout<<endl;
          //  cout<<i<<" "<<j<<" "<<res<<endl;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  rep(man, 2){
    rep(sen, 10){
      rep(hyaku, 10){
        rep(ju, 10){
          rep(ichi, 10){
            int keta = man + sen + hyaku + ju + ichi;
            if(keta >= a && keta <= b){
              int value = man*10000 + sen*1000 + hyaku*100 + ju*10 + ichi;
              if(value <= n) ans += value;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("unroll-loops")
     
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <functional>
    #include <iomanip>
    #include <iostream>
    #include <iterator>
    #include <limits>
    #include <climits>
    #include <list>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <random>
    #include <ratio>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <utility>
    #include <vector>
    using namespace std;
     
    typedef long long ll;
    typedef long double LD;
    #define int ll
    #define double LD
    #define pb push_back
    #define mp make_pair
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define loop(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define mem(a, b) memset(a, b, sizeof a)
    #define append push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define print(x) cout << (x) << endl
    #define PRECISION(x) cout << fixed << setprecision(x)
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
     
    const double PI=acos(-1);
    const int MOD = 1000000007;
    const int FMOD = 998244353;
    const double eps = 1e-9;
     
    mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
    
    signed main()
    {
    	
		int n;
		cin>>n;
		map<string,int> m;
		loop(i,n)
		{
			string s;
			cin>>s;
			m[s]++;
		}
		int mx=-1;
		for(auto x:m)
		{
			mx=max(mx,x.second);
		}
		set<string> st;
		for(auto x:m)
		{
			if(x.second==mx)
			{
				st.insert(x.first);
			}
		}
		for(auto x:st)
		{
			cout<<x<<endl;
		}
	}

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

int main(){
    string N;
    cin >> N;
    if(N == "SUN"){
        cout << "7";
    }else if(N == "MON"){
        cout << "6";
    }else if(N == "TUE"){
        cout << "5";
    }else if(N == "WED"){
        cout << "4";
    }else if(N == "THU"){
        cout << "3";
    }else if(N == "FRI"){
        cout << "2";
    }else if(N == "SAT"){
        cout << "1";
    }
    return 0;

}

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

int main(){
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
   
    if(a < b && b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
h,w=map(int,input().split())
n=int(input())
a=[0]+list(map(int,input().split()))
ans=[[0]*w for i in range(h)]
x=0
y=0
for i in range(1,n+1):
    for _ in range(a[i]):
        
        if y==w:
            x+=1
            y=0
            
        if x%2==0:
            ans[x][y]=i
            y+=1
        else:
            ans[x][w-1-y]=i
            y+=1
for u in ans:
    print(*u)

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/cdescription.jsp?cid=ACPC2017Day1&pid=D
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, M, s, t; cin >> N >> M >> s >> t;
	s--; t--;
	vector<int> d(N);
	vector<vector<int>> G(N);
	for (int i = 0; i < N;i++) cin >> d[i];
	for (int i = 0; i < M;i++) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
	}
	for (int i = 1; i < N;i++)G[i].push_back(i - 1);
	vector<ll> dist(N, INF);
	queue<pair<int, int>> q;
	q.push({ s,s });
	dist[s] = 0;
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int n = p.first, max_n = p.second;
		for (auto next : G[n]) {
			int cost = d[next];
			if (next < max_n) cost = 0;
			if (dist[next] > dist[n] + cost) {
				dist[next] = dist[n] + cost;
				q.push({ next,max(max_n,next) });
			}
		}
	}
	cout << dist[t] << endl;
	return 0;
}

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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

long long arr[101][2];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int i = 0; i < n; ++i)
        cin >> arr[i][0];
    for(int i = 0; i < n; ++i)
        cin >> arr[i][1];

    long long best = 0, top = 0, bottom = 0;

    for(int i = 0;i < n; ++i)
        bottom += arr[i][1];

    for(int i = 0; i < n; ++i){
        top += arr[i][0];
        best = max(best, top + bottom);
        bottom -= arr[i][1];
    }

    cout << best;



    return 0;
}


Measured memory_bytes: 256
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	vector<int> P; // value of pre & cycle
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	for(ll i=0; i<n; ++i){
		if(X[x] > -1){
			int cyc_len = P.size() - X[x];
			int nxt_len = (n - X[x]) % cyc_len;
			ll remain = 0; 
			rp(i, 0, X[x]) remain += P[i];
			ll cyc = (sum_p - remain) * ((n - X[x]) / cyc_len);
			rp(i, X[x], X[x] + nxt_len) remain += P[i];
			cout<< cyc + remain <<endl;
			return 0;
		}
		X[x] = i;
		P.push_back(x);
		sum_p += x;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int s;
  cin >> s;
  int cnt=1;
  if(s==2 || s==1 ){
    cout << 4;
    return 0;
  }
  while(1){
    if(s==4) break;
    cnt++;
    if(s%2==0) s /= 2;
    else s = 3*s+1;
  }

  cout << cnt+3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,at,bt,k,i;
  while(1){
    scanf("%d",&k);
      if(k==0)break;
      at=0;
      bt=0;
      for(i=0;i<k;i++){
	scanf("%d %d",&a,&b);
	if(a>b)at+=a+b;
	else if(b>a)bt+=a+b;
	else {
	  bt+=b;
	  at+=a;
	}
      }
      printf("%d %d\n",at,bt);
    }
    return 0;
  }

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	char a;
	set<char> st;
	for (int i = 0; i < N; i++) {
		cin >> a;
		st.insert(a);
	}
	if (st.size() == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
}

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

using namespace std;

class node{
public:
	int id;
	vector<int> children;
	int parent;
	int sibling;
	int depth;
	int height;
};

bool operator<=(node a, node b) {
	return a.id <= b.id;
}
bool operator<(node a, node b) {
	return a.id < b.id;
}

void preorder(node* nod, int index, int n) {
	cout << " " << nod[index].id;
	if (nod[index].children[0] != -1) {
		preorder(nod, nod[index].children[0], n);
	}
	if (nod[index].children[1] != -1) {
	 	preorder(nod, nod[index].children[1], n);
	}
}
void inorder(node* nod, int index, int n) {
	
	if (nod[index].children[0] != -1) {
		inorder(nod, nod[index].children[0], n);
	}
	cout << " " << nod[index].id;
	if (nod[index].children[1] != -1) {
		inorder(nod, nod[index].children[1], n);
	}
}
void postorder(node* nod, int index, int n) {

	if (nod[index].children[0] != -1) {
		postorder(nod, nod[index].children[0], n);
	}
	if (nod[index].children[1] != -1) {
		postorder(nod, nod[index].children[1], n);
	}
	cout << " " << nod[index].id;
}

int main() {
	int  n,tmp2,index_root;
	cin >> n;
	node* nod = new node[n];
	bool* root = new bool[n];
	for (int i = 0;i < n;i++) {
		cin >> nod[i].id;
		for (int j = 0;j < 2;j++) {
			cin >> tmp2;
			nod[i].children.push_back(tmp2);
		}
		root[i] = true;
	}
	sort(nod, nod + n);
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < nod[i].children.size();j++) {
			root[nod[i].children[j]] = false;
		}
	}
	for (int i = 0;i < n;i++) {
		if (root[i]) {
			index_root = i;
			break;
		}
	}
	cout << "Preorder" << endl;
	preorder(nod, index_root, n);
	cout << "\nInorder" << endl;
	inorder(nod, index_root, n);
	cout << "\nPostorder\n";
	postorder(nod, index_root, n);
	cout << "\n";


	
}






Measured memory_bytes: 3136
import java.io.*;
import java.util.*;
class Pair implements Comparable<Pair>
{
    int r;
    int c;
    int dist;
    public Pair(int r,int c,int d)
    {
        this.r=r;
        this.c=c;
        this.dist=d;
    }
    public int compareTo(Pair p)
    {
        if(this.dist>p.dist)
        return 1;
        else if(this.dist<p.dist)
        return -1;
        return 0;
    }
}
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int[]ar=split();
		int h=ar[0];
		int w=ar[1];
		int m=ar[2];
		int[][] arr=new int[m][2];
		HashMap<String,Integer> check=new HashMap<>();
		for(int i=0;i<m;i++)
		{
			ar=split();
			arr[i][0]=ar[0]-1;
			arr[i][1]=ar[1]-1;
			check.put(arr[i][0]+" "+arr[i][1],1);
		}
		int ans=0;
		int[]r=new int[h];
		int[]c=new int[w];
		int[][]r_h=new int[h][2];
		int[][]c_h=new int[w][2];
		for(int i=0;i<m;i++)
		{
			int row=arr[i][0];
			int col=arr[i][1];
			r[row]++;
			c[col]++;
			r_h[row][0]=r[row];
			r_h[row][1]=row;
			c_h[col][0]=c[col];
			c_h[col][1]=col;
		}
		Arrays.sort(r_h,new Comparator<int[]>() {
			public int compare(int[]a,int[]b)
			{
				return b[0]-a[0];
			}
		});
		Arrays.sort(c_h,new Comparator<int[]>() {
			public int compare(int[]a,int[]b)
			{
				return b[0]-a[0];
			}
		});
		for(int i=0;i<h;i++)
		{
			int cnt=r[i];
			int c1=c_h[0][1];
			int mx=c_h[0][0];
			cnt=cnt+mx;
			if(check.containsKey(i+" "+c1))
				cnt--;
			ans=Math.max(ans, cnt);
		}
		for(int i=0;i<w;i++)
		{
			int cnt=c[i];
			int r1=r_h[0][1];
			int mx=r_h[0][0];
			cnt=cnt+mx;
			if(check.containsKey(r1+" "+i))
				cnt--;
			ans=Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 125588
#include <iostream>
using namespace std;
using ll=long long;

const int MAX = 700000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll x,y; cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  int n=(x+y)/3;
  int a=2*n-x;
  COMinit();
  cout << COM(n,a) << endl;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
char s[100];
ll ans;
map<pair<unsigned int, unsigned int>, int> M;
int main() {
	cin >> n;
	cin >> s;
	for (int i = 0; i < (1 << n); ++i) {
		unsigned int t1 = 0, t2 = 0;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				t1 *= 13131;
				t1 += s[j];
			} else {
				t2 *= 13131;
				t2 += s[j];
			}
		}
		M[make_pair(t1, t2)]++;
	}
	reverse(s, s + 2 * n);
	for (int i = 0; i < (1 << n); ++i) {
		unsigned int t1 = 0, t2 = 0;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				t1 *= 13131;
				t1 += s[j];
			} else {
				t2 *= 13131;
				t2 += s[j];
			}
		}
		ans += M[make_pair(t2, t1)];
	}
	cout << ans;
}

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

const int mod=1e9+7;

int mod_pow(int x,int n)
{
   int res=1;
   while(n>0){
      if(n&1) res=res*x%mod;
      x=x*x%mod;
      n>>=1;
   }
   return res;
}

signed main()
{
   string s; cin>>s;
   int N=s.size();

   vector<int> sumA(N+1);
   vector<int> sumC(N+1);
   vector<int> sumX(N+1);

   for(int i=0;i<N;i++){
      sumA[i+1]=sumA[i]+(s[i]=='A');
      sumC[i+1]=sumC[i]+(s[i]=='C');
      sumX[i+1]=sumX[i]+(s[i]=='?');
   }

   int ans=0;
   for(int i=1;i<=N-2;i++){
      if(s[i]=='B' or s[i]=='?'){
         {
            ans+=sumA[i]*(sumC[N]-sumC[i+1])%mod*mod_pow(3,sumX[i]+(sumX[N]-sumX[i+1]))%mod;
            ans%=mod;
         }
         if(sumX[N]-sumX[i+1]>0){
            ans+=sumA[i]*(sumX[N]-sumX[i+1])%mod*mod_pow(3,sumX[i]+(sumX[N]-sumX[i+1]-1))%mod;
            ans%=mod;
         }
         if(sumX[i]>0){
            ans+=sumX[i]*(sumC[N]-sumC[i+1])%mod*mod_pow(3,(sumX[i]-1)+(sumX[N]-sumX[i+1]))%mod;
            ans%=mod;
         }
         if(sumX[i]>0 and sumX[N]-sumX[i+1]>0){
            ans+=sumX[i]*(sumX[N]-sumX[i+1])%mod*mod_pow(3,(sumX[i]-1)+(sumX[N]-sumX[i+1]-1))%mod;
            ans%=mod;
         }
      }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] num = new int[31];
		for (int i = 1; i < 31; i++) {
			if (i == 1) {
				num[i] = 1;
			} else if (i == 2) {
				num[i] = 2;
			} else if (i == 3) {
				num[i] = 4;
			} else {
				num[i] = num[i - 3] + num[i - 2] + num[i - 1];
			}
		}
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;

			int a = Math.max(num[n] / 10, 1) % 365;
			int ans = num[n] / 3650;
			if (a != 0) {
				ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 15344
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
		}
		if (n >= 2) {
			System.out.println(Math.max(Math.abs(w - a[n - 1]), Math.abs(a[n - 1] - a[n - 2])));
		} else if (n == 1) {
			System.out.println(Math.abs(w - a[0]));
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
ld n;
cin>>n;
ld x=100.0;
ll count=0;
while(x<n){
x=(x+(0.01*x));
ll p=x;
x=p;
count++;
}
cout<<count<<endl;
}

Measured memory_bytes: 3724
numbers = []
n = raw_input()
s = raw_input()
print s
numbers = s.split(" ")
for i in range(int(n)):
	numbers[i] = int(numbers[i])


for i in range(1, int(n)):
	v = numbers[i]
	j = i - 1
	while (j >= 0 and numbers[j] > v):
		numbers[j + 1] = numbers[j]
		j -= 1
	numbers[j + 1] = v
	print ' '.join([str(a) for a in numbers])

Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
int main ()
{
	ll a,h,n,val = 0;
	scanf("%lld%lld",&h,&n);
    for(int i = 0; i < n; ++ i){
        scanf("%lld",&a);
        val += a;
    }
    if (val >= h){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
	return 0;
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    string str;
    cin>>k>>str;
    n =str.size();
    for(i=0;i<min(k,n);i++)
        cout<<str[i];
    if(str.size()>k)
        cout<<"..."<<endl;
    return 0;
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    ll H, W;
    cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = longinf;
    {
        ll h1 = H / 2;
        ll h2 = H - h1;
        for (ll w = 1; w <= W - 1; w++) {
            ll s1 = w * H;
            ll s2 = (W - w) * h1;
            ll s3 = (W - w) * h2;

            chmin(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
        }
    }

    {
        ll w1 = W / 2;
        ll w2 = W - w1;
        for (ll h = 1; h <= H - 1; h++) {
            ll s1 = h * W;
            ll s2 = (H - h) * w1;
            ll s3 = (H - h) * w2;

            chmin(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
        }
    }

    {
        ll h1 = H / 3;
        ll h2 = (H - h1) / 2;
        ll h3 = H - h1 - h2;

        ll s1 = h1 * W;
        ll s2 = h2 * W;
        ll s3 = h3 * W;

        chmin(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
    }

    {
        ll w1 = W / 3;
        ll w2 = (W - w1) / 2;
        ll w3 = W - w1 - w2;

        ll s1 = w1 * H;
        ll s2 = w2 * H;
        ll s3 = w3 * H;

        chmin(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A%3 && B%3 && (A+B)%3 != 0){
    cout << "Impossible" << endl;
  } 
  else{
    cout << "Possible" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ll h, w; cin >> h >> w;
	ll ans = (h * w + 1) / 2;

	if (h == 1 || w == 1) dunk(1);
	else dunk(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm> 
#include <cmath>
#include <cstdlib>
using namespace std;
#define ll long long 
#define gc getchar_unlocked
const int MOD = 1000000007;
const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	cin>>N>>K;
	for(int i=1;i<=N;i++)
	{
		cin>>h[i];
	}
	for(int i=2;i<=N;i++)
	{
		dp[i] = INF;
		for(int j=i-1;j>=max(i-K,1);j--)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
		}
	}
	cout<<dp[N]<<"\n";
}

Measured memory_bytes: 4364
# C - Big Array

import numpy as np
import bisect

N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

ab = sorted(ab, key = lambda x : x[0])
a, b = zip(*ab)
b = np.array(b)
b = b.cumsum()

ans_idx = bisect.bisect_left(b, K)
print(a[ans_idx])

Measured memory_bytes: 45028
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <fstream>
#include <bitset>
 
using namespace std;
 
void solve();
 
int main( void ) {
 
	solve();
 
	return 0;
}
 
void solve() {
 
	int N;
 
	map<int,map<int,int>> mp;	//map[x][y] = w
	vector<pair<int,int>> v;
 
	scanf("%d\n",&N);
	v.resize(N);
 
	for( int i = 0; i < N; i++ ) {
		int x, y, w;
		scanf("%d %d %d\n",&x,&y,&w);
		mp[x][y] = w;
		v[i] = pair<int,int>(x,y);
	}
 
	int d[4][2] = { {0,1}, {1,1}, {1,0}, {0,0} };
 
	int wm = 0;
 
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < 4; j++ ) {
			int w = 0;
			pair<int,int> b(v[i]);
				b.first  -= d[j][0];
				b.second -= d[j][1];
			for( int k = 0; k < 4; k++ ) {
				pair<int,int> p(b);
					p.first += d[k][0];
					p.second += d[k][1];
				if( mp.find( p.first ) != mp.end() ) {
					if( mp[p.first].find( p.second ) != mp[p.first].end() ) {
						w += mp[p.first][p.second];
					}
				}
			}
			wm = max(w,wm);
		}
	}
 
	cout << wm << " / " << 1 << endl;
 
}

Measured memory_bytes: 17596
A = []
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
for i in range(N):
    A.append(list(map(int, input().split())))
ans = 0

for i in range(N):
    buffer = 0
    for j in range(M):
        buffer += A[i][j] * B[j]
    if(buffer + C > 0):
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {

	int a, b;
	cin >> a >> b;
	int ans = a - b * 2;
	if (ans < 0) {
		ans = 0;
	}
	cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vector<ll> vec(n);
  REP(i,n) cin >> vec[i];

  ll q;
  cin >> q;
  REP(i,q){
    ll k;
    cin >> k;
    ll lb, ub;

    ll lef = -1, rig = n;
    while(rig - lef > 1){
      ll mid = (lef + rig) / 2;
      if(vec[mid] >= k) rig = mid;
      else lef = mid;
    }
    lb = rig;
    cout << lb <<endl;
  }

  return 0;
}




Measured memory_bytes: 3644