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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main(){

	
	int N;
	pairs(A);
	cin >> N;
	fx(N) {
		int X, L;
		cin >> X >> L;
		pb(A,make_pair(X+L, X - L));
	}
	sorts(A);

	int t = -INT_MAX;
	int ans = 0;
	fx(N) {
		if (t<=A[x].second) {
			t = A[x].first;
			ans++;
		}
	}
	ce(ans)


    return 0;
}



Measured memory_bytes: 1400
n=int(input())
c=list(input())
w=0
r=0
for i in range(n):
    if c[i]=="W":
        pass
    else:
        r+=1
ans=max(w,r)
for i in range(n):
    if c[i]=="R":
        r-=1
    else:
        w+=1
    ans=min(ans,max(w,r))

print(ans)

Measured memory_bytes: 82648
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    for(a;a<b+1;a++)
    {
        if(c%a == 0)d++;
    }
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 2120
import math
from functools import reduce

k = int(input())

result = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            if a == b == c:
                result += a
            elif a == b and a!= c:
                result += gcd(a, c)*3
            elif a == c and a != b:
                result += gcd(a, b)*3
            elif b == c and a != b:
                result += gcd(a, b)*3
            else:
                result += gcd(a, b, c)*6
print(result)

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 10000000099
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> k(M);
  vector<vector<ll>> s(M, vector<ll>(0));
  rep(i, M){
    cin >> k.at(i);
    rep(j, k.at(i)){
      ll a;
      cin >> a;
      a--;
      s.at(i).push_back(a);
    }
  }
  vector<ll> p(M);
  rep(i, M){
    cin >> p.at(i);
  }
  ll ans = 0;
  rep(i, 1<<N){
    rep(j, M){
      ll on = 0;
      rep(l, k.at(j)){
        if(i >> s.at(j).at(l) & 1){
          on++;
        }
      }
      if(on % 2 != p.at(j)){
        break;
      }
      if(j == M-1){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    int N, M;
    int L[110000], R[110000];

    cin >> N >> M;
    rep(i, M){
        cin >> L[i] >> R[i];
    }

    int Max = 0;
    rep(i, M){
        if(Max < L[i]) Max = L[i];
    }
    int Min = 1000000;
    rep(i, M){
        if(Min > R[i]) Min = R[i];
    }
    int count;
    if(Min >= Max) count = Min - Max + 1;
    else
    {
        count = 0;
    }
    
    cout << count << endl;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    ll best = infl;
    forn (iter, 3) {
        ll diff = (a[0] * a[1]) * (a[2] % 2);
        best = min(best, diff);
        rotate(a, a + 1, a + 3);
    }
    cout << best << '\n';
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

// right, down, left, up
const int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

int H, W;
char Prog[20][20];

bool G[20][20][4][16]; // y, x, cour, memory

bool run(int x, int y, int cour, int mem) {
    while (!G[y][x][cour][mem]) {
        G[y][x][cour][mem] = true;

        switch (Prog[y][x]) {
        case '<':
            cour = 2;
            break;
        case '>':
            cour = 0;
            break;
        case '^':
            cour = 3;
            break;
        case 'v':
            cour = 1;
            break;
        case '_':
            if (mem == 0) {
                cour = 0;
            } else {
                cour = 2;
            }
            break;
        case '|':
            if (mem == 0) {
                cour = 1;
            } else {
                cour = 3;
            }
            break;
        case '?':
            REP(i, 4) {
                int sx = x + dx[i], sy = y + dy[i];
                if (sx < 0)  sx = W-1;
                if (sx >= W) sx = 0;
                if (sy < 0)  sy = H-1;
                if (sy >= H) sy = 0;
                if (run(sx, sy, i, mem)) return true;
            }
            return false;
        case '.':
            break;
        case '@':
            return true;
        case '+':
            if (mem == 15) {
                mem = 0;
            } else {
                mem++;
            }
            break;
        case '-':
            if (mem == 0) {
                mem = 15;
            } else {
                mem--;
            }
            break;
        default: // number
            mem = Prog[y][x] - '0';
        }

        x += dx[cour];
        y += dy[cour];
        if (x < 0)  x = W-1;
        if (x >= W) x = 0;
        if (y < 0)  y = H-1;
        if (y >= H) y = 0;

//        LOG("%02d\n", mem);
//        REP(sy, H) {
//            REP(sx, W) {
//                if (sx == x && sy == y) {
//                    LOG("#");
//                } else {
//                    LOG("%c", Prog[sy][sx]);
//                }
//            }
//            LOG("\n");
//        }
//        getchar();
    }
    return false;
}

int main() {
    cin >> H >> W;
    bool stoppable = false;
    REP(y, H) REP(x, W) {
        cin >> Prog[y][x];
        if (Prog[y][x] == '@') {
            stoppable = true;
        }
    }
    cout << (stoppable && run(0, 0, 0, 0) ? "YES" : "NO") << endl;
}

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

int main() {
  int K; cin >> K;
  string S; cin >> S;
  
  if(S.size() > K){
    for(int i=0; i<K; i++)
      cout << S[i];
    cout << "..." << endl;
  }
  else 
    cout << S << endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void)
{
    int D;
    cin >> D;

    cout << "Christmas";
    if(D <= 22) cout << " Eve";
    if(D <= 23) cout << " Eve";
    if(D <= 24) cout << " Eve";

    cout << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}

int N;

int main() {
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    int res = 0;
    for (int i = 0; i < N-1; i++) {
        if (p[i] == i+1) {
            swap(p[i],p[i+1]); res++;
        }
    }
    if (p[N-1] == N) {
        swap(p[N-1],p[N-2]); res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#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 k;
    cin >> k;
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a.at(k-1) << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

// https://atcoder.jp/contests/abc166/tasks/abc166_C
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] h = new int[n];
		boolean[] ans = new boolean[n];
		for(int i=0;i<n;i++) {
			h[i]=sc.nextInt();
			ans[i]=true;
		}

		for(int i=0;i<m;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(h[a-1]>h[b-1]) {
				ans[b-1]=false;
			}
			if(h[a-1]==h[b-1]) {
				ans[a-1]=false;
				ans[b-1]=false;
			}
			if(h[a-1]<h[b-1]) {
				ans[a-1]=false;
			}
		}
		sc.close();

		int ans1 = 0;
		for(int i=0;i<n;i++) {
			if(ans[i]) {
				ans1++;
			}
		}
		System.out.println(ans1);




	}
}


Measured memory_bytes: 49280
// AOJ 2781: Help the Princess!
// 2018.1.31 bal4u

#include <stdio.h>

#define QMAX 40000
typedef struct { int t, r, c; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int r, int c, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].r = r, que[i].c = c, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int H, W;
char map[203][203];
char mk[203][203];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int dijkstra(int sr, int sc)
{
	int i, r, c, nr, nc, d;
	int princess = 0x7fffff;

	qsize = 0;
	enq(sr, sc, 0);
	while (qsize) {
		r = que[0].r, c = que[0].c, d = que[0].t, deq();
		if (mk[r][c]) continue;
		mk[r][c] = 1;

		if      (map[r][c] == '@') princess = d;
		else if (map[r][c] == '$') return d > princess;

		for (i = 0; i < 4; i++) {
			nr = r + mv[i][0], nc = c + mv[i][1];
			if (nr < 0 || nr >= H || nc < 0 || nc >= W ||
				map[nr][nc] == '#') continue;
			if (mk[nr][nc]) continue;
			enq(nr, nc, d+1);
		}
	}
	return 1;
}

int main()
{
	int r, c, sr, sc, f;
	char buf[10];

	fgets(buf, 10, stdin), sscanf(buf, "%d%d", &H, &W);
	f = 0, sr = -1;
	for (r = 0; r < H; r++) {
		fgets(map[r], 203, stdin);
		if (sr >= 0 && f) continue;
		for (c = 0; c < W; c++) {
			if (map[r][c] == '%') sr = r, sc = c;
			else if (map[r][c] == '$') f = 1;
		}
	}

	if (!f) puts("Yes");
	else puts(dijkstra(sr, sc)? "Yes": "No");
	return 0;
}


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

int main(){
    int n, m, l;
    long long int matA[100][100];
    long long int matB[100][100];
    long long int matC[100][100] = {};
    
    cin >> n >> m >> l;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cin >> matA[i][j];
    }
    
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++) cin >> matB[i][j];
    }
    
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            for(int k = 0; k < m; k++) matC[i][j] += matA[i][k] * matB[k][j];
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l-1; j++) cout << matC[i][j] << " ";
        cout << matC[i][l-1] << endl;
    }
    
    return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

