akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int n, a, b;
    cin >> n >> a >> b;
    modint ans = modint(2).pow(n) - 1;
    modint x = 1;
    for(int i = 0; i < a; ++i){
        x *= (n - i);
        x /= i + 1;
    }
    ans -= x;
    x = 1;
    for(int i = 0; i < b; ++i){
        x *= (n - i);
        x /= i + 1;
    }
    ans -= x;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 200000 + 9;
int n,m,a[N],b[N],val[N*20];
set<int>s;
void up(int s,int e,int p,int id,int v)
{
    if(s==e)
    {
        val[p]=v;
        return;
    }
    int mid=(s+e)/2;
    if(id<=mid)up(s,mid,p*2,id,v);
    else up(mid+1,e,p*2+1,id,v);

    val[p]=min(val[p*2],val[p*2+1]);
}


int get(int s,int e,int p,int id)
{
    if(s==e)return val[p];

    int mid=(s+e)/2;
    if(id<=mid)return get(s,mid,p*2,id);
    else return get(mid+1,e,p*2+1,id);

}
 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n>>m;
        forr(i,1,n)cin>>a[i]>>b[i];


        forr(i,1,m)
        {
            if(i>=a[1]&&i<=b[1])up(1,m,1,i,1e9);
            else up(1,m,1,i,0),s.insert(i);
        }
        if(val[1]==1e9)cout<<-1<<endl;
        else cout<<1<<endl;
        forr(i,2,n)
        {
            auto it = s.lower_bound(a[i]);
            int mn = 1e9;
            vector<int>v;
            for(;;it++)
            {
                if( it==s.end() || *it>b[i])break;
                v.push_back(*it);
                int x = get(1,m,1,*it);
                if(x+b[i]+1-*it < mn)
                {
                    mn = x+b[i]+1-*it;
                }
                up(1,m,1,*it,1e9);
            }
            for(auto e:v)s.erase(e);

            if(mn<1e9&&b[i]+1<=m&&get(1,m,1,b[i]+1)>mn)up(1,m,1,b[i]+1,mn),s.insert(b[i]+1);

            if(val[1]>=1e9)cout<<-1<<endl;
            else cout<<val[1]+i<<endl;

        }






return 0;
}


Measured memory_bytes: 16584
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1<<28)
inline void cmax(int &a, int b) { if (a < b) a = b; }

int n, m, S, f[32][32], _sum[40][40];

inline int sum(int x1, int y1, int x2, int y2) {
    return _sum[x2+1][y2+1]-_sum[x2+1][y1]-_sum[x1][y2+1]+_sum[x1][y1];
}

int dp[32][32][32][32];

int solve(int lb) {
    for (int w = 0; w < n; w++) rep (x1, n-w) {
        const int x2 = x1+w;
        for (int h = 0; h < m; h++) rep (y1, m-h) {
            const int y2 = y1+h;
            if (sum(x1, y1, x2, y2) < lb) {
                dp[x1][x2][y1][y2] = -INF;
                continue;
            }
            dp[x1][x2][y1][y2] = 1;
            for (int i = x1; i < x2; i++) {
                cmax(dp[x1][x2][y1][y2], dp[x1][i][y1][y2]+dp[i+1][x2][y1][y2]);
            }
            for (int i = y1; i < y2; i++) {
                cmax(dp[x1][x2][y1][y2], dp[x1][x2][y1][i]+dp[x1][x2][i+1][y2]);
            }
        }
    }
    return dp[0][n-1][0][m-1];
}

