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

#define NIL NULL
#define INF 1000000001

using namespace std;



struct node {
    int key;
    struct node *right;
    struct node *left;
    struct node *parent;
};
typedef node * Node;



Node root = NIL;

void insert(int key){
    Node y = NIL;
    Node x = root;
    Node z;

    z = (Node)malloc(sizeof(struct node));
    z->key  = key;
    z->left = NIL;
    z->right= NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;

    if(y == NIL)root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;     
}

bool findElement(Node current_node,int v){
    if(current_node == NIL) return false;
    else if(current_node->key == v) return true;
    else if(current_node->key > v) return findElement(current_node->left, v);
    else if(current_node->key < v) return findElement(current_node->right,v);
}

void inOrder(Node current_node){
    if(current_node == NIL) return;
     inOrder(current_node->left);
    printf(" %d",current_node->key);
    inOrder(current_node->right);
}

void preOrder(Node current_node){
    printf(" %d",current_node->key);
    if(current_node->left != NIL)        preOrder(current_node->left);
    if (current_node->right != NIL) preOrder(current_node->right);
}



int main(){
    int num_query;
    char command[20];
    
    int key;
    scanf("%d",&num_query);
    for(int i = 0;i < num_query;i++){
        scanf("%s",command);
        if(command[0] == 'i'){
            scanf("%d",&key);
            insert(key);
        }else if(command[0] == 'f'){
            scanf("%d",&key);
            if(findElement(root,key)) printf("yes\n");
            else printf("no\n");
        }else if(command[0] == 'p'){
            inOrder(root);printf("\n");
            preOrder(root);printf("\n");
        }
    }
    return 0;   
}



Measured memory_bytes: 21872
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy

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

    ll n, m;
    cin >> n >> m;

    vpl in;
    FOR (i, 0, n) {
        ll x, y;
        cin >> x >> y;
        in.pb ({x, y});
    }

    sort (all (in) );
    ll ans = 0;
    FOR (i, 0, n) {
        ll need = m;
        ll have = in[i].s;
        ans += in[i].f * min (need, have);
        need -= min (need, have);
        m = need;
    }

    cout << ans << '\n';



    return 0;
}


Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


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

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	cin >> a >>b;

	cout << a * b - a - (b - 1) << endl;

	/*int N;
	cin >> N;
	string ans = "";
	while (N != 0) {
		if (N % 2 != 0) {
			N--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		N /= -2;
	}
	if (ans == "")ans = "0";
	cout << ans << endl;*/

}
	

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

using namespace std;

int main () {
    int a, b;
    cin >> a >> b;

    if (a % 2 != 0 && b % 2 != 0) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 3580
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
num = 3
cnt = 0
print(N // 3)

Measured memory_bytes: 5144
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();

    for(int i=0; i<S.length(); i++) {
    	ss[i] = ss[i+0];

    }
    	Arrays.sort(ss);
    int ans = 0;
    for(int i=0; i<S.length()-1; i++) {
    	if(ss[i] <= ss[i+1]-2) {
    		ans = ss[i] + 0;
    		break;
    	}
    }
    if(ss[0] != 97) {
    	System.out.println("a");
    }else if(ans != 0) {
    	System.out.println((char)(ans+1));
   	}else if(ss[S.length()-1] == 'z'){
    		System.out.println("None");
   	}else {
   		System.out.println((char)(ss[S.length()-1] +1));
   	}
    }
}


