akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int r, g, b, n;

int main(){
    cin >> r >> g >> b >> n;
    LL ans = 0;
    for(int i = 0;i <= 3000;i++){
        for(int j = 0;j <= 3000;j++){
            int k = n - i*r - j*g;
            if(k < 0)continue;
            if(k % b != 0)continue;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    
    string buff;
    cin >> buff;
    
    int pos=0,area=0;
    int sum[15]={};
    for(int i=0;i<buff.size();i++){
      if(buff[i] == 'M'){
	sum[pos]++;
      } else if(buff[i] == 'S'){
	area += (sum[pos]+1);
	sum[pos] = 0;
      } else{
	sum[pos] += (area+1);
	area = 0;
      }
      pos = (pos+1)%n;
    }
    sort(sum, sum+n);
    for(int i=0;i<n;i++){
      if(i != 0) cout << ' ';
      cout << sum[i];
    }
    cout << ' ' << area << endl;
  }

  return 0;
}



Measured memory_bytes: 3236
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char s[10];
int main()
{
	scanf("%s",s);
	if(s[1]==s[2]||s[2]==s[3]||s[0]==s[1])puts("Bad");
	else puts("Good");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int H1, M1, H2, M2, K;
int main(void){
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    if(H2 < H1) H2+=24;
    int s1 = 60*H1 + M1;
    int s2 = 60*H2 + M2;
    cout << s2 - s1 - K << endl;


    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M, Q;
	cin >> N >> M >> Q;
	string S[2000];
	rep(i, N) cin >> S[i];
	int B[2001][2001] = {};
	int C[2001][2001] = {};
	int D[2001][2001] = {};
	rep(i, N) {
		rep(j, M) {
			B[i + 1][j + 1] = B[i + 1][j] + S[i][j] - '0';
			if (i != 0) C[i + 1][j + 1] = C[i + 1][j] + ((S[i - 1][j] - '0') & (S[i][j] - '0'));
			if (j != 0) D[i + 1][j + 1] = D[i + 1][j] + ((S[i][j - 1] - '0') & (S[i][j] - '0'));
		}
	}
	rep(j, M) rep(i, N) {
		B[i + 1][j + 1] += B[i][j + 1];
		C[i + 1][j + 1] += C[i][j + 1];
		D[i + 1][j + 1] += D[i][j + 1];
	}
	
	rep(q, Q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int kotae;
		kotae = B[c][d] - B[c][b - 1] - B[a - 1][d] + B[a - 1][b - 1];
		kotae -= C[c][d] - C[c][b - 1] - C[a][d] + C[a][b - 1];
		kotae -= D[c][d] - D[c][b] - D[a - 1][d] + D[a - 1][b];
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 53504
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int x; cin>>x;
    int un=400;
    int up=599;
    int ans=8;
    for(int i=0;i<=8;i++){
        if((un+i*200)<=x && x<=(up+i*200)) cout<<ans-i<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	char s[10];
	int i;
	scanf("%s",&s);
	for(i=0;i<3;i++){
		if(s[i]==s[i+1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long INF=(long long)1e18;
int main(){
  long long n,res,ans;
  cin>>n;
  ans=INF;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      res=i+n/i;
      ans=min(ans,res);
    }
  }
  cout<<ans-2<<endl;
  return 0;
}

Measured memory_bytes: 3676
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

distance = abs(a-b)

if distance == 0:
    print("YES")
    exit()

if v <= w:
    print("NO")
else:
    fast = abs(v-w)
    if fast*t >= distance:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

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

	vector<char> a(s.size());
	vector<char> b(s.size());
	for(int i = 0; i < s.size(); i+=2){
		a.at(i) = '1';
		b.at(i) = '0';
	}
	for(int i = 1; i < s.size(); i+=2){
		a.at(i) = '0';
		b.at(i) = '1';
	}

	int diff_a = 0;
	int diff_b = 0;
	rep(i, s.size()){
		if(s.at(i) != a.at(i)){
			diff_a++;
		}else if(s.at(i) != b.at(i)){
			diff_b++;
		}
	}

	cout << min(diff_b, diff_a) << endl;
	return 0;
}

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

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

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

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

	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
		cout<<"Bad"<<endl;
	}else{
		cout<<"Good"<<endl;
	}


	return 0;
}


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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let N : isize = buf.trim().parse().unwrap();

    let mut A = vec![vec![vec![0;10];3];4];
    for _ in 0..N {
        buf.clear();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let B : usize = iter.next().unwrap().parse().unwrap();
        let F : usize = iter.next().unwrap().parse().unwrap();
        let R : usize = iter.next().unwrap().parse().unwrap();
        let V : isize = iter.next().unwrap().parse().unwrap();
        A[B - 1][F - 1][R - 1] += V;
    }
    for b in 0..4 {
        for f in 0..3 {
            for r in 0..10 {
                print!(" {}", A[b][f][r]);
            }
            println!();
        }
        if b < 3 {println!("####################");}
    }
}



Measured memory_bytes: 5028
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

fn main() {
    let (n, m) = (i::u(), i::u());
    let mut k = Vec::new();
    let mut s = Vec::new();
    for _ in 0..m {
        let t = i::u();
        k.push(t);
        s.push(i::uv(t));
    }
    let p = i::uv(m);

    let mut max = 1;
    for _ in 0..n {
        max *= 2;
    }
    let mut ans = 0;
    let mut i = 0;
    'case: while i < max {
        let mut l = i;
        let mut v = vec![false];
        for _ in 0..n {
            v.push(l % 2 == 0);
            l = l >> 1;
        }
        i += 1;

        for j in 0..m {
            let mut count = 0;
            for c in &s[j] {
                if v[*c] {
                    count += 1;
                }
            }
            //dbg!(&v, count);
            if count % 2 != p[j] {
                continue 'case;
            }
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define lb long double
using namespace std;


int main()
{
	ll n;
	cin >> n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin >>a[i];
	}
	ll d=0;
	
	for(int i=1;i<n-1;i++)
	{
		if((a[i]>a[i-1])&&(a[i]<a[i+1])) d++;
		else if((a[i]<a[i-1])&&(a[i]>a[i+1])) d++;
	}
	cout <<d;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String t = sc.next();
        for(int i = 0; i < t.length(); i++) {
            if(t.substring(i,i+1).equals("P")) {
                System.out.print("P");
            } else {
                System.out.print("D");
            }
        }
    }
}


Measured memory_bytes: 57860
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/


main :-
    get_number(N, M),
    get_numbers(M, Xs),
    sum_list(Xs, Y),
    Z is max(-1, N - Y),
    writeln(Z).


Measured memory_bytes: 8728
/*pata hai na?*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int a[3][3],mat[3][3];
    mem(a,0);
    mem(mat,0);
    for(int i=0;i<3;++i)
    {
        for(int j=0;j<3;++j)
            cin>>a[i][j];
    }

    int n;
    cin>>n;

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

        for(int j=0;j<3;++j)
        {
            for(int k=0;k<3;++k)
            {
                if(a[j][k]==b)
                {
                    mat[j][k]=1;
                    break;
                }
            }
        }
    }

    for(int i=0;i<3;++i)
    {
        bool fl=1;
        for(int j=0;j<3;++j)
        {
            if(!mat[i][j])
            {
                fl=0;
                break;
            }
        }

        if(fl)
        {
            cout<<"Yes";
            return;
        }
    }

    for(int i=0;i<3;++i)
    {
        bool fl=1;
        for(int j=0;j<3;++j)
        {
            if(!mat[j][i])
            {
                fl=0;
                break;
            }
        }

        if(fl)
        {
            cout<<"Yes";
            return;
        }
    }

    if((mat[0][0] && mat[1][1] && mat[2][2]) || (mat[2][0] && mat[1][1] && mat[2][0]))
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    set<seika> ans;
    auto dfs = [&](auto &&dfs, seika cur = "", int k = 0) -> void {
        if (k == n)
        {
            ans.insert(cur);
            return;
        }
        akari<int> flag(k + 1, 1);
        for (int i = 0; i < k; i++)
        {
            dfs(dfs, cur + cur[i], k + 1);
            flag[cur[i] - 'a'] = 0;
        }
        seika nx = cur;
        for (int i = 0; i <= k; i++)
        {
            if (flag[i])
            {
                nx += char('a' + i);
                break;
            }
        }
        dfs(dfs, nx, k + 1);
    };
    dfs(dfs);
    for (const seika &s : ans)
    {
        cout << s << endl;
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 14208
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		int sumPrice = 0;
		int cnt = 0;
		double sumCnt = 0;
		while(sc.hasNext()) {
			cnt++;
			Scanner s = new Scanner(sc.next().replaceAll(",", " "));
			int a = s.nextInt(), b = s.nextInt();
			sumPrice += a * b;
			sumCnt += b;
		}
		System.out.println(sumPrice);
		System.out.println((int)((sumCnt / cnt) + 0.5));
	}
}

Measured memory_bytes: 0
A, B, H, M = map(int,input().split())
import math
minute = H*60 +M

if (math.modf(minute/(180/5.5))[1])%2 ==0:
    theta = 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))
else:
    theta = 180 - 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))

ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))**(1/2)
print(ans)

Measured memory_bytes: 9524
#include <vector>
#include <bitset>
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
    for(;;){
        string s;
        getline(cin, s);
        if(s == ".")
            return 0;

        int n = s.size();
        stack<char> stk;
        bool ng = false;
        for(int i=0; i<n; ++i){
            if(s[i] == '(')
                stk.push(s[i]);
            if(s[i] == '[')
                stk.push(s[i]);
            if(s[i] == ')'){
                if(stk.size() == 0 || stk.top() != '('){
                    ng = true;
                    break;
                }
                stk.pop();
            }
            if(s[i] == ']'){
                if(stk.size() == 0 || stk.top() != '['){
                    ng = true;
                    break;
                }
                stk.pop();
            }
        }

        if(!ng && stk.empty())
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int x,h,m,s;
    scanf("%d",&x);
    h=x/(60*60);
    m=(x-h*(60*60))/60;
    s=x%60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
    
}


Measured memory_bytes: 2088
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  int counter[3]={0, 0, 0};
  int add_index;
  long long ans = 1;
  long long mod = 1e9+7;
  for (int i=0; i<N; i++){
    if (counter[0]==A[i]) add_index=0;
    else if (counter[1]==A[i]) add_index=1;
    else if (counter[2]==A[i]) add_index=2;
    else {
      ans=0;
      break;
    }
    int same_count = 1;
    for (int j=0; j<3; j++){
      if (j==add_index) continue;
      if (counter[j]==A[i]) same_count++;
    }
    ans *= same_count;
    ans %= mod;
    counter[add_index]++;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};


void Main()
{
	int D;
	cin>>D;
	vec(c,26);
	vin(c);

	vecvec(s,D,26);
	rep(i, D){
		rep(j,26){
			cin>>s[i][j];
		}
	}

	dout<<_n2;
	vec(last, 26);
	int maxDev=0;
	rep(d,D){
		int day=d+1;
		int maxIndex=-1;
		ll maxDev=LLONG_MIN;
		rep(j,26){
			ll dev = s[d][j] - (c[j] * (day-last[j]));
			if(dev==maxDev){
				if(c[j]>c[maxIndex])maxIndex=j;
			}
			else if(dev>maxDev){
				maxDev=dev;
				maxIndex=j;
			}
		}
		last[maxIndex]=day;
		cout<<maxIndex+1<<_n;
	}
}



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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,t,a,T,A;cin>>N>>t>>a;
  REP(i,N-1){
    cin>>T>>A;
    ll b=max((t+T-1)/T,(a+A-1)/A);
    t=b*T;a=b*A;
  }
  cout<<t+a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  
  if (S[K - 1] == 'A') {
    S[K - 1] = 'a';
  } else if (S[K - 1] == 'B') {
    S[K - 1] = 'b';
  } else if (S[K - 1] == 'C') {
    S[K - 1] = 'c';
  }
  
  cout << S << endl;
  
}

Measured memory_bytes: 256
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n=int(input())

b = []
for i in range(n):
    b.append(int(input()))

anc = 0
for row in a:
    cnt = 0
    for col in row:
        if col in b:
            cnt += 1
    if cnt == 3:
        anc += 1
        break
for i,row in enumerate(a):
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        anc += 1 
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        anc += 1
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
        anc += 1

if anc >= 1:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
    int n,q;cin>>n;
    ll sum=0;
    vector<ll> num(100010,0);
    for(int i=0;i<n;++i){
        ll a;cin>>a;
        sum+=a;
        num[a]++;
    }
    cin>>q;
    for(int i=0;i<q;++i){
        ll b,c;cin>>b>>c;
        sum+=(c-b)*num[b];
      	num[c]+=num[b];
        num[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4012
def main():
    S = input()
    N = len(S)
    V = S[:(N-1)//2]
    W = S[(N+1)//2:]
    ans = "Yes"
    for i in range(N//2):
        if S[i] != S[N-1-i]:
            ans = "No"
    M = len(V)
    L = len(W)
    for i in range(M//2):
        if V[i] != V[M-1-i]:
            ans = "No"
    for i in range(L//2):
        if W[i] != W[L-1-i]:
            ans = "No"
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from functools import reduce
from operator import xor

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

dXORs = set([A ^ (A-1) for A in As])
XOR = reduce(xor, As)

ans = 0
for i in reversed(range(30)):
    if XOR & (1<<i):
        d = ((1<<(i+1)) - 1)
        if d in dXORs:
            XOR ^= d
            ans += 1

print(ans if XOR == 0 else -1)


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

int main()
{
   int x=0,n;
   cin>>n;
   char s[n];
   cin>>s;
   int arr[n+1];
   arr[0]=0;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='I')
         x++;
       else
          x--;
       arr[i+1]=x;
   }
   sort(arr,arr+n+1);
   cout<<arr[n];
   return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_cur = a[0]

m = 1000
s = 0

for i in range(1, n):
    a_next = a[i]
    if a_cur < a_next:
        # buy current and sell next
        s = m // a_cur
        m += s * (a_next - a_cur)
    a_cur = a_next
print(m)

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>

#define Inf             987654321
using namespace std;

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    string t, s;
    cin >> s >> t;
    cout << t + s << "\n";



    return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

typedef int dat;
 
struct SegmentTree
{
    int N;
    vector<dat> st;
    
    dat merge(dat a, dat b)
    {
        dat res = max(a,b);
        return res;
    }
 
    dat query(int node, int l, int r, int i, int j)
    {
        if(l >= i && r <= j)
            return st[node];
        int m = (l+r)/2;
        if(j <= m)
            return query(2*node, l, m, i, j);
        else if(i >= m+1)
            return query(2*node+1, m+1, r, i, j);
        else
            return merge(query(2*node, l, m, i, j), query(2*node+1, m+1, r, i, j));
    }
 
    //modify arguments and handle point update as per question
    void update(int node, int l, int r, int pos, int val)
    {
        if(l == r)
        {
 			st[node]=max(st[node], val);
            return;
        }
        int m = (l+r)/2;
        if(pos <= m)
            update(2*node, l, m, pos, val);
        else if(pos >= m+1)
            update(2*node+1, m+1, r, pos, val);
        st[node] = merge(st[2*node], st[2*node+1]);
    }
 
    SegmentTree(int tree_size)
    {
        N=tree_size;
        st.resize(4*N+5);
    }
 
    dat query(int i, int j)
    {
        dat res = query(1, 0, N-1, i, j);
        return res;
    }
    
    void update(int pos, int val)
    {
        update(1, 0, N-1, pos, val);
    }
};

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	SegmentTree st = SegmentTree(n+1);

	int dp[n+1];
	memset(dp, 0, sizeof(dp));
	dp[0]=0;
	int ans = 0;
	for(int i=0;i<n;i++) {
		int mx = st.query(0, h[i]-1);
		st.update(h[i], mx+a[i]);
		ans = max(ans, st.query(h[i], h[i]));
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 14272
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int h = sc.nextInt();
		int w = sc.nextInt();
        String kesu;
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < w; i++) {
          builder.append(".");
        }
        kesu = builder.toString();
      
        ArrayList<String[]> list = new ArrayList<>();
        int[] whiteList = new int[w];
        int wRemoved = 0;
        // 横除去
        for(int i = 0; i < h; i++) {
          String value = sc.next();
          if (!value.equals(kesu)) {
            String[] splited = value.split("");
            list.add(splited);
        
            for(int index = 0; index < w; index++) {
              if (splited[index].equals(".")) {
                whiteList[index]++;
              }
            }
          } else {
            wRemoved++;
          }
        }
        // 縦除去
        for(int i = 0; i < w; i ++) {
          if (whiteList[i] == h - wRemoved) {
            for(int index = 0; index < list.size(); index++) {
              String[] target = list.get(index);
              target[i] = "";
              list.set(index, target);
            }
          }
        }
        for(int i = 0; i < list.size(); i++) {
          StringBuilder ansBuilder = new StringBuilder();
          String[] target = list.get(i);
          for(int index = 0; index < w; index++) {
            ansBuilder.append(target[index]);
          }
          // 出力
		  System.out.println(ansBuilder.toString()); 
        }
	}
}

Measured memory_bytes: 25300
#include<stdio.h>
#include<math.h>
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#define max(a,b)            (((a) > (b)) ? (a) : (b))


int main(){
	int H,W,L[28][28];
	int Min=0x3fffffff,sum=0;
	memset(L,0,sizeof(L));
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;++i)
		for(int j=0;j<W;++j)
			scanf("%d",L[i]+j);
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			int P[30]={0},sum=0;
			for(int I=0;I<H;++I)
				for(int J=0;J<W;++J)
					P[min(abs(I-i),abs(J-j))]+=L[I][J];
			for(int k=1;k<max(H,W);++k)
				sum+=k*P[k];
			if(sum<Min) Min=sum;}}
	printf("%d\n",Min);

	return 0;
}


Measured memory_bytes: 2100
from scipy.misc import comb
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  tmp = [0]*26
  for i in s:
    tmp[ord(i)-97] += 1
  tmp = tuple(tmp)
  if tmp in dic:
    dic[tmp] += 1
  else:
    dic[tmp] = 1
total = 0
for i in dic.values():
  if i<2:
    continue
  total += comb(i, 2, exact=True)
print(total)

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

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

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

    long long ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += (d[i] * d[j]);
        }
    }

    cout << ans << endl;
}

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

int main()
{
    long int num;
    long int sum = 0;
    cin >> num;
    int box[num];
    for(int i=0; i<num; i++){
        cin >> box[i];
        sum += box[i];
    }
    for(int i=0; i<num-1; i++){
        for(int j=i+1; j<num; j++){
            if(box[i] > box[j]){
                int tmp = box[i];
                box[i] = box[j];
                box[j] = tmp;
            }
        }
    }
    cout << box[0] << ' ' << box[num-1] << ' ' << sum << endl;
    
    return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;


int main(){

    ll n, a, b;
    cin >> n >> a >> b;

    ll amari = n % (a + b);

    cout << (n / (a + b)) * a + min(amari, a) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int h, n;
  cin >> h >> n;
  ll sum_val = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    sum_val += a;
  }

  if (sum_val >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t a,b;
  char op;
  cin >> a >> op >> b;
  if(op == '+'){
    cout << a+b << endl;
  }else{
    cout << a-b << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int a[100001];
int main()
{
	int n,i,j,x,s=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
	     x=0;j=i;
		while(a[i]==a[j])
		{
			x++;
			j++;
		}
		if(a[i]<x)
		{
		s+=x-a[i];
		}
		else if(a[i]>x) 
		{
		s+=x;
		}
	 i=j-1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 640
def comb(n, k):
    x, y = 1, 1
    k = min(k, n-k)
    for i in range(k):
        x *= n - i
        x %= MOD
        y *= i + 1
        y %= MOD
    return x*pow(y, MOD-2, MOD) % MOD

def modinv(a):
    b=MOD
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%MOD

MOD=10**9+7
N,M,K=map(int,input().split())


x=0
for i in range(1,N):
   x=x+i*(N-i)
x=(x*M*M)%MOD

y=0
for j in range(1,M):
    y=y+j*(M-j)
y=(y*N*N)%MOD
    
ans=comb(N*M-2,K-2)*(x+y)%MOD
print(ans)

Measured memory_bytes: 3064
sx, sy, tx, ty = map(int, input().split())
ans = 'U' * (ty - sy)
ans += 'R' * (tx - sx)
ans += 'D' * (ty - sy)
ans += 'L' * (tx - sx + 1)
ans += 'U' * (ty - sy + 1)
ans += 'R' * (tx - sx + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (ty - sy + 1)
ans += 'L' * (tx - sx + 1)
ans += 'U'
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   string s;
   map<string, ll> log;
   for (int i = 0; i < N; i++) {
      cin >> s;
      vector<char> tmp;
      for (int j = 0; j < 10; j++) {
         tmp.push_back(s[j]);
      }
      sort(tmp.begin(), tmp.end());
      string S;
      for (int j = 0; j < 10; j++) {
         S += tmp[j];
      }
      log[S]++;
   }
   ll ans = 0;
   for (auto& it : log) {
      if (it.second <= 1) continue;
      ll i = it.second;
      ll tmp2 = i * (i - 1);
      tmp2 /= 2;
      ans += tmp2;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    int cnt=0,m=0;
    rep(i,n){
        if(h[i]>=m){
            cnt++;
        }
        m=max(m,h[i]);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<pair<int, int>> X(N);
    map<int, int> m;
    rep(i, N) {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(X.begin(), X.end());
    rep(i, N) m[X[i].second] = i;
    rep(i, N) {
        int dst = m[i];
        if (dst < N / 2) cout << X[N/2].first << endl;
        else cout << X[N/2-1].first << endl;
    }
    return 0;
}


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

int N,M,cnt[100010]; bool v[100010];

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

    int i,x,y;
    v[1]=1;
    for (i=1; i<=N; i++) cnt[i]=1;
    for (i=1; i<=M; i++){
        cin >> x >> y;
        v[y]|=v[x];
        cnt[x]--;
        cnt[y]++;
        if (cnt[x]==0) v[x]=0;
    }

    int res=0;
    for (i=1; i<=N; i++)
        if (v[i]) res++;

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;char op;cin>>a>>op>>b;
  int ans=a-b;
  if(op=='+')ans=a+b;
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
# coding: utf-8
# Your code here!
N=int(input())

H=list(map(int,input().split()))

H.reverse()
#print(H)

for i in range(N-1):
    if H[i]<H[i+1]:
        H[i+1]-=1
        
#print(H)
        
if all(H[i]>=H[i+1] for i in range(N-1)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,Ans=0;
    string S;
    int Alpha[30]={};
    cin >> N >> S;
    REP(i,N){Alpha[(int)(S[i]-'a')]++;}
    
    
    REP(i,N){
        int calc=1;
        //cout << S[i] << " ";
        Alpha[(int)(S[i]-'a')]--;
        //REP(j,26){cout << Alpha[j] <<" ";}cout << endl;
        REP(j,26){
            if(S[i]!=(char)('a'+j)){
                calc=((Alpha[j]+1)*calc)%MOD;
            }
        }
        Ans=(Ans+calc)%MOD;
        //cout << calc << " " << Ans << endl;
    }
    cout << Ans << endl;
    
    
    return 0;
}


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

typedef pair<int,int> PII;

bool b[10];
int main(){
	for (int i = 0; i < 4; ++i){
		int a;
		cin>>a;
		b[a]=true;
	}

	if(b[1]&&b[9]&&b[7]&&b[4])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



// https://maspypy.com/%e5%a4%9a%e9%a0%85%e5%bc%8f%e3%83%bb%e5%bd%a2%e5%bc%8f%e7%9a%84%e3%81%b9%e3%81%8d%e7%b4%9a%e6%95%b0%e6%95%b0%e3%81%88%e4%b8%8a%e3%81%92%e3%81%a8%e3%81%ae%e5%af%be%e5%bf%9c%e4%bb%98%e3%81%91
// https://maspypy.com/%e5%a4%9a%e9%a0%85%e5%bc%8f%e3%83%bb%e5%bd%a2%e5%bc%8f%e7%9a%84%e3%81%b9%e3%81%8d%e7%b4%9a%e6%95%b0%ef%bc%88%ef%bc%92%ef%bc%89%e5%bc%8f%e5%a4%89%e5%bd%a2%e3%81%ab%e3%82%88%e3%82%8b%e8%a7%a3%e6%b3%95
// https://maspypy.com/%e5%a4%9a%e9%a0%85%e5%bc%8f%e3%83%bb%e5%bd%a2%e5%bc%8f%e7%9a%84%e3%81%b9%e3%81%8d%e7%b4%9a%e6%95%b0%ef%bc%88%ef%bc%93%ef%bc%89%e7%b7%9a%e5%bd%a2%e6%bc%b8%e5%8c%96%e5%bc%8f%e3%81%a8%e5%bd%a2%e5%bc%8f
// [x^S] *(x^A[i] + 2)
// [x^n](FG) = sum_{i+j=n}(f_i * g_j)
// f_iはFの係数　F = f_0*x^0 + f_1*x^1 + ...


int main(){

  ll N,S;
  cin >> N >> S;
  ll mod = 998244353;
  vector<ll> ans(S+1,0);
  ans[0] = 1;

  FOR(i,0,N){
    ll a;
    cin >> a;
    vector<ll> t(S+1,0);
    FOR(n,0,S+1){
      (t[n] += ans[n] * 2) %= mod;
    }
    FOR(n,a,S+1){
      (t[n] += ans[n-a] ) %= mod;
    }
    ans = t;
  }
  cout << ans[S] << endl;
}




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

int main(void)
{
    char s[1024];
    int n;
    int i, j;
 	
    scanf("%d", &n);
    fgets(s, 2001, stdin);
 	
    for (j = 0; j < n; j++){
        fgets(s, 2001, stdin);
        if (s[strlen(s) - 1] == '\n'){
            s[strlen(s) - 1] = '\0';
        }
		
		for (i = 0; s[i] != '\0'; i++){
            if (strncmp(&s[i], "Hoshino", 7) == 0){
                strncpy(&s[i], "Hoshina", 7);
            }
        }
        printf("%s\n", s);
    }
     
    return (0);
}

Measured memory_bytes: 584
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

class UF
{
	vector<int> parent;
	vector<long long int> size;

	public:
	UF(int n)
	{
		parent = vector<int>(n, -1);
		size = vector<long long int>(n, 1);
	}

	int getparent(int x)
	{
		if(parent[x] == -1) return x;
		else return parent[x] = getparent(parent[x]);
	}

	long long int getsize(int x)
	{
		return size[getparent(x)];
	}

	void update(int x, int y)
	{
		int px = getparent(x);
		int py = getparent(y);
		if(px == py) return;
		if(px > py) swap(px, py);
		parent[py] = px;
		size[px] += size[py];
	}

};

int main()
{
	long long int n, m;
	cin >> n >> m;
	long long int a[100001], b[100001];
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	UF uf(n);
	vector<long long int> ans;
	ans.push_back(n * (n - 1) / 2);
	long long int prevans = n * (n - 1) / 2;
	for(int i = m - 1; i >= 1; i--){
		if(prevans == 0){
			ans.push_back(0);
			continue;
		}
		if(uf.getparent(a[i]) == uf.getparent(b[i])){
			ans.push_back(prevans);
			continue;
		}
		long long int as = uf.getsize(a[i]);
		long long int bs = uf.getsize(b[i]);
		long long int res = prevans - as * bs;
		ans.push_back(res);
		prevans = res;
		uf.update(a[i], b[i]);
	}
	for(int i = m - 1; i >= 0; i--){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4980