akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long lli;
typedef vector<lli> vec;
typedef vector<vec> mat;

struct P{
  lli x, y;
  bool operator < (const P &p) const {
    return y == p.y ? x < p.x : y < p.y;
  }
};

const lli MOD = 1000000009;

lli modmul(lli a, lli b){
  return (((a * (b >> 20) % MOD) << 20) + a * (b & ((1 << 20) - 1))) % MOD;
}

void mul(const mat &a, const mat &b, mat &c){
  int n = a.size();

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      c[i][j] = 0;
      for(int k=0;k<n;k++){
        c[i][j] = (c[i][j] + modmul(a[i][k], b[k][j])) % MOD;
      }
    }
  }
}

vec mul(const vec &a, const mat &b){
  int n = a.size();
  vec c(n, 0);

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      c[i] = (c[i] + modmul(a[j], b[j][i])) % MOD;
    }
  }

  return c;
}

lli w, h;
int n;
P v[30];

void init_a(mat &a, mat a_pow[65]){
  a.assign(w, vec(w, 0));
  for(int i=0;i<w;i++){
    if(i - 1 >= 0) a[i][i-1] = 1;
    a[i][i] = 1;
    if(i + 1 < w) a[i][i+1] = 1;
  }

  a_pow[0].assign(w, vec(w, 0));
  a_pow[1] = a;
  for(int i=0;i<w;i++) a_pow[0][i][i] = 1;
  for(int i=2;i<65;i++){
    a_pow[i].assign(w, vec(w, 0));
    mul(a_pow[i-1], a_pow[i-1], a_pow[i]);
  }
}

mat pow(mat a, lli p, mat a_pow[65]){
  int n = a.size(), j = 0;
  mat C[2] = {mat(n, vec(n, 0)), mat(n, vec(n, 0))};

  for(int i=0;i<n;i++) C[0][i][i] = 1;

  for(int i=1;i<65;i++){
    if(p <= 0) break;
    if(p & 1) {
      mul(a_pow[i], C[j&1], C[!(j&1)]);
      j = !j;
    }
    p >>= 1;
  }

  return C[j&1];
}

lli solve(){
  lli pos = 1;
  int v_pos = 0;
  vec b(w, 0);
  vector<lli> obst_y;
  mat a;
  mat a_pow[65];

  init_a(a, a_pow);
  b[0] = 1;

  sort(v, v+n);
  for(int i=0;i<n;i++){
    if(v[i].y == 1) {
      v_pos++;
      continue;
    }
    if(obst_y.size() == 0 || obst_y[obst_y.size()-1] != v[i].y){
      obst_y.push_back(v[i].y);
    }
  }

  for(int i=0;i<obst_y.size();i++){
    b = mul(b, pow(a, obst_y[i]-pos, a_pow));
    for(;v_pos<n;v_pos++){
      if(v[v_pos].y != obst_y[i]) break;
      b[v[v_pos].x-1] = 0;
    }
    pos = obst_y[i];
  }
  b = mul(b, pow(a, h-pos, a_pow));

  return b[w-1];
}

int main(){
  int cnt = 1;

  while(1){
    scanf("%lld%lld%d",&w,&h,&n);
    if(w == 0 && h == 0) break;
    for(int i=0;i<n;i++){
      P p;
      scanf("%lld%lld",&p.x,&p.y);
      v[i] = p;
    }
    printf("Case %d: %lld\n",cnt++,solve());
  }
}

Measured memory_bytes: 4436
#include <stdio.h>
int t, n, p[1000001]; long long s[1000002];
int main() {
	for (int i = 0; i <= 1000000; i++) p[i] = i;
	for (int i = 2; i <= 1000000; i++) if (p[i] == i) for (int j = i; j <= 1000000; j += i) p[j] = p[j] / i * (i - 1);
	for (int i = 0; i <= 1000000; i++) s[i + 1] = s[i] + p[i];
	scanf("%d", &t);
	for (int i = 0; i < t; i++) scanf("%d", &n), printf("%lld\n", s[n + 1] + 1);
	return 0;
}