Measured memory_bytes: 39624
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  vector<int> v[10];
  rep(i,n) v[s[i]-'0'].pb(i);
  ll ans=0;
  rep(i,10) {
    rep(j,10) {
      rep(k,10) {
        int x=-1,y;
        y=upper_bound(all(v[i]),x)-v[i].begin();
        if(y==v[i].size()) continue;
        x=v[i][y];
        y=upper_bound(all(v[j]),x)-v[j].begin();
        if(y==v[j].size()) continue;
        x=v[j][y];
        y=upper_bound(all(v[k]),x)-v[k].begin();
        if(y==v[k].size()) continue;
        ans++;
      }
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	ll res{0};
	map<ll, ll> m;
	REP(i, N)
	{
		res += m[i-A[i]];
		m[i+A[i]]++;
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<P> v(n);
  rep(i,n){
      ll a;cin >> a;
      v[i]=mp(a,i+1);
  }
  sort(all(v));
  rep(i,n){
      cout << v[i].second << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <numeric> 
#include <iomanip>
#include <map> 
#include <stack>
#include <sstream>
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int MAX = 1e6;
long long max(long long a, long long b) { if (a > b)return a; else return b; }
long long min(long long a, long long b) { if (a < b)return a; else return b; }
const int MAXN = 1000000 + 30;
int a[MAXN];


  		     		    	   				   	

int main()
{
	
		ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
		ld size, m;
		std::cin >> size>>m;
		std::vector <ld> v(size);
		for (ld i = 0; i < v.size(); i++)
		{
			std::cin >> v[i];
		}
		ld cnt = 0;
		ld k = 1 / (4 * m);
		ll d = std::accumulate(v.begin(), v.end(), 0);
			
			for (ld i = 0; i < v.size(); i++)
			{
				ld f = v[i] / d;
				if (f >= k)
				{
					cnt++;
				}
			}
			if (cnt >= m)
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}

		/*for (int i = 0; i < v.size(); i++)
		{
			if (v[i] == k)
			{
				cout << "Yes" << endl;
			}
			else 
			{
				cout << "No" << endl;
				
			}
		
		}*/
			return 0;
	
}





	

  



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

struct node { int pa, le, ri; };
node T[300];
#define NIL -1

void preorder(int u)
{	
	if (u == NIL) return;
	cout << " " << u;
	preorder(T[u].le);
	preorder(T[u].ri);
}

void inorder(int u)
{
	if (u == NIL) return;
	inorder(T[u].le);
	cout << " " << u;
	inorder(T[u].ri);
}

void postorder(int u)
{
	if (u == NIL) return;
	postorder(T[u].le);
	postorder(T[u].ri);
	cout << " " << u;
}

int main()
{
	int n, l, r, u, i, j;
	cin >> n;

	for (i = 0; i < n; i++) T[i].pa = NIL;


	for (i = 0; i < n; i++)
	{
		cin >> u >> l >> r;
		T[u].le = l;
		T[u].ri = r;
		if (l != NIL)T[l].pa = u;
		if (r != NIL)T[r].pa = u;
	}

	for (i = 0; i < n; i++) if (T[i].pa == NIL) j = i;

	cout << "Preorder" << endl;
	preorder(j);
	cout << endl;
	cout << "Inorder" << endl;
	inorder(j);
	cout << endl;
	cout << "Postorder" << endl;
	postorder(j);
	cout << endl;

	return 0;
}




Measured memory_bytes: 3100
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int N;
vector<ll> a, b;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) {
        int t;
        cin >> t;
        a.push_back(t);
    }

    REP(i, N) {
        int t;
        cin >> t;
        b.push_back(t);
    }

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    ll ans = 0;

    // a[n]と足して，i-bit目が1になるようなb[j]の個数を求める
    for (int bit = 28; bit >= 0; bit--) {
        for (int j = 0; j < N; j++) {
            b[j] %= (1 << (bit + 1));
        }
        sort(all(b));

        ll g = 0;
        ll cbit = (1ll << bit);
        for (int j = 0; j < N; j++) {
            ll caj = a[j] % (1ll << (bit + 1)); // current a[j]
            if (a[j] & cbit) {
                // a[j]のbit目が1の場合
                // 全体＋足すとbit目が1になる下限—繰り上がり分
                g += N + lower_bound(all(b),2*cbit-caj)  - lower_bound(all(b), 3*cbit-caj);
            } else {
                // a[j]のbit目が0の場合
                // 上限はeにさらにbit目を足したもの（これにa[j]を足してもbit目は変わらないので
                // 第一項→ここより大きい値はa[j]を足すと繰り上がってbit目が0になる
                // 第二項→ここより小さい値はa[j]を足してもbit目は変わらず0
                // この間だけが1になる
                g += lower_bound(all(b), 2*cbit - caj) - lower_bound(all(b), cbit - caj);
            }
        }
        // 奇数個ならそのbitを足す
        if (g % 2 == 1) ans += cbit;
    }
    cout << ans << endl;


    return 0;
}


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

int main()
{
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	if(K >= A + B){
		cout << 2*A + B - K << endl;
	}else if(K > A && K < A + B){
		cout << A << endl;
	}else{
		cout << K << endl;
	}


}


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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[100010];
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int t;
		cin >> t;
		arr[t] = i + 1;
	}
	
	for(int i = 1; i <= n; i++){
		cout << arr[i] << " ";
	}
	cout << endl;
		
	return 0;
}


