akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[200000];
int main() {
    int i;
    int N,M;
    scanf("%d %d",&N,&M);
    for (i = 0; i < 2*N; i++) scanf("%d",&a[i]);
    sort(a,a+2*N);

    int l = 0,r = M-1;
    while (l < r) {
        int m = (l+r) / 2;
        printVar(m);
        int s = 0,e = N;
        while (s < e) {
            int mm = (s+e+1) / 2;
            for (i = 0; i < mm; i++) {
                if (a[i]+a[2*mm-i-1] > m) break;
            }
            if (i < mm) e = mm-1;
            else s = mm;
        }
        printVar(s);
        int rr = s;
        s = 0,e = N;
        while (s < e) {
            int mm = (s+e) / 2;
            int f = 0;
            for (i = 2*mm; i < 2*N; i++) {
                if (2*N-(i-2*mm)-1 <= i) break;
                if (a[i]+a[2*N-(i-2*mm)-1] < M) {
                    f = 1;
                    break;
                }
            }
            if (f) s = mm+1;
            else e = mm;
        }
        printVar(s);
        int ll = s;
        s = -1,e = N;
        while (s < e) {
            int mm = (s+e+1) / 2;
            int f = 0;
            for (i = 2*mm; i < 2*N; i++) {
                if (2*N-(i-2*mm)-1 <= i) break;
                if (a[i]+a[2*N-(i-2*mm)-1] > M+m) {
                    f = 1;
                    break;
                }
            }
            if (f) e = mm-1;
            else s = mm;
        }
        printVar(s);
        rr = min(rr,s);
        if (ll <= rr) r = m;
        else l = m+1;
    }
    printf("%d\n",l);

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////


int main() {
ll ans = 0;
	int N; cin >> N;
	ll A[N+2];  //h_i
	ll dp[N+2]; //たどり着くまでのコストの最小
	rep(i,N){cin >> A[i];}
	rep(i,N)
	{
		if(i == 0){dp[0] = 0; continue;}
		if(i == 1){dp[1] = abs(A[1] - A[0]); continue;}
		ll a1 = abs(A[i] - A[i-1]) + dp[i-1];
		ll a2 = abs(A[i] - A[i-2]) + dp[i-2];
		dp[i] = min(a1,a2);
	}
	ans = dp[N-1];

	cout << ans << endl;
}

Measured memory_bytes: 1792
import math

A, B, H, M = map(int,input().split())



kakudo = abs(H * 30 + M * 0.5 - M * 6)
if kakudo >= 180:
    kakudo = 360 - kakudo
AAA = A * A + B * B - 2 * A * B * math.cos(math.radians(kakudo))


C = math.sqrt(AAA)
print(C)

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

int colour[100][100];
int a[10000];

int main(){
  int H,W;
  cin >> H >> W;
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> a[i];
  }
  int dx=1;
  int x = 0 , y = 0;
  int cur_c = 0;
  while(1){
    if(a[cur_c]==0){
      cur_c++;
    }
    colour[y][x] = cur_c+1;
    a[cur_c]--;

    x += dx;
    if(x==W){
      x--;
      dx = -1;
      y++;
    }else if(x==-1){
      x++;
      dx = 1;
      y++;
    }
    if(y==H) break;
  }
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cout << colour[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	char s[300][600];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%s", &s[i]);
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			s[i][j+n]=s[i][j];
		}
	}
	int ans=0;
	for(int d=0; d<n; d++){
		int e=0;
		for(int i=0; i<n; i++){
			for(int j=d; j<i+d; j++){
				if(s[i][j]!=s[j-d][i+d]) e=1;
			}
		}
		if(e==0){
			ans=ans+n;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define Max 100005
#define mem(a,b) memset(a,b,sizeof(a));
#define pb push_back
#define mp make_pair
const LL mod=1e9+7;
const ULL base=131;
const LL LL_MAX=9223372036854775807;
using namespace std;
int a[2*Max],b[2*Max];
vector<int>ans;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=n;i>=1;i--){
        int sum=0;
        for(int j=i+i;j<=n;j+=i)
            sum+=b[j];
        if(sum%2!=a[i])
            b[i]=1,ans.push_back(i);
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%d ",ans[i]);
    printf("\n");
    return 0;
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

vector<vector<bool>> seen(22, vector<bool>(22, false));
vector<vector<int>> d(22, vector<int>(22, -1));
vector<vector<int>> d2(22, vector<int>(22, -1));

//スタートからゴールまでの距離を図るbfs

int bfs(int sx, int sy, int gx, int gy, int H, int W, vector<vector<char>> &maze) {
	d[sx][sy] = 0;
	queue<P> que;
	que.push(P(sx, sy));

	while (que.size()) {
		P p = que.front();
		que.pop();

		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			//迷路からはみ出すか,壁か,既に見ていたらスルー
			if (nx >= H || nx < 0 || ny >= W || ny < 0 || maze[nx][ny] == '#' || d[nx][ny] != -1) continue;

			//移動可能な場合
			que.push(P(nx, ny));
			d[nx][ny] = d[p.first][p.second] + 1;

		}

	}
	return d[gx][gy];
}

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> maze(H, vector<char>(W));

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> maze[i][j];
		}
	}
	vector<int> ans;
	for (int sx = 0; sx < H; sx++) {
		for (int sy = 0; sy < W; sy++) {
			for (int gx = 0; gx < H; gx++) {
				for (int gy = 0; gy < W; gy++) {
					if (maze[sx][sy] == '#' || maze[gx][gy] == '#') continue;
                  	ans.push_back(bfs(sx, sy, gx ,gy, H, W, maze));

					d = d2;
				}
			}
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());

	cout << ans[0] << endl;
}