X,Y = inputIL()

print(int(X+Y/2))


Measured memory_bytes: 64876
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///find_by_order, order_of_key

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int MAXN = 1e7;
int a[MAXN + 1];

int main()
{
    #ifdef ljuba
    auto pocetakChronoSata123 = high_resolution_clock::now();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);       
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    for(int i = 0; i <= MAXN; ++i)
    {
        a[i] = 1;
    }
    
    for(int i = 2; i <= MAXN; ++i)
    {
        for(int j = i; j <= MAXN; j += i)
        {
            ++a[j];
        }
    }

    int n;
    cin >> n;
    ll res = 0LL;

    for(int i = 1; i <= n; ++i)
    {
        //cout << a[i] << '\n';
        res += i * 1LL * a[i];
    }

    cout << res << '\n';
    
    #ifdef ljuba
    auto krajChronoSata123 = high_resolution_clock::now();
    auto trajanje = duration_cast<microseconds>(krajChronoSata123 - pocetakChronoSata123);
    cout << "----------------------------------------------------\n";
    cout << "Vreme u milisekundama: " << (ld)trajanje.count() / 1000.00 << '\n';
    #endif
    return 0;
}

Measured memory_bytes: 42676
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }
 
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    string s; cin>>s; int n=s.size();
    int gu=0,pa=0,ans=0;
    for (int i = 0; i < n; i++){
        if(s[i]=='g'){
            if(gu>pa){ans++; pa++;}
            else gu++;
        }else{
            if(gu>pa)pa++;
            else {ans--; gu++;}
        }
    }
    cout<<ans<<'\n';
}

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