Measured memory_bytes: 1280
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

using i64 = long long;
const string ans[2] = {"First", "Second"};
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    cout << ans[(s.front() == s.back()) ^ (n % 2 == 0)] << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  vector<ll> v;
  ll seq = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s.at(i) == s.at(i - 1)) {
      seq++;
    }
    else {
      v.push_back(seq);
      seq = 1;
    }
  }
  v.push_back(seq);

  ll ans = 0;
  if (s.front() == s.back()) {
    if (v.size() == 1) {
      ans = (v.at(0) * k) / 2;
    }
    else {
      for (int i = 0; i < v.size(); i++) {
        if (i == 0 || i == v.size() - 1) ans += v.at(i) / 2;
        else ans += (v.at(i) / 2) * k;
      }
      ans += ((v.front() + v.back()) / 2) * (k - 1);
    }
  }
  else {
    for (auto el : v) {
      ans += (el / 2) * k;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N = 26;
int D;
ll c[26];
ll s[366][36];
int t[366];
set<int> st[26];

void input(){
    cin >> D;
    for(int i = 0; i < N; i++) {
        cin >> c[i];
        st[i].insert(0); st[i].insert(D+1);
    }
    for(int i = 1; i <= D; i++){
        for(int j = 0; j < N; j++) cin >> s[i][j];
    }
    for(int i = 1; i <= D; i++) {
        cin >> t[i];
        t[i]--;
        st[t[i]].insert(i);
    }
}


ll calc_score(){
    vector<int> last(N);
    ll S = 0;
    for(int d = 1; d <= D; d++){
        last[t[d]]  = d;
        for(int i = 0; i < N; i++){
            S -= c[i]*(d-last[i]);
        }
        S += s[d][t[d]];
    }
    return S;
}

ll calc_change(ll prev, int d, int q){
    prev -= s[d][t[d]]; prev += s[d][q];
    // t[d]がなくなる
    {
        auto l = st[t[d]].find(d); l--;
        auto r = st[t[d]].upper_bound(d);
        ll dif_l = d-*l, dif_r = *r-d;
        prev -= (dif_l)*(dif_r)*c[t[d]];
    }
    // qが増える
    {
        auto l = st[q].lower_bound(d); l--;
        auto r = st[q].upper_bound(d);
        ll dif_l = d-*l, dif_r = *r-d;
        prev += (dif_l)*(dif_r)*c[q];
    }
    return prev;
}

void change(int d, int q){
    st[t[d]].erase(d); st[q].insert(d);
    t[d] = q;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    input();
    int M;
    cin >> M;
    ll prev = calc_score();
    for(int i = 0; i < M; i++){
        int d, q;
        cin >> d >> q; q--;
        prev = calc_change(prev, d, q);
        change(d, q);
        cout << prev << endl;
    }
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int INF = 100000;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H + 1, vector<char>(W + 1, '#'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> s[i][j];
    }
  }
  vector<vector<int>> dp(H + 1, vector<int>(W + 1, INF));
//  dp[0][0] = 0;
  if (s[1][1] == '#'){
    dp[1][1] = 1;
  } else {
    dp[1][1] = 0;
  }
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (i == 1 && j == 1) continue;
      if (s[i][j] == '#'){
        if (s[i - 1][j] == '.'){
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
        if (s[i][j - 1] == '.'){
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }
      } else {
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
      }
    }
  }
  /*
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (dp[i][j] == INF){
        cout << ' ';
      } else {
        cout << dp[i][j];
      }
    }
    cout << endl;
  }
  */
/*
5 6
.##...
...###
##.###
#####.
#####.
*/
  cout << dp[H][W];
}

Measured memory_bytes: 256
C = input()

A = ["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"]