int main() {
    for (;;) {
        scanf("%d%d%d", &n, &m, &S);
        if (n == 0) return 0;
        rep (i, n) rep (j, m) scanf("%d", f[i]+j);
        rep (i, n) rep (j, m) {
            _sum[i+1][j+1] = f[i][j]+_sum[i+1][j]+_sum[i][j+1]-_sum[i][j];
        }
        const int tot = sum(0, 0, n-1, m-1);
        const int ans = solve(tot-S);
        int l = 0, r = min(S+1, 120*32);
        while (r-l>1) {
            const int mid = (l+r) / 2;
            if (solve(tot-S+mid) >= ans) l = mid;
            else r = mid;
        }
        printf("%d %d\n", ans, l);
    }
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define ll long long
#define vrednost first
#define tezina second

using namespace std;

int n,w;
ll vmax=100009;
pair<ll,ll> predmeti[110];
ll dp[100010][110];

int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	cin>>n>>w;
	ll t,v;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>v;
		predmeti[i]=make_pair(v,t);
	}
	
	for(int j=0;j<=n;j++)
		for(int i=1;i<=vmax;i++)
			dp[i][j]=2*w;
			
	for(int i=0;i<n;i++)
		dp[predmeti[i].vrednost][i]=predmeti[i].tezina;
	
	
	sort(predmeti,predmeti+n);
	for(int j=1;j<=n;j++)
		for(int i=1;i<=vmax;i++)
			if(predmeti[j].vrednost<=i)
				dp[i][j]=min(dp[i][j-1],dp[i-predmeti[j].vrednost][j-1]+predmeti[j].tezina);
			else
				dp[i][j]=dp[i][j-1];
	//cout<<dp[w][n];
	for(int i=vmax;i>0;i--)
		if(dp[i][n]<=w)
		{
			cout<<i;
			return 0;
		}
	cout<<0;
	
	return 0;
}


Measured memory_bytes: 86272
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for a in A:
  if sum([a[i] * B[i] for i in range(M)]) + C > 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
using System;
class Program
{
  static void Main(string[] args)
  {
    var n=Read(4);
    var x=Read(n[0]);
    var y=Read(n[1]);
    if(max(max(x),n[2])<min(min(y),n[3])){
      Write("No War");
    }else{
      Write("War");
    }
  }

  static void Write(string s) { Console.WriteLine(s); return; }
  static void Write(long n) { Console.WriteLine(n.ToString()); return; }
  static string ReadStr() { return Console.ReadLine(); }
  static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
  static long Read() { return long.Parse(Console.ReadLine()); }
  static long[] Read(long n) {
    long[] p = new long[n];
    string[] t = Console.ReadLine().Split(' ');
    for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
    return p;
  }
  static long abs(long n) { return (n > 0) ? n : -n; }
  static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
  static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
  static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
  static long lcm(long a, long b) { return a * b / gcd(a, b); }
  static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
  static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
  static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
  static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
  static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
  static string clip(string s, int start, int count) {
    if (start + count < s.Length) { s = s.Remove(start + count); }
    if (start > 0) { s = s.Remove(0, start); }
    return s;
  }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#define F first
#define S second
#define PII pair<pair<long long, long long>, long long>

using namespace std;

const long long MX = 1e18;
const int N = 200;
long long n, m, d[N], a, b, c, di[N][N];
PII p[10000];

int main() {
  cin >> n >> m;
  fill(d, d + n, MX);
  for(int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      di[i][j] = MX;
  }
  for (int i = 0; i < N; i++)
    di[i][i] = 0;
  d[0] = 0;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (a == b && c < 0)
      return cout << "NEGATIVE CYCLE", 0;
    di[a][b] = min(di[a][b], c);
    p[i].F.F = a;
    p[i].F.S = b;
    p[i].S = c;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if(d[p[j].F.S] > d[p[j].F.F] + p[j].S && d[p[j].F.F] != MX)
        d[p[j].F.S] = d[p[j].F.F] + p[j].S;
    }
  }
  for (int i = 0; i < m; i++) {
    if(d[p[i].F.S] > d[p[i].F.F] + p[i].S && d[p[i].F.F] != MX)
      return cout << "NEGATIVE CYCLE" << '\n', 0;
  }
  for (int k = 0; k < n; k++) {
    for (int v = 0; v < n; v++) {
      for (int u = 0; u < n; u++) {
        if (di[v][u] > di[v][k] + di[k][u] && di[v][k] != MX && di[k][u] != MX)
          di[v][u] = di[v][k] + di[k][u];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0;  j < n; j++) {
      di[i][j] == MX ? cout << "INF" : cout << di[i][j];
      if (j != n - 1)
        cout << ' ';
    }
    cout << '\n';
  }
}



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li sum=0;

    li b[n-1];

    f(i,0,n-2)
    {
        cin>>b[i];
    }

    sum+=2*b[n-2];

    fr(i,n-3,0)
    {
        if(b[i]<=b[i+1])
        {
            sum-=b[i+1];
            sum+=2*b[i];
        }
        else
        {
            sum+=b[i];
        }
    }

    cout<<sum;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve( int(*pmap)[9],int col,int row ) {
	pmap[row][col] = 0;

	for (int i = 1; i < 4; i++) {
		//left
		if (col - i > 0 && pmap[row][col - i] == 1) {
			solve(pmap, col-i, row);
		}
	    //right
		if (col + i < 9 && pmap[row][col + i] == 1) {
			solve(pmap, col+i, row);
		}
		//up
		if (row - i > 0 && pmap[row-i][col] == 1) {
			solve(pmap, col, row-i);
		}
	    //down
		if (row + i > 0 && pmap[row + i][col] == 1) {
			solve(pmap, col, row+i);
		}
	}
}

