akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int x = scanner.nextInt();
		int i = 1;
		while(x != 0) {
			System.out.println("Case " + i +": " + x);
			x = scanner.nextInt();
			i++;
		}
	}
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_Q = (int)(2e5 + 5);

using event = tuple<ll, int, ll>;

int n, q;
ll d[MAX_Q];

priority_queue<event, vector<event>, greater<event>> events;

map<int, ll> ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &q);

  for (int i = 0; i < n; ++i) {
    ll s, t, x;
    scanf("%lld %lld %lld", &s, &t, &x);

    events.push(make_tuple(s - x, 1, x));
    events.push(make_tuple(t - x, -1, x));
  }

  for (int i = 0; i < q; ++i) {
    scanf("%lld", &(d[i]));
  }
  //
  // while (!events.empty()) {
  //   event cur_event = events.top();
  //   events.pop();
  //   printf("%lld\n", get<0>(cur_event));
  // }

  set<ll> pos_set;

  for (int i = 0; i < q; ++i) {
    ll period = d[i];

    // printf("%lld: ", period);

    while (!events.empty() && get<0>(events.top()) <= period) {
      event cur_event = events.top();
      events.pop();

      int in_or_erase = get<1>(cur_event);
      ll cur_pos = get<2>(cur_event);

      // printf("%lld ", get<0>(cur_event));

      if (in_or_erase == 1) {
        pos_set.insert(cur_pos);
      }
      else {
        pos_set.erase(cur_pos);
      }
    }

    // printf("\n");

    if (pos_set.empty()) {
      ans[i] = -1LL;
    }
    else {
      ans[i] = *(pos_set.begin());
    }
  }

  for (auto &e: ans) {
    printf("%lld\n", e.second);
  }

  return 0;
}


Measured memory_bytes: 26984
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

stack<int> st;

