akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h-1){
        cin>>s[i];
    }
    ll seen[h][w];
    ll ans=0;
    rep(i,0,h-1){
        rep(j,0,w-1){
            seen[i][j]=inf;
            if(s[i][j]=='.'){
                ans++;
            }
        }
    }
    queue<pair<ll,ll>> q;
    pair<ll,ll> p;
    seen[0][0]=0;
    q.push(make_pair(0,0));
    ll x,y;
    while(q.size()>0){
        p=q.front();
        q.pop();
        y=p.first;
        x=p.second;
        if(y+1<h){
            if(s[y+1][x]=='.'){
                if(seen[y+1][x]>seen[y][x]+1){
                    seen[y+1][x]=seen[y][x]+1;
                    q.push(make_pair(y+1,x));
                }
            }
        }
        if(y-1>=0){
            if(s[y-1][x]=='.'){
                if(seen[y-1][x]>seen[y][x]+1){
                    seen[y-1][x]=seen[y][x]+1;
                    q.push(make_pair(y-1,x));
                }
            }
        }
        if(x+1<w){
            if(s[y][x+1]=='.'){
                if(seen[y][x+1]>seen[y][x]+1){
                    seen[y][x+1]=seen[y][x]+1;
                    q.push(make_pair(y,x+1));
                }
            }
        }
        if(x-1>=0){
            if(s[y][x-1]=='.'){
                if(seen[y][x-1]>seen[y][x]+1){
                    seen[y][x-1]=seen[y][x]+1;
                    q.push(make_pair(y,x-1));
                }
            }
        }
    }
    /*rep(i,0,h-1){
        rep(j,0,w-1){
            cout<<seen[i][j];
        }
        cout<<endl;
    }
    */
    if(seen[h-1][w-1]==inf){
        cout<<-1<<endl;
    }else{
        cout<<ans-seen[h-1][w-1]-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
ll cnt = 0LL;
int ans = 0;
int tmp;
int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    cnt += b / x;
    if(a >= 1)
        cnt -= (a - 1) / x;
    else
        cnt += 1;
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

const int MAX_N = 1000000;

int prime[MAX_N];
bool is_prime[MAX_N];

int sieve(int n)
{
	int p = 0;
	for(int i=0;i<=n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<=n;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
	int n;
	while(scanf("%d",&n) > 0){
		printf("%d\n",sieve(n));
	}
}

Measured memory_bytes: 4468
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    set<ll>A;
    for(ll i=0;i<n;i++){
        ll a;cin>>a;
        A.insert(a);
    }
    ll m;cin>>m;
    set<ll>B;
    for(ll i=0;i<m;i++){
        ll b;cin>>b;
        B.insert(b);
    }
    set<ll>c;
    set_symmetric_difference(all(A),all(B),inserter(c,c.begin()));
    for(auto it=c.begin();it!=c.end();it++){
        cout<<*it<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 40648
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const long INF=114514810;
const int maxN=40;
const int maxA=400,maxB=400;


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//i番目の品物まででMa=a Mb=bとなる最小のお金テーブル
long dp[maxN+1][maxA+1][maxB+1];
int main(){
    Fill(dp,INF);
    dp[0][0][0]=0;

    int N,Ma,Mb;
    cin>>N>>Ma>>Mb;
    VI As(N);
    VI Bs(N);
    VI Cs(N);
    REP(i,N){
        cin>>As[i]>>Bs[i]>>Cs[i];
    }

    REP(n,N){
        REP(i,maxA){
            REP(j,maxB){
                if(dp[n][i][j]==INF){continue;}
                dp[n+1][i][j]=min(dp[n+1][i][j],dp[n][i][j]);//n番目を使わない場合
                dp[n+1][i+As[n]][j+Bs[n]]=min(dp[n+1][i+As[n]][j+Bs[n]],dp[n][i][j]+Cs[n]);//n番目を使う場合
            }
        }
    }
    
    long ans=INF;
    FOR(i,1,maxA+1) FOR(j,1,maxB+1){
        if(i*Mb==j*Ma){
            ans=min(ans,dp[N][i][j]);
        }
    }
    if(ans==INF){
        ans=-1;
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 51712
#include<bits/stdc++.h>
#define N 205
using namespace std;

int a[N][N],ans=-1,n,dis[N];

inline int bfs(int x)
{
	memset(dis,0x3f,sizeof dis);
	queue<int>q;
	q.push(x);
	dis[x]=1;
	int cur=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();cur=max(cur,dis[x]);
		for(int i=1;i<=n;++i)
			if(a[x][i])
			{
				if(dis[i]<0x3f3f3f3f)
				{
					if(dis[i]!=dis[x]-1&&dis[i]!=dis[x]+1) return -1;
				}
				else dis[i]=dis[x]+1,q.push(i);
			}
	}
	return cur;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			scanf("%1d",&a[i][j]);
	for(int i=1;i<=n;++i) ans=max(ans,bfs(i));
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,m) for(ll i=(n);i<(m);i++)
ll n,m;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    for(int i=0;i<n;i++) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
int main(){
    cin>>n>>m;
    ll ans=n;
    UnionFind tree(n);
    For(i,0,m){
      ll a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      if(tree.same(a,b)) continue;
      else{
        tree.unite(a,b);
        ans--;
      }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((a+b) > (c+d)) cout << "Left" << endl;
  else if((a+b) < (c+d)) cout << "Right" << endl;
  else cout << "Balanced" << endl;

  return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int p[n];
  int q[n];
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  int a,b;
  a = 1;

  int base[n];
  rep(i,n) base[i] = i+1;
  bool flag = false;
  while(!flag){
    flag = true;
    rep(i,n){
      if(p[i] != base[i]){
        flag = false;
        break;
      }
    }
    next_permutation(base,base+n);
    a++;
  }

  b = 1;
  rep(i,n) base[i] = i+1;
  flag = false;
  while(!flag){
    flag = true;
    rep(i,n){
      if(q[i] != base[i]){
        flag = false;
        break;
      }
    }
    next_permutation(base,base+n);
    b++;
  }

  printf("%d\n", abs(a-b));
  return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    s:Chars
    }

    let mut cnt = 0;

      if s[0] == 'R' {
        cnt += 1;
        if s[1] == 'R'{
          cnt += 1;
          if s[2] == 'R' {
            cnt +=1;
          } 
        }
      }else{
        if s[1]=='R'{
          cnt +=1;
          if s[2]=='R'{
            cnt +=1;
          }
        }else{
          if s[2] =='R'{
            cnt +=1;
          }
        }
      }

     println!("{}", cnt);
}


Measured memory_bytes: 2064
n = int(input())
a = list(map(int,input().split()))
sa = max(a)-min(a)
if sa>1:
  print("No")
  exit()
elif sa == 0:
  if max(a) == n-1:
    print("Yes")
  elif max(a) <= n//2:
    print("Yes")
  else:
    print("No")
else:
  alone = a.count(min(a))
  pair = a.count(max(a))
  ceil = alone + pair//2
  floor = alone + 1
  if floor <= max(a) and max(a)<=ceil:
    print("Yes")
  else:
    print("No")
      


Measured memory_bytes: 14092
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 6, 1, 4, 5]), 'YES')

    def test_2(self):
        self.assertEqual(think([4, 1, 3, 1, 6, 2]), 'NO')

    def test_3(self):
        self.assertEqual(think([10000000, 10000000]), 'NO')


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    return 'YES' if len(a) == len(set(a)) else 'NO'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()


Measured memory_bytes: 112812
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

struct Temp{
  using Pos = pair<int, int>;

  int H, W;
  vector<vector<char>> table;
  vector<vector<int>> result;
  Temp(int H, int W)
    : H(H)
    , W(W)
    , table(H, vector<char>(W))
    , result(H, vector<int>(W, -1))
  {};

  /** {0, 0} -> {H-1, W-1} の最短距離 */
  int operator()() {
    result[0][0] = 1;
    rec(0, 0);
    return result[H-1][W-1];
  };

  /** 白マスの数 */
  int count() {
    return boost::accumulate(table, 0, [](int r, const auto& row){
      return r + boost::accumulate(row, 0, [](int r, char c){
        return r + (c == '.');
      });
    });
  };

  void rec(int h, int w) {
    Pos nextList[] = {
      {h-1, w},
      {h+1, w},
      {h, w-1},
      {h, w+1},
    };
    auto current = result[h][w];
    for (const auto& np : nextList) {
      auto nh = np.first;
      auto nw = np.second;
      if (nh < 0 || nh >= H) { continue; }
      if (nw < 0 || nw >= W) { continue; }
      if (table[nh][nw] != '.') { continue; }
      auto& nr = result[nh][nw];
      if (nr == -1) {
        nr = current+1;
        rec(nh, nw);
      }
      else if (chmin(nr, current+1)) {
        rec(nh, nw);
      }
    }
  };
};
void solve(void)
{
  int H, W; cin >> H >> W;
  Temp t(H, W);
  for (auto& row : t.table) {
    for (auto& cell : row) {
      cin >> cell;
    }
  }
  auto res = t();
  auto shiroCount = t.count();
  int ans;
  if (res == -1) {
    ans = -1;
  }
  else {
    ans = shiroCount - res;
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    string s;
    cin >> s;
    bool ok = true;
    for(ll i = 0; i < s.length(); i+=2){
        if(s[i]!='h'||s[i+1]!='i'){
            ok = false;
            break;
        }
    }
    if(ok==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

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

ll n;
vector<pair<ll, ll>> a;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}


int main() {

    cin >> n;
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        a.push_back(make_pair(x, y));
    }
    sort(a.begin(), a.end(), pairCompare);


    ll sum = 0;
    bool isSafe = true;
    REP(i, n) {
        sum += a[i].first;
//        cout << "sum " << sum << endl;
//        cout << "limit " << a[i].second << endl;
        if (sum > a[i].second) {
            isSafe = false;
            break;
        }
    }

    if (isSafe) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

public class Main {
	public static void main(String[] a){
		int height[] = new int[10];
		Scanner in = new Scanner(System.in);
		for(int i = 0;i<10;i++){
			try{
				height[i] = in.nextInt();
			}catch(Exception e){
				break;
			}
		}
		Arrays.sort(height);
		System.out.println(height[9]);
		System.out.println(height[8]);
		System.out.println(height[7]);
	}
}

Measured memory_bytes: 26104
#import sys
#import math
#import numpy as np

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,k=map(int,input().split())
ans=s=0
li=[]
if a>b:
  s=a
  a=b
  b=s
for i in range(1,b+1):
  if a%i==0 and b%i==0:
    li.append(i)
li.sort()

print(li[-k])


Measured memory_bytes: 3060
class Shopping
  def initialize(x)
    @x = x
    @dp = Array.new(x + 1, 0)
    @dp[0] = 1
  end

  def solve
    (100 .. 105).each do |i|
      (0 .. @x).each do |j|
        if @dp[j] == 1 && i + j <= @x
          @dp[i + j] = 1
        end
      end
    end
    @dp[@x]
  end
end

def run
  x = gets.chomp.to_i
  puts Shopping.new(x).solve
end

run


Measured memory_bytes: 14896
#include <stdio.h>

int main(void) {
	int A, B, C, D, E;
	if (scanf("%d%d%d%d%d", &A, &B, &C, &D, &E) != 5) return 1;
	if (A < 0) {
		printf("%d\n", C * (-A) + D + E * B);
	} else {
		printf("%d\n", E * (B - A));
	}
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int a,b,t;
    scanf("%d%d%d",&a,&b,&t);
    printf("%d\n",(t/a)*b);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

void solve() {
  int w, h;
  vector<ll> horiz, vert;
  cin >> w >> h;
  horiz.resize(w);
  for(int i = 0; i < w; i++) cin >> horiz[i];
  sort(horiz.begin(), horiz.end());
  vert.resize(h);
  for(int i = 0; i < h; i++) cin >> vert[i];
  sort(vert.begin(), vert.end());
  ll ret = 0;
  int hh = 0;
  int ww = 0;
  while(ww < horiz.size() || hh < vert.size()) {
    if(ww < horiz.size() && (hh == vert.size() || horiz[ww] < vert[hh])) {
      ret += (vert.size()+1-hh) * horiz[ww++];
    }
    else {
      ret += (horiz.size()+1-ww) * vert[hh++];
    }
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main(){
    int n;
    cin>>n;
    vector<string> s;
    string cnt;
    for(int i=0;i<n;i++)
    {
        cin>>cnt;
        s.push_back(cnt);
    }
    sort(s.begin(),s.end());
    int kind=0;
    for(int k=0;k<n-1;k++){
        if(s[k]!=s[k+1]){kind++;}
    }
    cout<<kind+1;
}

Measured memory_bytes: 11656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll n;
ll ans;
ll d;
ll c[4];
ll k[4] = {2,3,5};
map<ll,ll> dp;
ll cal(ll x){
    if (x == 0) return 0;
    if (dp.count(x)) return dp[x];
    ll ret = INF;
    if (x < ret / d) ret = x * d;
    REP (i,3) {
        ll dn = x / k[i], up = (x+k[i]-1) / k[i];
        ret = min(ret,cal(dn) + c[i] + llabs(dn*k[i] - x)*d);
        ret = min(ret,cal(up) + c[i] + llabs(up*k[i] - x)*d);
    }
    return dp[x] = ret;
}
int main(){
    IOS();
    int t;
    cin >> t;
    while (t--) {
        dp.clear();
        cin >> n;
        REP (i,3) cin >> c[i];
        pary(c,c+3);
        cin >> d;
        dp[1] = d;
        cout << cal(n) << endl;
    }
}


Measured memory_bytes: 4404
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;  
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)1e5 + 5;

int fenw[MAXN];

int arr[MAXN];

int n, ans;

void compress() {
    vector<pii> V;

    for (int i = 1; i <= n; ++i) {
        V.pb(mp(arr[i], i));
    }

    sort(all(V));

    for (int i = 0; i < V.size(); ++i) {
        arr[V[i].se] = i + 1;
    }    
}

void fenwUpd(int p, int x) {
    for (; p <= n; p |= (p + 1)) {
        fenw[p] += x;
    }
}

int prefSum(int p) {
    int ret = 0;

    for (; p > 0; --p) {
        ret += fenw[p];
        p &= (p + 1);
    }

    return ret;
}

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }

    compress();   

    for (int i = 1; i <= n; ++i) {
        if (i % 2 != arr[i] % 2) {
            ++ans;            
        }
    }        

    printf("%d\n", ans / 2);
}

int main() {
    int tt = 1;

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

    return 0;
}


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

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


int main()
{
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    REP(i, H){
        REP(j, W){
            if(i < B and j < A) cout << 1;
            else if(i >= B and j >= A) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<double, double> pi;

int n;
double d;
pi a[200005];

struct disj{
	int par[200005], sz[200005];
	void init(int n){
		for(int i=0; i<=n; i++){
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x){
		return par[x] = (par[x] == x ? x : find(par[x]));
	}
	bool uni(int p, int q){
		p = find(p), q = find(q);
		if(p == q) return 0;
		par[q] = p;
		sz[p] += sz[q];
		return 1;
	}
}disj;

struct rmq{
	pi tree[530000];
	int lim;
	void init(int n){
		fill(tree, tree + 530000, pi(-1e9, -1e9));
		for(lim = 1; lim <= n; lim <<= 1);
	}
	void add(int x, pi v){
		x += lim;
		while(x){
			tree[x] = max(tree[x], v);
			x >>= 1;
		}
	}
	pi q(int s, int e){
		pi ret(-1e9,-1e9);
		s += lim;
		e += lim;
		while(s < e){
			if(s%2 == 1) ret = max(ret,tree[s++]);
			if(e%2 == 0) ret = max(ret,tree[e--]);
			s >>= 1;
			e >>= 1;
		}
		if(s == e) ret = max(ret,tree[s]);
		return ret;
	}
}rmq;

vector<double> vx, vy;

int main(){
	scanf("%d %lf",&n,&d);
	d *= 1.5;
	for(int i=0; i<n; i++){
		double x, y;
		scanf("%lf %lf",&x,&y);
		a[i] = pi(x+y, x-y);
		vx.push_back(x+y);
		vy.push_back(x-y);
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
	vy.resize(unique(vy.begin(), vy.end()) - vy.begin());
	for(int i=0; i<n; i++){
		a[i].first = lower_bound(vx.begin(), vx.end(), a[i].first) - vx.begin();
		a[i].second = lower_bound(vy.begin(), vy.end(), a[i].second) - vy.begin();
	}
	rmq.init(n);
	disj.init(n);
	sort(a,a+n);
	for(int i=0; i<n; i++){
		int e = i;
		while(e < n && a[e].first == a[i].first) e++;
		for(int j=i; j<e; j++){
			if(j != i && vy[a[j-1].second] >= vy[a[j].second] - d){
				disj.uni(j-1, j);
			}
			int st = lower_bound(vy.begin(), vy.end(), vy[a[j].second] - d) - vy.begin();
			int ed = lower_bound(vy.begin(), vy.end(), vy[a[j].second] + 1) - vy.begin() - 1;
			pi t = rmq.q(st, ed);
			if(t.first >= 0 && vx[t.first] >= vx[a[j].first] - d){
				disj.uni(t.second, j);
			}
			st = lower_bound(vy.begin(), vy.end(), vy[a[j].second]) - vy.begin();
			ed = lower_bound(vy.begin(), vy.end(), vy[a[j].second] + d + 1) - vy.begin() - 1;
			t = rmq.q(st, ed);
			if(t.first >= 0 && vx[t.first] >= vx[a[j].first] - d){
				disj.uni(t.second, j);
			}
		}
		for(int j=i; j<e; j++){
			rmq.add(a[j].second, pi(a[j].first, j));
		}
		i = e-1;
	}
	int ret = 1;
	for(int i=0; i<n-1; i++){
		ret += disj.uni(i, i+1);
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 17488
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int d = sc.nextInt();
			long s = 0;
			for(int i = d; i + d <= 600; i += d){
				s += f(i) * d;
			}
			System.out.println(s);
		}
	}

	public static long f(int x){
		return (long)x*x;
	}
}

Measured memory_bytes: 26224
def resolve():
  n = int(input())
  l = list(map(int, input().split()))
  l.sort()
  sum = 0
  for i in range(n-1):
    sum += l[i]

  if sum > l[n-1]:
    print("Yes")
  else:
    print("No")
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long x = sc.nextLong();
			x = Math.abs(x);
			long k = sc.nextLong();
			long d = sc.nextLong();
			if (x / d > k) {
				System.out.println(x - d * k);
			} else {
				long cnt = x / d;
				if ((k - cnt) % 2 == 0) {
					System.out.println(x - cnt * d);
				} else {
					System.out.println((cnt + 1) * d - x);
				}
			}
		}
	}
}

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

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i=0; i<n; i++) {
    cin >> w[i];
  }
  int ans = 1e9;
  for (int i=1; i<n; i++) {
    int l = 0;
    int r = 0;
    for (int j=0; j<i; j++) l += w[j];
    for (int j=i; j<n; j++) r += w[j];
    ans = min(ans, abs(l-r));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll sum(ll l,ll r){
    return(l+r)*(r-l+1)/2;
}

int main(){
ll n;
cin>>n;
string s;
cin>>s;
vector<ll>v(n);
rep(i,n){
    if(s[i]=='R')v[i]=0;
    if(s[i]=='G')v[i]=1;
    if(s[i]=='B')v[i]=2;
    
}
vector<ll>cnt(3);
rep(i,n){
  cnt[v[i]]++;
}
ll ans=1;
rep(i,3){
    ans*=cnt[i];
}
rep(j,n)rep(i,j){
    ll k=j+j-i;
    if(k<n){
    if(v[k]==v[i])continue;
    if(v[i]==v[j])continue;
    if(v[k]==v[j])continue;
    ans--;
    }
}

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



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((abs(a-b)<=d&&abs(c-b)<=d)||abs(a-c)<=d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
H,W,M = map(int,input().split())
#h = np.empty(M,dtype=np.int)
#w = np.empty(M,dtype=np.int)
bomb = set()
hh = np.zeros(H+1,dtype=np.int)
ww = np.zeros(W+1,dtype=np.int)

for i in range(M):
    h,w = map(int,input().split())
    bomb.add((h,w))
    hh[h] += 1
    ww[w] += 1

#print(bomb)
h_max = np.max(hh)
w_max = np.max(ww)

h_max_ids = list()
w_max_ids = list()
for i in range(1,H+1):
    if hh[i] == h_max:
      h_max_ids.append(i)
for j in range(1,W+1):
    if ww[j] == w_max:
      w_max_ids.append(j)
      
for i in h_max_ids:
  for j in w_max_ids:
    if not (i,j) in bomb:
      print(h_max + w_max)
      exit()

#print("hmax:{} wmax:{}".format(h_max_id, w_max_id))
#print("hmax:{} wmax:{}".format(hh[h_max_id], ww[w_max_id]))
print(h_max + w_max - 1)


Measured memory_bytes: 101480
#include <iostream>
#include <vector>

int main(int argc, char const *argv[])
{
    int H, W;
    std::vector<int> input_H, input_W;

    while (true)
    {
        std::cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }
        else
        {
            input_H.emplace_back(H);
            input_W.emplace_back(W);
        }
    }

    for (int i = 0; i < input_H.size(); i++)
    {
        for (int j = 0; j < input_H[i]; j++)
        {
            for (int k = 0; k < input_W[i]; k++)
            {
                if (j == 0 || j == input_H[i] - 1 || k == 0 || k == input_W[i] - 1)
                {
                    std::cout << "#";
                }
                else
                {
                    std::cout << ".";
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define push_back(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
ostream& operator<<(ostream &os, const vector<pii> &st){
  for(int i=0;i<(int)st.size();++i){
    if(i==(int)st.size()-1) os << st[i].se << endl;
    else os << st[i].se << " ";
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string in;
  cin >> in;
  V<pii> s;
  int sz = in.size();
  int a = 1;//フラグ
  int sum = 0;
  REP(i,sz){
    if(in[i]=='A'){
      if(a==1) sum++;
      else s.push_back(make_pair(a,sum)),sum = 1;
      a = 1;
    }else if(i!=sz-1&&in.substr(i,2)=="BC"){
      if(a==0) sum++;
      else s.push_back(make_pair(a,sum)),sum = 1,a = 0;
      i++;
    }else{
      if(a==-1) sum++;
      else s.push_back(make_pair(a,sum)),sum = 1;
      a = -1;
    }
  }
  s.push_back(make_pair(a,sum));
  ll ans = 0;
  // cout << s;
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i].fi==1&&s[i+1].fi==0) {
      ans += s[i].se*s[i+1].se;
      if(i+2<(int)s.size()&&s[i+1].se&&s[i+2].fi==1) s[i+2].se += s[i].se;
      //++i;
    }
    //cout << ans << endl;

  }
  cout << ans << endl;
}


Measured memory_bytes: 2700
n = int(input())
ans=n
for i in range(n-1):
    i+=1
    j=n-i
    i=list(str(i))
    j=list(str(j))
    for a in range(len(i)):
        i[a]=int(i[a])
    for a in range(len(j)):
        j[a]=int(j[a])
    if sum(i)+sum(j)<ans:
        ans=sum(i)+sum(j)
print(ans)


Measured memory_bytes: 3064
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
   // CIN(n);vector<V> a(n,V(n));
    CIN(a,b,c,x);
    int count=0;
    REP(i,a+1)REP(j,b+1)REP(k,c+1)if(500*i+100*j+50*k==x)count++;
    COUT(count);


    return 0;
}


Measured memory_bytes: 256
words = ["dream", "dreamer", "erase", "eraser"]
s = input()
dp = [0] * (len(s)+1)
dp[0] = 1

for i in range(len(s)+1):
  if dp[i]!=1: continue
  for word in words:
    if word in s[i:i+len(word)]:
      dp[i+len(word)] = 1
      
print("YES" if dp[len(s)] else "NO")



Measured memory_bytes: 3956
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count500 = sc.nextInt();
		int count100 = sc.nextInt();
		int count50 = sc.nextInt();
		int expectedSum = sc.nextInt();

		int result = getCoinsResult(count500, count100, count50, expectedSum);
		System.out.println(result);
	}

	public static void testCoins() {
		System.out.println(getCoinsResult(2,2,2,100)); // 2
		System.out.println(getCoinsResult(5,1,0,150)); // 0
		System.out.println(getCoinsResult(30,40,50,6000)); // 213
	}

	public static int getCoinsResult(int count500, int count100, int count50, int expectedSum) {
		int patterns = 0;
		for (int c500 = 0; c500 <= count500; c500++)
		{
			for (int c100 = 0; c100 <= count100; c100++)
			{
				for (int c50 = 0; c50 <= count50; c50++)
				{
					int sum = c500 * 500 + c100 * 100 + c50 * 50;
					if (sum == expectedSum)
					{
						patterns ++;
					}
				}

			}

		}
		return patterns;
	}

}


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

using ll = long long;

const ll MOD = 1e9+7;
vector<vector<int>> g;
ll dp[100001][2] = {};

void rec(int u, int r) {
	dp[u][0] = 1;
	dp[u][1] = 1;
	for(int v:g[u]) {
		if(v == r) continue;
		rec(v, u);
		dp[u][0] = dp[u][0] * dp[v][1] % MOD;
		dp[u][1] = dp[u][1] * (dp[v][0] + dp[v][1]) % MOD;
	}
}

int main() {
	int N;
	cin >> N;
	g = vector<vector<int>>(N);
	for(int i=0;i<N-1;i++) {
		int x, y;
		cin >> x >> y;
		x--;y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	rec(0, -1);
	cout << (dp[0][0] + dp[0][1]) % MOD << '\n';
}

Measured memory_bytes: 14208
import java.util.Scanner;
     
     
    public class Main{
     
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
     
    		int a=Integer.parseInt(sc.next());
    		int b=Integer.parseInt(sc.next());;
    		int sum=0;
     
    		for(int i=0;i<2;i++){
    			if(a>=b){
    				sum+=a;
    				a=a-1;
    			}else{
    				sum+=b;
    				b=b-1;
    			}
    		}
    		System.out.println(sum);
    	}
     
    }

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else if(n == 2){
        int a,b; cin >> a>> b;
        cout << a+b << endl;
    }
    return 0;
}

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

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  string s,t;
  cin >> s >> t;
  if(s==t.substr(0,t.size()-1))cout << "Yes";
  else cout << "No";
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

ll ext_gcd(ll a, ll b, ll &x, ll &y){ // ax+by=gcd(a,b)なるx,y,gcdを返す
  if(b == 0){
    x = 1; y = 0; return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a-q*b, x, y);
  ll z = x - q * y;
  x = y; y = z;
  return g;
}

int main(){
#define int ll
  int n, x; cin >> n >> x;
  vi a(n+1); rep(i,n) cin >> a[i];
  a[n] = x;
  sort(all(a));
  if(n == 1){
    cout << a[1] - a[0] << endl;
    return 0;
  }
  int tmpx,tmpy;
  int gcd = ext_gcd(a[1]-a[0],a[2]-a[1],tmpx,tmpy);
  rep(i,n-2) gcd = ext_gcd(a[i+3]-a[i+2],gcd,tmpx,tmpy);
  cout << gcd << endl;
}

Measured memory_bytes: 1024
import std.stdio, std.array, std.conv;

void main() {
  while (true) {
    string[] input = split(readln());
    int H = to!int(input[0]);
    int W = to!int(input[1]);

    if (H == 0 && W == 0) break;

    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        write(is_dots(i, j) ? "." : "#");
      }
      writeln("");
    }
    writeln("");
  }
}

bool is_dots(int y, int x) {
  return (((y % 2) + x) % 2 == 1);
}

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

int main(){

    int H, W;
    cin >> H >> W;

    vector<vector<char> > s(H, vector<char>(W));
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) cin >> s[i][j];

    int ans = 0;
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) if(s[i][j] == '.') ans++;

    queue<pair<int, int> > Q;
    vector<vector<int> > memo(H, vector<int>(W, 1e8));    
    Q.push(make_pair(0, 0));
    memo[0][0] = 1;
    while(!Q.empty()){
        pair<int, int> p = Q.front();
        Q.pop();
        if(p.first == H - 1 && p.second == W - 1){
            break;
        }else{
            int x, y;
            x = p.first + 1; y = p.second;
            if(0 <= x && x < H && 0 <= y && y < W && s[x][y] == '.' && memo[x][y] == 1e8){
                Q.push(make_pair(x, y));
                memo[x][y] = memo[x - 1][y] + 1;
            }
            x = p.first - 1; y = p.second;
            if(0 <= x && x < H && 0 <= y && y < W && s[x][y] == '.' && memo[x][y] == 1e8){
                Q.push(make_pair(x, y));
                memo[x][y] = memo[x + 1][y] + 1;
            }
            x = p.first; y = p.second + 1;
            if(0 <= x && x < H && 0 <= y && y < W && s[x][y] == '.' && memo[x][y] == 1e8){
                Q.push(make_pair(x, y));
                memo[x][y] = memo[x][y - 1] + 1;
            }
            x = p.first; y = p.second - 1;
            if(0 <= x && x < H && 0 <= y && y < W && s[x][y] == '.' && memo[x][y] == 1e8){
                Q.push(make_pair(x, y));
                memo[x][y] = memo[x][y + 1] + 1;
            }
        }
    }

    if(memo[H - 1][W - 1] != 1e8) ans -= memo[H - 1][W - 1];
    else ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
int main(){
    vector<int> b,a;
    int n,x,f=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        b.push_back(x);
    }
    while(f){
        f=0;
        for(int i=b.size()-1;i>=0;i--){
            if(b[i]==i+1){
                f=1;
                a.push_back(b[i]);
                b.erase(b.begin()+i);
                break;
            }
        }
    }
    if(b.empty()){
        for(int i=a.size()-1;i>=0;i--){
            printf("%d\n",a[i]);
        }
    }
    else{
        printf("-1\n");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll binarySearch(function<bool(ll)> check, ll ok, ll ng) {
  while ((ok - ng > 1) || (ng - ok > 1)) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}
ll N,K,Q;
ll A[2010];
bool Check(ll diff){
	for(ll i=0;i<N;i++){
		ll deleteCnt=0;
		ll nowSize=0;
		ll inRangeCnt=0;
		for(ll j=0;j<N;j++){
			if(A[i]<=A[j]){
				nowSize++;
				if(A[j]<=A[i]+diff)inRangeCnt++;
			}else{
				deleteCnt+=max(0ll,min((nowSize+1-K),inRangeCnt));
				nowSize=0;
				inRangeCnt=0;
			}
		}
		deleteCnt+=max(0ll,min((nowSize+1-K),inRangeCnt));
		if(deleteCnt>=Q)return false;
	}
	return true;
}
int main(){
    cin>>N>>K>>Q;
	for(ll i=0;i<N;i++){
		cin>>A[i];
	}
	cout<<binarySearch(Check,-1,INF)+1<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n, ans = 0;
  cin >> n;
  vll h(n);
  for (ll i = 0; i < n; i++) {
    cin >> h[i];
  }
  h.push_back(10e9+1);
  
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (h[i] < h[i+1]) {
      ans = max(cnt, ans);
      cnt = 0;
    }
    else {
      cnt++;
    }
  }
  
  cout << ans << endl;
}

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

int main(){
  long long n,m;
  cin>>n>>m;
  vector<long long> a(n);
  long long memo=0;
  for(int i=0;i<n;i++){
    long long x,cnt=0;
    cin>>x;
    a[i]=x/2;
    while(x%2==0){
      x/=2;
      cnt++;
    }
    if(i==0) memo=cnt;
    if(i!=0&&cnt!=memo) {cout<<0<<endl; return 0;}
  }
  sort(a.begin(),a.end());
  long long mem;
  if(n==1) mem=a[0];
  else mem=a[0]/__gcd(a[0],a[1])*a[1];
  for(int i=2;i<n;i++){
    if(mem>m) {cout<<0<<endl; return 0;}
    if(mem%a[i]!=0) mem=mem/__gcd(mem,a[i])*a[i];
  }
  long long ans=0,me=mem;
   while(me<=m){
    ans++;
    me+=2*mem;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1024