akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

bool tb[55556];

void hurui() {

	for (int i = 0; i < 55556; i++) {
		tb[i] = true;
	}

	tb[0] == false;
	tb[1] == false;

	tb[2] == true;

	for (int i = 2; i < 55556; i++) {
		if (tb[i] == true) {
			for (int j=2; i*j < 55556; j++) {
				tb[i*j] = false;
			}
		}
	}

}

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

	hurui();

	int index = 6;

	vector<int> ans;

	while (n > 0) {
		if (tb[index] == true) {
			ans.push_back(index);
			n--;
		}

		if (index + 5 < 55556) {
			index += 5;
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];

		if (i == ans.size() - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

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

    ll r, d, x;
    cin >> r >> d >> x;
    for(int i = 1; i <= 10; i ++) {
        x = x * r - d;
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>

using namespace std;
typedef long long ll;

int main(){
	ll H,W;
	cin >> H >> W;
	ll four = (H - H%2) * (W - W%2);
	ll two = 0, one = 0;
	if(H%2 && W%2){
		one = 1;
		two = H+W-2;
	}else if(W%2)
		two = H;
	else if(H%2)
		two = W;
	vector<int> cnt(30);
	for(int y=0;y<H;y++){
		string s;
		cin >> s;
		for(int x=0;x<s.size();x++)
			cnt[s[x]-'a']++;
	}
	bool ok=false;
	for(int i=0;i<cnt.size();i++){
		while(cnt[i]>=4 && four>0){
			cnt[i]-=4;
			four-=4;
		}
		while(cnt[i]>=2 && two>0){
			cnt[i]-=2;
			two-=2;
		}
		while(cnt[i]>=1 && one>0){
			cnt[i]-=1;
			one--;
		}
	}
	if(four==0 && two==0 && one==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

A_1 = int(str(10-(A-int(A/10)*10))[-1])
B_1 = int(str(10-(B-int(B/10)*10))[-1])
C_1 = int(str(10-(C-int(C/10)*10))[-1])
D_1 = int(str(10-(D-int(D/10)*10))[-1])
E_1 = int(str(10-(E-int(E/10)*10))[-1])

_max = max(A_1,B_1,C_1,D_1,E_1)


print(A+B+C+D+E+A_1+B_1+C_1+D_1+E_1-_max)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if (n == 1) {
        if (a == b) cout << 1 << '\n';
        else cout << 0 << '\n';
    } else {
        if (a < b) {
            cout << (n - 2) * (b - a) + 1 << '\n';
        } else if (a == b) cout << 1 << '\n';
        else cout << 0 << '\n';
    }
}


Measured memory_bytes: 256
// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+20;

int a[N];
int psum[N];

int query(int l, int r){
	return psum[r] - psum[l];
}

int32_t main(){

	fastio;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	for(int i = 1; i <= n; ++i){
		psum[i] = psum[i-1] + a[i-1];
	}

	int ans = 1e18;
	for(int l = 2; l+2 <= n; ++l){
		int s1 = query(0,l), s2 = query(l,n);
		int lo = 0, hi = l;
		while(hi - lo > 1){
			int mid = (lo + hi) / 2;
			if(query(0,mid) <= s1/2) lo = mid;
			else hi = mid;
		}
		vector<ii> op1;
		for(int cut = lo-3; cut <= lo+3; ++cut){
			if(cut <= 0) continue;
			if(cut >= l) break;
			op1.pb( make_pair( query(0,cut), query(cut,l) ) );
		}
		lo = l, hi = n;
		while(hi - lo > 1){
			int mid = (lo + hi) / 2;
			if(query(l,mid) <= s2/2) lo = mid;
			else hi = mid;
		}
		vector<ii> op2;
		for(int cut = lo-3; cut <= lo+3; ++cut){
			if(cut <= l) continue;
			if(cut >= n) break;
			op2.pb( make_pair(query(l,cut), query(cut,n)) );
		}

		// test
		for(ii p1 : op1) for(ii p2 : op2){
			int mx = max({p1.first, p1.second, p2.first, p2.second});
			int mn = min({p1.first, p1.second, p2.first, p2.second});
			ans = min(ans, mx - mn);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6308
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  if (s1.back() == s2.front() && s2.back() == s3.front()){
  cout << "YES" << endl;
  } else {
  cout << "NO" << endl;
  }
  return 0 ;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(16);
  int n,memo;
  cin >> n >> memo;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  
  int minn=a[0],maxsa=0;
  Vi are(0);
  
  rep(i,1,n){
    maxsa = max(maxsa,a[i]-minn);
    are.pb(a[i]-minn);
    minn = min(minn,a[i]);
  }
  cout << count(ALL(are), maxsa) << endl;
  
  return 0;
}

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

int main() {
	int64_t N;
	cin >> N;
	int64_t ans = 0;
	if (N != 1) ans = N*(N-1)/2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}

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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n+1),b(n);
  rep(i,0,n+1)std::cin>>a[i];
  rep(i,0,n)std::cin>>b[i];

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

  std::cout<<ans<<"\n";

  return 0;
}



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

int n;
string s;

int cek(int x){
	string tmp = "";
	for(int i=0;i<3;i++){
		tmp+=(char)((x%10) + '0');
		x/=10;
	}
	reverse(tmp.begin(),tmp.end());
	int idx = 0;
	for(int i=0;i<n;i++){
		if(s[i] == tmp[idx]){
			idx++;
		}
		if(idx == 3) return 1;
	}
	return 0;
}

int main(){
	scanf("%d",&n);
	getchar();
	cin >> s;
	int ans = 0;
	for(int i=0;i<1000;i++){
		ans+=cek(i);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
	int N,l[1000],r[1000];

	 cin >> N;

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


      int sum = 0;
	 for (int i = 0;i < N;i++){
       int a = r[i]-l[i]+1;
        sum += a;
	 }

	 cout << sum << endl;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    sort(s.begin(),s.end());
    if(s<t)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),K = sc.nextInt();
		int R = sc.nextInt(),S = sc.nextInt(),P = sc.nextInt() ;
		String str = sc.next();
		char[] list = str.toCharArray();
		ArrayList<Character> ch = new ArrayList<>();
		for(char s : list) ch.add(s);
		ch = check(ch,K);
		for(int i = 0; i < ch.size(); i++) {
			if(ch.get(i) == 'r') {
				ans += P;
			}else if(ch.get(i) == 's') {
				ans += R;
			}else if(ch.get(i) == 'p') {
				ans += S;
			}
		}
		System.out.println(ans);
	}
	public static ArrayList<Character> check(ArrayList<Character> list, int k) {
		for(int i = k; i < list.size(); i++) {
			if(list.get(i).equals(list.get(i-k))) {
				list.set(i, 'n');
			}
		}
		return list;
	}
}

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

int main() {
  int N;
  cin >> N;
  using pp = pair<pair<string, int>, int>;
  vector<pp> data(N);
  for(int i = 0; i < N; i++) {
    string s;
    int p;
    int sec = i + 1;
    cin >> s >> p;
    data.at(i) = make_pair(make_pair(s, -p), sec);
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < N; i++) {
    cout << data.at(i).second << endl;
  }
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		
		if(x < a ) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
		
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

static vector<string> m[10][10];
vector<string> ans;
int main(void){
    int N;
    cin>>N;
    m[0][0].push_back("a");
    rep(i, N-1){
        rep(j, i+1){
            rep(k, m[i][j].size()){
                string str=m[i][j][k];
                string nei="a";
                nei[0]+=(j+1);
                m[i+1][j+1].push_back(str+nei);
                rep(l, j+1){
                    string ne="a";
                    ne[0]+=l;
                    m[i+1][j].push_back(str+ne);
                }
            }
        }
    }
    
    rep(i, N){
        rep(j, m[N-1][i].size()){
            ans.push_back(m[N-1][i][j]);
        }
    }
    sort(all(ans));
    rep(i, ans.size()){
        cout<<ans[i]<<endl;
    }
    return 0;
}


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

#define INF 2000000000
#define MaxN 100005

using namespace std;

int N,T,BestPos=-1;
int Best=INF,A;

int main()
{
    cin>>N>>T>>A;
    T*=500;
    A*=500;

    for(int i=1;i<=N;i++)
    {
        int X;
        cin>>X;
        if(abs(Best-A)>abs(A-T+3*X))
        {
            Best=T-3*X;
            BestPos=i;
        }
    }
    cout<<BestPos;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding space */
int main(){
  int N; cin >> N;
  if(N == 3){cout << 2 << endl << 5 << endl << 63 << endl;return 0;}
  if(N == 4){cout << 2 << endl << 5 << endl << 20 << endl << 63 << endl;return 0;}
  if(N == 5){cout << 2 << endl << 3 << endl << 8 << endl << 14 << endl << 9 << endl; return 0;}
  set<int> ans;
  ans.insert(2);
  ans.insert(3);
  int i = 0;
  while((int)ans.size() != N){
    if((int)ans.size()!=N)ans.insert(6*i+2);
    if((int)ans.size()!=N)ans.insert(6*i+3);
    if((int)ans.size()!=N)ans.insert(6*i+4);
    if((int)ans.size()!=N)ans.insert(6*i+6);
    i++;
  }
  ll ans_sum = 0;
  for(auto x: ans)  ans_sum += x;
  int tar = 0;
  if(ans_sum%6 == 2) tar = 8,i--;
  if(ans_sum%6 == 3) tar = 9;
  if(ans_sum%6 == 5) tar = 9;
  for(auto x: ans){
    if(x == tar){
      if(ans_sum%6 == 5) cout << (6*(i-1)+4) << endl;
      else  cout << 6*i+6 << endl;
    }else cout << x << endl;;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
const u32 P=1e9+7;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}

const int N=1e5+1;
int n, p[N];
u32 f[N];
char s[N];
int main() {
	u32 ans=0;
	int pos[3]={};
	assert(scanf("%s", s)==1);
	n=strlen(s);
	for(int i=0; i<n; ++i) s[i]=(s[i]=='a')?1:2;
	bool diff=true;
	for(int i=1; i<n; ++i) if(s[i]==s[i-1]) diff=false;
	if(diff) {
		puts("1");
		return 0;
	}
	for(int i=0; i<n; ++i) p[i+1]=(p[i]+s[i])%3;
	f[0]=1;
	for(int i=0, j=0; i<n; ++i) {
		int pinkrabbit=(p[i]-s[i]+3)%3, &k=pos[pinkrabbit];
		inc(f[i+1], f[i]);
		if(cmax(j, i+1)) while(j<n&&s[j-1]!=s[j]) ++j;
		if(cmax(k, j+1)) while(k<=n&&p[k]!=pinkrabbit) ++k;
		if(k<=n) inc(f[k], f[i]);
		if(p[i]!=p[n]) inc(ans, f[i]);
	}
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 1152
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

ll modinv(ll num){
  ll n=MOD-2LL;
  ll ret=1LL;
  while(n>0){
    if(n&1)ret=num*ret%MOD;
    num=num*num%MOD;
    n>>=1;
  }
  return ret;
}

int main(){
  ll h, w, a, b;cin>>h>>w>>a>>b;
  ll origin=1LL;
  repb(i, b+1, h-a+b){
    origin*=i;
    origin%=MOD;
  }
  repb(i, 1, h-a){
    origin*=modinv(ll(i));
    origin%=MOD;
  }
  repb(i, w-b, a+w-b-1){
    origin*=i;
    origin%=MOD;
  }
  repb(i, 1, a){
    origin*=modinv(ll(i));
    origin%=MOD;
  }
  ll ans=origin;
  repb(i, 1, w-b){
    origin*=h-a+b-1+i;
    origin%=MOD;
    origin*=modinv(ll(b+i));
    origin%=MOD;
    origin*=w-b-i;
    origin%=MOD;
    origin*=modinv(ll(a+w-b-1-i));
    origin%=MOD;
    ans+=origin;
    ans%=MOD;
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
#define allSum(a) accumulate(a.begin(),a.end(),0)
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n;
  cin>>n;
  vector<long double> a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  int ares=a[0],bres=b[0];
  rep(i,n){
    long double p,q;
    p=ares/a[i];
    q=bres/b[i];
    p=ceil(p);
    q=ceil(q);
    int res=max(p,q);
    ares=a[i]*res;
    bres=b[i]*res;
  }
  out(ares+bres);

  return 0;
}



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


vector<int> s;
int cnt;
int n, p, a;

void bs(int t){
  int right = n;
  int left = 0;
  // cout << "hoge" << endl;
  while(right > left){
    // cout << "hoge" << endl;
    int mid = (right+left)/2;
    if(s[mid] == t){
      cnt++;
      break;
    }
    else if(s[mid] > t){
      right = mid;
    }else if(s[mid] < t){
      left = mid+1;
    }

  }

}

int main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    s.push_back(a);
  }
  // cout << "hoge" << endl;
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(), s.end()), s.end()); 

  cin >> p;
  for(int i = 0; i < p; i++){
    cin >> a;
    bs(a);
  }
  //cout << "hoge" << endl;
  cout << cnt << endl;

 
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n;cin>>n;
    vector<ll> x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];

    vector<ll> a(n),b(n);
    rep(i,n) a[i]=x[i]-y[i];
    rep(i,n) b[i]=x[i]+y[i];

    ll res=0;
    sort(ALL(a));
    sort(ALL(b));
    chmax(res,abs(a[0]-a.back()));
    chmax(res,abs(b[0]-b.back()));
    cout<<res<<endl;
    return 0;
}

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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int tStartLater = max(A, C);
  int tEndEarlier = min(B, D);
  
  cout << max(tEndEarlier - tStartLater, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>

#define rep(i,n) for(int i=1; i<n+1;i++)
typedef long long ll;
//typedef std::pair<int,int> mypair;

using namespace std;

int maze[52][52];
int h,w;
int counter;
const int INF = 100000000;
//vector< vector<int>> e;
//vector<vector<int>> e(4, vector<int>(4));
queue<pair<int,int>> que;

int main(){
cin >> h >> w;
for(int i = 0; i < 52; i++)for(int j = 0; j < 52;j++)maze[i][j] = -1;

char tmp;
rep(i,h){
  rep(j,w){
    cin >> tmp;
    if (tmp == '.'){maze[i][j] = INF;counter++;}
  }
}

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

pair<int,int> p;
p = make_pair(1,1);


que.push(p);


bool flag = true;
while(!que.empty()){
  p = que.front();
  if(p.first == h && p.second == w){
    cout << counter - (maze[p.first][p.second] + 1) << endl;
    flag = false;
    break;
  }
  for(int t = 0; t < 4; t++){
    if(maze[p.first+dx[t]][p.second+dy[t]] == INF){
      maze[p.first+dx[t]][p.second+dy[t]] = maze[p.first][p.second] + 1;
      //a = make_pair(p.first+dx[t],p.second+dy[t]);
      que.push(make_pair(p.first+dx[t],p.second+dy[t]));
    }
  }
  que.pop();
}
if(flag) cout << -1 << endl;




return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

struct Node * find(struct Node *u , int k)
{
	while( u != NIL && k != u->key)
	{
		if( k < u->key)u = u->left;
		else u = u ->right;
	}
	return u;
}

void insert(int k)
{
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL)
	{
		y = x;
		if(z->key < x->key)
		{
			x = x->left;
		}
		else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL)
	{
		root = z;
	}
	else{
		if(z->key < y->key)
		{
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u)
{
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u)
{
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void)
{
	int n , i , x;
	char com[100];
	char str1[] = "insert";
	char str2[] = "print";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		while(scanf("%s",com) != EOF)
		
		if( com[0] == 'f')
		{
			scanf("%d",&x);
			struct Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if(strcmp(com,str1)==0)
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(strcmp(com,str2)==0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}




Measured memory_bytes: 20452
S=input()
 
s = {'A','T','G','C'}
 
ans = 0
for i,q in enumerate(S):
    cur  =0
    ind = i
    while ind < len(S) and S[ind] in s:
        cur += 1
        ind += 1
    ans = max(ans, cur)
print(ans)    

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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    
    for (int i = 0; i < m; i++){
        n -= a[i];
    }
    
    if (n < 0){
        cout << -1 << endl;
        return 0;
    }
    else{
        cout << n << endl;
        return 0;
    }
    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int h, w;
    cin >> h >> w;

    rep(i, h) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }

    return 0;
}

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

void output(){
	for(int k=0;k<20;k++)
		printf("#");
	printf("\n");
}

int main(){
	int A[12][10];
	int b,f,r,v;
	int c;//数组中的层数 
	int n;
	cin>>n;	
	for(int i=0;i<12;i++){
		for(int j=0;j<10;j++){
			A[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		c=3*(b-1)+f-1;
		A[c][r-1] +=v;
	}
		
	
	for(int i=0;i<12;i++){
		for(int j=0;j<10;j++){
			printf(" %d", A[i][j]);
		}
		printf("\n");
		if(((i+1)%3==0)&&(i!=11))
			output();
	}
	
	return 0;
}


Measured memory_bytes: 3232
N, M = map(int, raw_input().split())
  
if N == 1 and M == 1:
    print(1)
elif N == 1 :
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N * M - 2*N - 2*M + 4)

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
vector<int>ad[200000] = {};
int j = 1;
void display(int a[], int n)
{
    for (int i = 0; i < n; i++) {
        ad[j].push_back(a[i]);
    }
    j++;
    //cout << endl;
}
void findPermutations(int a[], int n)
{
    sort(a, a + n);
    do {
        display(a, n);
    } while (next_permutation(a, a + n));
}
int main()
{
    int n;
    cin >> n;
    int arr[1000] = {};
    for(int i = 0; i < n; i++)
    {
        arr[i] = i+1;
    }
    findPermutations(arr, n);
    int a[1000] = {};
    int b[1000] = {};
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    int pos = 0;
    for(int i = 1; i < j; i++)
    {
        bool ok = true;
        for(int k = 0; k < n; k++)
        {
            if(a[k] != ad[i][k])
            {
                ok = false;
                break;
            }
        }
        if(ok == true)
        {
            pos = i;
            break;
        }
    }
    int pos2 = 0;
    for(int i = 1; i < j; i++)
    {
        bool ok = true;
        for(int k = 0; k < n; k++)
        {
            if(b[k] != ad[i][k])
            {
                ok = false;
                break;
            }
        }
        if(ok == true)
        {
            pos2 = i;
            break;
        }
    }
    cout << abs(pos-pos2) << endl;
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int A,B,C,D; cin >> A >> B >> C >> D;
    int t = 0;
    while(A > 0 && C > 0){
        if(t%2 == 0){
            C -= B;
        }
        else{
            A -= D;
        }
        t++;
    }
    cout << (A<=0 ? "No" : "Yes") << en;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

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

  vector<i64> x(N);
  for(int i = 0;i < N;i++) cin >> x[i];

  i64 res = -1;
  for(int i = 0;i + K - 1 < N;i++) {
    int j = i + K - 1;
    i64 ans = 0;
    if(x[i] >= 0) {
      ans = x[j];
    }
    else if(x[j] <= 0) {
      ans = -x[i];
    }
    else {
      ans = min(abs(x[i]) * 2 + abs(x[j]), abs(x[i]) + abs(x[j]) * 2);
    }
    if(res == -1) res = ans;
    else res = min(res, ans);
  }
  cout << res << endl;
}


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

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


Measured memory_bytes: 3096
def myAnswer(S:list) -> int:
   zero = 0
   one = 0
   for s in S:
      if(s == "0"):
         zero += 1
      else:
         one += 1
   return min(zero,one)*2

def modelAnswer(S:list) -> int:
   return

def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()



Measured memory_bytes: 4652
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        char[] arr = new char[s.length()];
        for (int i = 0; i < s.length(); i++) {
            arr[i] = s.charAt(i);
        }
        Arrays.sort(arr);

        int i = 0;
        for (char ch = 'a'; ch <= 'z'; ch++) {
            if (i >= s.length() || arr[i] != ch) {
                System.out.println(ch);
                return;
            }
            while (i < s.length() && arr[i] == ch) {
                i++;
            }
        }
        System.out.println("None");
    }
}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

bool ok_eight_queen(vector<pair<int, int>> q){
    set<int> r, c, cr1, cr2;
    for(int i=0; i<q.size(); i++){
        r.insert(q[i].first);
        c.insert(q[i].second);
        cr1.insert(q[i].first + q[i].second);
        cr2.insert(q[i].first - q[i].second);
    }
    return (c.size() == 8) && (r.size() == 8) && (cr1.size() == 8) && (cr2.size() == 8);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int k;
    cin >> k;
    vector<pair<int, int>> Q(k);
    for(int i=0; i<k; i++){
        int x, y;
        cin >> Q[i].first >> Q[i].second;
    }

    vector<int> rc(8);
    for(int i=0; i<8; i++){
        rc[i] = i;
    }

    do{
        bool flag = true;
        for(int i=0; i<k; i++){
            if(rc[Q[i].first] != Q[i].second) flag = false;
        }
        if(!flag) continue;

        vector<pair<int, int>> q(8);
        for(int i=0; i<8; i++){
            q[i].first = i;
            q[i].second = rc[i];
        }
        if(ok_eight_queen(q)){
            // print
            for(int i=0; i<8; i++){
                for(int j=0; j<8; j++){
                    if(rc[i] == j) cout << "Q";
                    else cout << ".";
                }
                cout << endl;
            }
        }
    }while(next_permutation(rc.begin(), rc.end()));

    return 0;
}


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

 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if ((a+d-1)/d >= (c+b-1)/b) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }    
}


Measured memory_bytes: 3612
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

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

    map<string,int>unique;

    repa(i,1,n)
    {
        string buf; cin>>buf;
        unique[buf]++;
    }

    cout<<unique.size()<<endl;


}

Measured memory_bytes: 19196
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	alist := make([]int, n)

	for i := 0; i < n; i++ {
		alist[i] = nextInt()
	}
	sort.Ints(alist)
	sa := 0
	for i := n - 1; i >= 0; i-- {
		if i%2 == 0 {
			sa += alist[i]
		} else {
			sa -= alist[i]
		}
	}

	fmt.Println(abs(sa))

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

typedef int weight;
typedef pair<weight, int> P;
constexpr weight EPS = 1e-8;

class edge {
public:
	int to;
	int cap;
	weight cost;
	int rev;
	edge(int to_, int cap_, weight cost_, int rev_):to(to_), cap(cap_), cost(cost_), rev(rev_){};
};

vector<vector<edge> > G;

void init(int V) {
	G.assign(V, vector<edge>());
}

void add_edge(int from, int to, int cap, weight cost) {
	G[from].emplace_back(to, cap, cost, G[to].size());
	G[to].emplace_back(from, 0, -cost, G[from].size() - 1);
}

weight min_cost_flow(int s, int t, int f) {
	const int n = G.size();
	weight res = 0;
	vector<int> prevv(n), preve(n);
	vector<weight> h(n, 0);
	while(f > 0) {
		priority_queue<P, vector<P>, greater<P> > que;
		vector<weight> dist(n, INT_MAX);
		dist[s] = 0;
		que.push({0, s});
		while(!que.empty()) {
			const int d = que.top().first;
			const int v = que.top().second;
			que.pop();

			if(dist[v] < d) continue;

			for(unsigned i = 0; i < G[v].size(); ++i) {
				const edge &e = G[v][i];
				if(e.cap > 0 && dist[e.to] > d + e.cost + h[v] - h[e.to] + EPS) {
					dist[e.to] = d + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push({dist[e.to], e.to});
				}
			}
		}

		if(dist[t] == INT_MAX) return -1;

		for(int v = 0; v < n; ++v) {
			h[v] += dist[v];
		}

		int d = f;
		for(int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}

		f -= d;
		res += d * h[t];
		for(int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}

	return res;
}

constexpr int NUMBER_OF_DAYS = 365;

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

	for(int n; cin >> n && n;) {
		init(NUMBER_OF_DAYS + 1);
		for(int i = 0; i < NUMBER_OF_DAYS; ++i) {
			add_edge(i, i + 1, 2, 0);
		}

		for(int i = 0; i < n; ++i) {
			int l, r, w;
			cin >> l >> r >> w;
			add_edge(l - 1, r, 1, -w);
		}

		cout << -min_cost_flow(0, NUMBER_OF_DAYS, 2) << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
    string s ;
    cin >> s ;
    int cnt[26] = {0} ;
    for(char c : s){
        cnt[c-'a']++;
    }
    for(int x : cnt){
        if ( x&1 ){
            cout << "No" << endl;
            return 0 ;
        }
    }
    cout << "Yes" << endl;
    return 0 ;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count

def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a)

n = int(sys.stdin.readline())
A = list()
for i in range(n):
    A.append(int(sys.stdin.readline()))

shellSort(A, n)



Measured memory_bytes: 45520
//
// Created by Tzyark on 2018/9/19.
//
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    ll N, T, A, t, a;
    cin >> N;
    t = a = 1;
    for (ll n = 0; n < N; n++) {
        cin >> T >> A;
        ll k = max((t+T-1)/T, (a+A-1)/A);
        t = k * T;
        a = k * A;
        //cout << t << " " << a << endl;
    }
    cout << t+a << endl;
    return 0;
}

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

#define dbg(a)	cerr << __LINE__ << ": " << #a << " = " << a << '\n'

int main(){
	int a, b;	scanf("%2d %2d", &a, &b);
	if(a >= 1 and a <= 12 and b >= 1 and b<=12)	puts("AMBIGUOUS");
	else if((a==0 or a > 12) and (b==0 or b>12))	puts("NA");
	else if(a <= 12 and a > 0)	puts("MMYY");
	else puts("YYMM");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n, m;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	ios::sync_with_stdio(false);
	cin >> n >> m;
	if (m == 1) cout << 1 << ' ' << 2 << endl;
	else if (n & 1) {
		for (int i = 1; i <= m; ++i)
			cout << i << ' ' << n - i << endl;
	} else {
		int i = 1;
		for (i = 1; i < m; ++i) {
			if (i * 2 - 1 >= n - i + 1 - i) break;
			cout << i << ' ' << n - i + 1 << endl;
		}
		for (; i <= m; ++i)
			cout << i << ' ' << n - i << endl;
	}
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  int give,get;
  give=800*n;
  get=200*(n/15);
  cout<<give-get<<endl;
  return 0;
}


Measured memory_bytes: 256
s= input()

s_r = s[::-1]
N = len(s)
s_2 = s[:int((N-1)/2)]
s_3 = s[int((N+1)/2):]

if ( (s == s_r) & (s_2 ==s_2[::-1]) &(s_3 ==s_3[::-1])):
  print('Yes')
else :
  print('No')
  

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

#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)
int main(void)
{
	//freopen("C:\\Users\\YuXiaoKang\\Desktop\\test.txt","r",stdin);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int W,H,N;
    cin>>W>>H>>N;
    int x,y,a;
    int a1=0,a2=W,a3=0,a4=H;
    for(int i=0;i<N;i++)
    {
        cin>>x>>y>>a;
        if(a==1)
        {
            a1=max(a1,x);
        }
        else if(a==2)
        {
            a2=min(a2,x);
        }
        else if(a==3)
        {
            a3=max(a3,y);
        }
        else if(a==4)
        {
            a4=min(a4,y);
        }
    }
    if(a2-a1>0&&a4-a3>0)
    {
        cout <<(a2-a1)*(a4-a3)<<endl;
    }
    else
    {
        cout <<0 <<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int inf=1000000001;
int wf[100][100];

int main()
{
	for(int n,k;cin>>n>>k,n;){
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=(i==j)?0:inf;

		while(k--){
			int type;	cin>>type;
			if(type==0){
				int a,b;	cin>>a>>b;
				a--,b--;
				cout<<(wf[a][b]<inf?wf[a][b]:-1)<<endl;
			}
			else{
				int c,d,e;	cin>>c>>d>>e;
				c--,d--;
				wf[c][d]=wf[d][c]=min(wf[c][d],e);
				for(int i=0;i<n;i++)for(int j=0;j<n;j++){
					wf[i][j]=min(wf[i][j],wf[i][c]+wf[c][d]+wf[d][j]);
					wf[i][j]=min(wf[i][j],wf[i][d]+wf[d][c]+wf[c][j]);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 904