int main(void) {
	int n, round, i, j, x, y;
	int map[9][9];
	string str;

	cin >> n;
	for (round = 0; round < n; round++) {
		for (i = 1; i < 9; i++) {
			cin >> str;
			for (j = 0; j < 8; j++) {
				map[i][j + 1] = str[j] - '0';
			}
			str.clear();
		}
		cin >> x >> y;
        
		solve(map,x,y);

		cout << "Data " << round + 1 << ":" << endl;
		for (i = 1; i < 9; i++) {
			for (j = 1; j < 9; j++) {
				cout << map[i][j];
			}
			cout << endl;
		}

	}


	return 0;
}




Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
queue<int>qx,qy,qxi;
const int MAXN=105;
bool vis[5][MAXN]; 
int a[5][MAXN],n;
int xx[2]={1,0};
int yy[2]={0,1},ans;
int main()
{
	cin>>n;
	for(int i=1 ; i<=2 ; i++)
	{
		for(int j=1 ; j<=n ; j++)
		{
			cin>>a[i][j];
		}
	}
	qx.push(1);
	qy.push(1);
	qxi.push(a[1][1]);
	while(!qx.empty())
	{
		for(int i=0 ; i<2 ; i++)
		{
			int dx=qx.front()+xx[i];
			int dy=qy.front()+yy[i];
			if(dx>=1&&dx<=2&&dy>=1&&dy<=n)
			{
				qx.push(dx);
				qy.push(dy);
				qxi.push(a[dx][dy]+qxi.front());
			}
		}
		qx.pop();
		qy.pop();
		qxi.pop();
		ans=max(ans,qxi.front());
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

	    int N=gi();
        int[] A=new int[100001];
        

	    for(int i=0; i<N; i++) {
	        int ind=gi();
	    	A[ind]++;;
	    }
	    
        int max=0;
	    for (int i=0; i<100001;i++) {
	    	int v=A[i];
	    	if(i+1<N)v+=A[i+1];
	    	if(i+2<N)v+=A[i+2];
	    	if(v>max)max=v;
	    }

		System.out.println(max);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 58744
#include <cstdio>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a + b > c + d){
        printf("Left\n");
    }else if(a + b < c + d){
        printf("Right\n");
    }else{
        printf("Balanced\n");
    }

    return 0;
}

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

