akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}

void solve(){
	ll n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x+((n%x)>0))*t<<'\n';
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tc=1;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	// cin>>tc;
    while(tc--)solve();
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n;
	t = 1;
	while(t--) {
	 cin >> n;
	 cout << "ABC" << n << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
)
(()

1 0
0 1

)(
()

1 1
0 0 うちけしあったときに1 1でNG

4
((()))
((((((
))))))
()()()
0 0
0 6
6 0
0 0

3
(((
)
)
0 3
1 0
1 0

)(
)(
1 1
1 1 )()(でNG

どれかは0が必要か

3
(
)
))((

0 1
1 0
2 2

01
10
22

01
22 21
10 11


01 02 03 
6
10 20 20
5
HP6と HP5みたいな

01 = -1
10 = +1
12 = -1
16 = -5
21
21
...

0のやつだけHP管理。
それ以外は差分を入れる

01を先頭に、10を最後尾にする。

3     R L
))    2 0 ...Lが2個余裕ある。＝LのHPが2
)()(( 1 2 tupleで保存。((2-1), 1, 2)
　　　　　　　　//差分がプラス＝Lが対処しなきゃいけない
        　　　　　　　　　　　＝Rにとっては回復
        　　　 //差分がマイナスだと、Rが対処

)))))(((( 5 4 = 1
))(       2 1 = 1


((())
))(((

(((((

))))))((((((((((
)((


RのHP１から開始。
攻撃(1, 1, 2)
R -= get<1>(A[i])
このとき、Rが1回でも負になった時点で"No"


(     0 1...Rが1個余裕ある　＝RのHPが1


->
123210 = min=0
((())) [0] 0
->
-1-2-3 -2-1 0 min=-3
)))((( [3] 3

-> -1 0 -1
)() 1 [0]
1 0 1<- min = [0]
01
12
20

【Yesになるべき。NoでもACしたパターン】
4
(
)((
))((((
))))

*/

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  ll L=0, R=0;
  vector<pair<ll,ll>> plus(0, {0,0}), minus(0, {0,0});
  rep(i, N){
    string S; cin>>S;
    ll j=-1, tmp=0, q=0, p=0;
    while (S[++j]){
      if (S[j] == ')'){//qpで管理
        tmp--;
        chmin(q,tmp);
      }
      else
        tmp++;
    }
    tmp = 0;
    while (--j >= 0){
      if (S[j] == '('){
        tmp--;
        chmin(p, tmp);
      }
      else
        tmp++;
    }
    if (q==0)
      R -= p;
    else if (p==0)
      L -= q;
    else{
      ll tmp = -(p-q); //プラスなら '(' が回復
      if (tmp > 0)
        plus.push_back({-q, -p});
      else
        minus.push_back({-q, -p});
    }
  }
  bool ans = true;
  sort(all(plus));
  sort(all(minus));
  reverse(all(minus));
  ll psz = plus.size();
  //まず回復パターン。弱い攻撃から受ける
  rep(i, psz){
    R -= plus[i].first;
    if (R < 0){
      ans = false;
      break;
    }
    R += plus[i].second;
  }
  //防御パターン。大きい攻撃から受ける
  ll msz = minus.size();
  rep(i, msz){
    R -= minus[i].first;
    if (R < 0){
      ans = false;
      break;
    }
    R += minus[i].second;
  }
  R -= L;
  if (R != 0)
    ans = false;
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
int n, m, a[1005], b[1005], f[20005];
int main() {
	cin>>m>>n;
	for(int i = 1; i <= n; i++)
	   cin>>a[i]>>b[i];
	for(int i = 1; i <= m; i++)
	   f[i] = 1e8;
	for(int i = 1; i <= n; i++)
	   for(int j = 1; j <= m; j++) {
	   	int rt = j - a[i];
	   	rt = max(rt, 0);
	   	f[j] = min(f[j], f[rt] + b[i]);
	   }
	cout<<f[m]<<endl;
	return 0;
	
}

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

int main(){
  vector<int> x(5);
  int mostminno=-1,mmin=10;
  for(int i=0;i<5;i++){
    cin>>x[i];
    if ((x[i]%10)!=0){
      if ((x[i]%10)<mmin){
        mmin=x[i]%10;
        mostminno=i;
      }
    }
  }
  
  
  int ans=0;
  for(int i=0;i<5;i++){
    if (i!=mostminno){
      ans+=(x[i]+9)/10*10;
    }
  }
  
  if (mostminno!=-1){
    ans+=x[mostminno];
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    char str[25];
    scanf("%[^\n]", str);

    for (int i=0; str[i] != '\0'; i++){
        if (i == 5 || i == 13){
            printf(" ");
        }
        else
        {
            printf("%c", str[i]);
        }
    }
    return 0;
}


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

void printA(vector<int> A) {
    for (int i = 0; i < A.size(); i++) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(vector<int> &A) {
    printA(A);
    for (int i = 1; i < A.size(); i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        printA(A);
    }
}

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

    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    insertionSort(A);

    return 0;
}



Measured memory_bytes: 3180
#include <stdio.h>

int main(void)
{
	int a,b,c,min,middle,max;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b){
		if(b<=c){
			min=a,middle=b,max=c;
		}else{ 
			if(a<=c) min=a,middle=c,max=b;
			else min=c,middle=a,max=b;
		}
	}else{
		if(c<=b){
			min=c,middle=b,max=a;
		}else{
			if(c<=a) min=b,middle=c,max=a;
			else min=b,middle=a,max=c;
		}
	}
	printf("%d %d %d\n",min,middle,max);
	return 0;
}

Measured memory_bytes: 596
#![allow(non_snake_case,unused_imports,dead_code)]
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        M:usize,
        LRD:[(Usize1,Usize1,isize);M],
    }
    let mut E = vec![HashMap::new();N];

    for &(l,r,d) in &LRD{
        E[l].insert(r,d);
        E[r].insert(l,-d);
    }

    let INF = 1e15 as isize;
    let mut D = vec![-INF;N];
    for i in 0..N{
        if D[i]==-INF{bfs_dist_weighted_tree(N, &E, i, &mut D);}
    }
    let mut ans = true;
    for &(l,r,d) in &LRD{
        ans &= D[r]-D[l] == d;
    }
    println!("{}",if ans {"Yes"} else {"No"});
}

fn bfs_dist_weighted_tree(_N:usize,E:&Vec<HashMap<usize,isize>>,start:usize,d:&mut Vec<isize>){
        let mut q = VecDeque::new();
        q.push_back(start);
        d[start] = 0;
        while let Some(i) = q.pop_front(){
            for (&j,&c) in E[i].iter(){
                if d[j]!= -1e15 as isize{continue;}
                d[j] = d[i]+c;
                q.push_back(j);
            }
        }
    }

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    deque< char > dq;
    string s;
    cin >> s;
    for( int i = 0; i < s.size(); ++i ) {
        dq.push_back(s[i]);

    }

    int q;
    cin >> q;
    bool b = true;
    while( q-- ) {
        int a;
        cin >> a;
        if( a == 1 ) {
            b = (!b);

        } else {
            int f;
            char c;
            cin >> f >> c;
            if( f == 1 ) {
                if( b ) dq.push_front(c);
                else dq.push_back(c);

            } else {
                if( b ) dq.push_back(c);
                else dq.push_front(c);

            }
        }
    }
    if( b ) {
        while( !dq.empty() ) {
            cout << char(dq.front());
            dq.pop_front();

        }
    } else {
        while( !dq.empty() ) {
            cout << char(dq.back());
            dq.pop_back();

        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(i, 2) rep(j, N) cin >> A[i][j];
    
    int ans = 0;
    rep(i, N) {
        int res = 0;
        rep(j, i + 1) res += A[0][j];
        for (int j = i; j < N; ++j) res += A[1][j];
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  lint n, s = 0ll, t, dif = 1e18;
  cin >> n;
  vector<lint> a(n);
  for (auto&& w : a) cin >> w;
  for (auto&& w : a) s += w;
  t = 0ll;
  for (int i = 0; i < n - 1; i++) {
    t += a[i];
    dif = min(dif, abs(s - 2 * t));
  }
  cout << dif << endl;
  
}

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

int main() {
  int N; cin >> N;
  vector<long> A(N+1); for (int i =0; i<N+1; i++) cin >> A.at(i);
  vector<long> B(N); for (int i =0; i<N; i++) cin >> B.at(i);
  
  long count =0;
  for (int i =N; i>=1; i--) {
    if (B.at(i-1) >= A.at(i)) {
      count += A.at(i); B.at(i-1) -= A.at(i); A.at(i) =0;
    } else {
      count += B.at(i-1); A.at(i) -= B.at(i-1); B.at(i-1) =0;
    }
    if (B.at(i-1) >= A.at(i-1)) {
      count += A.at(i-1); B.at(i-1) -= A.at(i-1); A.at(i-1) =0;
    } else {
      count += B.at(i-1); A.at(i-1) -= B.at(i-1); B.at(i-1) =0;
    }
  }
  if (B.at(0) >= A.at(0)) {
    count += A.at(0); 
  } else {
    count += B.at(0);
  }
  cout << count << endl;
}

Measured memory_bytes: 4844
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    int d=gi();
	    int e=gi();
	    int k=gi();


	   
	    	//System.out.print(max);

        if (e-a>k) {
        	System.out.print(":(");
        }else {
        	System.out.print("Yay!");
        }


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

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

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

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

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

vector<int> a;
vector<int> ord;
int sz;
vector<int> rest;
int n,vidx=0;
vector<int> g[100];

void dfs(int& i,int pre){
  if(a[i]>0){
    int crtv=vidx++;
    ord.push_back(crtv);
    sz++;
    if(pre!=-1){
      g[pre].push_back(crtv);
      g[crtv].push_back(pre);
    }
    rest[crtv]=a[i]-(pre==-1?0:1);
    while(rest[crtv]){
      dfs(++i,crtv);
      rest[crtv]--;
    }
    ord.pop_back();
    sz--;
  }else{
    int crtv=pre;
    int backv=ord[sz-1+a[i]];
    rest[backv]--;
    g[crtv].push_back(backv);
    g[backv].push_back(crtv);
  }
}

void solve(){
  a.clear();
  n=0;
  while(1){
    int aa;
    cin>>aa;
    if(aa==0)break;
    if(aa>0)n++;
    a.push_back(aa);
  }
  vidx=0;
  ord.clear();
  sz=0;
  rest.clear();
  rest.resize(n);
  rep(i,n)g[i].clear();
  int hoge=0;
  dfs(hoge,-1);
  rep(i,n){
    sort(all(g[i]));
    cout<<i+1<<" "<<g[i][0]+1;
    repl(j,1,g[i].size())cout<<" "<<g[i][j]+1;
    cout<<endl;
  }
}

int main(){
  int cases;
  cin>>cases;
  while(cases--){
    solve();
  }
  return 0;
}



Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static boolean solve(int i, int x, List<Integer> list) {
		if(x == 0) {
			return true;
		} else if (i >= list.size() || x < 0) {
			return false;
		} else {
			return(solve(i + 1, x, list)) || solve(i + 1, x - list.get(i), list);
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		Set<String> set = new HashSet<>();
		int n = Integer.parseInt(br.readLine());
		List<Integer> list = new ArrayList<>();
		String[] strings = br.readLine().split(" ");
		for(int i = 0; i < n; i++) {
			list.add(Integer.parseInt(strings[i]));
		}
		int q = Integer.parseInt(br.readLine());
		strings = br.readLine().split(" ");
		for (int i = 0; i < q; i++) {
			if(solve(0, Integer.parseInt(strings[i]), list)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
}


Measured memory_bytes: 25356
import sys
input = sys.stdin.readline
import itertools

N,M = map(int,input().split())
a=[tuple(map(str,input().split())) for _ in range(M)]
ac = [0]*N
wa = [0]*N
for i in range(M):
    q = int(a[i][0])-1
    res = a[i][1]
    if res == 'AC':
        ac[q] = 1
    else:
        if ac[q] == 0:
            wa[q] += 1
wa2=0
for i in range(N):
    if ac[i]==1:
        wa2 += wa[i]
print("{} {}".format(sum(ac),wa2))


Measured memory_bytes: 22984
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] Alpha = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
		String S = scan.next();
		List<String> SList = new ArrayList<String>();
		for(int i = 0; i < S.length(); i++) {
			SList.add(S.substring(i, i + 1));
		}
		List<String> SHashList = new ArrayList<String>(new HashSet<String>(SList));
		if(SHashList.size() == 26) {
			System.out.println("None");
		} else {
			for(int i = 0; i < Alpha.length; i++) {
				if(S.indexOf(Alpha[i]) == -1) {
					System.out.println(Alpha[i]);
					break;
				}
			}
		}
		scan.close();

	}

}


Measured memory_bytes: 32848
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "functional"
#include <math.h>


using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)


int main(void) {
	double t, x;
	cin >> t >> x;
	cout << t / x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<set>
#include <string>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

const int INF = 1e9;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	printf("%lld\n", abs((ll)(n - 2)*(m - 2)));
}



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

#define N 2001
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define fastio ios::sync_with_stdio(false); cin.tie(0)

string brd[N];
int hashr[N][N], hashc[N][N] = {-1};
int szr[N][N], szc[N][N]; 


int down(int i, int j, int k, int r, int c){
	if(i >= r || brd[i][j] == '#'){
		return 1;
	}
	hashc[i][j] = k;
	return down(i+1, j, k, r, c) + 1;
}

void fc(int i, int j, int r, int c){
	if(brd[i][j] == '.' && hashc[i][j] == -1){
		szc[i][j] = down(i+1, j, i, r, c);
		hashc[i][j] = i;
	}
}

int right(int i, int j, int k, int r, int c){
	if(j >= c || brd[i][j] == '#'){
		return 1;
	}
	hashr[i][j] = k;
	return right(i, j+1, k, r, c) + 1;
}

void fr(int i, int j, int r, int c){
	if(brd[i][j] == '.' && hashr[i][j] == -1){
		szr[i][j] = right(i, j+1, j, r, c);
		hashr[i][j] = j;
	}
}

int calc(int i, int j){
	if(brd[i][j] == '#') return 0;
	else return szc[hashc[i][j]][j] + szr[i][hashr[i][j]] - 1;
}

int main(){
	fastio;
    int r, c, ans = 0;
    cin >> r >> c;
    for(int i = 0 ; i < r ; i++) cin >> brd[i];
    for(int i = 0 ; i < r ; i++)
    	for(int j = 0 ; j < c ; j++)
    		hashr[i][j] = -1, hashc[i][j] = -1;

    for(int i = 0 ; i < r ; i++){
    	for(int j = 0 ; j < c ; j++){
    		fc(i, j, r, c);
    		fr(i, j, r, c);
    	}
    }

	for(int i = 0 ; i < r ; i++)
    	for(int j = 0 ; j < c ; j++)
    		ans = max(ans, calc(i, j));

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


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

using namespace std;

int main(){
    long long int N,M,ans=0;
    cin >> N >> M;
    vector<long long int> H(N);
    vector<vector<int>> graph(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }

    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    for(int i=0;i<N;i++){
        bool ok= true;
        for(int j=0;j<graph[i].size();j++){
            if(H[i]<=H[graph[i][j]]){
                ok = false;
            }
        }

        if(ok){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i,n) cin >> a.at(i);
	rep(i,m) cin >> b.at(i);
	bool ans=false;
	rep(i,n-m+1){
		rep(j,n-m+1){
			bool same=true;
			rep(k,m){
				if(a.at(i+k).substr(j,m)!=b.at(k)) same=false;
			}
			if(same) ans=true;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char s[maxn];
int n,t[maxn],ans;

void dfs(int x,int v) {
    if(x==26) return ans=(ans+v)%mod,void();
    dfs(x+1,v),dfs(x+1,1ll*v*t[x]%mod);
}

int main() {
    read(n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++) t[s[i]-'a']++;
    dfs(0,1);write(ans-1);
    return 0;
}


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

const int maxn = 305;
int n, K, h[maxn];

ll dp[maxn][maxn][maxn];
ll INF = 1e18;
void amin(ll& a, ll b) {
    a = min(a,b);
}

ll f(int i, int j, int k) {
    //i=curr,j = index of current height, k = # modifications left available
    if (i == n+1) return h[j];
    ll& res = dp[i][j][k];
    if (res >= 0) return res;
    res = INF;
    if (h[i] > h[j]) {
        amin(res,f(i+1,i,k));
        if (k > 0) {
            amin(res,f(i+1,j,k-1));
        }
    }
    else if (h[i] < h[j]) {
        amin(res,h[j]-h[i]+f(i+1,i,k));
        if (k > 0) {
            amin(res,f(i+1,j,k-1));
        }
    }
    else {
        amin(res,f(i+1,j,k));
    }
    //printf("[%d][%d][%d]: %lld\n",i,j,k,res);
    return res;
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> K;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    memset(dp,-1,sizeof dp); 
    ll ans = f(1,0,K);
    cout << ans << '\n';
}



Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
	ll l,r;
	cin>>l>>r;
	int mod = 2019;


	/*for(int i=1;2019*i>1e9;i++){
		if(l<=2019*i&&r>=2019*i){
			cout<<0<<endl;return 0;
		}
	}*/
	ll i = 1e9+7;
	ll j = 1e9+7;
	ll cnt1=0,cnt2=0;
	int tmp = 0;
	for(ll x=l;x<=r;x++){
		cnt2=0;
		for(ll y=x+1;y<=r;y++){
			i = min((x*y)%2019LL,i);
			cnt2++;
			if(cnt2>2019)break;
		}
		cnt1++;
		if(cnt1>2019)break;
	}
	cout<<i<<endl;
}


Measured memory_bytes: 256
// Problem : H - Grid 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_h
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}
vvi dp;
void solve()
  {
int h, w; cin>>h>>w;
vector<string> v(h);
f(i, 0, h-1) cin>>v[i];
// f(i, 0, h-1) cout<<v[i]<<endl;
dp.resize(h+1, vi (w+1, 0));
f(i, 2, w) {
	if(v[0][i-1]=='#') { break; }
	else dp[1][i]=1;
	// qw2(i, dp[1][i]);
	// f(i,1,h) {f(j,1,w) cout<<dp[i][j]<<' '; cout<<endl;}
	
}
//f(i,1,h) {f(j,1,w) cout<<dp[i][j]<<' '; cout<<endl;}
f(i, 2, h) {
	if(v[i-1][0]=='#') { break; }
	else dp[i][1]=1;
}
// f(i,1,h) {f(j,1,w) cout<<dp[i][j]<<' '; cout<<endl;}
f(i, 2, h)
	f(j, 2, w)
	{
		if(v[i-2][j-1]=='#' && v[i-1][j-2]=='#')
			continue;
		else if(v[i-2][j-1]=='#')
		dp[i][j]=(dp[i][j-1])%md;
		else if(v[i-1][j-2]=='#')
		dp[i][j]=(dp[i-1][j])%md;
		else
		dp[i][j]=(dp[i-1][j]+dp[i][j-1] + md) % md;		
	}
// f(i,1,h) {f(j,1,w) cout<<dp[i][j]<<' '; cout<<endl;}
cout<<(dp[h][w]) % md<<endl;

  }

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}
 
}








Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
   fast
   ll n;
   cin>>n;
   ll arr[n],i;
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   sort(arr,arr+n);
   double ans=arr[0];

   for(i=1;i<n;i++)
   {
       ans = (double)(ans+arr[i])/2;
       //cout<<ans<<endl;
   }

   cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> P;
typedef vector<vector<P> > graph;

int n;

void calc(graph &g, vector<int> &ans, int now) {
	for(P p : g[now]) {
		int next = p.first;
		int md = p.second;
		if(ans[next]==-1) {
			ans[next] = (ans[now]+md)%2;
			calc(g,ans,next);
		}
	}
}

int main() {
	cin >> n;
	graph g(n);
	for(int i = 0; i < n; i++) {
		int u,v,w;
		cin >> u >> v >> w;
		P p1(v-1,w%2);
		g[u-1].push_back(p1);
		P p2(u-1,w%2);
		g[v-1].push_back(p2);
	}
	vector<int> ans(n,-1);
	ans[0] = 0;
	calc(g,ans,0);
	for(int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, de[ohara], su[ohara], tmp, tmpp, m, h, w, x, y, sum, pos, k, s, t;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge
{
    ll to, cost;
};
vector<edge> g[ohara];
vector<edge> gg[ohara];

//-------------------------↓↓↓↓↓↓------------------------

void dijkstra(ll s)
{
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
    fill(de, de + n, LINF);
    de[s] = 0;
    que.push(pair<ll, ll>(0LL, s));
    while (!que.empty())
    {
        pair<ll, ll> p = que.top();
        que.pop();
        ll v = p.second;
        if (de[v] < p.first)
            continue;
        rep(i, Size(g[v]))
        {
            edge e = g[v][i];
            if (de[e.to] > de[v] + e.cost)
            {
                de[e.to] = de[v] + e.cost;
                que.push(pair<ll, ll>(de[e.to], e.to));
            }
        }
    }
}

void dijkstra2(ll s)
{
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
    fill(su, su + n, LINF);
    su[s] = 0;
    que.push(pair<ll, ll>(0LL, s));
    while (!que.empty())
    {
        pair<ll, ll> p = que.top();
        que.pop();
        ll v = p.second;
        if (su[v] < p.first)
            continue;
        rep(i, Size(gg[v]))
        {
            edge e = gg[v][i];
            if (su[e.to] > su[v] + e.cost)
            {
                su[e.to] = su[v] + e.cost;
                que.push(pair<ll, ll>(su[e.to], e.to));
            }
        }
    }
}

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

    cin >> n >> m >> s >> t;
    s--;
    t--;
    rep(i, m)
    {
        cin >> a >> b >> c >> d;
        a--;
        b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
        gg[a].push_back({b, d});
        gg[b].push_back({a, d});
    }
    dijkstra(s);
    dijkstra2(t);
    pair<ll, ll> add[ohara];
    rep(i, n) add[i] = make_pair(de[i] + su[i], i);
    sort(add, add + n);
    unordered_map<ll, ll> out;
    ll mita = 0;
    rep(i, n)
    {
        while (1)
        {
            if (out[add[mita].second] == 1)
                mita++;
            else
                break;
        }
        Cout(1000000000000000 - add[mita].first);
        out[i] = 1;
    }
    return 0;
}


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


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string ans = "xxx";
  ans[0] = a[0];
  ans [1] = b[0];
  ans [2] = c[0];
  
  //transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
  
  cout << ans << endl;
  return 0;
  
}

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

int main(){
	int n;cin>>n;
	vector<tuple<int,int>> tasks(n);
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		tasks.at(i)=make_tuple(b,a);
	}
	sort(tasks.begin(),tasks.end());
	int cur=0;
	for(int i=0;i<n;i++){
		cur+=get<1>(tasks.at(i));
		if(cur>get<0>(tasks.at(i))){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;	
	return 0;
}


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

// 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()
{
    int n = 0, k = 0;
    cin >> n >> k;

    vector<vector<int>> s(n + 1, vector<int>(k, 0));

    for (int i = 0; i < k; i++)
    {
        int d = 0;
        cin >> d;

        for (int j = 0; j < d; j++)
        {
            int a = 0;
            cin >> a;
            s[a][i]++;
            // s[a].insert(j);
        }
    }

    // return 0;

    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        int zero = 0;
        for (int j = 0; j < k; j++)
        {
            zero += s[i][j];
        }
        if (zero == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

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

int main() {
  int N;
  cin >> N;
  vector<ll> T(N);
  rep(i,N) cin >> T.at(i);
  
  ll res = 1ll;
  rep (i,N) res = lcm(res, T.at(i));
  
  cout << res << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

int main()
{
    int n, k;
    scanf("%d %d",&n,&k);
    vi in(n);
    for(int &a : in) scanf("%d",&a);
    vi dp(n + k, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k; j++)
            dp[i + j] = min(dp[i + j], dp[i] + abs(in[i + j] - in[i]));
    }
    cout << dp[n - 1];
    
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    ll sn = 0;
    ll N;
    N = stoi(S);

    REP(i, S.length()){
        sn += S[i] - '0';
    }
    // cout << sn << endl;
    // cout << N << endl;
    if(N%sn == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

typedef long long ll;

int main()
{
	string S;
	cin >> S;
	int tmp = 10 * (S[5] - '0') + S[6] - '0';
	if (tmp < 5)
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
   int n,k=0;
   double ans=0,fans=0;
   cout << fixed << setprecision(10);
   cin>>n;
   vector<pll> a(n);
   rep(i,n)cin>>a.at(i).first>>a.at(i).second;
   
   sort(ALL(a));
   //rep(i,n)cout<<a.at(i).first<<" "<<a.at(i).second<<endl;
   
   do {
       rep(i,n-1){
           ans=pow(a.at(i).first-a.at(i+1).first,2)+pow(a.at(i).second-a.at(i+1).second,2);
           ans=pow(ans,0.5);
           fans+=ans;
          
       } k++; 
       
  } while (next_permutation(ALL(a)));
  //cout<<k<<endl;
  cout<<fans/k<<endl;
  //cout<<pow(2,0.5)<<endl;

}



Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main(){
	int n,m;
	cin >> n;
	cin >> m;
	while(n>0){
		int sn=n;
		int ba=m;
		vector<pair<int,int> > demap(sn);
		for(int i=0;i<sn;i++){
			int temp,temp2;
			cin >> temp;
			cin >> temp2;
			demap[i]=make_pair(temp2,temp);
		}
		sort(demap.begin(),demap.end());
		int fin=sn-1;;
		while(ba>0){
			if(fin<0){
				break;
			}
			if(demap[fin].second > ba){
				demap[fin].second-=ba;
				ba=0;
			}else{
				ba-=demap[fin].second;
				demap[fin].second=0;
				fin--;
			}
		}
		long long ans=0;
		for(int i=0;i<sn;i++){
		ans+=demap[i].first*demap[i].second;
		}
		cout << ans << endl;
		cin >> n;
		cin >> m;
	}
	
}


Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			if (n % 10 == 3) {
				System.out.println("bon");
			} else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
				System.out.println("pon");
			} else {
				System.out.println("hon");
			}
		}
	}
}


Measured memory_bytes: 35756
/**
 *    author:  zjsdut
 *    created: 2020/03/14 20:03:43
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int N;
  void dfs(string s, char ma) {
    if (SZ(s) == N) {
      println(s);
      return;
    }
    for (char c = 'a'; c <= ma; ++c) {
      dfs(s + c, ma);
    }
    dfs(s + char(ma + 1), ma + 1);
  }
int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  scan(N);
  dfs("a", 'a');
    return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {cin >> a[i].first; a[i].second = i+1;}
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) cout << a[i].second << " \n"[i==n-1];
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
#define ull unsinged long long
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define inf (1LL<<62)
#define sf scanf
#define pf printf
#define repi(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define depi(i,a,b) for(int i=a;i>=b;--i)
#define dep(i,a,b) for(ll i=a;i>=b;--i)
#define mod 1000000007

using namespace std;

struct cmp
{
    bool operator()(const double &a,const double b)const
    {
        return a>b;
    }
};

multiset<double,cmp> s;
multiset<double,cmp>::iterator it;

int main()
{
    //std::ios::sync_with_stdio(false);
    int n,m;
    double x;
    sf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
    {
        cin>>x;
        s.insert(x);
    }
    for(int i=1;i<=m;++i)
    {
        double a=*s.begin();
        s.erase(s.begin());
        s.insert(a*1.0/2);
    }
    ll ans=0;
    for(it=s.begin();it!=s.end();++it)
    {
        ans+=(int)*it;
    }
    pf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 4992
import sys
def input():
    return sys.stdin.readline().strip()
n, a, b, c = map(int, input().split())
s = []
for _ in range(n):
    s.append(input())

# 0 <= i < n-1
ans = []
for i in range(n-1):
    if s[i] == 'BC':
        if b > c:
            ans.append('C')
            b -= 1
            c += 1
        elif b < c:
            ans.append('B')
            b += 1
            c -= 1
        elif s[i+1] == 'AB':
            ans.append('B')
            b += 1
            c -= 1
        else:
            ans.append('C')
            b -= 1
            c += 1

    elif s[i] == 'AC':
        if a > c:
            ans.append('C')
            a -= 1
            c += 1
        elif a < c:
            ans.append('A')
            a += 1
            c -= 1
        elif s[i+1] == 'BC':
            ans.append('C')
            a -= 1
            c += 1
        else:
            ans.append('A')
            a += 1
            c -= 1

    else:
        if a > b:
            ans.append('B')
            a -= 1
            b += 1
        elif a < b:
            ans.append('A')
            a += 1
            b -= 1
        elif s[i+1] == 'AC':
            ans.append('A')
            a += 1
            b -= 1
        else:
            ans.append('B')
            a -= 1
            b += 1

    if a < 0 or b < 0 or c < 0:
        print('No')
        exit()

# i = n-1
if s[n-1] == 'BC':
    if b > c:
        ans.append('C')
        b -= 1
        c += 1
    else:
        ans.append('B')
        b += 1
        c -= 1

elif s[n-1] == 'AC':
    if a > c:
        ans.append('C')
        a -= 1
        c += 1
    else:
        ans.append('A')
        a += 1
        c -= 1

else:
    if a > b:
        ans.append('B')
        a -= 1
        b += 1
    else:
        ans.append('A')
        a += 1
        b -= 1

if a < 0 or b < 0 or c < 0:
    print('No')
    exit()

print('Yes')
for i in ans:
    print(i)

Measured memory_bytes: 80340
/*
**   Contest : AtCoder Beginner Contest 127
**   Problem : D - Integer Cards
**
**    Author : Dhiraj Govindvira
**      Date : 24-Jun-2020 ~ Wednesday
**      Time : 09:10:04 PM
*/
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin>>args), ...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, m;
    cin>>n>>m;

    vector<ll> a(n);
    cin>>a;
    sort(all(a));

    vector<pair<ll,ll>> qry(m);
    cin>>qry;

    auto comp = [](const auto &lhs, const auto &rhs) {
        return lhs.second > rhs.second;
    };
    sort(all(qry), comp);

    ll id = 0;
    d(a);
    for(auto &q : qry)
    {
        ll b = q.first;
        ll c = q.second;
        while(id < n and b and a[id] < c) {
            a[id] = c;
            id++, b--;
        }
    }
    ll sm = accumulate(all(a),0LL);
    cout<<sm<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}

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

int main() {
  int N;
  string S;
  int A;
  cin>>N;

  for (int i = 0; i < N; i++)
  {
    cin>>S;
    if (S=="Y")
    {
      A++;
    }
  }

  if (A>=1)
  {
    cout<<"Four";
  }

  else
  {
    cout<<"Three";
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> Ans = new ArrayList<Integer>();
		String line;
		
		shop A = new shop(200, 380, 5, 0.20);
		shop B = new shop(300, 550, 4, 0.15);
		shop C = new shop(500, 850, 3, 0.12);
		
		while((line = in.readLine()) != null){
			int need = Integer.parseInt(line);
			
			if(need==0) break;
			
			int minCost = 1000000000;
			for(int a=0; a<=need/A.vol; a++){
				for(int b=0; b<=need/B.vol; b++){
					for(int c=0; c<=need/C.vol; c++){
						if(a*A.vol+b*B.vol+c*C.vol == need){
							int ap = A.getCost(a);
							int bp = B.getCost(b);
							int cp = C.getCost(c);
							int total = ap + bp + cp;
							if(total < minCost){
								minCost = total;
							}
						}
					}
				}
			}
			
			Ans.add(minCost);
		}
		
		for(int n=0; n<Ans.size(); n++){
			System.out.println(Ans.get(n));
		}
	}
	
}

class shop{
	int vol;
	int price;
	int discount;
	double rate;
	
	public shop(int vol, int price, int discount, double rate){
		this.vol = vol;
		this.price = price;
		this.discount = discount;
		this.rate = rate;
	}
	
	public int getCost(int x){
		int cost = x * this.price;
		if(x >= this.discount){
			cost -= (int)(x/this.discount) * this.rate * this.price * this.discount;
		}
		
		return cost;
	}
}

Measured memory_bytes: 9248