Measured memory_bytes: 1404
import java.util.Scanner
import java.lang.Math.*

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n  = scn.nextInt()
	val hs = IntArray(n){scn.nextInt()}
	val arr = IntArray(n){-1}

	for (i in arr.indices){
		when(i){
			0 -> arr[0] = 0
			1 -> arr[1] = abs(hs[1] - hs[0])
			else -> arr[i] = min(arr[i-2]+abs(hs[i]-hs[i-2]), arr[i-1]+abs(hs[i]-hs[i-1]))
		}
	}
	println(arr.last())

}

Measured memory_bytes: 53780
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> cnt(n+1,0);
  for(Int i=0;i<m;i++){
    Int l,r;
    cin>>l>>r;
    l--;
    cnt[l]++;
    cnt[r]--;
  }
  for(Int i=0;i<n;i++) cnt[i+1]+=cnt[i];

  Int ans=0;
  for(Int i=0;i<n;i++)
    ans+=cnt[i]==m;
  cout<<ans<<endl;
  return 0;
}


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

void solve() {
    int N;
    cin >> N;
    ll a, b; 
    vector<ll> va, vs ;
    for (int i = 0; i < N; ++i) {
        cin >> a >> b;
        va.emplace_back(a + b) ;
        vs.emplace_back(a - b) ;
    }
    sort(va.begin(), va.end());
    sort(vs.begin(), vs.end());
    cout << max( va.back() - va[0], abs(vs.back() - vs[0])) << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 6692
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a =0;
    int flag = 0;
    for (int i = 0; i < N; i++) {
      a  = sc.nextInt();
      if(a%2 == 0){
        if(a%3== 0 || a%5== 0){
        }else{
          System.out.println("DENIED");
          return;
        }
        
      }
    }
    System.out.println("APPROVED");
  }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ld n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n>>m;

	res=(ll)(n*m);

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	int n;
	VI _array;
	string str;
	while ( ~scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d", &_array[ i ] );
			_array[ i ] %= 52;
		}
		cin >> str;
		for ( int i = 0; i < str.size(); i++ ) {
			for ( int j = 0; j < _array[ i % n ]; j++ ) {
				if ( str[ i ] - 1 < 'a' && ( str[ i ] < 'A' || str[ i ] > 'Z' ) ) {
					str[ i ] = 'Z';
				}
				else if ( str[ i ] - 1 < 'A' && ( str[ i ] < 'a' || str[ i ] > 'z' ) ) {
					str[ i ] = 'z';
				}
				else {
					str[ i ]--;
				}
			}
		}
		printf( "%s\n", str.c_str() );
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(3*n);
  for(int i=0;i<3*n;i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long ans=0;
  for(int i=1;i<2*n;i+=2) ans+=a.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 1408
//ABC150 D

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#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++)
const lint mod = 1000000007;


lint ans = 0;
lint N,M;
lint A[100000];


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

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

int cnt(lint x){
  int res = 0;
  while(x%2 == 0){
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  cin >> N >> M;
  
  lint hkbs = 1;
  rep(i,N){
    scanf("%lld",&A[i]);
    A[i] /= 2;
  }
  int tmp = cnt(A[0]);
  hkbs = lcm(hkbs,A[0]);
  reps(i,1,N){
    if(tmp != cnt(A[i])){
      cout << "0" << endl;
      return 0;
    }
    if(hkbs < A[i]){
      hkbs = lcm(A[i],hkbs);
    }
    else{
      hkbs = lcm(hkbs,A[i]);
    }
  }
  
//  tmp = hkbs;
//  while(tmp <= M){
//    tmp += hkbs*2;
//    ans++;
  //}
  ans = M/hkbs;
  ans = (ans+1)/2;

  printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{ int x,y,j,n,i;
  char a[1000][1000],b[1000];
   scanf("%d%d",&x,&y);
   for(i=0;i<x;i++)
   scanf("%s",&a[i]);
   for(i=0;i<y+2;i++)
   printf("#");
   printf("\n");
    for(i=0;i<x;i++)
    {printf("#");
	  printf("%s",a[i]);
	  printf("#");
	  printf("\n");
	 } 
   for(i=0;i<y+2;i++)
   printf("#");
   printf("\n");
	   return 0;
     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
//#define int long long

inline void solve(){
    
    ll n;
    cin >> n;
    cout << n * (n-1)/2 << endl;

}

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut map = std::collections::HashMap::new();

    for i in 0..n {
        let count = map.entry(s[i].to_string()).or_insert(0);
        *count += 1;
    }

    println!("AC x {}", map.get(&String::from("AC")).unwrap_or(&0));
    println!("WA x {}", map.get(&String::from("WA")).unwrap_or(&0));
    println!("TLE x {}", map.get(&String::from("TLE")).unwrap_or(&0));
    println!("RE x {}", map.get(&String::from("RE")).unwrap_or(&0));
}


Measured memory_bytes: 7752
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int a[4], b[4];

    signed call_of_Cthulhu( signed datum ) {

        b[0] = 1;
        b[1] = 4;
        b[2] = 7;
        b[3] = 9;
        for ( int i = 0; i < 4; i++ ) {
            read a[i];
        }
        bozo_sort(a,a+4);
        boolean flg = true;
        for ( int i = 0; i < 4; i++ ) {
            flg &= ( a[i] == b[i] );
        }
        echo (flg ? "YES" : "NO") fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int m, f, r;
    while (1){
        cin >> m >> f >> r;
        char ans;
        if (m == -1 && f == -1 && r == -1){
            break;
        }
        if ( m == -1 || f == -1) {
            ans = 'F';
        } else if (m+f >= 80){
            ans = 'A';
        } else if (m+f >= 65){
            ans = 'B';
        } else if (m+f >= 50){
            ans = 'C';
        } else if (m+f >= 30 && r >= 50){
            ans = 'C';
        } else if (m+f >= 30 && r < 50){
            ans = 'D';
        } else if (m+f < 30) {
            ans = 'F';
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
N,A,B = map(int,input().split())
X = [1<<20]*4040

for n in range(N):
  a,b,c = map(int,input().split())
  t = A*b-B*a
  X = [min(X[m],(0 if (m-t)%4040==0 else X[(m-t)%4040])+c) for m in range(4040)]

if 1<<18<X[0]:
  print(-1)
else:
  print(X[0])

Measured memory_bytes: 9280
w, h, n = map(int, input().split())
ws = hs = 0

li_point = list()
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        ws = x if x >= ws else ws
    elif a == 2:
        w = x if x <= w else w
    elif a == 3:
        hs = y if y >= hs else hs
    else: # a == r
        h = y if y <= h else h

yoko = w - ws if w - ws > 0 else 0
tate = h - hs if h - hs > 0 else 0

print(yoko * tate)



Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<stdlib.h>

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>

#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1e6+6;
const int mod=1e9+7;
ll a[maxn],b[maxn];

int main()
{
    cin.tie(0);std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    cout<<max(a[n]-a[1],b[n]-b[1])<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 6844
#include <stdio.h>
#include <stdlib.h>
#include <string.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()
{
	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: 20520
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

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

    int sum=0;
    int ma = 0;
    rep(i,N){
        int l ;
        cin >> l;

        sum +=l;
        ma = max(ma,l);

    }
    if(ma < sum-ma) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3580
#include <stdio.h>
int main() {
	char s[3];
        char t[3]; 
         int cnt;
	cnt = 0;

	scanf("%s", s);
	scanf("%s", t);

	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll h, w; cin >> h >> w;

    ll s1, s2, s3;
    ll s_abs;
    ll diff_min = 1e11;
    for(int i = 1; i < w; i++){
        s1 = h * i;
        s2 = h * ((w - i) / 2);
        s3 = h * ((w - i) - (w - i) / 2);
        diff_min = min(max({s1, s2, s3}) - min({s1, s2, s3}), diff_min);
    }
    for(int i = 1; i < h; i++){
        s1 = w * i;
        s2 = w * ((h - i) / 2);
        s3 = w * ((h - i) - (h - i) / 2);
        diff_min = min(max({s1, s2, s3}) - min({s1, s2, s3}), diff_min);
    }
    for(int i = 1; i < w; i++){
        s1 = h * i;
        s2 = h / 2 * (w - i);
        s3 = (h - h / 2) * (w - i);
        diff_min = min(max({s1, s2, s3}) - min({s1, s2, s3}), diff_min);
    }
    for(int i = 1; i < h; i++){
        s1 = w * i;
        s2 = w / 2 * (h - i);
        s3 = (w - w / 2) * (h - i);
        diff_min = min(max({s1, s2, s3}) - min({s1, s2, s3}), diff_min);
    }
    cout << diff_min << endl;
}

Measured memory_bytes: 256
N=int(input())
S=list(input())
s=1

if len(S)%2==1:
    print("No")

else:
    for i in range (len(S)//2):
        if S[i]!=S[i+len(S)//2]:
            print("No")
            s=0
            break
    if s==1:
        print("Yes")

Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
	long long int sho;
	long long int ans;
	long long int x;
	scanf("%lld", &x);
	
	if ((1 <= x) && (x <= 6))
		ans = 1;
	
	else if ((7 <= x) && (x <= 11))
		ans = 2;
	
	else
	{
		sho = x / 11;
		ans = 2 * sho;
		if (x % 11 != 0)
			ans++;
		if (7 <= (x % 11))
			ans++;
	}
	
	printf("%lld", ans);
	
	
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
	char s[4];
	scanf("%s",s);
	int i,c[27]={0};
	for(i=0;i<4;i++)c[s[i]-'A']++;
	for(i=0;i<27;i++){
		if(c[i]==2||c[i]==0);
		else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
<?php

    while(fscanf(STDIN,"%d %d",$tate,$yoko)) {
        if ($tate == 0 && $yoko == 0) {
            exit;
        }

        for($i = 1; $i <= $tate; $i++) {
            for ($j = 1; $j <= $yoko; $j++) {
                echo "#";
            }
            echo PHP_EOL;
        }
        echo PHP_EOL;
    }

?>



Measured memory_bytes: 9192
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
vector<int> x,y;
int main(){
    int N,M,X,Y;
    int Z;
    cin >> N >> M >> X >> Y;
    x.resize(N);
    y.resize(M);
    rep(i,0,N) cin >> x[i];
    rep(i,0,M) cin >> y[i];

    int x_max = *max_element(x.begin(),x.end());
    int y_min = *min_element(y.begin(),y.end());
    //cout << "max" << x_max << "min" << y_min << endl;
    if (x_max < y_min)
        Z = y_min;
    else
        Z = -101;
    while (x_max < Z)
    {
        if(X < Z && Z <= Y){
            //cout << X << " " << Y << " " << Z << endl;
            cout << "No War" << endl;
            return 0;
        }
        Z--;
    }
     cout << "War" << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	string s;
	cin>>s;

	if(s=="SUN")cout<<7<<endl;
	if(s=="MON")cout<<6<<endl;
	if(s=="TUE")cout<<5<<endl;
	if(s=="WED")cout<<4<<endl;
	if(s=="THU")cout<<3<<endl;
	if(s=="FRI")cout<<2<<endl;
	if(s=="SAT")cout<<1<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int n;
string s;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>s;
	
	int cnt=0;
	fore(a1,0,9){
		fore(a2,0,9){
			fore(a3,0,9){
				char c[3];
				c[0]='0'+a1;
				c[1]='0'+a2;
				c[2]='0'+a3;
				
				int ptr=0;
				forn(i,0,n){
					if(s[i]==c[ptr]){
						ptr++;
						if(ptr>=3) break;
					}
				}
				
				if(ptr>=3){
					cnt++;
				}
			}
		}
	}
	
	cout<<cnt<<'\n';
	
	return 0;
}


Measured memory_bytes: 384
/* ex9_2
   nabe9393 */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 100001
//キュー内の各データの定義
typedef struct node{
  int elem;
  struct node *next;
}node;

//データを追加
void push(node **first, char elem){
  //追加する分の領域を確保
  node *new = calloc(1, sizeof(node));
  if(new == NULL) exit(1);
  new->elem = elem;
  //追加
  new->next = *first;
  *first = new;
}
 
//スタックからデータを取り出す
char pop(node **first){
  char elem;
  node *tmp = *first;
  if(tmp == NULL) exit(1);
  elem = tmp->elem;
  *first = tmp->next;
  //取り出したノードのメモリを解放
  free(tmp);
}
 
 
int main(void){
  //最終的な答え
  int count=0, i;
  char cube[SIZE];
  //ノードの先頭
  node *first=NULL;
  scanf("%s",cube);

  for(i=0;i<strlen(cube);i++){
    if(first==NULL || cube[i]==first->elem){
      //スタックにノードを追加
      push(&first,cube[i]);
    }
    else{
      //一つの要素をスタックからデータを取り出す
      pop(&first);
      //カウントを2追加
      count=count+2;
    }
  }
  //答えの出力
  printf("%d\n",count);
  return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
const int MOD = 1000000007;

vector<bool> prime_sieve; //Á¥†Êï∞„Åã„Å©„ÅÜ„Åã
vector<ll> prime_numbers; //Á¥†Êï∞„ÅÆ„É™„Çπ„Éà
void init_prime(ll n){
  prime_sieve.resize(n+1, true);
  prime_sieve[0] = prime_sieve[1] = false;
  for(ll i = 2; i <= n; i++){
    if(prime_sieve[i] == true){
      if(i % 5 == 1) prime_numbers.push_back(i);
      for(ll j = 2; i * j <= n; j++){
	prime_sieve[i * j] = false;
      }
    }
  }
}

//Á¥†Êï∞„ÅãÂà§ÂÆö O(sqrt(N))
bool is_prime(ll N){
  if(N <= 1) return false;
  for(ll i = 2; i * i <= N; i++){
    if(N % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  init_prime(55555);
  int N; cin >> N;
  int res = 0;
  for(int i = 0; i < N; i++){
    if(i) cout << " ";
    cout << prime_numbers[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

int n, cnt;
int h[101];
int g[101];

bool func1() {

  rep(i, n) {
    if(g[i]!=h[i]) return false;
  }

  return true;
}

void func2(int x) {

  g[x] += 1;

  for(int j=x+1; j<n; ++j) {
    if(g[j]==h[j]) {
      return;
    }else {
      g[j] += 1;
    }
  }

  return;
}

int main() {

  cin >> n;
  rep(i, n) cin >> h[i];

  while(true) {

    if(func1()) break;

    rep(i, n) {
      if(g[i]!=h[i]) {
        ++cnt;
        func2(i);
        break;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    string s;
    cin>>s;
    while ((int)s.length()<15) s+='o';
    cout<<(count(s.begin(),s.end(),'o')>=8 ? "YES\n" : "NO\n");
    
    
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

string doublet(const vector<bool>& v)
{
    int n = v.size();
    for (int i = 0; i < n; i++)
    {
        if (v[i])
        {
            int j = i;
            while (j+1 < n && v[j+1]) j++;
            if (j-i+1 >= 3) return "Yes";
            i = j;
        }
    }
    return "No";
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<bool> v(n);
    for (int i = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
        v[i] = (a == b);
    }
    cout << doublet(v) << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int w;
	if (!n) { pc('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	while (w--) pc(buf[w]);
}

#define MAX_N 500002
#define INF   0x7f7f7f7f

int a[MAX_N];
int w[MAX_N/2+2];
int cnt;

void merge_sort(int low, int high) 
{ 
	int i, j, k, p, mid; 

	if (low < high) {
		mid = (low + high) >> 1;
		merge_sort(low,   mid);
		merge_sort(mid+1, high);

cnt += high-low+1;

		p = mid-low+1;
		memcpy(w, a+low, p << 2);
		i = mid+1, j = 0; k = low;

		w[p] = INF;
		while (i <= high) {
			if (w[j] <= a[i]) a[k++] = w[j++];
			else              a[k++] = a[i++];
		}
		memcpy(a+k, w+j, (p-j) << 2);
	}
}

int main()
{
	int n, i;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();

	cnt = 0;
	merge_sort(0, n-1);

	mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
	mypr(cnt); pc('\n');
	return 0;
}


Measured memory_bytes: 4636
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)   printf("Yes\n");
  else  printf("No\n");
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

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

    int n, cnt = 0;
    cin >> n;
    vector<int> p(n);

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

    for (int i = 1; i < n - 1; ++i){
        if (((p[i] > p[i-1]) && (p[i] < p[i+1])) ||
            ((p[i] < p[i-1]) && (p[i] > p[i+1]))) {
            ++cnt;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
s= gets.chomp.split("")
t= gets.chomp.split("")

min=t.length

(0..s.length-t.length).each do |p|
    cnt=0
    t.each_index {|i|
        cnt+=1 if t[i]!=s[p+i]
    }
    min = cnt if cnt < min
end

puts min


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int mod=1e9+7;
const int N=1e5+5;

int n;
int cache[N][3];
vector <int> g[N];

int dp(int k,int par,int c)
{
     int &ans=cache[k][c];
     if(ans!=-1)
          return ans;
     bool check=false;
     ans=1;
     for(auto &it:g[k])
     {
          if(it==par)
               continue;
          check=true;     
          int temp=dp(it,k,0);
          ans%=mod;
          if(c==0)
               temp+=dp(it,k,1);
          temp%=mod;
          ans*=temp;
          ans%=mod;
     }
     if(!check)
          return 1;
     return ans;
}

int32_t main()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
         int u,v;
         cin>>u>>v;
         g[u].pb(v);
         g[v].pb(u);
    }
    memset(cache,-1,sizeof cache);
    int ans=dp(1,0,1)+dp(1,0,0);
    ans%=mod;
    cout<<ans;
}

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

typedef long long int ll;

const int MAX = 110000;
const int MOD = 1000000007;

// facts[n]: n! % MOD, factInvs[n]: 1/(n!) % MOD, invs[n]: 1/n % MOD
ll facts[MAX], factInvs[MAX], invs[MAX];
void init() {
  facts[0] = facts[1] = 1;
  factInvs[0] = factInvs[1] = 1;
  invs[1] = 1;
  for (int i = 2; i < MAX; ++i) {
    facts[i] = facts[i-1] * i % MOD;
    invs[i] = MOD - invs[MOD % i] * (MOD / i) % MOD;
    factInvs[i] = factInvs[i-1] * invs[i] % MOD;
  }
}

// nCk % MOD
ll comb_mod(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return facts[n] * (factInvs[n - k] * factInvs[k] % MOD) % MOD;
}

/*
与えられた整数の素因数分解，素因数のvectorを返す．
e.g.) 60 -> <2,2,3,5>
*/
vector<ll> factor(ll n) {
  vector<ll> ret;

  ll p = 2;
  while(n > 1) {
    while(n % p == 0) {
      ret.push_back(p);
      n /= p;
    }
    p++;
  }
  return ret;
}

/*
与えられた素因数vectorの各要素の次数を要素とするvectorを返す．
e.g) factor(60) -> <2,1,1>
*/
vector<ll> factor_count(vector<ll> fs) {
  vector<ll> ret;

  ll i = 0;
  ll count = 1;
  while(i < fs.size()) {
    if ( (i + 1 < fs.size()) && fs[i] == fs[i+1]) {
      count++;
    } else {
      ret.push_back(count);
      count = 1;
    }
    i++;
  }

  return ret;
}

ll solver(ll N, ll M) {
  ll ret = 1;
  vector<ll> fs = factor(M);
  vector<ll> exps = factor_count(fs);

  for (ll i=0; i< exps.size(); ++i) {
    ret *= comb_mod(exps[i] + N - 1, exps[i]);
    ret %= MOD;
  }

  return ret;
}

int main() {
  ll N,M;
  cin >> N >> M;

  init();
  ll ret = solver(N,M);
  cout << ret;

  return 0;
}

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

#define abs(N) ((N>0)?N:-1*N)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(int argc, char const *argv[])
{
  int N,M;
  cin >> N >> M;
  unsigned long long res=0;

  long long x[N],y[N],z[N];

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

  for (int xi = -1; xi <= 1; xi+=2)
  {
    for (int yi = -1; yi <= 1; yi+=2)
    {
      for (int zi = -1; zi <= 1; zi+=2)
      {
        long long m[N];
        for (int i = 0; i < N; ++i)
        {
          m[i] = x[i]*xi + y[i]*yi + z[i]*zi;
        }
        sort(m,m+N,greater<long long>());
        long long sum = 0;
        for (int i = 0; i < N; ++i)
        {
          // print(m[i]);
          // print(",");
        }
        // println("");
        for (int i = 0; i < M; ++i)
        {
          sum += m[i];
        }
        if(abs(sum) > res) res = abs(sum);
      }
    }
  }

  println(res);
  return 0;
}


Measured memory_bytes: 256
def lcm(a, b):
    return a * b // gcd(a, b)
    
    
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a%b)

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    base = 2
    while A[0] % (base*2) == 0:
        base *= 2
    minimum = 1
    for a in A:
        if a % base != 0 or (a // base) % 2 == 0:
            print(0)
            return
        minimum = lcm(minimum, a//base)
        if minimum > M:
            print(0)
            return
    minimum *= base // 2
    ans = (M // minimum + 1) // 2
    print(ans)
        

if __name__ == '__main__':
    main()

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

std::vector<int> v(3);

int main()
{
    int sum=0;
    for (int i=0; i<3; i++) {
        cin>>v.at(i);
        sum+=v.at(i);
    }
    if (sum>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T = [[]for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        t = list(map(int,input().split()))
        T[i].append(t)
S = []
for i in range(2**N):
    f = 1
    for j in range(N):
        for k in range(len(T[j])):
            x = T[j][k][0]-1
            y = T[j][k][1]
            if (i>>j)&1:
                if ((i>>x)&1)^y:
                    f = 0
    if f == 1:
        S.append(i)
n = len(S)
m = 0
for i in range(n):
    s = S[i]
    a = 0
    for j in range(N):
        if (s>>j)&1:
            a += 1
    m = max(a,m)
print(m)

Measured memory_bytes: 42876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int n, m; cin >> n >> m;
  if(abs(n-m)>1){ cout << 0; return 0; }
  ll ans=1;
  if((n+m)%2==0){ ans *= 2; ans %= MOD; }
  while(n){ ans *= n; ans %= MOD; n--; }
  while(m){ ans *= m; ans %= MOD; m--; }
  
  cout << ans;
  
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a ;
  int64_t b ;
  int64_t c ;
  cin >> a >> b >> c ;
  if ( a ==0 )
    cout << b/c+1 << endl;
if ( a!=0) 
  cout << b/c - (a-1)/c << endl;
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n,w; cin>>n>>w;
    vector<ll> weight(n);
    vector<ll> value(n);
    rep(i,n){
        cin>>weight[i]>>value[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(w+1, 0));
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            chmax(dp[i+1][j],dp[i][j]);
            if(j-weight[i]>=0) chmax(dp[i+1][j],dp[i][j-weight[i]] + value[i]); 
        }
    }

    cout<<dp[n][w]<<endl;
    
}

Measured memory_bytes: 80256
#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();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#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 SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#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,K; cin >> A >> B >> C >> K;
    cout << A+B+C-max(max(A,B),C)+max(max(A,B),C)*pow(2,K) << endl;
    return 0;
}

Measured memory_bytes: 512