int main() {
    int k, x;
    cin >> k >> x;
    int max = x + k - 1;
    int min = x - k + 1;
    for (int i = min;i < max;i++){
        cout << i << ' ' ;
    }
    cout << max << endl;
}


Measured memory_bytes: 256
import java.util.*

fun <T> permutationList(sortedList: Array<T>): List<List<T>> {
    val permutations = mutableListOf<List<T>>()
    val queue = ArrayDeque<List<T>>().apply { addLast(listOf()) }
    while (queue.isNotEmpty()) {
        val p = queue.removeLast()

        if (p.size == sortedList.size) {
            permutations.add(p)
        } else {
            sortedList.filterNot { p.contains(it) }
                .forEach { queue.addLast(p + it) }
        }
    }

    return permutations
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    permutationList((1..n).toList().toTypedArray())
        .let { Math.abs(it.indexOf(p) - it.indexOf(q)) }
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 45708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int p = N % 10;
  if (p == 3) {
    cout << "bon" << endl;
  } else if (p == 0 || p == 1 || p == 6 || p == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n, c;
  cin >> n >> c;
  vector<ll> x(n), v(n);
  rep(i, n) cin >> x[i] >> v[i];

  ll ans = 0;
  vector<ll> sum(n + 1, 0);
  rep(i, n) sum[i + 1] = sum[i] + v[i];
  rep(i, n) {
    sum[i + 1] -= x[i];
    sum[i + 1] = max(sum[i], sum[i + 1]);
  }
  ans = max(ans, sum[n]);
  ll res = 0;
  repr(i, n - 1) {
    res += v[i];
    ans = max(ans, res + sum[i] - (c - x[i]) * 2);
  }
  reverse(x.begin(), x.end());
  rep(i, n) x[i] = c - x[i];
  reverse(v.begin(), v.end());
  rep(i, n + 1) sum[i] = 0;
  rep(i, n) sum[i + 1] = sum[i] + v[i];
  rep(i, n) {
    sum[i + 1] -= x[i];
    sum[i + 1] = max(sum[i], sum[i + 1]);
  }
  ans = max(ans, sum[n]);
  res = 0;
  repr(i, n - 1) {
    res += v[i];
    ans = max(ans, res + sum[i] - (c - x[i]) * 2);
  }
  cout << ans << endl;




  
  return 0;
}

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

using namespace std;

#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define LL long long 

const LL MOD = 1e9 + 7;
const int N = 81;

int n;
int a[N];
vector <pi> W[N];
bool C[N];

bool check(){
    FOR(i,1,n) if(C[i]){
        REP(j,0,a[i]){
            int k = W[i][j].fi;
            int v = W[i][j].se;
            if(C[k] != v) return 0;
        }
    }
    return 1;
}
int main(){
    cin >> n;
    FOR(i,1,n){
        cin >> a[i];
        FOR(j,1,a[i]){
            int x,y;
            cin >> x >> y;
            W[i].push_back(mp(x,y));
        }
    }
    //
    int m = (1 << n),res = 0;
    REP(i,1,m){
        int d = 0;
        FOR(j,1,n) C[j] = 0;
        REP(j,0,n){
            if((i >> j) & 1){
                ++d;
                C[j + 1] = 1;
            }
        }
        if(check()) res = max(res,d);
    }
    
    cout << res;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int digitsum(int num) {
    int ret = 0;
    while(num > 0) {
        ret += num % 10;
        num /= 10;
    }
    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n % digitsum(n) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    cin >> n;
    double a, t, w, r;
    a = t = r = w = 0;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if(s == "AC")
            ++a;
        if(s == "WA")
            ++w;
        if(s == "TLE")
            ++t;
        if(s == "RE")
            ++r;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x "<<r << endl;
}

Measured memory_bytes: 3844
N = int(input())
S = list(input())
assert len(S) == N

def solve():
    i = 0
    opens = []
    inspos = 0
    while i < len(S):
        if S[i] == '(':
            opens.append(i)
        elif opens:
            opens.pop()
        else:
            S.insert(inspos, '(')
            i += 1
        i += 1
    for _ in range(len(opens)):
        S.append(')')

solve()
print(''.join(S))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int h,w;
  cin >> h >> w;
  rep(i,h){
    string s;
    cin >> s;
    cout << s << endl << s << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200005],n,b[200005],i,l,A,M,r=200005;
int P(int x){for(i=1;i<=n*2-1;i++)b[i]=(a[i]>=x);b[0]=b[1];
for(i=n;i<=n+n;i++){if(b[i]==b[i+1])return b[i];if(b[n+n-i]==b[n+n-i-1])return b[n+n-i];}}
int main(){
cin>>n;for(i=1;i<=n*2-1;i++)cin>>a[i];
while(l<=r){M=(l+r)/2;if(P(M))l=M+1,A=M;else r=M-1;}cout<<A;}

Measured memory_bytes: 1920
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
stores = []
for _ in range(N):
    stores.append(list(map(int, input().split())))

stores = sorted(stores, key=lambda x: x[0])

ans = 0
buy = 0
for a, b in stores:
    if buy+b >= M:
        ans += a*(M-buy)
        break
    else:
        ans += a*b
        buy += b
print(ans)


Measured memory_bytes: 29728
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  int n;
  n=s.size();
  int count1=0;
  int count2=0;
  int i=0;
  while(2*i<n){
    if(s[2*i]!='1'){
      count1++;
    }
    i++;
  }
  
  i=0;
  while(2*i+1<n){
    if(s[2*i+1]!='0'){
      count1++;
    }
    i++;
  }
  
  i=0;
  while(2*i<n){
    if(s[2*i]!='0'){
      count2++;
    }
    i++;
  }
  i=0;
  while(2*i+1<n){
    if(s[2*i+1]!='1'){
      count2++;
    }
    i++;
  }
  
  int ans = min(count1,count2);
  cout << ans << endl;
  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int v[n], c[n];
    for(int i = 0;i < n;i++) {
        cin >> v[i];
    }
    for(int i = 0;i < n;i++) {
        cin >> c[i];
    }
    int num[n];
    for(int i = 0;i < n;i++) {
        num[i] = v[i]-c[i];
    }
    int sam = 0;
    for(int i = 0;i < n;i++) {
        if(num[i]>0) {
            sam+=num[i];
        }
    }
    cout << sam << endl;
}

Measured memory_bytes: 256
#include <cstring>

#include <iostream>
#include <algorithm>
using namespace std;

long long memo[101][10][1001];

// x以下からちょうどk個でsを作る
long long solve(int x, int k, int s) {
  if(k == 0 && s == 0) return 1;
  if(s < 0) return 0;
  if(x < 0) return 0;
  if(k == 0) return 0;
  long long &res = memo[x][k][s];
  if(res != -1) return res;
  return res = solve(x - 1, k, s) + solve(x - 1, k - 1, s - x);
}

int main() {
  memset(memo, -1, sizeof(memo));
  while(true) {
    int n, s; cin >> n >> s;
    if(n == 0 && s == 0) break;
    cout << solve(100, n, s) << endl;
  }
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

const int N=1e6+500;

int main()
{
    FAST
    int pos=1;
    int k;cin>>k;
    int mod=7%k;
    f(i,0,N)
    {
        if(mod==0)
        {
            cout<<pos<<endl;
            return 0;
        }
        mod = (mod*10+7)%k;
        pos++;
    }
    cout<<"-1\n";
    return 0;

}


Measured memory_bytes: 3632
def primes(n):
    is_prime = [0] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 1
    for i in range(2, n+1):
        for j in range(i, n + 1, i):
            is_prime[j] += j
    return sum(is_prime)
    
n = int(input())
ans = 0
print(primes(n)+(n*(n+1)//2)-1)

Measured memory_bytes: 146016
N,A,B,C=map(int,input().split())
take=[int(input()) for _ in range(N)]

class T:
    def __init__(self):
        self.ans=A+B+C

    def rec(self,i,a,b,c,m):
        if i==N:
            if a*b*c:
                self.ans=min(self.ans,abs(A-a)+abs(B-b)+abs(C-c)+m*10)
            return
        self.rec(i+1,a+take[i],b,c,m+1)
        self.rec(i+1,a,b+take[i],c,m+1)
        self.rec(i+1,a,b,c+take[i],m+1)
        self.rec(i+1,a,b,c,m)
        
    def __call__(self):
        self.rec(0,0,0,0,-3)
        return self.ans
        
print(T()())

Measured memory_bytes: 3064
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,k,ans=1;
  cin >> n >> k;
  ans = k;
  for(int i=1;i<n;i++){
    ans *= (k-1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let (n, k) = (io.read::<usize>(), io.read::<usize>());
    let mut a = io.readn::<i64>(n);
    let mut mp = BTreeMap::new();
    for &x in a.iter() {
        *mp.entry(x).or_insert(0) += 1;
    }
    let mut pair = Vec::new();
    for (key, &val) in mp.iter() {
        pair.push((val, key));
    }
    pair.sort();
    let sz = pair.len();
    if sz <= k {
        io.writeln(0);
        return;
    }
    let mut ans = 0;
    for i in 0..sz - k {
        ans += pair[i].0;
    }
    io.writeln(ans);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 11484
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string a, b;
  cin>>a>>b;
  string c;
  rep(i, b.size()){
    c += a[i];
    c += b[i];
  }
  if(a.size()>b.size()) c += a.back();
  cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ull num=0;
    int k;
    cin>>k;
    if(k%2==0)
    {
        cout<<-1;
        return 0;
    }
    int i;
    for(i=1;i<1e6;i++)
    {
        num%=k;
        num=(num*10);
        num+=7;
        if(num%k==0)
        {
            cout<<i;
            return 0;
        }
    }    
    cout<<-1;
    return 0;
}

Measured memory_bytes: 3616
import sys

class BIT(object):
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def sum(self, i):
        cumulative_sum = 0
        while i > 0:
            cumulative_sum += self.data[i]
            i -= i & (-i)
        return cumulative_sum

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & (-i)
        return

def main():
    N, K = map(int, input().split())
    A_list = [int(input()) for i in range(N)]

    cumulative_sum = 0
    b_list = [(0, 0)]
    for i, i_A in enumerate(A_list, 1):
        cumulative_sum += i_A
        b_list.append((cumulative_sum - K*(i), i))

    b_list.sort()
    compression_number = 1
    c_list = [None]*(N+1)
    for _, i in b_list:
        c_list[i] = compression_number
        compression_number += 1

    bit = BIT(N+1)
    ans = 0
    for i_c in c_list:
        ans += bit.sum(i_c)
        bit.add(i_c, 1)

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 78040
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
string s;
cin>>s;
int ans=0;
for(int i=0;i<s.size();i++)
if(s[i]=='1')
ans++;
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl count(13,0);count[0]++;
    rep(i,n){
        ll a;cin >> a;
        count[a]++;
    }
    rep(i,13){
        if(count[i]>2){
            cout << 0 <<endl;
            return 0;
        }
    }
    if(count[0]==2||count[12]==2){
        cout << 0 <<endl;
        return 0;
    }
    set<ll> s;
    ll k=0;
    rep(i,13){
        if(i==0||i==12){
            if(count[i])s.ins(i);
        }
        else {
            if(count[i]==2){
                s.ins(i);s.ins(24-i);
            }
            if(count[i]==1){
                if(k%2==0)s.ins(i);
                else s.ins(24-i);
                k++;
            }
        }
    }
    s.ins(24);
    vl v;
    for(auto p:s)v.pb(p);
    ll ans=inf;
    rep(i,v.size()-1)chmin(ans,v[i+1]-v[i]);
    cout <<ans <<endl;
}

Measured memory_bytes: 256
import itertools
N, M = [int(_) for _ in input().split()]
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i, j in itertools.product(range(N-M+1), repeat=2):
    if [_[j:j+M] for _ in A[i:i+M]] == B:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(1000000)

N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)

dfs(1, 0)

for c in col[1:]:
    print(c)

Measured memory_bytes: 79468
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int N,M;
	cin >> N >> M;

	const int NMMAX=50;
	int A[NMMAX],B[NMMAX],C[NMMAX],D[NMMAX];

	for(int i=0;i<N;++i){
		cin >> A[i] >> B[i];
	}

	for(int j=0;j<M;++j){
		cin >> C[j] >> D[j];
	}
	
	for(int i=0;i<N;++i){
		int min_dist=abs(A[i]-C[0])+abs(B[i]-D[0]),checkpoint=1;

		for(int j=1;j<M;++j){
			const int cur_dist=abs(A[i]-C[j])+abs(B[i]-D[j]);
			if(min_dist>cur_dist){
				min_dist=cur_dist;
				checkpoint=j+1;
			}
		}

		cout << checkpoint << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "#" not in a[i]:
        del a[i]
        h -= 1

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m

for k in range(h):
    print("".join(u[k] for u in n))


Measured memory_bytes: 3064
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <utility>
#include <iomanip>

using namespace std;

#ifdef _MSC_VER
#define scanf scanf_s
#define KEYWAIT getchar();getchar();
#else
#define KEYWAIT
#endif

int main()
{
    int n, d, x;

    vector<int> a;

    cin >> n;
    cin >> d >> x;
    
    int sum = x;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += (d-1) / a + 1;
    }

    cout << sum << endl;

    KEYWAIT

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int Min=1000,Sum=0,tmp,N,i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&tmp);
		if(tmp%10!=0 && tmp<Min)Min=tmp;
		Sum+=tmp;
	}
	if(Min==1000){
		Min=0;
	}
	if(Sum%10==0)Sum-=Min;
	if(Sum%10==0){
		printf("0");
		return 0;
	}
	printf("%d",Sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
long long q(long long n){
	int sum=1;
	while(n!=1){
		if(n%2==0) n/=2;
		else n=3*n+1;
		sum++;
	}
	return sum+1; 
}
int main()
{
	long long n;
	cin>>n;
	if(n==1||n==2) cout<<4<<endl;
	else cout<<q(n)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main()
{   
    int n;
    cin>>n;
    int res=n;
    for(int i=0;i<=n;i++){
        int cc=0;
        int t=i;
        while(t>0) cc+=t%6, t/=6;
        t=n-i;
        while(t>0) cc+=t%9, t/=9;
        if(res>cc) res=cc;
    }
    cout<<res<<endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

int main()
{
	int n, m;
	std::cin >> n >> m;
	std::vector<int> h(n);
	for (auto &e : h) {
		std::cin >> e;
	}
	
	std::vector<std::vector<int>> graph(n);
	int a, b;
	for (int i = 0; i < m; i++) {
		std::cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
	}
	
	int cnt = 0;
	std::vector<bool> seen(n);
	std::function<void(int)> dfs;
	dfs = [&](int v) {
		seen[v] = true;
		int max = 0;
		for (auto e : graph[v]) {
			if (h[e] > max) max = h[e];
			if (seen[e]) continue;
			dfs(e);
		}
		if (max < h[v]) {
			cnt++;
		}
	};
	for (int i = 0; i < n; i++) {
		if (seen[i]) continue;
		dfs(i);
	}
	
	std::cout << cnt << std::endl;
	
	return 0;
}


Measured memory_bytes: 9952
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int d[51];
int cop[51];
int main(void){
  int n,r;
  while(cin>>n>>r){
    if(n==0) break;
    REP(i,n) d[i] = n-i;
    REP(i,r){
      int p,c;
      cin>>p>>c;
      REP(j,c)cop[j] = d[p-1+j];
      for(int j=p-2; j>=0; j--){
        d[j+c] = d[j];
      }
      REP(j,c) d[j] = cop[j];
    }
    cout<<d[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << h2*60+m2-(h1*60+m1)-k;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

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

  string S = "";
  int ans =0;
  int now =0;

  rep(i,s.size()){
    string ss = s.substr(now,i-now+1);
    if(S != ss){
      S = ss;
      ans++;
      now = i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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, M;
  cin >> N >> M;
  vector<int> a(M);
  rep(i,M) cin >> a[i];
  for (int i = 1; i < M; ++i) {
    if (a[i] - a[i-1] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  vector<ll> ways(N+1);
  ways[0] = 1; ways[1] = 1, ways[2] = 2;
  for (int i = 3; i <= N; ++i) {
    ways[i] = (ways[i-1] + ways[i-2]) % 1000000007;
  }

  if (M == 0) {
    cout << ways[N] << endl;
    return 0;
  }

  vector<int> p(M+1);
  p[0] = a[0] - 1;
  p[M] = N - a[M-1] - 1;
  for (int i = 1; i < M; ++i) {
    p[i] = a[i] - a[i-1] - 2;
  }

  ll ans = 1;
  rep(i,M+1) {
    ans *= ways[p[i]];
    ans %= 1000000007;
  }
  cout << ans << endl;

  return 0;
}

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

const int NMAX = 1e5 + 5;
int n, a[NMAX], dp[NMAX], sol;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[n] = 1;
    sol = 1;
    for(int i = n - 1; i >= 1; i --) {
        if(a[i] >= a[i + 1]) {
            dp[i] = 1 + dp[i + 1];
        } else {
            dp[i] = 1;
        }
        sol = max(sol, dp[i]);
    }
    cout << sol - 1;
    return 0;
}

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

int main(){
  int k , x ;
  cin >> k >> x ;
  for(int i=1;i<k;i++){
    cout << x-k+i << endl;
  }
  cout << x << endl;
  for(int i=1;i<k;i++){
    cout << x + i << endl;
  }
  
}

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


void solve(long long N, std::vector<long long> a){
    double a_mean = 0;
    long long ans = 0;
    for(auto i: a) a_mean += (double)i;
    a_mean = a_mean/(double)N;
    for(int i = 0; i < N; ++i) ans += round((double)a[i] - a_mean) * round((double)a[i] - a_mean);
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a[5];
	int mi=10, ans=0;
	REP(i, 5){
		cin>>a[i];
		if(a[i]%10!=0){
			CHMIN(mi, a[i]%10);
		}
		ans+=((a[i]-1)/10+1)*10;
	}
	cout<<ans+(mi!=10 ? mi-10 : 0)<<'\n';
	return 0;
}


Measured memory_bytes: 256