int main() {
	for(int p; cin >> p;) {
		if(p == 0) {
			printf("%d\n", st.top());
			st.pop();
		} else {
			st.push(p);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    char S[4];
    for(int i=0;i<4;i++){
        cin>>S[i];
    }
    int check=0;
    for(int i=0;i<3;i++){
        if(S[i]==S[i+1]){
            check=1;
            break;
        }
    }

    if(check==1){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v._size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v._size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }

        

        

        

        void solve1(){
            cin >> n;
            string s1,s2;
            cin >> s1 >> s2;
            if(s1 == s2){
                cout << "0\n";
                return;
            }
            int len1 = 0, len2 = 0;
            for(int i=0;i < n; i++){
                if(s1[i] == '1') len1++;
                if(s2[i] == '1') len2++;
            }
            if(len1 != len2) {cout << "-1\n"; return;}
        }


        void solve(){
            cin >> n >> k;
            vector<int> v(n);
            for(int i=0; i < n;i++){
                cin >> v[i];
            }
            sortV(v);
            int sum = 0;
            for(int i=0; i < k; i++) sum += v[i];
            cout << sum << endl;
        }

       
    


        int main(){
            ios_base::sync_with_stdio(false);

            

            

            int cases = 1;
            //cin >> cases;

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

        }

Measured memory_bytes: 3672
W, H, N = [int(i) for i in input().split()]

w, h = 0, 0
for x, y, a in [[int(i) for i in input().split()] for _ in range(N)]:
    if a == 1:
        w = max(w, x)
    if a == 2:
        W = min(W, x)
    if a == 3:
        h = max(h, y)
    if a == 4:
        H = min(H, y)

print(max(0, W - w) * max(0, H - h))

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

using namespace std;

int main(){
	while(true){
	int a,b,q;
	char op;
	cin >> a >> op >> b;
	if(op=='?')break;
	if(op=='+'){
		q=a+b;
	}
	else if(op=='-'){
		q=a-b;
	}
	else if(op=='*'){
		q=a*b;
	}
	else if(op=='/'){
		q=a/b;
	}
	cout << q << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
#include<vector>
#include<cstring>
#include<iostream>
#include<set>
using namespace std;
int n,m;
struct problem 
{
	int p,t;
	bool tp;
}p[100010];
char s[10];
set<int> se;
int ans1,ans2;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		p[i].t=0;
		p[i].tp=false;
	}
	for(int i=1;i<=m;i++)
	{
		int x;
		cin>>x;
		scanf("%s",s+1);
		if(s[1]=='A')
		{
			if(!p[x].tp)
			{
				p[x].tp=true;
				ans1++;
				ans2+=p[x].t;
			}
		}
		else
		{
			p[x].t++; 
		}
	}
	printf("%d %d\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
char c[114][514];
using namespace std;
signed main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int l=0;l<w;l++){
            cin>>c[i][l];
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int l=0;l<w;l++){
            ans=0;
            if(c[i][l]=='.'){
                for(int j=-1;j<=1;j++){
                    for(int k=-1;k<=1;k++){
                        if(c[i+j][l+k]=='#'){
                            ans++;
                        }
                    }
                }
                cout<<ans;
            }
            else{
                cout<<c[i][l];
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
# coding:utf-8

n = int(input())
h = list(map(int, input().split()))

#1 2 2 1
# リストを与えると、0より大きい最大の区間までを-1する関数

ans = 0
index = 0

while True:
    #if index == len(h) - 1:
    #    break
    if max(h) == 0:
        break

    
    if h[index] == 0:# indexが0の時
        index += 1
        continue
    
    # 1 (2 2 1)
    ushiro = h[index:]
    for i in range(len(ushiro)):
        if h[index+i] != 0:
            h[index+i] -= 1# 1 (2 2 1) を引いてく
        else:
            break
    ans += 1

print(ans)




Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (writeln!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      a: usize,
      b: usize,
    }

    let ans = min(b, a*n);
    puts!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        if (A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 25044
n = int(input())
dist = [list(map(int, input().split())) for i in range(n)]
use = [[True]*n for _ in range(n)]
# 最短性の確認
for i in range(n):
    for j in range(n):
        for k in range(n):
            if dist[j][k] > dist[j][i] + dist[i][k]:
                print(-1)
                exit()
            if (i - j) * (j - k) * (k - i) and dist[j][k] == dist[j][i] + dist[i][k]:
                use[j][k] = False
                
ans = 0

for i in range(n):
    for j in range(i+1, n):
        if use[i][j]:
            ans += dist[i][j]

print(ans)


Measured memory_bytes: 46428
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S;
    int K;
    int count = 0;

    cin >> S;
    cin >> K;

    for (char c : S) {
        if (c == '1') {
            ++count;
        } else {
            cout << c << endl;
            return 0;
        }

        if (count >= K) {
            cout << 1 << endl;
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll m,count=0,count1=0,x,y,res=0;
cin>>m;
string s;
cin>>s;
ll n=s.length();
for(int i=0;i<n-1;i++)
{if(s[i]==s[i+1])
 count++;
 else
 break;
}
for(int i=n-1;i>0;i--)
{if(s[i]==s[i-1])
 count1++;
 else
 break;
}
count++;
count1++;
if(count==m||count1==m)
cout<<0;
else if((count+count1)==m)
{if(s[0]=='R')
 cout<<0;
 else
 cout<<count1;
}
else
{x=0;
 y=n-1;
while(x<y)
 {if(s[x]=='W'&&s[y]=='R')
  {ll temp=s[y];
  s[y]=s[x];
   s[x]=temp;
   x++;
   y--;
   res++;
  }
  else if(s[x]=='W'&&s[y]=='W')
   y--;
   else if(s[x]=='R'&&s[y]=='W')
   {x++;
    y--;
   }
   else if(s[x]=='R'&&s[y]=='R')
   x++;
   
 }
 cout<<res;
}
}

Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	double R;
	cin >> R;

	double pi = acos(-1.0);

	cout << fixed;
	cout << setprecision(5) << 2 * pi * R << endl;

	return 0;
}


Measured memory_bytes: 3788
N = int(input())
A = []

def f(s):
    if s != '' and eval(s) > N:
        return 0
    if all(s.count(i) >= 1 for i in '753'):
        A.append(eval(s))
    for i in '753':
        f(s + i)

f('')
print(len(A))
# print(sorted(A))

Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        if (N == 1 and M == 1) {
                cout << 1 << endl;
                return 0;
        } else if (N == 2 or M == 2) {
                cout << 0 << endl;
                return 0;
        } else {
                ll a = max(1ll, N - 2);
                ll b = max(1ll, M - 2);
                cout << a * b << endl;
        }

}

Measured memory_bytes: 256
/* 
 * Author: pawanmsr
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //

// Functions //

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    int r; cin >> r;
    static float pi = 3.141593;
    cout << 2 * pi * r << endl;
    return 0;
}


Measured memory_bytes: 3784
# 基本的には一文字ずつ変えていけば変わるはずだがある一つの文字に複数の別の文字が当たってると変換できない
# chokudai
# redkuoai
# redcouai
# reucodai
# raucodei
# iaucoder

S = list(input())
T = list(input())

from collections import defaultdict
s_dic = defaultdict(set)
t_dic = defaultdict(set)
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if len(s_dic[s]) > 0 and t not in s_dic[s]:
        print('No')
        exit()
    if len(t_dic[t]) > 0 and s not in t_dic[t]:
        print('No')
        exit()
    s_dic[s].add(t)
    t_dic[t].add(s)

print('Yes')


Measured memory_bytes: 12452
class SegmentTree():
  def __init__(self, n, oper, e):
    self.n = n
    self.oper = oper
    self.e = e
    self.log = (n - 1).bit_length()
    self.size = 1 << self.log
    self.data = [e] * (2 * self.size)

  def update(self, k):
    self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1])

  def build(self, arr):
    #assert len(arr) <= self.n
    for i in range(self.n):
      self.data[self.size + i] = arr[i]
    for i in range(self.size-1,0,-1):
      self.update(i)

  def set(self, p, x):
    #assert 0 <= p < self.n
    p += self.size
    self.data[p] = x
    for i in range(1, self.log + 1):
      self.update(p >> i)

  def get(self, p):
    #assert 0 <= p < self.n
    return self.data[p + self.size]

  def prod(self, l, r):
    #assert 0 <= l <= r <= self.n
    sml = smr = self.e
    l += self.size
    r += self.size
    while l < r:
      if l & 1:
        sml = self.oper(sml, self.data[l])
        l += 1
      if r & 1:
        r -= 1
        smr = self.oper(self.data[r], smr)
      l >>= 1
      r >>= 1
    return self.oper(sml, smr)

  def all_prod(self):
    return self.data[1]

  def max_right(self, l, f):
    #assert 0 <= l <= self.n
    #assert f(self.)
    if l == self.n: return self.n
    l += self.size
    sm = self.e
    while True:
      while l % 2 == 0: l >>= 1
      if not f(self.oper(sm, self.data[l])):
        while l < self.size:
          l = 2 * l
          if f(self.oper(sm, self.data[l])):
            sm = self.oper(sm, self.data[l])
            l += 1
        return l - self.size
      sm = self.oper(sm, self.data[l])
      l += 1
      if (l & -l) == l: break
    return self.n

  def min_left(self, r, f):
    #assert 0 <= r <= self.n
    #assert f(self.)
    if r == 0: return 0
    r += self.size
    sm = self.e
    while True:
      r -= 1
      while r > 1 and (r % 2): r >>= 1
      if not f(self.oper(self.data[r], sm)):
        while r < self.size:
          r = 2 * r + 1
          if f(self.oper(self.data[r], sm)):
            sm = self.oper(self.data[r], sm)
            r -= 1
        return r + 1 - self.size
      sm = self.oper(self.data[r], sm)
      if (r & -r) == r: break
    return 0

#import sys
#input = sys.stdin.readline

n,k=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i]=int(input())
maxa=max(a)

st = SegmentTree(maxa+1,max,0)
#st.build(a)


ans=0
for i in range(n):
    l=max(a[i]-k,0)
    r=min(a[i]+k,300000)
    tmp=st.prod(l,r+1)+1
#    print(i,l,r+1,tmp)
    ans=max(ans,tmp)
    st.set(a[i],tmp)

print(ans)


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

using namespace std;

#define LL long long
#define INF 0x3f3f3f3f

LL n,xb,mx,ans[2],a[3000],out[3000];
pair<LL,LL> mtd;
vector<LL> vec[2];

int main(){
	scanf("%lld",&n);
	mx=-INF;
	for (LL i=1;i<=n;++i){scanf("%lld",&a[i]); mx=max(mx,a[i]);}
	if (mx<=0){
		printf("%lld\n",mx);
		LL i;
		for (i=n;a[i]!=mx;--i) out[++xb]=i;
		for (--i;i;--i) out[++xb]=1;
		printf("%lld\n",xb);
		for (LL i=1;i<=xb;++i) printf("%lld\n",out[i]);
		return 0;
	}
	for (LL i=1;i<=n;++i)
		if (a[i]>0){
			if (i&1){ans[0]+=a[i]; vec[0].push_back(i);}
			else{ans[1]+=a[i]; vec[1].push_back(i);}
		}
	LL k;
	k=ans[0]>ans[1]?0:1;
	printf("%lld\n",ans[k]);
	LL sz=vec[k].size()-1;
	for (LL i=n;i>vec[k][sz];--i) out[++xb]=i;
	for (LL i=sz;i;--i){
		LL j=(vec[k][i]+vec[k][i-1])/2;
		for (;j>vec[k][i-1];--j) out[++xb]=j;
	}
	for (LL i=vec[k][0]-1;i;--i) out[++xb]=1;
	printf("%lld\n",xb);
	for (LL i=1;i<=xb;++i) printf("%lld\n",out[i]);
	
	return 0;
}
			

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pas;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(c=1; c<=100000; c++){
        d=c*8/100;
        e=c/10;
        if(d==a&&e==b){
            cout<<c;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll st=0;
  int ans,date;
  vector<int> c(26),l(26,0);
  vector<vector<int>> s(date,vector<int>(26));
  cin >> date;
  rep(i,26) cin >> c.at(i);
  rep(i,date) {
    rep(j,26){
      cin >> s.at(i).at(j);
    }
  }
  rep(i,date) {
    cin >>ans;
    l[ans-1]=i+1;
    st+=s[i][ans-1];
    rep(j,26)st-=c[j]*(i+1-l[j]);
    cout <<st<<endl;
  }
}

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

int main()
{
	int n;
	cin>>n;
	int temp=12;
	int cc=4;
	while(cc--)
	{
		int k=n%10;
		if(k==temp)
		{
			cout<<"Bad";
			return 0;
		}
		n=n/10;
		temp=k;
	}
	cout<<"Good";
}



Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, a: "List[int]"):
    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)
    g = a[0]
    for v in a:
        tmp = gcd(g, v)
        g = g * v // tmp
        if M < g // 2:
            print(0)
            return
    for v in a:
        if (g // v) % 2 == 0:
            print(0)
            return
    M -= g // 2
    ret = M // g + 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 60576
#include <algorithm>
#include <cstdio>
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int lp[35], rp[35], app[35], val[35], inv[35], dp[40005][15];
bool in_S[35], in_T[35];
int main()
{
	// freopen("B.in", "r", stdin);
	int n, q, cnt = 0, off = 0;
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d%d", lp + i, rp + i);
		app[cnt++] = --lp[i];
		app[cnt++] = rp[i];
	}
	std::sort(app, app + cnt);
	cnt = std::unique(app, app + cnt) - app;
	if (app[0])
	{
		off = app[0];
		n -= off;
		for (int i = 0; i < cnt; i++)
			app[i] -= off;
		for (int i = 0; i < q; i++)
		{
			lp[i] -= off;
			rp[i] -= off;
		}
	}
	for (int i = 0; i < q; i++)
	{
		lp[i] = std::lower_bound(app, app + cnt, lp[i]) - app;
		rp[i] = std::lower_bound(app, app + cnt, rp[i]) - app;
	}
	for (int i = 1; i < cnt; i++)
	{
		val[i] = (ll)(quick_pow(10, app[i] - app[i - 1]) - 1) * (MOD + 1) / 9 % MOD;
		inv[i] = quick_pow(val[i], MOD - 2);
	}
	auto get_in = [&] (int mask, bool * res)
	{
		for (int i = 0; i < cnt; i++)
			res[i] = false;
		for (int i = 0; i < q; i++)
		{
			if (mask & (1 << i))
				res[lp[i]] = res[rp[i]] = true;
		}
	};
	auto trans = [&] (int S, int T)
	{
		get_in(S, in_S);
		get_in(T, in_T);
		for (int i = 0; i < cnt; i++)
		{
			if (in_S[i] && in_T[i])
				return;
		}
		int coef = 1;
		for (int i = 1; i < cnt; i++)
		{
			if (in_T[i] && in_T[i - 1])
				coef = (ll)coef * (val[i] + 1) % MOD * inv[i] % MOD;
		}
		for (int i = 1; i < 10; i++)
			dp[S | T][i] = (dp[S | T][i] + (ll)dp[S][i - 1] * coef) % MOD;
	};
	dp[0][0] = 1;
	for (int i = 0; i + 1 < 1 << q; i++)
	{
		int rem = (1 << q) - 1 ^ i, low = rem & -rem;
		for (int j = rem ^ low; ; j = (j - 1) & (rem ^ low))
		{
			trans(i, j | low);
			if (!j)
				break;
		}
	}
	int ans = 0, cur = 1;
	for (int i = 1; i < 10; cur = cur * (9 - i), i++)
		ans = (ans + (ll)dp[(1 << q) - 1][i] * cur) % MOD;
	for (int i = 1; i < cnt; i++)
		ans = (ll)ans * val[i] % MOD;
	printf("%lld\n", (ll)ans * quick_pow(10, off + n - app[cnt - 1]) % MOD);
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
vl parent;
vvl adj;

void buildParent(ll cur) {
        for (ll nei : adj[cur]) {
                if (nei == parent[cur]) continue;
                parent[nei] = cur;
                buildParent(nei);
        }
}

ll countNodes(ll cur) {
        ll res = 1;
        for (ll nei : adj[cur]) {
                if (nei == parent[cur]) continue;
                res += countNodes(nei);
        }
        return res;
}
int main(){ cin.sync_with_stdio(0);
        ll N; cin >> N;
        adj.resize(N);

        FOR(i, 0, N-1) {
                ll a, b; cin >> a >> b;
                a--, b--;

                adj[a].pb(b);
                adj[b].pb(a);
        }

        parent.assign(N, -1);
        buildParent(0);


        vl path;

        ll cur = N-1;
        while (parent[cur] != -1) {
                path.pb(cur);
                cur = parent[cur];
        }


        ll middle = path[(sz(path)-1)/2];


        ll whites = countNodes(middle);


        if (whites >= N-whites) {
                cout << "Snuke" << endl;
        } else {
                cout << "Fennec" << endl;
        }
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 12408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ch = true;
    REP (i, 0, a) if (!('0' <= s[i] && s[i] <= '9')) ch = false;
    if (s[a] != '-') ch = false;
    REP (i, a + 1, a + b + 1) if (!('0' <= s[i] && s[i] <= '9')) ch = false;
    cout << (ch ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N (800000+1000)
#define MOD (924844033)
#define LL long long
using namespace std;

struct Edge{int to,next;}edge[N];
LL n,u,v,fn=1,l,r[N],a[N],b[N];
LL fac[N],inv[N],facinv[N],ans[N];
LL head[N],num_edge,size[N],cnt[N];

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

LL Qpow(LL a,LL b)
{
	LL ans=1,base=a;
	while (b)
	{
		if (b&1) ans=ans*base%MOD;
		base=base*base%MOD; b>>=1;
	}
	return ans;
}

void NTT(LL n,LL *a,LL opt)
{
	for (int i=0; i<n; ++i)
		if (i<r[i]) swap(a[i],a[r[i]]);
	for (int k=1; k<n; k<<=1)
	{
		LL wn=Qpow(5,(MOD-1)/(k<<1));
		for (int i=0; i<n; i+=(k<<1))
		{
			LL w=1;
			for (int j=0; j<k; ++j, w=w*wn%MOD)
			{
				LL x=a[i+j], y=w*a[i+j+k]%MOD;
				a[i+j]=(x+y)%MOD; a[i+j+k]=(x-y+MOD)%MOD;
			}
		}
	}
	if (opt==-1)
	{
		reverse(a+1,a+n);
		LL g=Qpow(n,MOD-2);
		for (int i=0; i<n; ++i) a[i]=a[i]*g%MOD;
	}
}

void Init()
{
	fac[0]=1; inv[1]=1; facinv[0]=1;
	for (int i=1; i<=n; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

LL C(LL n,LL m)
{
	if (n<m) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

void Dfs(int x,int fa)
{
	size[x]=1;
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			Dfs(edge[i].to,x); 
			cnt[size[edge[i].to]]++;
			size[x]+=size[edge[i].to];
		}
	cnt[n-size[x]]++;
}

int main()
{
	scanf("%lld",&n);
	for (int i=1; i<=n-1; ++i)
	{
		scanf("%lld%lld",&u,&v);
		add(u,v); add(v,u);
	}
	Init(); Dfs(1,-1);
	while (fn<=n+n) fn<<=1, l++;
	for (int i=0; i<=fn; ++i)
		r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
		
	for (int i=0; i<=n; ++i) a[i]=cnt[i]*fac[i]%MOD;
	for (int i=0; i<=n; ++i) b[i]=facinv[n-i];

	NTT(fn,a,1); NTT(fn,b,1);
	for (int i=0; i<=fn; ++i) a[i]=a[i]*b[i]%MOD;
	NTT(fn,a,-1);
	
	for (int i=1; i<=n; ++i) ans[i]=-facinv[i]*a[n+i]%MOD+MOD;
	for (int i=1; i<=n; ++i) ans[i]=(ans[i]+n*C(n,i))%MOD;
	for (int i=1; i<=n; ++i) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 52608
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int A, B;
  cin >> A >> B;
  
  if(A >= 13) cout << B << endl;
  else if((A <= 12) && (A >= 6)) cout << B / 2 << endl;
  else cout << 0 << endl;

  return 0;
  
}

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

//             5,000,000,000,000,000
// 10^18 = 1,000,000,000,000,000,000
// 2^5,000,000,000,000,000

//1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112

int main(void)
{
	char s[101];
	long long k;
	long long i;
	int s_size;

	gets(s);
	scanf("%lld",&k);

	s_size = strlen(s);

	for(i=0; i<s_size; i++){
		if(s[i] != '1'){
			break;
		}
	}

	if(k-1 < i){
		i = k-1;
	}

	printf("%c\n",s[i]);

	return 0;
}


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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    #define mod %MOD
    #define sz(a) a.size()
    
    const long long inf = (long long)1e18;
    const long long MOD = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    ll bpw(ll a, ll b) {
        if(b == 0) return 1;
        if(b % 2 == 1) {
            return bpw(a, b - 1) * a mod;
        } else {
            ll b2 = bpw(a, b / 2) mod;
            return b2 * b2 mod;
        }
    }
    ll ncr(ll n, ll r) { 
        ll p = 1, k = 1, m; 
        if (n - r < r) 
            r = n - r; 
        if (r != 0) { 
            while (r) { 
                p *= n; 
                k *= r; 
                m = __gcd(p, k); 
                p /= m; 
                k /= m; 
                n--; 
                r--; 
            } 
        } 
        else
            p = 1;  
        return p; 
    } 

    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll p, n, d = -1, m, ans = 0;
        cin >> p >> n;
        ll a[n];
        cin >> a[0];
        fab(i, 1, n) 
            cin >> a[i];
        ans = min(a[n - 1] - a[0], p - a[1] + a[0]);
        fab(i, 1, n - 1) {
            ans = min(ans, p - a[i] + a[i - 1]);
            ans = min(ans, p - a[i + 1] + a[i]);
        }
        ans = min(ans, p - a[n - 1] + a[n - 2]);
        ans = min(ans, a[n - 1] - a[0]);
        cout << ans;
        return 0;
    }

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll a[3000];
ll memo[2][3000][3000];
ll solve(int turn, int l, int r) {
	if (l == r) {
		if (turn) return a[l];
		else return -a[l];
	}
	if (memo[turn][l][r] != 1LL << 60) return memo[turn][l][r];
	if (turn) {
		return memo[turn][l][r] = max(a[l] + solve(!turn, l + 1, r), a[r] + solve(!turn, l, r - 1));
	}
	else {
		return memo[turn][l][r] = min(-a[l] + solve(!turn, l + 1, r), -a[r] + solve(!turn, l, r - 1));
	}
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	fill((ll*)memo, (ll*)(memo + 2), 1LL << 60);
	cout << solve(1, 0, N - 1) << endl;
}

Measured memory_bytes: 141184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  int ans = (a + b) % 24;
  cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
const int INF=1e9;
int sum_w[300100];
int sum_e[300100];
int num;
int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;
  cin >> n >> s;
  
  //1-indexed
  sum_w[0] = 0;
  sum_e[0] = 0;  
  REP(i, n){
    if(s[i] == 'W') {
      sum_w[i+1] = sum_w[i]+1;
      sum_e[i+1] = sum_e[i];
    }
    if(s[i] == 'E'){
      sum_e[i+1] = sum_e[i]+1;
      sum_w[i+1] = sum_w[i];      
    }
  }
  ll tmp, ans=INF;
  FOR(leader,1,n+1){    
    //cout << "migi E:" << sum_e[n]-sum_e[leader] << endl;
    //cout << "hidari W:" << sum_w[leader-1]-sum_w[0] << endl;
    tmp =  sum_e[n]-sum_e[leader] +  sum_w[leader-1]-sum_w[0];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	ll ans=0LL;
	cin >>s;
	V dis(s.size() + 1,-1);
	char last = '>';
	rep(i,s.size()){
		if(last=='<' and  dis[i-1]!=-1){
			chmax(dis[i], dis[i - 1] + 1);
		}

		if(last=='>' and  s[i]=='<'){
			dis[i] = 0;
		}

		last = s[i];
	}
	if(last=='<'){
		dis[s.size()] = 1+dis[s.size() - 1];
	}else{
		dis[s.size()]=0LL;
	}
	for (int i = s.size() - 1; i >= 0;i--){
		if(s[i]=='>'){
			chmax(dis[i], 1 + dis[i + 1]);
		}

	}// clog << dis << endl;
	rep(i, dis.size()) { ans += dis[i]; }
	cout<<ans<<endl;
}
/*
0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1
6
3
15
3
1
*/

Measured memory_bytes: 7648
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template <class Q>
void clearQueue(Q & q) {
    q=Q();
}
void solve(){
	int n;cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++){
		int x,y;cin>>x>>y;
		if(x==y) cnt++;
		else cnt=0;
		if(cnt==3){
			cout<<"Yes";return;
		} 
	}
	cout<<"No";
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 3652
// AOJ ALDS1_1_C Prime Numbers
// 2018.4.27 bal4u

#include <stdio.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int N, i, a, r, ans;

	N = in();
	ans = 0;
	while (N--) {
		a = in();
		if (a == 2) ans++;
		else if (a&1) {
			r = (int)sqrt(a);
			for (i = 3; ; i+=2) {
				if (i > r) { ans++; break; }
				if (a%i == 0) break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}




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

int main() {
    long long n, d, x, y;
    cin >> n >> d;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> x >> y;
        long long l2 = x * x + y * y;
        double l = sqrt((double)l2);
        if (l <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
// #define DEBUGGING
using namespace std;
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll M;
    cin >> M;
    V<PLL> vp(M);
    for(auto &&ele : vp) cin >> ele.first >> ele.second;
    ll ans = 0;
    ll sum = 0;
    V<ll> rests;
    for(ll i = 0; i < vp.size(); i++) {
        ll d, c;
        tie(d, c) = vp[i];
        ans += c - 1;
        ll tmp = c * d;
        while(10 <= tmp) {
            if(tmp % 10) rests.push_back(tmp % 10);
            else ans++;
            tmp /= 10;
            ans += tmp - 1;
        }
        rests.push_back(tmp);
    }

    DEBUG(ans);
    DEBUG(rests);
    while(2 <= rests.size()) {
        ll a = rests.back();
        rests.pop_back();
        ll b = rests.back();
        rests.pop_back();
        ll c = a + b;
        if(10 <= c) rests.push_back(1);
        rests.push_back(c % 10);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21224
N = gets.to_i
AS = [nil] + gets.split.map(&:to_i)
BS = [nil] + gets.split.map(&:to_i)
CS = [nil] + gets.split.map(&:to_i)

ans = 0
prev_x = -1
for i in 1..N
  x = AS[i]
  ans += BS[x]
  if x == prev_x + 1
    ans += CS[prev_x]
  end
  prev_x = x
end
p ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<pair<long long, long long>> v;
    for (int i=0; i<n; i++){
        long long x,y;
        cin >> x >>y;
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end());
    long long ans=10e19;
    for (int i=0; i<n-k+1; i++){
        for (int j=i+k-1; j<n; j++){
            vector<long long> vv;
            for (int x=i; x<=j; x++){
                vv.push_back(v[x].second);
            }
            sort(vv.begin(),vv.end());
            for (int l=0; l<j-i-k+2; l++){
                int m=l+k-1;
                long long scale=(v[j].first-v[i].first)*(vv[m]-vv[l]);
                ans=min(ans,scale);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = 3
rows = [list(map(int, input().split())) for i in range(n)]
nums = rows[0] + rows[1] + rows[2]
isTrue = False
if nums[0]-nums[1] == nums[3]-nums[4] == nums[6]-nums[7] and nums[0]-nums[3] == nums[1]-nums[4] == nums[2]-nums[5]:
    isTrue = True
else:
    isTrue = False
if nums[1]-nums[2] == nums[4]-nums[5] == nums[7]-nums[8] and nums[3]-nums[6] == nums[4]-nums[7] == nums[5]-nums[8]:
    isTrue = True
else:
    isTrue = False
if isTrue:
    print("Yes")    
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110000];
int L[110000];
int R[110000];
int segtree[262144];
void add(int a,int b,int c,int d,int e,int f){
	if(d<a||b<c)return ;
	if(c<=a&&b<=d){
		segtree[e]=(segtree[e]+f)%26;
		return;
	}
	add(a,(a+b)/2,c,d,e*2,f);
	add((a+b)/2+1,b,c,d,e*2+1,f);
}
int sum(int a){
	a+=131072;
	int ret=0;
	while(a){
		ret+=segtree[a];
		a/=2;
	}
	return ret%26;
}
set<int>g[110000];
int ptr[110000];
int see[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",L+i,R+i);
		L[i]--;
	}
	int N=n/2;
	for(int i=0;i<N;i++){
		int t=in[i]+26-in[n-1-i];
		if(t>=26)t-=26;
		add(0,131071,i,i,1,t);
	}
	for(int i=0;i<a;i++){
		if(R[i]<=N){
			if(L[i]!=R[i])
			g[L[i]].insert(R[i]);
		}else if(L[i]>=N){
			if(n-R[i]!=n-L[i])
			g[n-R[i]].insert(n-L[i]);
		}else{
			int pl=L[i];
			int pr=n-R[i];
			if(pl>pr)swap(pl,pr);
			if(pl<pr)
			g[pl].insert(pr);
		}
	}
	for(int i=0;i<N;i++)ptr[i]=i;
	//for(int i=0;i<N;i++)std::sort(g[i].begin(),g[i].end());
	for(int i=0;i<N;i++)see[i]=i;
	for(int i=0;i<N;i++){
		int I=see[i];
		if(!g[see[i]].empty()){
			int fi=*(g[see[i]].begin());
			int now=sum(i);
			int ad=26-now;
			add(0,131071,i,fi-1,1,ad);
			g[I].erase(fi);
			if(g[I].size()<g[see[fi]].size()){
				for(set<int>::iterator it=g[I].begin();it!=g[I].end();it++){
					g[see[fi]].insert(*it);
				}
			}else{
				for(set<int>::iterator it=g[see[fi]].begin();it!=g[see[fi]].end();it++){
					g[I].insert(*it);
				}
				see[fi]=I;
			}
		}
		if(sum(i)){
			printf("NO\n");return 0;
		}
	}
	printf("YES\n");
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int times = (n + x - 1) / x;
    int ans = t * times;
    cout << ans << endl;
}

Measured memory_bytes: 3644
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,x;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	int rev = 1;
	deque<int>deq;
	for(int i = 1;i <= n;i++)
	{
		cin >> x;
		if(rev == 1) deq.push_back(x);
		else deq.push_front(x);
		rev = !rev;
	}
	if(!rev) reverse(deq.begin(),deq.end());
	for(auto it : deq) cout << it << ' ';
}

Measured memory_bytes: 3840
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt64()

	m := int64(0)
	var needMinus bool
	for N >= 10 {
		if N%10 != 9 {
			needMinus = true
		}
		m += 9
		N /= 10
	}
	m += N
	if needMinus {
		m -= 1
	}

	println(m)
}


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

int main(){
  int H,W;

  cin>>H>>W;

  vector<string> S(H);

  int i,j;

  for(i=0;i<H;i++)
  cin>>S.at(i);

  vector<int> dx={0,1,1,1,0,-1,-1,-1};
  vector<int> dy={1,1,0,-1,-1,-1,0,1};

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(S.at(i).at(j)=='#')
      continue;

      int count=0;
      for(int k=0;k<8;k++){
        int nx=j+dx.at(k);
        int ny=i+dy.at(k);

        if(nx<0||ny<0||(nx>W-1)||(ny>H-1))
        continue;
        if(S.at(ny).at(nx)=='#')
        count++;
      }
      S.at(i).at(j)='0'+count;
    }
  }
  for(i=0;i<H;i++)
  cout<<S.at(i)<<endl;

}


Measured memory_bytes: 256