struct RollingHash {
  typedef unsigned long long ull;
  string S;
  ull B;
  int len;
  vector<ull> hash, p;
  RollingHash() {}
  RollingHash(string S_, ull B_ = 1000000007LL):
    S(S_), B(B_), len(S.length()), hash(len+1), p(len+1) {
    hash[0] = 0; p[0] = 1;
    for ( int i = 0; i < len; i++ ) {
      hash[i+1] = hash[i]*B+S[i];
      p[i+1] = p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l, int r){
    return hash[r]-hash[l]*p[r-l];
  }
};

int main() {
  string T, P;
  cin >> T >> P;

  int t = T.size();
  int p = P.size();  
  /*for ( int i = 0; i <= t-p; i++ ) {
    if ( P == T.substr(i, p) ) cout << i << endl;
    }*/

  RollingHash rht(T), rhp(P);  
  for ( int i = 0; i <= t-p; i++ ) {
    if ( rht.find(i, i+p) == rhp.find(0, p) ) cout << i << endl;    
  }
  
  return 0;
}



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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld k;
    cin>>k;
    ld l=k/3.0;
    cout<<setprecision(20)<<l*l*l<<endl;
}


Measured memory_bytes: 256
N = input()
if N == "SUN":
    print(7)
elif N == "MON":
    print(6)
elif N == "TUE":
    print(5)
elif N == "WED":
    print(4)
elif N == "THU":
    print(3)
elif N == "FRI":
    print(2)
elif N == "SAT":
    print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vector<int> r(m*2),s(n);
	for (int i=0; m*2>i; i++){
		cin>>r.at(i);
		s.at(r.at(i)-1) ++;
	}
	for (int j=0; n>j; j++){
		cout<<s.at(j)<<endl;
	}
}

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

int main()
{
	for( int i = 1 ; i <= 9 ; i ++ )
	{
		for( int j = 1 ; j <= 9 ; j ++ )
		{
			cout << i << "x" << j << "=" << (i*j) << "\n" ;
		}
	}

	return 0 ;
}

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

int main(){
    int n,k,s=0;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    sort(a.begin(),a.end());
    
    for(int i=0; i<k; i++){
        s+=a.at(i);
    }
        cout << s << endl;
}

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

struct _card{
    char t;
    int v;

    int i; //index
};
typedef struct _card card;


void swap( card *a, card *b ){

    char t = a->t;
    int v = a->v;
    int i = a->i;

    a->t = b->t;
    a->v = b->v;
    a->i = b->i;

    b->t = t;
    b->v = v;
    b->i = i;
}

int partition( card *a, int p, int r ){

    int i, j;
    int x;

    x = a[r].v;
    i = p-1;


    for( j=p; j<r; j++ ){

        if( a[j].v <= x ){
            i++;
            swap( &a[i], &a[j] );
        }
    }
    i++;
    swap( &a[i], &a[r] );


    return i;

}

void quicksort( card *a, int p, int r ){

    int q;

    if( p<r ){
        q = partition( a, p, r );
        quicksort( a, p, q-1 );
        quicksort( a, q+1, r );
    }
}



int main(){

    int n, i;
    int f = 0;
    card *c;

    scanf( "%d\n", &n );

    c = (card*)malloc(sizeof(card)*n);

    for( i=0; i<n; i++ ){
        c[i].i = i;
        scanf( "%c %d\n", &c[i].t, &c[i].v );
    }

    quicksort( c, 0, n-1);

    for( i=0; i<(n-1); i++ ){
        if( c[i].v == c[i+1].v && c[i].i > c[i+1].i){
            f++;
        }
    }
    if( f == 0 ) printf( "Stable\n" );
    else printf( "Not stable\n" );


    for( i=0; i<n; i++ ){
        printf( "%c %d\n", c[i].t, c[i].v );
    }
    
    free(c);

    return 0;
}



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

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

  int k = 0;

  for(int i = 0; i < n; i ++){
    int a;
    cin >> a;

    int j;
    j = 0;

    while(a % 2 == 0){
      a /= 2;
      //cout << a <<" ";
      j ++;
    }
    //cout << ":" << j << endl;
    if(i == 0){
      k = j;
    }
    if(k > j){
      k = j;
    }
    //cout << k << endl;
  }
  cout << k << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

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

	double a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 1; i < n; i++) {
		a[i] = (a[i-1] + a[i])/2;
	};
	cout << a[n-1];
	return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int res=0, flag=0;
    char ch;
    if((ch=getchar())=='-') flag=1;
    else if(ch>='0'&&ch<='9') res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
    return flag?-res:res;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