Measured memory_bytes: 14336
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	i := getNextInt(scanner)

	fmt.Fprintln(writer, n-i+1)
	writer.Flush()
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
int N, H, a[100001], b[100001], ans;
int main() {
  scanf("%d %d", &N, &H);
  for(int i = 1; i <= N; ++i) {
    scanf("%d %d", &a[i], &b[i]);
  }
  sort(a+1, a+N+1);
  sort(b+1, b+N+1);
  for(int i = N; i > 0; --i) {
    if(b[i] <= a[N]) break;
    H -= b[i]; ++ans;
    if(H <= 0) break;
  }
  while(H > 0) {
    H -= a[N]; ++ans;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 896
n = int(input())
FK = [2] * (n+1)
FK[0] = 0
FK[1] = 1

if n == 1:
    print(1)
elif n == 2:
    print(5)
else:
    FK[2] = 2
    for i in range(4, n+1, 2):
        FK[i] += 1

    for i in range(3, n+1):
        for j in range(i*2, n+1, i):
            FK[j] += 1

    ans = 0
    for i in range(1, n+1):
        ans += i*FK[i]
        
    print(ans)


Measured memory_bytes: 151548
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = (X-A)%B;
		System.out.println(C);
	}
}


Measured memory_bytes: 21588
n, m = map(int, input().split())
d = {i+1 : [] for i in range(n)}
for _ in range(m):
  a, b = map(int, input().split())
  d[a].append(b)
  d[b].append(a)
ans = 0
def go(c, rem):
  global ans
  if not len(rem):
    ans += 1
    return
  for cand in d[c]:
    if cand in rem:
      i = rem.index(cand)
      go(cand, rem[:i] + rem[i+1:])
go(1, list(range(2, n+1)))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
    a[i]--;
  }
  vector<ll> order(n, -1);
  vector<bool> vis(n, false);
  ll count = 0;
  ll st = -1;
  ll now;
  ll prev = 0;
  ll ans = -1;
  order[0] = a[0];
  vis[0] = true;
  bool flag = true;
  while(1){
    count++;
    now = a[prev];
    if (count == k){
      ans = now + 1;
      break;
    }
    if (vis[now] && flag){
      if (st == -1){
        st = count;
        vis = vector<bool>(n, false);
      }
      else{
        ll loop = count - st;
        k -= count;
        k %= loop;
        k += loop;
        count = 0;
        flag = false;
        vis = vector<bool>(n, false);
      }
    }
    vis[now] = true;
    prev = now;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <vector>
#define F first
#define S second
#define PLL pair<ll, ll>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
ll n;
ll a[200005];
ll b[200005];
ll d[200005];
ll s[200005];
vector<PLL> ve;

int main()
{
    scanf("%lld", &n);
    s[0] = d[0] = 1;
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        if(b[a[i]] > 0 && b[a[i]] < i - 1)
        {
            d[i] = s[b[a[i]]];
        }
        s[i] = s[i - 1] + d[i];
        s[i] %= M;
        b[a[i]] = i;
    }
    cout<<s[n]<<endl;
    return 0;
}


Measured memory_bytes: 6528
a, b, c, d = map(int, input().split(' '))
res1 = a // c
res2 = a // d
res3 = b // c
res4 = b // d
tmp1 = c
tmp2 = d
if tmp1 < tmp2:
    while tmp1:
        tmp = tmp1
        tmp1 = tmp2 % tmp1
        tmp2 = tmp
    result = tmp2
else:
    if tmp1 >= tmp2:
        while tmp2:
            tmp = tmp2
            tmp2 = tmp1 % tmp2
            tmp1 = tmp
        result = tmp1
result = c * d // result
res5 = a // result
res6 = b // result
i = res3 - res1
j = res4 - res2
k = res6 - res5
if a % c == 0:
    i += 1
if a % d == 0:
    j += 1
if a % result == 0:
    k += 1

print(b - a - i - j + k + 1)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<queue>
int X,Y,Z;
struct item{
	int A,B,C;
	bool operator<(const item&it)const{return C-B<it.C-it.B;}
}items[100010];
long long SB[100010],SC[100010];
void get_SB(){
	std::priority_queue<int>Q;
	long long s=0;
	for(int i=0;i<X+Y+Z;i++){
		Q.push(items[i].A-items[i].B);
		s+=items[i].B;
		if(Q.size()>Y)s+=Q.top(),Q.pop();
		SB[i+1]=s;
	}
}
void get_SC(){
	std::priority_queue<int>Q;
	long long s=0;
	for(int i=X+Y+Z;i--;){
		Q.push(items[i].A-items[i].C);
		s+=items[i].C;
		if(Q.size()>Z)s+=Q.top(),Q.pop();
		SC[i]=s;
	}
}
int main(){
	scanf("%d%d%d",&X,&Y,&Z);
	for(int i=0;i<X+Y+Z;i++)scanf("%d%d%d",&items[i].A,&items[i].B,&items[i].C);
	std::sort(items,items+X+Y+Z);
	get_SB();
	get_SC();
	long long ans=-1ll<<62;
	for(int i=Y;i<=X+Y;i++)if(SB[i]+SC[i]>ans)ans=SB[i]+SC[i];
	printf("%lld\n",ans);
}

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

