akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long a[n], c[9], t = 0;
    for (long long i = 0; i < 9; i++) c[i] = 0;
    for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] >= 3200) c[8]++;
        else c[a[i] / 400]++;
    }
    for (long long i = 0; i < 8; i++)
        if (c[i] > 0) t++;
    cout << max(t, (long long) 1) << ' ' << t + c[8];
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int i=0;
    bool flag = false; 
    while(i<S.size()-1){
        if(S[i]==S[i+1]){
            flag = true;
            break;
        }
        i++;
    }
    if(flag) cout<<"Bad";
    else cout<<"Good";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for(long long i = 0; i < n; i++)
#define MAX 10e9
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

void vprint(vector<P> v);

int main() {
  ll N;
  cin >> N;
  vector<ll> X(N), L(N);
  vector<P> answers;
  ll current = -MAX;
  ll sum = 0;
  rep(i, N) {
    cin >> X[i] >> L[i];
  }

  vector<P> robots;

  rep(i, N) {
    robots.push_back(P(X[i] + L[i], X[i] - L[i]));
  }

  sort(robots.begin(), robots.end());
  //vector<pair<int, int>> をソートすると、デフォルトではpair型.firstの
  //小さい順にソートするようになっている
  //参照:https://www.geeksforgeeks.org/sorting-vector-of-pairs-in-c-set-1-sort-by-first-and-second/

  rep(i, N) {
    if (current <= robots[i].second) {
      sum++;
      current = robots[i].first;
      answers.push_back(robots[i]);
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 6384
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from math import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10 ** -7

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

def lcm(x, y): return (x * y) // gcd(x, y)


K = inp()

def gcd_3(x, y, z):
    return gcd(gcd(x, y), z)

dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        # tmp = gcd(i, j)
        for k in range(j, K + 1):
            # a = gcd(tmp, k)
            # a = gcd(gcd(i, j), k)
            a = gcd_3(i, j, k)
            if i == j == k:
                ans += a
            elif i == j or j == k:
                ans += a * 3
            else:
                ans += a * 3 * 2
print(ans)


Measured memory_bytes: 10560
#include<stdio.h>
int main(void){
    int r,D,x2000[11];
    int i;

    scanf("%d %d %d",&r,&D,&x2000[0]);

    for(i=0;i<10;i++){
    x2000[i+1]=r*x2000[i]-D;
    printf("%d\n",x2000[i+1]);
    }
return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <random>
//#include <chrono>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    MotoHaiyaku
    string s,t;
    ll n,ans=0;
    cin>>n>>s;
    t=s;
    sort(s.begin(),s.end());
    rep(i,s.size()) if(s[i]!=t[i]) ans++;
    cout<<ans/2;
}


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


int main() {
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
int  N;
int  K;
int *H;
int ans = 0;


int main(void){
    std::cin >> N >> K;
    H = new int[N];

    for(int i = 0; i < N; i++){
        std::cin >> H[i];
        if(H[i] >= K)
            ans++;
    }
    std::cout << ans << std::endl;
    delete[] H;
    return 0;
}

Measured memory_bytes: 640
//59
#include<iostream>

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int a[100],b[100];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
  }
  int c=0;
  int np;
  for(np=0;c<n;np++){
    int x,r=c;
    for(int i=0;i<m;i++){
      if(a[i]<=c+1&&r<b[i]){
	r=b[i];
	x=i;
      }
    }
    if(r==c) break;
    c=b[x];
  }
  if(c<n){
    cout<<"Impossible"<<endl;
  }else{
    cout<<np<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    if(max(a,max(b,c))*2-a-b-c==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << 1 << endl;
    else if(a==b || b==c || c==a) cout << 2 << endl;
    else cout << 3 << endl;
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int h,w,n;
    cin>>w>>h>>n;
    int i1=0;
    int i2=w;
    int j1=0;
    int j2=h;
    rep0(i,n){
        int x,y,t;
        cin>>x>>y>>t;
        if(t==1){
            i1=max(i1,x);
        }
        else if(t==2){
            i2=min(i2,x);
        }
        else if(t==3){
            j1=max(j1,y);
        }
        else if(t==4){
            j2=min(j2,y);
        }
    }
    //deb(i1,i2,j1,j2);
    cout<<max(0LL,i2-i1)*max(0LL,j2-j1);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

int main()
{
    int n, index, w, idx = 0, mx = -1;
    cin >> n;

    for(int i=0;i < n; ++i) {
        cin >> index >> w;
        if (mx < w || (mx == w && idx > index)) idx = index-1, mx = w;
    }

    cout << idx+1 << " " << mx << endl;

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

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

	std::vector<lld> v(n);
	std::vector<lld> ans(n);

	lld temp=0;

	for(lld i=0;i<n;i++)
	{
		cin>>v[i];

		temp = temp^v[i];
	}

	for(lld i=0;i<n;i++)
	{
		ans[i] = v[i]^temp;
		cout<<ans[i]<<" ";
	}

	cout<<endl;	
}

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

const int mxN = 3e3 + 10;
int n;
double p[mxN], dp[mxN][2 * mxN + 10];

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

    dp[0][n + 1] = p[0];
    dp[0][n - 1] = 1 - p[0];
    for (int i = 1; i < n; i++)
    {
        for (int diff = -n; diff <= n; diff++)
        {
            dp[i][diff + n] = p[i] * dp[i - 1][n + diff - 1] + (1 - p[i]) * dp[i - 1][n + diff + 1];
        }
    }

    double ret = 0;
    for (int i = n + 1; i <= 2 * n; i++)
    {
        ret += dp[n - 1][i];
    }
    printf("%.10lf\n", ret);
}

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

 int main()
 {
     string s;
     cin>>s;
     int a=s.size()-1;
     if(s[a]=='e'){
        s = s+"s";
     }
     else if(s[a]=='s'){
        s= s+"es";
     }
     else{
        s=s+"s";
     }
     cout<<s<<endl;
 }


Measured memory_bytes: 3604
N, x = map(int, input().split())
child_list = list(map(int, input().split()))

if len(child_list) == 1:
    if x > min(child_list):
        please_child = 0
    elif x == min(child_list):
        please_child = 1
elif len(child_list) > 1:
    nokori = x - min(child_list)
    please_child = 0 
    while nokori >=0:
        please_child +=1
        mini = min(child_list)
        child_list.remove(mini)
        if child_list == []:
            break
        if len(child_list) == 1:
            if nokori == min(child_list):
                please_child += 1
            if nokori > min(child_list):
                break
            else:
            	break
        else:    
            nokori -= min(child_list)
print(please_child)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n, i;
    long long int a[1000000];
    int min, max;
    long long int sum;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }
    
    min = a[0];
    for(i = 1; i < n; i++){
        if(a[i] < min){
            min = a[i];
        }
    }
    printf("%d ", min);

    max = a[0];
    for(i = 1; i < n; i++){
        if(a[i] > max){
            max = a[i];
        }
    }
    printf("%d ",max);

    sum = 0;
    for(i = 0; i < n; i++){
        sum += a[i];
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 3212
N, M  = map(int, input().split())
H = list(map(int, input().split()))
win = [1]*N

for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        win[B-1] = 0
    elif H[A-1] < H[B-1]:
        win[A-1] = 0
    else:
        win[A-1] = 0
        win[B-1] = 0

print(sum(win))

Measured memory_bytes: 20060
#include<bits/stdc++.h>
#define M 100006
using namespace std;
stack<int> m;
queue<int> p;
struct node{
	int b,e;
}; 
vector<node> q[M];
int d[M],n,t,s[M],mx;
int max(int a,int b)
{
	if(a>b)return a;
	return b;
}
void edge(){
	cin>>n>>t;
	while(t--)
	{
		int a,b;
		cin>>a>>b;
		q[a].push_back({a,b});
		d[b]++;
	}
}
void tp(){
	for(int i=1;i<=n;++i)
	{
		if(d[i]==0)m.push(i);
	}
	while(!m.empty()){
		int k=m.top();
		m.pop();
		p.push(k);
		for(auto i:q[k])
		{
			d[i.e]--;;
			if(d[i.e]==0)m.push(i.e);
		}
	}
}
int main()
{
	edge();
	tp();
	while(!p.empty())
	{
		int k=p.front();
		p.pop();
		for(auto i:q[k])
		{
			s[i.e]=max(s[i.e],s[i.b]+1);
			mx=max(mx,s[i.e]);
		}
	}
	cout<<mx;
}

Measured memory_bytes: 6912
#include <stdio.h>

int main ()
{
  int n,i;
  char s[102];

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

  if(n%2 != 0){
    printf("No");
    return 0;
  }

  for(i=0; i< n/2; i++)
  {
    if(s[i] != s[n/2+i]){
      printf("No");
      return 0;
    }
  }

  printf("Yes");
  return 0;
}


Measured memory_bytes: 1624
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int BIT[100001], sizee = 100001;
void update(int x, int delta)
{   
     for(; x <= sizee; x += x&-x){
       //cout << (x&-x) << endl;
       BIT[x] += delta;
     }
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x){
       sum += BIT[x];
       //cout << x << " " << BIT[x] << endl;
    }
    return sum;
}
int main ()
{
  prep();
  long long n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int> > > pairs;

  for (int i=0; i<n; i++){
      int a, b;
      cin >> a >> b;
      pairs.emplace_back(b-a+1, make_pair(a, b));
  }
  
  sort(pairs.begin(), pairs.end());
  // sums will represent all under x, since all over or == to x must have it
  int curind = 0;
  for (int i=1; i<=m; i++){
      while (curind < pairs.size() && pairs[curind].first < i){
          
          // add to sum
          update(pairs[curind].second.first, 1);
          update(pairs[curind].second.second+1, -1);
          curind++;
      }
      int summ = 0;
      for (int j=i; j<=m; j += i){
          summ += query(j);
          
      }
      cout << summ+n-curind << '\n';
      //cout << summ << " " << curind << endl;
  }
  
  return 0; 
}


Measured memory_bytes: 8048
N=int(input())
XL=[]
for i in range(N):
    a,b=map(int,input().split())
    XL.append([a-b,a+b])
    #XL.append(list(map(int,input().split())))
XL=sorted(XL,key = lambda x: (x[1], x[0]))




ans=0
end=-10**(19)
for i in range(N):
    if XL[i][0]>=end:
        ans+=1
        end=XL[i][1]
        
print(ans)

Measured memory_bytes: 29860
# coding:utf-8


def inpl(): return list(map(int, input().split()))


H, W = inpl()
board = []
for i in range(H):
    board.append(inpl())

ans = []
cnt = 0
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            if board[h][w] % 2 == 1:
                board[h][w] -= 1
                if w + 1 < W:
                    board[h][w + 1] += 1
                    ans.append([h + 1, w + 1, h + 1, w + 2])
                    cnt += 1
                elif h + 1 < H:
                    board[h + 1][w] += 1
                    ans.append([h + 1, w + 1, h + 2, w + 1])
                    cnt += 1

    else:
        for w in range(W)[::-1]:
            if board[h][w] % 2 == 1:
                board[h][w] -= 1
                if 0 < w:
                    board[h][w - 1] += 1
                    ans.append([h + 1, w + 1, h + 1, w])
                    cnt += 1
                elif h + 1 < H:
                    board[h + 1][w] += 1
                    ans.append([h + 1, w + 1, h + 2, w + 1])
                    cnt += 1

print(cnt)

for a in ans:
    print(' '.join(map(str, a)))


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

int main(){
  string s;
  cin>>s;
  int t=0;
  for(int i=0;i<s.size()-1;i++){
    if(s.at(i)==s.at(i+1)){
      t=1;
      break;
    }
  }
  if(t==0){
    cout<<"Good"<<endl;
  }
  else{
    cout<<"Bad"<<endl;
  }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn factorize(mut x: i64) -> Vec<i64> {
    let mut qs = vec![];
    let r = (x as f64).sqrt() as i64 + 1;

    for p in 2..r as i64 {
        let mut q = 1;

        while x >= p && x % p == 0 {
            x /= p;
            q *= p;
        }

        if q > 1 {
            qs.push(p);
        }
    }

    if x > 1 {
        qs.push(x);
    }

    qs
}

fn main() {
    let (N, M) = read!(i64, i64);
    let x = M / N;
    let g = if M % N == 0 {
        x
    } else {
        let ps = factorize(M);
        debug!(ps);

        let mut queue = BinaryHeap::new();
        let mut done = BTreeSet::new();
        let mut ma = 1;

        queue.push(M);
        while let Some(d) = queue.pop() {
            debug!(d);
            let k = M / d;
            if k >= N {
                ma = max(ma, d);
            }

            for &p in &ps {
                let x = d / p;
                if d % p == 0 && d >= p && done.insert(x) {
                    queue.push(x);
                }
            }
        }

        ma
    };
    println!("{}", g)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int k;
  cin>>k;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    v.push_back(a);
  }
  vector<int> dp;
  dp.push_back(0);
  dp.push_back(abs(v[0]-v[1]));
  for(int i=2;i<n;i++)
  {
    int ans=abs(v[i]-v[i-1])+dp[i-1];
    for(int j=2;j<=k;j++)
    {
      if(i-j>=0)
        ans=min(ans,abs(v[i]-v[i-j])+dp[i-j]);
      else
        break;
    }
    dp.push_back(ans);
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1400
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
int color[101];
int main() {
    
set<int> s;
rep(i,3){
    int a;cin>>a;
    s.insert(a);
}
cout<<s.size()<<endl;

    return 0;
}


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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N,X,T;
    int num;
    cin >> N >> X >> T;

    num = N / X;
    if( N % X != 0 ){
        num++;
    }
    cout << num * T << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1;
	int a=0,b=0;
	cin>>s1;
	for(int i=0;i<3;i++) 
		if(s1[i]=='A') a++;
		else b++;
	if(a==0||b==0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl; 
	
	
	return 0;
} 

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

#define endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int maxn = 400 + 5;
const ll oo = 0x3f3f3f3f3f3f3f3f;

int n;
ll dp[maxn][maxn], a[maxn], sum[maxn];

ll solve(int lo, int hi){
	if(hi - lo < 1)
		return 0;
	if(dp[lo][hi] != -1)
		return dp[lo][hi];
	ll ans = oo;
	
	for(int i = lo; i < hi; i++)
		ans = min(ans, solve(lo, i) + solve(i + 1, hi) - sum[lo - 1] + sum[hi]);
	
	return dp[lo][hi] = ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i], sum[i] = sum[i - 1] + a[i];

	memset(dp, -1, sizeof(dp));
	cout << solve(1, n) << endl;

	return 0;
}

Measured memory_bytes: 1536
import copy
n, k = map(int, input().split())
B = list(map(int, input().split()))
A = []
for l in range(0, n):
	for r in range(l+1, n+1):
		A.append(sum(B[l:r]))
#print(A)
ans = 0
for i in range(41, -1, -1):
	tmp = []
	res = 0
	for a in A:
		if (a >> i) & 1 == 1:
			tmp.append(a)
			res += 1
	if res >= k:
		ans += 1 << i
		A = copy.copy(tmp)
print(ans)

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

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

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R >= 1200 && R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed  main(){
    int n;cin>>n;
    string s[114514];
    rep(i,0,n){
        cin>>s[i];
        if(i){
            if(s[i][0]!=s[i-1][s[i-1].size()-1]){
                cout<<"No"<<endl;return 0;
            }
        }
    }
    rep(i,0,n){
        rep(j,0,n){
            if(i==j)continue;
            if(s[i]==s[j]){
                cout<<"No"<<endl;return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1152
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
const int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    vector<vector<int> > mat(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                function<void(int, int)> popu = [&](int x, int y){
                    for(int i = 0; i < 8; i++){
                        int nx = x + dx[i];
                        int ny = y + dy[i];
                        if(nx >= 0 && nx < h && ny >= 0 && ny < w && s[nx][ny] == '.'){
                            mat[nx][ny] += 1;
                        }
                    }
                };
                popu(i, j);
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                cout << s[i][j];
            }else{
                cout << mat[i][j];
            }
        }
        cout << nl;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;

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


int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];
    rep(i, h){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    
}


Measured memory_bytes: 256
#include <stdio.h>

#define EXIST 1
#define MISSING 0

int main(void)
{
    int i, j;
    int n;
    int cards[4][14];
    char suit[2];
    int rank;
    /*cards[suit][rank]
        suit 0: Spade, 1: Heart, 2: Club, 3: Diamond
        rank = 1, 2, ..., 13*/

    /*initialize*/
    for (i = 0; i < 4; i++){
        cards[i][0] = EXIST;
        for (j = 1; j < 14; j++){
            cards[i][j] = MISSING;
        }
    }

    /*input*/
    scanf("%d", &n);
    for (i = 1; i <= n; i++){
        scanf("%s %d", suit, &rank);
        switch (suit[0]){
            case 'S':
                cards[0][rank] = EXIST;
                break;
            case 'H':
                cards[1][rank] = EXIST;
                break;
            case 'C':
                cards[2][rank] = EXIST;
                break;
            case 'D':
                cards[3][rank] = EXIST;
                break;
            default:
                printf("ERROR!\n");
                break;
        }
    }

    /*output*/
    for (j = 1; j < 14; j++){
        if (cards[0][j] == MISSING){
            printf("S %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[1][j] == MISSING){
            printf("H %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[2][j] == MISSING){
            printf("C %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[3][j] == MISSING){
            printf("D %d\n", j);
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#define REP(i,n) for ( int i=0; i<int(n); i++ )
using namespace std;

const int N=1e5+5;

int main() {
    int n,p;
    cin >> n >> p;
    vector<long long> dp(2);
    dp[0]=1;
    REP(i,n) {
        int a;
        cin >> a;
        vector<long long> ndp=dp;
        REP(j,2) {
            ndp[(j+a)%2]+=dp[j];
        }
        dp=ndp;
    }
    cout << dp[p] << '\n';
    return 0;
}




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

int main(){
	int N;
	cin>>N;
	int a[N],b[N],c[N];
	for(int i=0;i<N;++i) cin>>a[i]>>b[i]>>c[i];
	long dp[N][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<N;++i){
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
	}
	cout<<max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2])<<endl;
}


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

int main()
{
	int n,p,d1,d2,mp,md;
	while(cin >> n){
		mp=0,md=0;
		if(n == 0)
			break;
		for(int i=0;i<n;i++){
			cin >> p >> d1 >> d2;
			if(md < d1+d2){
				mp = p;
				md = d1+d2;
			}
		}
		cout << mp <<" "<< md << endl;
	}
	return 0;
}

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

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

  int dp[3010][3010]={0};

  for(int i=0; i<s.size(); ++i){
    for(int j=0; j<t.size(); ++j){
      if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1], dp[i][j]+1);
      dp[i+1][j+1]=max(dp[i+1][j], dp[i+1][j+1]);
      dp[i+1][j+1]=max(dp[i][j+1], dp[i+1][j+1]);
    }
  }

  string ans="";
  int i=s.size(), j=t.size();
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j])--i;
    else if(dp[i][j]==dp[i][j-1])--j;
    else{
      ans=s[i-1]+ans;
      --i; --j;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 35712
class gv:
    input = None;
    
def build():
    gv.str = input()

def solve():
    slen = len(gv.str)
    if (slen&1) == 1:
        print("No")
        return
    
    for i in range(0,slen,2):
        if (gv.str[i:i+2] == "hi") :
            pass
        else :
            print("No")
            return
    
    print("Yes")
    
    

if __name__ == '__main__':
    build()
    solve()



Measured memory_bytes: 3060
s = input()
n = int(s)
r = 0
# bitの２進数表記で+を入れる位置を総当たりする
for bit in range(2**(len(s)-1)):
    # eは先頭文字
    e = s[0]
    # +が入る位置が、右からi桁目（0<= i <= Sの長さ－1）のとき
    for i in range(len(s)-1):
        if ((bit>>i)&1) == 1:
            # bitの２進数表記で右からi桁目が1のとき
            # '+'を入れる
            e += '+'
        # 次の文字（左からi番目）を入れる
        e += s[i+1]
    # +を入れた文字列を+で分割して整数に変換し、加算する
    r += sum(map(int, e.split('+')))
print(r)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long mod = 1000000007;
const double eps = 1e-11;
const int inf = 1ll << 61;

signed main() {
	string s; cin >> s;
	int ans = 700;
	if (s[0] == 'o')ans += 100;
	if (s[1] == 'o')ans += 100;
	if (s[2] == 'o')ans += 100;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int idx1,idx2,xnum1 = 0,xnum2 = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(xnum1 < a[i]){
            xnum1 = a[i];
            idx1 = i;
        }
    }
    a[idx1] = 0;
    for (int i = 0; i < n; i++)
    {
        xnum2 = max(xnum2,a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        if(a[i] != 0) cout << xnum1 << endl;
        else cout << xnum2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    double ans;
    ans = sqrt(pow(c-a, 2) + pow(d-b, 2));
    cout << fixed << setprecision(6) <<  ans << endl;
    return 0;
}


Measured memory_bytes: 3292
def resolve():
    import itertools
    impossible = 10 ** 20
    n, m, x = map(int, input().split())
    ans = impossible
    books = [None] * n
    for i in range(n):
        books[i] = list(map(int, input().split()))
    for i in list(itertools.product([True, False], repeat=n)):
        u = [0] * m
        yen = 0
        for index, j in enumerate(i):
            if not j:
                continue
            yen += books[index][0]
            for k in range(m):
                u[k] += books[index][k + 1]
        for j in u:
            if j < x:
                break
        else:
            ans = min(yen, ans)
    print(ans if ans < impossible else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 69000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int n;  
  cin>>n;
  int a[200005];
  rep(i,n) cin>>a[i];
  int keta=0;
  while(1){
    int cnt1=0;
    int end=0;
    rep(i,n){
      if(a[i]>=(1<<keta)) cnt1+=(a[i]>>keta)&1;
      if(a[i]<=(1<<(keta+1))-1) end++;
    }
    if(cnt1%2==1){
      rep(i,n){
	a[i]^=1<<keta;
      }
    }
    keta++;
    if(end==n) break;
    //printf("%d %d\n",cnt1,keta);
  }
  rep(i,n) cout<<a[i]<<' ';
  cout<<endl;
  return 0;
}


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

int main(void)
{
    int N;
    std::cin >> N;
    std::vector<int> s(N);

    for (int i = 0; i < N; i++) std::cin >> s[i];

    std::sort(s.begin(), s.end());

    int total = std::accumulate(s.begin(), s.end(), 0);
    if (total % 10 == 0) {
        for (auto x: s) {
            if ((total - x) % 10 != 0) {
                total -= x;
                goto print;
            }
        }
        total = 0;
    }
print:
    std::cout << total << std::endl;
    // std::copy(s.begin(), s.end(), std::ostream_iterator<int>(std::cout, ", "));

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!

int a[200001];
ii b[200001];
int ans[200001];
int main(){
	int n;
	ri(n);
	FOR(i,0,n){
		ri(a[i]);
		b[i]={a[i],i};
	}
	int an1,an2;
	sort(b,b+n);
	an1=b[n/2-1].F;
	an2=b[n/2].F;
	FOR(i,0,n){
		int num = a[i];
		if(num<=an1){
			printf("%d\n",an2);
		}else if(num>an1){
			printf("%d\n",an1);
		}
	}

}

Measured memory_bytes: 4480
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
        
A, B, C, D = map(int, input().split())
lcm = int(C * D / gcd(C, D))

num_B_C = B // C
num_B_D = B // D
num_B_CD = B // (lcm)

num_A_C = (A-1) // C
num_A_D = (A-1) // D
num_A_CD = (A-1) // (lcm)

num_all = (num_B_C - num_A_C) + (num_B_D - num_A_D) - (num_B_CD - num_A_CD)
result = (B - (A-1)) - num_all

print(result)

Measured memory_bytes: 38256
import java.io.*;

class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	    String st = sc.readLine();
	    int n = Integer.valueOf(st);
	    for(int i=0; i<n; i++){
		String[] pt = sc.readLine().split(" ");
		double[] a = new double[8];
		for(int j=0; j<8; j++)
		    a[j] = Double.valueOf(pt[j]);
		if((a[3]-a[1])/(a[2]-a[0]) == (a[7]-a[5])/(a[6]-a[4]))
		    System.out.println("YES");
		else
		    System.out.println("NO");
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    rep(i,n) std::cin >> a[i];

    ll kane = 1000, kabu = 0;
    for(int i=0; i<n-1; i++){
        ll kabu = 0;
        if(a[i]<a[i+1]) kabu = kane/a[i];
        kane += (a[i+1]-a[i])*kabu;
    }

    std::cout << kane << "\n";
    return 0;
}


Measured memory_bytes: 3608
import itertools

N = int(input())
Q = tuple(map(lambda x: int(x)-1,input().split()))
P = tuple(map(lambda x: int(x)-1,input().split()))

a = 0
for _ in itertools.permutations(range(N)):
    if not(_ > Q) and not(_ < Q):
        break
    a += 1

b = 0
for _ in itertools.permutations(range(N)):
    if not(_ > P) and not(_ < P):
        break
    b += 1

print(abs(a-b))

Measured memory_bytes: 3064
N,M = map(int,input().split())
py = [list(map(int,input().split()))+[i] for i in range(M)]
py.sort()
P = py[0][0]
c = 0
ans = []
for p,y,i in py:
    if p == P:
        c += 1
    else:
        P = p
        c = 1
    ansc = str(c)
    ansp = str(p)
    anser = "0" * (6-len(ansp)) + ansp + "0" *(6-len(ansc)) + ansc
    ans.append([i,anser])
ans.sort()
for i,anser in ans:
    print(anser)

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

int main() {
  int n; cin >> n;
  vector<string> s(n);
  for(int i = 0;i < n; i++){
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  int out = 1;
  for(int i = 1; i < n; i++){
    if(s.at(i - 1) != s.at(i)) out++;
  }
  cout << out;
}


Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll d = s.size();
    if (k > d) {
        cout << 0 << endl;
        return 0;
    }
    // dp[i][j][hoge] : 下から i 桁まで決定して non-zero が j コで s 以下の個数
    // hoge == 0 : i 桁目まで s に全一致, 1 : どこかで不一致
    vector<vvll> dp(d + 1, vvll(k + 1, vll(2)));
    // 0
    dp[0][0][0] = 1;
    REP(i, d) {
        REP(j, k + 1) {
            REP(x, 2) {
                REP(nxt, 10) {
                    ll nj = j, nx = x;
                    if (nxt) nj++;
                    if (nj > k) continue;
                    if (nxt > s[i] - '0' && x == 0) continue;
                    if (nxt < s[i] - '0') nx = 1;
                    dp[i + 1][nj][nx] += dp[i][j][x];
                }
            }
        }
    }
    ll res = dp[d][k][0] + dp[d][k][1];
    cout << res << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll dfs(vvl &dp, vvi &v, int i, int c, int p) {
	if (dp[i][c] != -1)return dp[i][c];
	ll ret = 1;

	REP(j, v[i].size()) {
		if (v[i][j] == p)continue;
		ret *= dfs(dp,v, v[i][j], 1, i);
		ret %= MOD;
	}

	if (c == 1) {
		ll tmp = 1;
		REP(j, v[i].size()) {
			if (v[i][j] == p)continue;
			tmp *= dfs(dp,v, v[i][j], 0, i);
			tmp %= MOD;
		}
		ret += tmp;
		ret %= MOD;
	}
	return dp[i][c] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vvi v(n);
	REP(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vvl dp(n, vl(2, -1));
	dfs(dp, v, 0, 1, -1);
	cout << dp[0][1] << endl;
}

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

int main() {
	long int N, X;
	cin >> N >> X;
	vector<long int> vec (N);
	for(long int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	
	long int dummy = 0;
	long int count = 0;
	for(long int i = 1;i < N;i++){
		if(vec.at(i) + vec.at(i-1) - min(dummy,vec.at(i-1)) > X){
			dummy = (vec.at(i) + vec.at(i-1) - min(dummy,vec.at(i-1))) - X;
			count += dummy;
		}
		else{
			dummy = 0;
		}
	}
	cout << count << endl;
}

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

int main(void){
    unsigned long long h,w;
    cin >> h >> w;
    if ((h==1) || (w==1)){
        cout << "1" << endl;
        return 0;
    }else{
        unsigned long long ret = 0;
        ret += (h / 2) * w;
        if ((h % 2) == 1){
            ret += (w + 1) / 2;
        }
        cout << ret << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i] << " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    ll a,b,c,d,e,f,g,n,m,k,t,p,x;
 
    ll mod = 998244353;
 
   


    void solve(){
        cin >> n >> m;
        cout << (n*(n-1)/2) + (m * (m-1)/2) << endl;
    }
 
 
 
    int main(){
        ios_base::sync_with_stdio(false);
     
        int cases = 1; 
        //cin >> cases;

        while(cases--){
            solve();
        }
        return 0;
 
    }

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

using namespace std;

int main() {
	int N;
	int syogen[15][15] = {};
	cin >> N;
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)syogen[i][j] = -1;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		for (int j = 0; j < A; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			syogen[i][x] = y;
		}
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if ((bit >> j) % 2 == 1)cnt++;
		}

		bool f = true;
		for (int i = 0; i < N; i++) {
			if ((bit >> i) % 2 == 0)continue;
			for (int j = 0; j < N; j++) {
				if (i == j)continue;
				if (syogen[i][j] == -1)continue;
				if ((syogen[i][j] == 0 && (bit >> j) % 2 == 1) || (syogen[i][j] == 1 && (bit >> j) % 2 == 0)) {
					f = false;
				}
			}
		}
		if (f) {
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  string op;
  cin >> a >> b;
  c= (a*b)%2;
  
  if (c == 0) {
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		while(true){
			var pf=new Pf(n);
			long p=0,q=0;
			pf.Get((k,v)=>{
				p++;
				q=k;
			});
			if(q==n&&p==1){break;}
			n++;
		}
		Console.WriteLine("{0}",n);
	}
}
public class Pf{
	public Dictionary<long,int> hs=new Dictionary<long,int>();
	public Pf(long n){
		if(n%2==0){
			int p=0;
			while((n&1)==0){n>>=1;p++;}
			hs.Add(2,p);
		}
		var q=(int)Sqrt(n)+1;
		for(int i=3;n!=1&&i<q;i+=2){
			if(n%i==0){
				int p=0;
				while(n%i==0){n/=i;p++;}
				q=(int)Sqrt(n)+1;
				hs.Add(i,p);
			}
		}
		if(n!=1){hs.Add(n,1);}
	}
	public void Get(Action<long,int> f){
		foreach(var e in hs){f(e.Key,e.Value);}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26660