int dis[N];

int main ()
{
    int n;
    LL A, B, ans=0;
    scanf("%d%lld%lld",&n,&A,&B);
    FOR(i,1,n) scanf("%d",dis+i);
    FOR(i,2,n) ans+=min((dis[i]-dis[i-1])*A,B);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

enum City
{
	City_A = 0,
	City_B,
	City_W,
	City_X,
	City_Y,
	City_Z
};

class Node
{
public:
	Node(City c) : city(c)
	{
		pNext[0] = pNext[1] = NULL;
	}
	
	~Node(){}

	void setNode(Node* n, int no)
	{
		pNext[no] = n;
	}
	
	Node* getNextNode(int no)
	{
		return pNext[no];
	}
	
	City getCity()
	{
		return city;
	}
	
private:
	City  city;
	Node* pNext[2];
};

int main()
{
	Node a(City_A);
	Node b(City_B);
	Node w(City_W);
	Node x(City_X);
	Node y(City_Y);
	Node z(City_Z);

	a.setNode(&x, 0);
	a.setNode(&y, 1);
	b.setNode(&y, 0);
	b.setNode(&x, 1);
	w.setNode(&b, 0);
	w.setNode(&y, 1);
	x.setNode(NULL, 0);
	x.setNode(&z, 1);
	y.setNode(&x, 0);
	y.setNode(NULL, 1);
	z.setNode(&w, 0);
	z.setNode(&b, 1);

	string p;
	while(1)
	{
		cin >> p;
		if(p == "#")
		{
			break;
		}

		Node* pCurrent = &a;

		for(int i = 0; i < p.length(); ++i)
		{
//			cout << "i=" << i << ", p[i]=" << p[i] << ", city=" << pCurrent->getCity() << endl;

			if(p[i] == '0')
			{
				pCurrent = pCurrent->getNextNode(0);
			}
			else
			{
				pCurrent = pCurrent->getNextNode(1);
			}
			
			if(pCurrent == NULL)
			{
				break;
			}
		}
		
		if(pCurrent != NULL && pCurrent->getCity() == City_B)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2*n - 1)
    {
        cout << "No" << endl;
        return 0;
    }
    if(n==2)
    {
        cout << "Yes" << endl;
        cout << 1 << "\n" << 2 << "\n" << 3 << "\n";
        return 0;
    }
    if(x == 2)
    {
        cout << "Yes" << endl;
        int counter = 5;
        for(int i=0; i<n-2; i++)
        {
            cout << counter << endl;
            counter++;
        }
        cout << "3\n2\n1\n4\n";
        for(int i=0; i<n-3; i++)
        {
            cout << counter << endl;
            counter++;
        }
    }
    else
    {
        cout << "Yes" << endl;
        int counter = 1;
        if(counter == x-2)
        {
            counter = x+2;
        }
        for(int i=0; i<n-2; i++)
        {
            cout << counter << endl;
            counter++;
            if(counter == x-2)
            {
                counter = x+2;
            }
        }
        cout << (x-1)<< "\n"<< (x) << "\n" << (x+1) << "\n"<< (x-2)<< "\n";
        for(int i=0; i<n-3; i++)
        {
            cout << counter << endl;
            counter++;
            if(counter == x-2)
            {
                counter = x+2;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long a = ni();
        long b = ni();
        long c = ni();
        if(a%2==0 || b%2==0||c%2==0){
            out.println(0);
        }else{
            long ans = Math.min(Math.min(a*b, b*c),c*a);
            out.println(ans);
        }
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33128
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int x[5];
int main(){
    cin >> x[0]>> x[1]>> x[2]>>x[3]>>x[4];
    rep(i,5){
        if(x[i]==0){
            cout<<i+1;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

// 区間の更新と区間の最小値を返す O(Nlog(N)) で返す
// 最大値が欲しい場合は compare メソッド と INF を変更する
template <typename T>
class SegmentTree {
  using Fx = function<T(T, T)>;
  Fx fx;
  const T ex;
  int n;             // 最下段のノード数
  vector<T> node;

 public:
  SegmentTree(const vector<T>& v, Fx f, T e) : fx(f), ex(e) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;      // N: 最下段の横幅
    node.resize(2 * n - 1, e);  // e で初期化

    // 最下段に値を挿入
    rep(i, sz) node[(n - 1) + i] = v[i];

    // 最下段以外を更新していく
    for (int i = n - 2; i >= 0; i--) {
      node[i] = fx(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  void update(int i, T x) {
    i += n - 1;  // i 番目の葉のノード番号
    node[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;  // ノード i の親ノードの番号に変える
      node[i] = fx(node[i * 2 + 1], node[i * 2 + 2]);  // 左右の子の min を計算し直す
    }
  }

  // [a, b) の区間に対するクエリについてノード k (区間 [l, r) 相当) が答える
  // 注意 [a, b) は半区間なので 区間 [m, n] の最小値を求めたい場合は find(m, n+1) とする
  T find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;

    if (r <= a || b <= l) return ex;  // 区間がかぶらない場合は ex を返す
    if (a <= l && r <= b) {
      return node[k];  // ノード k の担当範囲がクエリ区間 [a, b) に完全に含まれる
    } else {
      int c1 = find(a, b, 2 * k + 1, l, (l + r) / 2);  // 左の子に値を聞く
      int c2 = find(a, b, 2 * k + 2, (l + r) / 2, r);  // 右の子に値を聞く
      return fx(c1, c2);
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<int> v(n, int((1LL<<31)-1));
  auto f = [](int x1, int x2) -> int {return min(x1, x2);};
  SegmentTree<int> seg(v, f, (1LL<<31)-1);

  rep(i, q) {
    int cmd; cin >> cmd;
    if (cmd == 0) {
      int x, y; cin >> x >> y;
      seg.update(x, y);
    } else {
      int x, y; cin >> x >> y;
      cout << seg.find(x, y+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4120
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]

price = sum(c)
l =0

for i in range(2**n):
    kari = 0
    skill = [0]*m
    for j in range(n):
        if (i>>j) & 1:
            skill = [x + y for(x,y) in zip(skill,a[j]) ]
            kari += c[j]
    if all([z >= x for z in skill]):
        price = min(price, kari)
        l += 1

if l == 0:
    print(-1)
else:
    print(price)

Measured memory_bytes: 9244
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int day = Integer.parseInt(sc.nextLine());
      //since 9/9/17 is Saturday, 9/1/17 is Friday
      switch(day % 7) {
         case 1:
            System.out.println("fri");
            break;
         case 2:
            System.out.println("sat");
            break;
         case 3:
            System.out.println("sun");
            break;
         case 4:
            System.out.println("mon");
            break;
         case 5:
            System.out.println("tue");
            break;
         case 6:
            System.out.println("wed");
            break;
         case 0:
            System.out.println("thu");
            break;
      }
   }
}


Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N; cin >> N;
    vector<ll> a(N); vector<ll> b(N);
    vector<ll> gap(N);
    ll tarinai=0;
    ll ans=0;
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        cin >> b[i];
        gap[i]=a[i]-b[i];
        if(gap[i]<0) {tarinai-=gap[i]; ans++;}
    }
    sort(gap.begin(), gap.end());
    reverse(gap.begin(), gap.end());
    int idx=0;
    while(tarinai>0){
        if(gap[idx]<=0) {ans=-1; break;}
        tarinai -= gap[idx];
        ans++; idx++;
    }
    cout << ans << endl;    
}



Measured memory_bytes: 2560
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    ans = inf
    for i in range(1,int(sqrt(N)+1)):
        if N%i==0:
            ans = i+N//i-2

    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 64364
# frozen_string_literal: true

n, k = gets.split.map(&:to_i)
heights = n.times.map { gets.to_i }.sort

min_diff = Float::INFINITY

heights.each_with_index {|min, i|
  max = heights[k + i -1]
  break unless max

  diff = max - min
  min_diff = diff if diff < min_diff
}

puts min_diff


Measured memory_bytes: 4528
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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()
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k;

  return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>
int main()
{
	char a[100][101];
	int h,w,i,j;
	while(scanf("%d%d",&h,&w), h)
	{
		for(i = 0; i < h; ++i)
			scanf("%s", a[i]);
		i = j = 0;
		bool isPlaced[100][100] = {false};
		while(a[i][j] != '.')
		{
			if(isPlaced[i][j])
			{
				printf("LOOP\n");
				goto NEXT;
			}
			isPlaced[i][j] = true;
			switch(a[i][j])
			{
			case '>': ++j; break;
			case '<': --j; break;
			case '^': --i; break;
			case 'v': ++i; break;
			}
		}
		printf("%d %d\n", j, i);
NEXT:
		;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main{
 
	public static void main(String[] args){
      
      Scanner scanner = new Scanner(System.in);
      
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      
      int result = a * b;
      
      if(result % 2 ==0 ){ System.out.println("Even");}
      else{System.out.println("Odd");}
  
 }
}

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

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

  vector<bool> row(h, false), col(w, false);
  string s[h];

  for (int i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        row[i] = col[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (!row[i]) continue;
    for (int j = 0; j < w; j++) {
      if (!col[j]) continue;
      cout << s[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    string S;
    bool strong = true ;
    cin >> S;
    string T = S ;
    reverse(T.begin(), T.end());
    string subs1 = S.substr(0, (S.size()-1)/2) ;
    string subs2 = S.substr((S.size()+3)/2 -1 , S.size());
    string revsub1  = subs1;
    string revsub2  = subs2;
    reverse(revsub1.begin(), revsub1.end());
    reverse(revsub2.begin(), revsub2.end());
    if ( S != T) {
        strong = false;
    }
    if ( subs1 != revsub1) {
        strong = false;
    }
    if ( subs2 != revsub2) {
        strong = false;
    }
    if (strong){
        cout << "Yes" << endl;
    }
    else { 
        cout << "No" << endl;
    }



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
	int n, m;
	cin >> n >> m;
	ll a, c;
	int b;
	set<ll> s;
	map<ll, int> M;
	FOR(i, n) {
		cin >> a;
		s.insert(a);
		M[a]++;
	}
	FOR(i, m) {
		cin >> b >> c;
		int j = b;
		while(j>0) {
			if (c <= *s.begin())break;
			if (M[*s.begin()] <= j) {
				s.insert(c);
				M[c] += M[*s.begin()];
				j -= M[*s.begin()];
				M[*s.begin()] = 0;
				s.erase(s.begin());
			}
			else {
				s.insert(c);
				M[c] += j;
				M[*s.begin()] -= j;
				break;
			}
		}
	}
	ll ans = 0;
	auto itr = s.begin();
	FOR(i, s.size()) {
		ans += *itr * M[*itr];
		itr++;
	}
	cout << ans << endl;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N%2 == 1) cout << "No" << endl;
    else {
        for (int i=0;i<N/2;i++){
            if (S[i] != S[i+N/2]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}

// Notes: https://searleser97.gitlab.io/competitive-programming-notes/AtCoder/dp_p.png

void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> adj(n);
  auto addEdge = [&](int u, int v) { adj[u].pb(v); };
  rep(n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    addEdge(u, v);
    addEdge(v, u);
  }
  const int mod = 1e9 + 7;
  function<pairii(int, int)> f = [&](int u, int p) -> pairii {
    int ifwhitecnt = 1, ifblackcnt = 1;
    for (int v : adj[u]) {
      if (v == p) continue;
      auto ans = f(v, u);
      ifwhitecnt = ((li)ifwhitecnt * ((ans.fi + ans.se) % mod)) % mod;
      ifblackcnt = ((li)ifblackcnt * ans.fi) % mod;
    }
    return {ifwhitecnt, ifblackcnt};
  };
  auto ans = f(0, 0);
  cout << ((ans.fi + ans.se) % mod) << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 16844
import sys
#import bisect
#from collections import deque
import math

def input():
    return sys.stdin.readline().rstrip('\n')


a,b,x = list(map(int, input().split()))

if a*a*b/2 > x:
    adash = x / a / b * 2
    # tan(theta) = adash / b
    theta = math.atan(adash/b)
    # convert radian to degree  (2 * pi radian = 360 degree)
    theta_degree = theta * 180 / math.pi
    print(90-theta_degree)
else:
    adash = ((a*a*b)-x) / a / a * 2
    # tan(theta) = adash / a
    theta = math.atan(adash/a)
    # convert radian to degree  (2 * pi radian = 360 degree)
    theta_degree = theta * 180 / math.pi
    print(theta_degree)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, M = MI()
    S, C = [], []
    for i in range(M):
        s, c = MI()
        S.append(s - 1)
        C.append(c)

    ans = [-1] * N

    for i in range(M):
        if ans[S[i]] != -1 and ans[S[i]] != C[i]:
            print(-1)
            exit()

        ans[S[i]] = C[i]

    if ans[0] == 0:
        if N != 1:
            print(-1)
            exit()
        else:
            print(0)
            exit()

    if N == 1 and ans[0] == -1:
        print(0)
        exit()

    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0 if i != 0 else 1
        ans[i] = str(ans[i])

    print("".join(ans))


main()


Measured memory_bytes: 65092
A, B, C, D = map(int, input().split())
N = C//B
M = A//D
n = C % B
m = A % D
 
if N < M:
  print('Yes')
elif N == M:
  if n == 0:
    print('Yes')
  elif m == 0:
    print('No')
  else:
    print('Yes')
elif N == M + 1:
  if n == 0:
    print('Yes')
  else:
    print('No')
elif N > M + 1:
  print('No')

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,ans[200005];
vector <pii> daftar;
int main()
{
	scan(n);
	for(int i=0;i<n;i++)
	{
		int input;
		scan(input);
		daftar.eb(input,i);
	}
	sort(all(daftar));
	for(int i=0;i<n/2;i++)
		ans[daftar[i].se]=daftar[n/2].fi;
	for(int i=n/2;i<n;i++)
		ans[daftar[i].se]=daftar[n/2-1].fi;
	for(int i=0;i<n;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 4720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dist(ll x,ll y){
    return abs(x)+abs(y);
}

int main(){
    string s="RLUD";
    int n;cin>>n;
    ll x[n],y[n];
    bool odd=false,even=false;
    rep(i,n){
        cin>>x[i]>>y[i];
        if(abs(x[i]+y[i])%2)odd=true;
        else even=true;
    }
    if(even&&odd){
        cout<<"-1"<<endl;
        return 0;
    }
    ll a[40];
    int m;
    cout<<(m=39+even)<<endl;
    ll res=1LL<<38;
    rep(i,39){
        cout<<(a[i]=res)<<" ";
        res>>=1;
    }
    if(even)cout<<(a[39]=1);
    cout<<endl;
    rep(i,n){
        rep(j,m){
            ll mi=longinf;
            int ret=-1;
            if(dist(x[i]+a[j],y[i])<mi){mi=dist(x[i]+a[j],y[i]);ret=1;}
            if(dist(x[i]-a[j],y[i])<mi){mi=dist(x[i]-a[j],y[i]);ret=0;}
            if(dist(x[i],y[i]+a[j])<mi){mi=dist(x[i],y[i]+a[j]);ret=3;}
            if(dist(x[i],y[i]-a[j])<mi){mi=dist(x[i],y[i]-a[j]);ret=2;}
            cout<<s[ret];
            if(ret==0)x[i]-=a[j];
            if(ret==1)x[i]+=a[j];
            if(ret==2)y[i]-=a[j];
            if(ret==3)y[i]+=a[j];

        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char pass[5];
    scanf("%s", pass);
    for(int i=0; i<3; i++){
        if(pass[i] == pass[i+1]) {
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");
    
    return 0;
}


Measured memory_bytes: 128