for i in range(26):
  if C == A[i]:
    print(A[i+1])
  elif C == "z":
    print("a")

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<string>s(n);
	rep(i, n) {
		cin >> s[i];
	}
	vector<int>ans(4, 0);
	rep(i, n) {
		if (s[i] == "AC")ans[0]++;
		else if (s[i] == "WA")ans[1]++;
		else if (s[i] == "TLE")ans[2]++;
		else if (s[i] == "RE")ans[3]++;
	}
	cout << "AC x " << ans[0] << endl;
	cout << "WA x " << ans[1] << endl;
	cout << "TLE x " << ans[2] << endl;
	cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 6296
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000009
#define fi first
#define se second

int search(int sx,int sy);
typedef pair<int,int>P;
int h,w;
char mp[21][21];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int main(){
  int ans=0;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j]!='#'){
        ans=max(ans,search(j,i));
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}

int search(int sx,int sy){
  int mx=0;
  int d[21][21];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=INF;
    }
  }
  queue<P>que;
  que.push(P(sx,sy));
  d[sy][sx]=0;

  while(!que.empty()){
    P p=que.front();
    que.pop();
    int x=p.fi;
    int y=p.se;
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]!='#'&&d[ny][nx]==INF){
        d[ny][nx]=d[y][x]+1;
        mx=max(mx,d[ny][nx]);
        que.push(P(nx,ny));
      }
    }
  }

  return mx;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <set>
#include <string>

using namespace std;


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

    long long int res = n + n*n + n*n*n;
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 3652
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        string ret;
        if (a > 0) ret = "Positive";
        else if (a == 0 | b == 0 | (a < 0 && b > 0)) ret = "Zero";
        else if (a < 0 && b < 0 && (b - a + 1) % 2 == 0) ret = "Positive";
        else ret = "Negative";
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

const int MAX = 100000;

stack<int> P;

void clear(){
  stack<int> empty;
  swap(P,empty);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,C,K;
  cin >> N >> C >> K;
  int T[N];
  for(int i=0;i<N;i++){
    cin >> T[i];
  }
  sort(T,T+N);
  int ans=1;
  int j,k;
  for(int i=0;i<N;i++){
    if(P.size()==C){
      ans++;
      clear();
    }
    if(P.empty()){
      P.push(T[i]);
      j=T[i]+K;
      continue;
    }
    if(T[i]<=j){
      P.push(T[i]);
      continue;
    }else if(T[i]>j){
      ans++;
      clear();
      P.push(T[i]);
      j=T[i]+K;
      continue;
    }
  }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	ll H, A;
	cin >> H >> A;

	ll res = H/A;
	if (H%A) res++;
	cout << res << "\n";
}


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

const int maxn=100000;