int main(){
    long long x,y;
    cin>>x>>y;
    long long ans=0;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	
	int  n;
	cin>>n;
	
	long long ans=0;
	
	for(int i=0;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans=ans+i;
		}
	}
	
	cout<<ans;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 200010;
int p[limit], d[limit];

int smin[limit], smax[limit];

bool is_sorted(int a, int b){
	const int n = b - a + 1;
	int val = 0;
	if(b - 1 >= 0) val += d[b - 1];
	if(a - 1 >= 0) val -= d[a - 1];
	return (val + 1) == n; 
}

int main(void){
	int n, k;
	cin >> n >> k;
	rep(i, n) cin >> p[i];

	rep(i, n - 1){
		if(i - 1 >= 0) d[i] += d[i - 1];
		d[i] += (p[i] < p[i + 1]);
	}

	deque<int> deq;

	const int inf = 1 << 20;

	rep(i, n){
		if(i - k + 1 >= 0 and !deq.empty() and deq.front() == p[i - k + 1]) deq.pop_front();
		while(!deq.empty()and deq.back() > p[i]) deq.pop_back();
		deq.push_back(p[i]);
		smin[i] = (deq.empty()) ? inf :deq.front();
	}	

	deq.clear();

	rep(i, n){
		if(i - k + 1 >= 0 and !deq.empty() and deq.front() == p[i - k + 1]) deq.pop_front();
		while(!deq.empty()and deq.back() < p[i]) deq.pop_back();
		deq.push_back(p[i]);
		smax[i] = (deq.empty()) ? inf :deq.front();
	}

	int ans = n - k + 1;
	int sorted_num = 0;

	rep(i, n - k){
		const int amin = p[i];
		const int amax = p[i + k];
		const int bmin = smin[i + k - 1];
		const int bmax = smax[i + k - 1];
		bool sorted = is_sorted(i, i + k);
		if(sorted == false and amin < bmin and bmax < amax) ans--;
	}

	rep(i, n - k + 1){
		if(is_sorted(i, i + k - 1)){
			ans--;
			sorted_num++;
		}
	}

	if(sorted_num) ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int ABCD;
  cin >> ABCD;
  vi num(4);
  num.at(3) = ABCD % 10;
  ABCD /= 10;
  num.at(2) = ABCD % 10;
  ABCD /= 10;
  num.at(1) = ABCD % 10;
  ABCD /= 10;
  num.at(0) = ABCD % 10;
  for(int i = 0; i < (1<<3); i++){
    int res = num.at(0);
    int aa = num.at(0)+'0';
    string ans = "";
    ans += (char)aa;
    for(int j = 0; j < 3; j++){
      if((i>>j) & 1){
        ans += '+';
        res += num.at(j+1);
        ans += num.at(j+1)+'0';
      }
      else{
        ans += '-';
        res -= num.at(j+1);
        ans += num.at(j+1)+'0';
      }
    }
    if(res == 7){
      cout << ans << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, m ;
    cin >> n >> m ;
    string s = "", t = "" ;
    rep(i, 0, m) {
        s += (char)(n+48) ;
    }
    rep(i, 0, n) {
        t += (char)(m+48) ;
    }
    if(s < t) cout << s << endl ;
    else cout << t << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int a[100005]={},b[100005]={};
    int n;
    cin >> n;
    rep(i,n){
        int tmp;
        cin >> tmp;
        if(i%2)b[tmp]++;
        else a[tmp]++;
    }
    int ma=0,mb=0,res=0,ia,ib,ma2,mb2;
    rep(i,100005){
        res+=a[i];
        if(ma<=a[i]){
            ma2=ma;
            ma=a[i];
            ia=i;
        }else if(ma2<=a[i])ma2=a[i];
    }
    rep(i,100005){
       res+=b[i];
        if(mb<=b[i]){
            mb2=mb;
            mb=b[i];
            ib=i;
        }else if(mb2<=b[i])mb2=b[i];
    }
    if(ia==ib)cout << min(res-ma-mb2,res-ma2-mb) << endl;
    else cout << res-ma-mb << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int n,k; cin >> n >> k;
  cout << n-k+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    s1[0] += 'A' -'a';
    s2[0] += 'A' -'a';
    s3[0] += 'A' -'a';
    cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;

const int Mod = (int)1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    for (string &str : grid)
        cin >> str;
    vector<vector<int>> left(n, vector<int>(m)), right(n, vector<int>(m)), up(n, vector<int>(m)), down(n, vector<int>(m));


    for (int i = 0; i < n; ++i) {
        int cur = -1;
        for(int j = 0; j < m; ++j) {
            if (grid[i][j] == '#') {
                cur = j;
            } else {
                left[i][j] = cur;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        int cur = m;
        for(int j = m - 1; j >= 0; --j) {
            if (grid[i][j] == '#') {
                cur = j;
            } else {
                right[i][j] = cur;
            }
        }
    }
    for (int j = 0; j < m; ++j) {
        int cur = -1;
        for(int i = 0; i < n; ++i) {
            if (grid[i][j] == '#') {
                cur = i;
            } else {
                up[i][j] = cur;
            }
        }
    }
    for (int j = 0; j < m; ++j) {
        int cur = n;
        for(int i = n - 1; i >= 0; --i) {
            if (grid[i][j] == '#') {
                cur = i;
            } else {
                down[i][j] = cur;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (grid[i][j] != '#') {
//                cout << i << ' ' << j << ' ' << left[i][j] << ' ' << right[i][j] << endl;
                ans = max(ans, right[i][j] - left[i][j] + down[i][j] - up[i][j] - 3);
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 67328
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

double dp[105][105];
double g[105][105];

double solve(int n, int m){
    rep(i,n) dp[0][i] = 1;
    range(day,1,m){
        rep(now,n){
            rep(before,n){
                dp[day][now] = max(dp[day][now], dp[day - 1][before] * g[before][now]);
            }
        }
    }

    double retval = 0;
    rep(i,n){
        retval = max(dp[m - 1][i], retval);
    }

    return retval;
}

int main(){
    int n, m;
    while(cin >> n >> m, n||m){
        rep(i,105) rep(j,105) dp[i][j] = 0;
        rep(i,n) rep(j,n) cin >> g[i][j];
        printf("%.2lf\n", solve(n, m));
    }
}

Measured memory_bytes: 1416
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<vector>
using namespace std;
int n,k;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	int Gcd,Max;
	scanf("%d",&Gcd);
	Max=Gcd;
	for(int i=2,x;i<=n;++i){
		scanf("%d",&x);
		Max=max(Max,x);
		Gcd=__gcd(Gcd,x);
	}
	if(k%Gcd==0&&k<=Max)puts("POSSIBLE");
		else puts("IMPOSSIBLE");
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
# Problem C - Tsundoku

# input
N, M, K = map(int, input().split())
a_nums = list(map(int, input().split()))
b_nums = list(map(int, input().split()))

# initialization
max_count = 0
b_i = M
a_cums = [0]*(N+1)
b_cums = [0]*(M+1)
for i in range(1, N+1):
    if i>1:
        a_cums[i] = a_cums[i-1] + a_nums[i-1]
    else:
        a_cums[i] = a_nums[i-1]
for i in range(1, M+1):
    if i>1:
        b_cums[i] = b_cums[i-1] + b_nums[i-1]
    else:
        b_cums[i] = b_nums[i-1]

for i in range(N+1):
    if a_cums[i]<=K:
        while b_i>0 and a_cums[i]+b_cums[b_i]>K:
            b_i -= 1
        if i+b_i>max_count:
            max_count = i+b_i

# output
print(max_count)


Measured memory_bytes: 47484
from functools import reduce
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)

N = int(input())
T = [int(input()) for _ in range(N)]

print(reduce(lcm, T))

Measured memory_bytes: 3572
import sys
a,b,c=map(int,input().split()) 
if a==b :
    if a==c:
        print('No')
        sys.exit()
    else:
        print('Yes')
        sys.exit()
if b==c:
    print('Yes')
    sys.exit()

if a==c:
    print('Yes')
    sys.exit()
    
print('No')

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

using namespace std;

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

#define sz(a) int(a.size())

#define dbg(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {
    cerr << str << " : " << t << "\n";
}
template <class T, class... S> void dbs(string str, T t, S... s) {
    int idx = str.find(',');
    cerr << str.substr(0, idx) << " : " << t << ",";
    dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator <<(ostream& os, const pair<S, T>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template <class T> void debug(T a, T b) {
    cerr << "[";
    for (T i = a; i != b; ++i) {
        if (i != a) cerr << ", ";
        cerr << *i;
    }
    cerr << "]\n";
}

ll getCount(ll n, ll p) {
    ll ret = 0;
    ll q = p;
    while (n >= q) {
        ret += n / q;
        if (q <= n / p) {
            q *= p;
        } else {
            break;
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll ai, ao, at, aj, al;
    cin >> ai >> ao >> at >> aj >> al;
    ll ans = ao;
    for (ll i = 0; i <= ai and i <= aj and i <= al; ++i) {
        ll x = ai - i;
        ll y = aj - i;
        ll z = al - i;
        ll cur = ao + i * 3 + x - (x & 1) + y - (y & 1) + z - (z & 1);
        ans = max(ans, cur);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, A, B, C, D;
string S;

int main() {
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    cin >> S;

    for (int i = A; i <= C - 1; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = B; i <= D - 1; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    if (C < D) {
        cout << "Yes" << endl;
        return 0;
    } else {
        for (int i = B - 1; i <= D - 1; i++) {
            if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n), ac(n, 0), ar;
  unordered_set<ll> st;
  rep(i, n) cin >> a[i], a[i]--;

  ll next = 0, cnt1 = 0, cnt2 = 0;
  st.insert(0);
  ar.push_back(0);
  while (1) {
    next = a[next];
    st.insert(next);
    ar.push_back(next);
    // cout << next << endl;
    ac[next]++;
    if (ac[next] >= 2) cnt2++;
    if (ac[next] >= 3) break;
  }

  ll cnt = k - ((ll)st.size() - cnt2 + 1);
  cnt1 = cnt % (cnt2 - 1);
  // cout << "cnt: " << cnt << endl;

  // rep(i, ar.size()) cout << ar[i] << " ";
  // cout << endl;

  ar.resize(st.size());
  // rep(i, ar.size()) cout << ar[i] << " ";
  // cout << st.size() << endl;
  // cout << cnt2 - 1 << endl;

  if (k <= (ll)st.size() - cnt2 + 1)
    cout << ar[k] + 1 << endl;
  else
    cout << ar[(ll)st.size() - cnt2 + 1 + cnt1] + 1 << endl;
  return 0;
}


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

int main(){
  string T;
  cin >> T;
  while(T != ""){
    if(T.length() < 5){
      cout << "NO" << endl;
      return 0;
    }else if(T.substr(T.size() - 5) == "dream"){
      T = T.substr(0,T.length() - 5);
    }else if(T.substr(T.size() - 5) == "erase"){
      T = T.substr(0,T.length() - 5);
    }else if(T.substr(T.size() - 6) == "eraser"){
      T = T.substr(0,T.length() - 6);
    }else if(T.substr(T.size() - 7) == "dreamer"){
      T = T.substr(0,T.length() - 7);
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

#define MAX 5


int main()
{
	int i,j,t;
	int str[MAX];

	for (i = 0; i < 5; i++)
	{
		scanf("%d", &str[i]);
	}
	
		for (i = 0; i < 4; i++)
		{
			for (j = i + 1; j < 5; j++)
			{
				if (str[i] < str[j])
				{
					t = str[i];
					str[i] = str[j];
					str[j] = t;
				}
			}
		}
		for (i = 0; i < 5; i++)
		{
			if (i)
			{
				putchar(' ');
			}
			printf("%d",str[i]);
		}
		printf("\n");

	
	return 0;
}


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

const ll INF = 1e15;

main(){
    ll n;
    cin >> n;
    char f1;
    ll f2;
    ll ind_w[n];
    ll ind_b[n];
    pair<ll,ll>  a[n+n];

    for(int i=0;i<n+n;++i){
        cin >> f1 >> f2;
        if(f1 == 'W'){
            ind_w[f2] = i;
            a[i] = {0,f2};
        }
        else{
            ind_b[f2] = i;
            a[i] = {1,f2};
        }
    }


    vector<vector<pair<int,int>>> grater_left(n+1);

    for(int i=0;i<=n;++i){
        vector<pair<int,int>> pref(n+n, {0,0});
        for(int j=0;j<n+n;++j){
            pref[j].first = pref[max(j-1, 0)].first;
            pref[j].second = pref[max(j-1,0)].second;
            if(a[j].first == 0){
                pref[j].first += (a[j].second>i);
            }
            else{
                pref[j].second += (a[j].second>i);
            }
        }
        grater_left[i] = pref;
    }


    ll dp[n+1][n+1];

    dp[0][0] = 0;

    for(int i=1;i<=n;++i){
        dp[0][i] = dp[0][i-1] + grater_left[i][ind_w[i]].first + grater_left[0][ind_w[i]].second;
    }

    for(int i=1;i<=n;++i){
        dp[i][0] = dp[i-1][0] + grater_left[i][ind_b[i]].second + grater_left[0][ind_b[i]].first;
    }

    for(int i=1;i<n+1;++i){
        for(int j=1;j<n+1;++j){
            dp[i][j] = min(dp[i-1][j] + grater_left[i][ind_b[i]].second + grater_left[j][ind_b[i]].first    , dp[i][j-1] + grater_left[j][ind_w[j]].first + grater_left[i][ind_w[j]].second);
            //cout << i << ' ' << j << dp[i]
        }
    }
    cout << dp[n][n];
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VP vec;
    rep(i,n){
        ll x, l;
        cin >> x >> l;
        vec.push_back({x + l, x - l});
    }
   /* rep(i,n){
        cout<<vec[i].F<<" "<<vec[i].S<<endl;
    }*/
    sort(all(vec));
    ll ans = 0;
    ll t = -1e18;
    rep(i,n){
        if(t<=vec[i].S){
            ans++;
            t = vec[i].F;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans = "Yes";
    if (s.size() % 2 == 1) ans = "No";
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 1) {
            if (s[i] != 'i') ans = "No";
        } else {
            if (s[i] != 'h') ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int ans = 1;
        int count = 0;
        for (int i=0;i<n;i++) {
            count+=sc.nextInt();
            if (count<=x)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35972
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf-8').split(' ');
const a: number = parseInt(input[0]);
const b: number = parseInt(input[1]);
const x: number = parseInt(input[2]);


if (x <= a * a * b / 2) { // 三角
  const y = x * 2 / (b * a);
  const ans = Math.atan(b / y);
} else { // 台形
  const b2 = x * 2 / (a * a) - b;
  const ans = Math.atan((b - b2) / a);
}
    
console.log(ans * 180 / Math.PI);

Measured memory_bytes: 11468
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <functional>
using namespace std;

int N, L[100009], S;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) { cin >> L[i]; S += L[i]; }
	sort(L, L + N);
	if (S - L[N - 1] > L[N - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

# stdin = open("testdata.txt", "r")
n, k = map(int, sys.stdin.readline().split())

def solve(n, k):
	mx = (n-1)*(n-2)//2
	isolated = [(i, j) for i in range(2, n) for j in range(i+1, n+1)]
	edges = [(1, j) for j in range(2, n+1)]
	while mx != k:
		edge = isolated.pop()
		edges.append(edge)
		mx -= 1
	return edges

if k > (n-1)*(n-2)//2:
	print(-1)
else:
	res = solve(n, k)
	print(len(res))
	for edge in res:
		print(*edge)

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

void solve(std::string S)
{
    int res = 0;
    for (size_t i = 0; i < S.length(); i++)
    {
        if (S[i] == '+')
        {
            res++;
        }
        else
        {
            res--;
        }
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
const ll INF = 1001001001;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int cnt = 0;
  int cntb = 0;
  rep(i,n){
    if(s[i]=='a'){
      if(cnt<a+b){
        cout << "Yes" << endl;
        cnt++;
      }
      else cout << "No" << endl;
    }
    if(s[i]=='b'){
      if((cnt<a+b)&&(cntb<b)){
        cout << "Yes" << endl;
        cnt++; cntb++;
      }
      else cout << "No" << endl;
    }
    if(s[i]=='c'){
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3784
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    int t = 0;
    cin >> a;
    cin >> b;
    if(b>=a)
    {
        cout << a;

    }
    if(b<a)
    {
        cout << a-1;
    }
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, w, a[1 << 18], b[1 << 18], c[1 << 18];

inline int add(int x, int y) {
	x += y; return x < mod ? x : x - mod;
}
inline int dec(int x, int y) {
	x -= y; return x < 0 ? x + mod : x;
}
inline int mul(int x, int y) {
	return 1ll * x * y % mod;
}
inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

void fwt(int *a) {
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 1 << n; ++j)
			if (j >> i & 1) {
				int x = a[j ^ (1 << i)], y = a[j];
				a[j ^ (1 << i)] = add(x, y); a[j] = dec(x, y);
			}
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 1 << n; ++i) {
		scanf("%d", &a[i]); w += a[i];
	}
	w = fpow(w, mod - 2);
	for (int i = 0; i < 1 << n; ++i) {
		a[i] = dec(0, mul(a[i], w));
		b[i] = 1;
	}
	c[0] = dec(0, 1 << n); 
	a[0] = add(a[0], 1);
	fwt(a); fwt(b); fwt(c);
	for (int i = 1; i < 1 << n; ++i) {
		a[i] = mul(add(b[i], c[i]), fpow(a[i], mod - 2));
		a[0] = dec(a[0], a[i]);
	}
	fwt(a);
	w = fpow(1 << n, mod - 2);
	for (int i = 0; i < 1 << n; ++i)
		printf("%d\n", mul(a[i], w));
}


Measured memory_bytes: 5888
n = gets.to_i
s = {}
n.times{
    tmp = gets.chop
    s[tmp] = (s[tmp] ? s[tmp] + 1 : 1)
}

m = gets.to_i
m.times{
    tmp = gets.chop
    s[tmp] = (s[tmp] ? s[tmp] - 1 : -1)
}

ans = 0
s.map{|k, v|
    ans = v if ans < v
}
p ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int month,day;
    month = (s[5]-'0')*10+(s[6]-'0');
    day = (s[8]-'0')*10+(s[9]-'0');
    if(month<5){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}

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

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (x&1) ans ^= 1;
	}
	if (!ans) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, x;
  cin >> N >> x;
  if (x == 1 || x == N * 2 - 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    vl ans;
    if (x == N)
      REP(i, N * 2 - 1) cout << i + 1 << endl;
    else if (x < N) {
      REP(i, N - 1) {
        if (i + 2 == x)
          continue;
        cout << i + 2 << endl;
      }
      cout << 1 << endl;
      cout << x << endl;
      cout << (2 * N) - 1 << endl;
      REP(i, N - 2) cout << i + N + 1 << endl;
    } else {
      REP(i, N - 2) cout << i + 2 << endl;
      cout << 1 << endl;
      cout << x << endl;
      cout << (2 * N) - 1 << endl;
      REP(i, N - 1) {
        if (i + N == x)
          continue;
        cout << i + N << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int W,H,N;
    cin >> W >> H >> N;
    vector<vint> S(H,vint(W,0));
    vector<pair<int,int>> P;
    vint A;
    REP(i,N){
        int x,y,a;
        cin >> x >> y >> a;
        P.pb({x,y});
        A.pb(a);
    }

    REP(i,N){
        switch(A[i]){
        case 1:
            REP(j,H){
                REP(k,P[i].first){
                    S[j][k] = 1;
                }
            }
            break;
        case 2:
            REP(j,H){
                for(int k=P[i].first; k<W; k++){
                    S[j][k] = 1;
                }
            }
            break;
        case 3:
            REP(j,P[i].second){
                REP(k,W){
                    S[j][k] = 1;
                }
            }
            break;
        case 4:
            for(int j=P[i].second; j<H; j++){
                REP(k,W){
                    S[j][k] = 1;
                }
            }
            break;
        default:
            break;
        }
    }
    int cnt = 0;
    REP(i,H){
        REP(j,W){
            if(S[i][j] == 0){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, r;
int ans;

int main() { 

  cin >> n >> r;

  if (n >= 10) {
    ans = r;
  } else {
    ans = r + 100 * (10 - n);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

string num;
int k;

int dfs(int idx,bool limit,int k){
	if(k<0) return 0;
	if(k==0) return 1;
	if(idx==0) {
		if(k>1) return 0;
		else if(k==0) return 1;
		else {
			if(limit) return num[idx]-'0';
			else return 9;
		} 
	}
	int up = limit? num[idx]-'0' : 9;
	if(up==0) return dfs(idx-1,limit,k);
	else if(limit) return dfs(idx-1,limit,k-1)+dfs(idx-1,false,k-1)*(up-1)+dfs(idx-1,false,k);
	else return dfs(idx-1,false,k-1)*up + dfs(idx-1,false,k);

}

int main(){
	//freopen("in","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> num >> k;
	reverse(num.begin(),num.end());
	int res = dfs(num.size()-1,true,k);
	cout << res << endl;
}

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

int fen[100005];
int a[100005];
int b[100005];
int n;
void ref(){
	for(int i = 1 ; i <= n ; i ++)
		fen[i] = 0;
}
void upd(int p, int val){
    for(int i = p; i <= n; i += i & -i)
        fen[i] += val; 
}

int sum(int p) {
    int ans = 0;
    for(int i = p; i; i -= i & -i)
        ans += fen[i];
    return ans;
}
bool f(int u){
	ref();
	int ans = 0;
	vector<pair<int,int> > vp;
	for(int i = 1 ; i <= n ; i ++){
		b[i] = b[i - 1] + (a[i] >= u ? 1 : -1);
		if(b[i] >= 0) ans ++;
		vp.push_back({b[i], i});
	}
	sort(vp.begin(), vp.end());
	for(pair<int,int> p: vp){
		ans += sum(p.second);
		upd(p.second, 1);
	}
	return ans >= (n*(n + 1)/4);
}
signed main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i];
	int L = *min_element(a + 1, a + n + 1);
	int R = *max_element(a + 1, a + n + 1);
	while(L < R){
		//cout << L  << " " << R << endl;
		if(L == R - 1){
			if(f(R)) L = R;
			else R = L;
		}
		int M = (L + R) >> 1;
		if(f(M)) L = M;
		else R = M - 1;
	}
	cout << L;
}


Measured memory_bytes: 6260
n = int(input())

dp = [[0 for _ in range(3)] for _ in range(n)]

a, b, c = map(int, input().split())
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c

for i in range(1, n):
    abc = [int(x) for x in input().split()]
    
    for j in range(len(abc)):
        dp[i][j] = max(dp[i - 1][(j + 1) % 3] + abc[j], dp[i - 1][(j + 2) % 3] + abc[j])

print(max(dp[n - 1]))

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

int main(){
    int H, W;
    cin >> H >> W;
    string mojiretu;

    vector <string> sharp (W + 2);

    for (int i = 0; i < W + 2; i++){
        sharp.at(i) = "#";
    }
    for (int i = 0; i < W + 2; i++){
        cout << sharp.at(i);
    }
    cout << endl;
    for (int i = 0; i < H; i++){
        cin >> mojiretu;
        cout << "#" << mojiretu << "#" << endl;
    }

    for (int i = 0; i < W + 2; i++){
        cout << sharp.at(i);
    }
    cout << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits.h>

using namespace std;

int n, num[26] = {}, now[26] = {};
char s[51];

int main(){
	for (int i = 0; i < 26; i++){
		num[i] = INT_MAX;
	}

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

		int a = 0;
		while (s[a] != 0){
			now[s[a] - 'a']++;
			a++;
		}

		for (int i = 0; i < 26; i++){
			num[i] = min(now[i], num[i]);
			now[i] = 0;
		}
	}

	for (char i = 'a'; i <= 'z'; i++){
		for (int j = 1; j <= num[i -'a']; j++){
			cout << i;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N; cin >> N;
    ll MAX = 1000000000000000000;
    ll ans = 1;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0){
            printf("0\n");
            return 0;
        }
    }

    for(ll i = 0; i < N; i++){
        if((MAX / A[i]) / ans == 0){
            printf("-1\n");
            return 0;
        }
        ans = ans * A[i];
    }

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


Measured memory_bytes: 3980
#include <iostream>
using namespace std;
#include<algorithm>
#include<vector>
int main(){
    int p,a=0;
    cin>>p;
    if(3<=p&&p<=20){
    vector<int>n(p);
    for(int i=0;i<p;i++){
        cin>>n.at(i);
    }
    for(int i=0;i<p-2;i++){
        if(n.at(i)<n.at(i+1)&&n.at(i+1)<n.at(i+2)){
            a++;
        }
        else if(n.at(i)>n.at(i+1)&&n.at(i+1)>n.at(i+2)){
            a++;
        }
    }
    std::cout << a << std::endl;
}}

Measured memory_bytes: 3620
package main

import "fmt"

func main(){
	var S string
	var a[200] int
	var i, count int
	var x string

	fmt.Scan(&S)

	for i = 0 ; i < len(S) ; i++ {
		a[S[i]]++
	}
	for i = 'a' ; i <= 'z' ; i++{
		if a[i] == 0 {
			break;
		}else {count++}
	}
	if count == 26{
		 fmt.Println("None")
	}else{
		x = string(i)
		 fmt.Println(x)
	}
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstring>
using namespace std;
#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)
#define REP(i,n)  FOR( i, 0, (n) - 1 )

int main(){
    int D;
    cin >> D;
    char a[30] = "Christmas";
    char b[] = " Eve";
    while(D++ < 25){
        strcat(a,b);
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemE
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var K = read[1];
            var maxK = N * (N - 1) / 2 - N + 1;
            var m = N - 1 + (maxK - K);
            if (K > maxK)
                Console.WriteLine(-1);
            else
            {
                var us = new List<int>();
                var vs = new List<int>();
                for (int i = 1; i < N+1; i++)
                {
                    for (int j = i+1; j < N+1; j++)
                    {
                        us.Add(i);
                        vs.Add(j);
                        if (us.Count() == m)
                            break;
                    }
                    if (us.Count() == m)
                        break;
                }
                Console.WriteLine(m);
                for (int i = 0; i < us.Count(); i++)
                {
                    Console.WriteLine(us[i] + " " + vs[i]);
                }
            }
        }
    }
}


Measured memory_bytes: 11348