int a[60];



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

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

    int ans=0;

    for(int i=0;i<=min(n,k);++i)
    {
        for(int j=0;j<=i;++j)
        {
            vector<int> vec;
            for(int k=0;k<j;++k)
                vec.push_back(a[k]);
            for(int k=0;k<i-j;++k)
                vec.push_back(a[n-k-1]);

            sort(vec.begin(),vec.end());


            int t=k-i;
            int l;
            for(l=0;l<vec.size()&&t>0;++l)
            {
                if(vec[l]>=0)
                    break;
                --t;
            }
            int sum=0;
            //printf("****%d**",i);
            for(;l<vec.size();++l)
            {

                //printf("%d ",vec[l]);
                sum+=vec[l];
            }
            //putchar('\n');
            ans=max(ans,sum);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,i,j,sl,sr,ans=10000000;
    int w[120];
    for(i=0;i<120;i++){
        w[i]=0;
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    sl=w[0];
    sr=0;
    for(i=1;i<n;i++){
        sr+=w[i];
    }
    ans=abs(sl-sr);
    for(i=1;i<n;i++){
        sl+=w[i];
        sr-=w[i];
        if(abs(sl-sr)<ans){
            ans=abs(sl-sr);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

N = int(input())
W = [input() for i in range(N)]

if len(W) == len(set(W)):
    is_unique = True
else:
    is_unique = False

shiri = True
if is_unique:
    for i in range(N-1):
        shiri = W[i][-1] == W[i+1][0]
        if not shiri:
            break

if shiri and is_unique:
    print("Yes")
else:
    print("No")


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  float ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + v[i]) / 2.0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3780
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
int32_t main(){
    FastIO;
    int x=1;
    int n=5;
    while(n--) {
        int a;
        cin >> a;
        if (!a) {cout << x << endl; break;}
        x++;
    }
    return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> v;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        v.push_back({a, i});
    }
    sort(v.begin(), v.end());
    for (auto p : v) {
        cout << p.second << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
//#include <I AK IOI>
using namespace std;
int n, m, x[15005], y[15005];
bool vis[15005];
vector<int> g[15005];
long long ans;
void dfs(int x) {
    if(vis[x])
        return;
    vis[x] = true;
    for(int i = 0; i < g[x].size(); i++)
        dfs(g[x][i]);
}
int cnt; 
int main() {
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
        cin >> x[i] >> y[i];
    for(int i = 1; i <= m; i++) {
        memset(vis, false, sizeof(vis));
        for(int j = 1; j <= n; j++) {
            g[j].clear();
        }
        for(int j = 1; j <= m; j++) {
            if(j != i) {
                g[x[j]].push_back(y[j]);
                g[y[j]].push_back(x[j]);
            }
        }
        for(int j = 1; j <= n; j++) {
            if(!vis[j]) {
                dfs(j);
                cnt++;
            }
        }
        if(cnt > 1) {
            ans++;
        }
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		double T = sc.nextInt();
		double X = sc.nextInt();
		System.out.println(T / X);
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

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

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 100005;
int a[N];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n)scanf("%d", &a[i]);
	VVI g(n);
	REP(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].PB(y);
		g[y].PB(x);
	}
	VVI forest;
	vector<bool> visit(n);
	REP(i, n) {
		if (visit[i])continue;
		visit[i] = true;
		VI tree;
		deque<int> q;
		q.push_back(i);
		while (!q.empty()) {
			int u = q.front();
			q.pop_front();
			tree.PB(a[u]);
			for (auto v : g[u]) {
				if (visit[v])continue;
				q.push_back(v);
				visit[v] = true;
			}
		}
		forest.PB(tree);
	}
	int k = forest.size();
	if (k == 1) {
		printf("0\n");
		return 0;
	}
	if (2 * (k-1) > n) {
		printf("Impossible\n");
		return 0;
	}
	REP(i, k)SORT(forest[i]);

	LL ret = 0;
	VI rem;
	REP(i, k) {
		ret += forest[i][0];
		FOR(j, 1, forest[i].size())rem.PB(forest[i][j]);
	}
	SORT(rem);
	REP(i, k - 2)ret += rem[i];
	cout << ret << endl;
	return 0;
}

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

int main() {
  int A , B , C , D ;
  cin >> A >> B >> C >> D ;
  if ((A + B) == (C + D)){
  	cout << "Balanced" << endl;
  }else if((A + B) > (C + D)){
  	cout << "Left" << endl;
  }else{
  	cout << "Right" << endl;
  }
}

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

int N, M;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    for (int i = 0; i < M; i++) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        tree.unite(X-1, Y-1);
    }

    set<int> S;
    for (int i = 0; i < N; i++) {
        S.insert(tree.root(i));
    }

    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 5376
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class CDiceAndCoin {
public:
	void solve(std::istream& in, std::ostream& out) {
        double n,k;
        in>>n>>k;
        double ans=0;
        double x = 1/n;
        for(ll i=1; i<=n; i++){
            double tmp = 1/n;
            double now = i;
            while (now<k){
                now*=2;
                tmp*=0.5;
            }
            ans+=tmp;

        }
        printf("%.16f",ans);
	}
};


int main() {
	CDiceAndCoin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
#define MAXN 21
#define MOD 1000000007
 
int N;
long long dp[MAXN][1<<MAXN];
int m[MAXN][MAXN];
 
int d(int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];
  
  	dp[i][j] = 0;
  
  	for (int k = 0; k < N; k++) {
      if (m[i][k] == 1 && (j&(1<<k))) {
        dp[i][j] = (dp[i][j] + d(i-1,j^(1<<k)))%MOD;
      }
    }
  
  return dp[i][j];
}
 
int main() {
	cin >> N;
  	for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> m[i][j];
      }
    }
  	for (int i = 0; i < N; i++) {
      for (int j = 0; j < (1<<N); j++) {
        dp[i][j] = -1;
      }
    }
  for (int i = 0; i < (1<<N); i++) {
    dp[0][i] = 0;
    for (int j = 0; j < N; j++) {
      if (m[0][j] == 1 && (i&(1<<j))) {
        dp[0][i]++;
      }
          }
          }
  cout << d(N-1,(1<<N)-1) << endl;
}

Measured memory_bytes: 344320
s = input()
k = int(input())
ans = ""
for i in range(len(s)-1):
    cost = ord("z")+1-ord(s[i])
    if s[i] == "a" or k < cost:
        ans += s[i]
    else:
        ans += "a"
        k -= cost
c = s[-1]
k %= 26
for _ in range(k):
    if c == "z": c = "a"
    else: c = chr(ord(c)+1)
ans += c
print(ans)

Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,a,i,j,k,ans=0;
  cin>>h>>w;
  vector<vector<int>> c(10,vector<int>(10));
  for(i=0;i<10;i++) for(j=0;j<10;j++) cin>>c.at(i).at(j);
  for(k=0;k<10;k++) for(i=0;i<10;i++) for(j=0;j<10;j++) c.at(i).at(j)=min(c.at(i).at(j),c.at(i).at(k)+c.at(k).at(j));
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>a;
      if(a!=-1) ans+=c.at(a).at(1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3556
n = int(input())
a = list(map(int,input().split()))
ans = 1
ju = 0
j = 0
if 0 in a:
    ju=1

for i in range(n):
    ans = ans*a[i]
    if ans>10**18:
        j = 1
        break

if ju==1:
    print(0)
elif j==1:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 84416
#include <iostream>
#include <string>

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

    int t_score = 0;
    int h_score = 0;
    
    for (int i = 0; i < n; i++) {
        std::string t_card;
        std::cin >> t_card;
  
        std::string h_card;
        std::cin >> h_card;
        
        if(t_card > h_card)
            t_score+=3;
        if(h_card > t_card)
            h_score+=3;
        if(t_card == h_card){
            t_score++;
            h_score++;
        }
    }
    std::cout << t_score << " " << h_score << std::endl;
            
    return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<int> roads(n);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    roads.at(--a)++;
    roads.at(--b)++;
  }
  for (int e: roads) cout << e << endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 22 2020 21:55:24 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vi a(n);
    fori(i,n) cin >> a[i];
    vi ans(n);
    int mx = 0;
    fori(i,n-1){
        mx = max(mx,a[i]);
        ans[i+1] = mx;
    }
    mx = 0;
    repd(i,n-1,1){
        mx = max(mx,a[i]);
        ans[i-1] = max(mx,ans[i-1]);
    }
    fori(i,n){
        cout << ans[i] << endl;
    }

    time_taken();
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int k;
  cin >> k;

  priority_queue<ll, vector<ll>, greater<ll> > pque;
  for (int i = 1; i <= 9; i++) pque.push(i);
  int p = 0;
  ll ans = 0;
  while (!pque.empty()) {
    auto now = pque.top();
    pque.pop();
    p++;
    if (p == k) {
      ans = now;
      break;
    }
    if (now % 10 > 0) pque.push(now * 10 + now % 10 - 1);
    pque.push(now * 10 + now % 10);
    if (now % 10 < 9) pque.push(now * 10 + now % 10 + 1);
  }

  cout << ans << endl;

  return 0;
}


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

#define int long long

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

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; 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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int h,w;
	cin>>h>>w;
	int dis[10][10];
	rep(i,10){
		rep(j,10){
			cin>>dis[i][j];
		}
	}
	rep(i,10){
		rep(j,10){
			rep(k,10){
				dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
			}
		}
	}
	int cnt[10]={};
	rep(i,h){
		rep(j,w){
			int a;
			cin>>a;
			if(a!=-1)cnt[a]++;
		}
	}
	int re=0;
	rep(i,10){
		re+=cnt[i]*dis[i][1];
	}
	cout<<re<<endl;
}

Measured memory_bytes: 256