akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
int in1[100];
int in2[100];
int Lto[100];
int Rto[100];
int Lbfs[100];
int Rbfs[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",in1+i);
		for(int i=0;i<a;i++)scanf("%d",in2+i);
		for(int i=0;i<a;i++){
			if(in1[i]==0)Lto[i]=i;
			if(in1[i]==1){
				Lto[i]=i;
				for(int j=i+1;j<a;j++){
					if(in1[j]!=1){
						break;
					}
					Lto[i]=j;
				}
			}
			if(in1[i]==2){
				for(int j=i-1;j>=0;j--){
					Lto[i]=j;
					if(in1[j]!=2)break;
				}
			}
			if(in1[i]==0)Lto[i]=i;
			if(in2[i]==0)Rto[i]=i;
			if(in2[i]==1){
				Rto[i]=i;
				for(int j=i+1;j<a;j++){
					if(in2[j]!=1){
						break;
					}
					Rto[i]=j;
				}
			}
			if(in2[i]==2){
				for(int j=i-1;j>=0;j--){
					Rto[i]=j;
					if(in2[j]!=2)break;
				}
			}
			//printf("%d %d\n",Lto[i],Rto[i]);
		}
		for(int i=0;i<a;i++)Lbfs[i]=Rbfs[i]=999999;
		queue <pair<int,int> > Q;
		Lbfs[Lto[0]]=0;
		Rbfs[Rto[0]]=0;
		Q.push(make_pair(0,Lto[0]));
		Q.push(make_pair(1,Rto[0]));
		while(Q.size()){
			int type=Q.front().first;
			int index=Q.front().second;
			if(type==0){
				if(Rbfs[Rto[index]]==999999){
					Rbfs[Rto[index]]=Lbfs[index]+1;
					Q.push(make_pair(1,Rto[index]));
				}
				if(index<a-1&&Rbfs[Rto[index+1]]==999999){
					Rbfs[Rto[index+1]]=Lbfs[index]+1;
					Q.push(make_pair(1,Rto[index+1]));
				}
				if(index<a-2&&Rbfs[Rto[index+2]]==999999){
					Rbfs[Rto[index+2]]=Lbfs[index]+1;
					Q.push(make_pair(1,Rto[index+2]));
				}
			}else{
				if(Lbfs[Lto[index]]==999999){
					Lbfs[Lto[index]]=Rbfs[index]+1;
					Q.push(make_pair(0,Lto[index]));
				}
				if(index<a-1&&Lbfs[Lto[index+1]]==999999){
					Lbfs[Lto[index+1]]=Rbfs[index]+1;
					Q.push(make_pair(0,Lto[index+1]));
				}
				if(index<a-2&&Lbfs[Lto[index+2]]==999999){
					Lbfs[Lto[index+2]]=Rbfs[index]+1;
					Q.push(make_pair(0,Lto[index+2]));
				}
			}
			Q.pop();
		}
		if(min(Lbfs[a-1],Rbfs[a-1])>=999999)printf("NA\n");
		else printf("%d\n",min(Lbfs[a-1],Rbfs[a-1]));
	}
}

Measured memory_bytes: 0
object Main extends App {
  import scala.io.StdIn._
  val n = readInt()
  val pairs = Array.fill(n){
    val Array(f, t) = readLine.trim.split(' ').map(_.toInt)
    (f, t)
  }
  val result = pairs.map(p ⇒ makeFunc(p._1, p._2)).reduce(_ | _)
  println(result)
  def makeFunc(from: Int, to: Int): Token = {
    if (to == 0) 0
    else (0 until 32).collect{
      case digit if (to & (1 << digit)) != 0 ⇒ makeDigit(from, digit)
    }.reduce(_ | _)
  }
  def makeDigit(from: Int, digit: Int): Token = {
    digit match {
      case 0 if (from & 1) == 1 ⇒ X&1
      case 0 if (from & 1) == 0 ⇒ ~X&1
      case _ if (from & (1 << digit)) != 0 ⇒ (X&(1<<digit)) & makeDigit(from, digit - 1)*2
      case _ ⇒ (~X&(1<<digit)) & makeDigit(from, digit - 1) * 2
    }
  }
  sealed trait Token {
    def &(that: Token): Token = Expression(this, "&", that)
    def |(that: Token): Token = Expression(this, "|", that)
    def ^(that: Token): Token = Expression(this, "^", that)
    def +(that: Token): Token = Expression(this, "+", that)
    def -(that: Token): Token = Expression(this, "-", that)
    def *(that: Token): Token = Expression(this, "*", that)
    def unary_~(): Token = Negative(this)
    def apply(x: Int): Int
  }
  case object X extends Token {
    override def toString: String = "x"
    override def apply(x: Int): Int = x
  }
  implicit class Number(value: Int) extends Token {
    override def toString: String = value.toString
    override def apply(x: Int): Int = value
  }
  case class Expression(left: Token, op: String, right: Token) extends Token {
    override def toString: String = s"($left$op$right)"
    override def apply(x: Int): Int = {
      op match {
        case "&" ⇒ left(x) & right(x)
        case "|" ⇒ left(x) | right(x)
        case "^" ⇒ left(x) ^ right(x)
        case "+" ⇒ left(x) + right(x)
        case "-" ⇒ left(x) - right(x)
        case "*" ⇒ left(x) * right(x)
      }
    }
  }
  case class Negative(token: Token) extends Token {
    override def toString: String = s"(~$token)"
    override def apply(x: Int): Int = ~token(x)
  }
}


Measured memory_bytes: 45124
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------
int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; string s; cin>>n>>s;
    int ans = 0;
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                bool s1 = 0,s2 = 0,s3 = 0;
                for(int t = 0; t < n; t++) {
                    if(!s1&&s[t]-'0'==i) s1 = 1;
                    else if(s1&&!s2&&s[t]-'0'==j) s2 = 1;
                    else if(s1&&s2&&!s3&&s[t]-'0'==k) s3 = 1;
                }
                if(s1&&s2&&s3) ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i)
        reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();)
    {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j)
        {
            string d = divide[j];
            if (S.substr(i, d.size()) == d)
            { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2)
        { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 512
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    v = LI()
    first_counter = {}
    second_counter = {}

    for i in range(N):
        if i % 2 == 0:
            if v[i] not in first_counter:
                first_counter[v[i]] = 0
            first_counter[v[i]] += 1
        else:
            if v[i] not in second_counter:
                second_counter[v[i]] = 0
            second_counter[v[i]] += 1

    first_items = sorted([(v, k) for k, v in first_counter.items()], reverse=True)
    second_items = sorted([(v, k)
                           for k, v in second_counter.items()], reverse=True)

    # print(first_items, second_items)
    first_counter, first_value = first_items.pop(0)
    second_counter, second_value = second_items.pop(0)

    first_total_count = (N + (2 - 1)) // 2
    second_total_count = N // 2

    if first_value != second_value:
        print(first_total_count - first_counter + second_total_count - second_counter)
    else:
        first_all_replace_count = first_total_count + second_total_count - second_counter
        second_all_replace_count = second_total_count + first_total_count - first_counter
        first_all_next_replace_count = 10 ** 9
        second_all_next_replace_count = 10 ** 9

        if len(first_items) > 0:
            next_first_counter, next_first_value = first_items.pop(0)
            first_all_next_replace_count = first_total_count - next_first_counter + \
                second_total_count - second_counter

        if len(second_items) > 0:
            next_second_counter, next_second_value = second_items.pop(0)
            second_all_next_replace_count = second_total_count - \
                next_second_counter + first_total_count - first_counter

        print(min(first_all_replace_count,
                  second_all_replace_count,
                  first_all_next_replace_count,
                  second_all_next_replace_count))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63536
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

long R,G;
inline void solve(){
  IN2(R,G);
  OUT(2*G-R);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

char s[N + N];

int cnt[123];

int main(){
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    ll ans = 0;
    for(int i = 1; i <= len; i++){
        ans = ans + (i - 1);
        ans -= cnt[s[i]];
        cnt[s[i]]++;
    }
    printf("%lld\n", ans + 1ll);
}


Measured memory_bytes: 384
N = int(input())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[2],reverse=True)
for x in range(101):
    for y in range(101):
        a,b,h = A[0]
        H = h+abs(x-a)+abs(y-b)
        flag = 1
        for i in range(1,N):
            a,b,h = A[i]
            if max(0,H-abs(x-a)-abs(y-b))==h:continue
            else:
                flag = 0
                break
        if flag==1:
            cx = x
            cy = y
            break
    if flag==1:break
print(cx,cy,H)

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

const int N=1e6;

char Istr[N+3];
int Ncnt[3],posA[N+3];
int n,Nn;
stack< pair<int,int> > Smod;

void fSwap(int Ca,int Cb){
	swap(Ncnt[Ca],Ncnt[Cb]);
	for(int i=1;i<=n;i++)
		if(Istr[i]=='A'+Ca) Istr[i]='A'+Cb;
		else if(Istr[i]=='A'+Cb) Istr[i]='A'+Ca;
}
void SurA(){
	int Ctb=0,Ctc=0,Cta=0;
	for(int i=1;i<=n;i++)
		if(Istr[i]=='A')
			posA[++Cta]=i;
	posA[++Cta]=n+1;
	for(int i=1;i<=Cta;i++){
		bool Bb=false;
		for(int j=posA[i-1]+1;j<=posA[i]-1;j++)
			Bb|=Istr[j]=='B';
		Ctb+=Bb;
	}
	Cta--;
	for(int i=1;i<=Cta-1;i++)
		if(posA[i]+1==posA[i+1]-1 && Istr[posA[i]+1]=='C')
			Ctc++;
	int Vmor=Ctc-Ctb;
	Nn=n;n=0;
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='A')
			if(Vmor>0 && n>=2 && Istr[n]=='C' && Istr[n-1]=='A') Vmor--;
			else Istr[++n]=Istr[i];
		else
			if(Istr[n]!=Istr[i]) Istr[++n]=Istr[i];
	if(Vmor>0) exit(0);
}
void DelC(){
	int Vdel=0;
	for(int i=1;i<=n;i++){
		if(Istr[i]=='C') Vdel++;
		if(Istr[i]=='B') Vdel--;
	}
	Nn=n;n=0;Istr[Nn+1]='-';
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='C')
			if(Vdel && (!n || Istr[n]!=Istr[i+1])) Vdel--;
			else Istr[++n]=Istr[i];
		else Istr[++n]=Istr[i];
}
void DelBC(){
	int Cta=0,Ctb=0,Ctc=0;
	for(int i=1;i<=n;i++){
		if(Istr[i]=='A') Cta++;
		if(Istr[i]=='B') Ctb++;
		if(Istr[i]=='C') Ctc++;
	}
	if(Ctb<Cta) exit(0);
	int Nn=n;n=0;Istr[Nn+1]='-';
	for(int i=1;i<=Nn;i++)
		if(Istr[i]=='A') Istr[++n]=Istr[i];
		else if(Ctb>Cta && n && ((Istr[n]=='B' && Istr[i]=='C') || (Istr[n]=='C' && Istr[i]=='B')) && Istr[i+1]!=Istr[n-1])
			Ctb--,n--;
		else Istr[++n]=Istr[i];
	Istr[n+1]='\0';
}
int main(){
	scanf("%s",Istr+1);
	Nn=strlen(Istr+1);n=0;
	for(int i=1;i<=Nn;i++)
		if(Istr[n]!=Istr[i]){
			Istr[++n]=Istr[i];
			Ncnt[Istr[i]-'A']++;
		} 
	Istr[Nn+1]=0;
	if(Ncnt[0]>Ncnt[1]) fSwap(0,1),Smod.push(make_pair(0,1));
	if(Ncnt[1]>Ncnt[2]) fSwap(1,2),Smod.push(make_pair(1,2));
	if(Ncnt[0]>Ncnt[1]) fSwap(0,1),Smod.push(make_pair(0,1));
	if(!Ncnt[0]) exit(0);
	SurA();DelC();DelBC();
	while(!Smod.empty()){
		fSwap(Smod.top().first,Smod.top().second);
		Smod.pop();
	}
	printf("%s\n",Istr+1);
	return 0;
}


Measured memory_bytes: 5376
fun main(args: Array<String>) {
    val X = readInt()
    val list = mutableSetOf<Int>()
    for (x in 2..100003) {
        if (list.any { x%it == 0 }) continue
        if (x >= X){
            println(x)
            return
        }
        list.add(x)
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())

Measured memory_bytes: 38456
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX 110
#define INF (int)(2<<29)

int main(){
	int n, r, c, m[MAX][MAX] = {}, p[MAX];
	
	cin>>n;
	
	for(int i = 1; i <= n; i++){
		cin>>r>>c;
		p[i-1] = r;
		p[i] = c;
	}
	for(int l = 2; l <= n; l++){
		for(int i = 1; i <= n-l+1; i++){
			int j = i + l - 1;
			m[i][j] = INF;
			for(int k = i; k < j; k++){
				m[i][j] = min(m[i][j],m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j]);
			}
		}
	}
	// for(int i = 0; i <= n; i++){
		// for(int j = 0; j <= n; j++){
			// printf("%12d", m[i][j]);
		// }cout<<endl;
	// }
	
	cout<<m[1][n]<<endl;
	
	return 0;
}


Measured memory_bytes: 3164
def bisect(ng, ok, judge, eps=1):
    while abs(ng-ok) > eps:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N,K = map(int,input().split())
A = tuple(map(int,input().split()))

K += N
def judge(d):
    return sum((a-1)//d+1 for a in A) <= K


for d in range(1,7):
    r = sum((a-1)//d+1 for a in A)

res = bisect(0,max(A),judge)
print(res)

Measured memory_bytes: 104444
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
signed main() {
  int n;
  cin >> n;
  int a;
  deque<int> dq;
  rep(i,n) {
    cin>> a;
    if(i%2==0) dq.push_back(a);
    else dq.push_front(a);
  }

  if(n%2==0) rep(i,n) cout << dq[i] <<" " << flush;
  else rrep(i,n) cout << dq[i] <<" " << flush;
  cout << "" << endl;


  return 0;
}


Measured memory_bytes: 5240
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, N) for(int i = 0; i < N; i++)

int node[100010] = {};

class UnionFind {
public:
    vector<int> node;

    UnionFind(int N) {
        node = vector<int>(N, -1);
    }

    int unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) {
            return false;
        }
        if (size(a) < size(b)) swap(a, b);

        node[a] += node[b];
        node[b] = a;
        return true;
    }

    int find(int a) {
        if (node[a] < 0) return a;
        else return node[a] = find(node[a]);
    }

    int size(int a) {
        return -node[find(a)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);

    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vector<ll> ans(M);
    ans[M - 1] = (ll)N * (N - 1) / 2;

    UnionFind uf(N);

    for (int i = M - 1; i >= 1; i--) {
        if(uf.find(A[i]) != uf.find(B[i])) {
            ans[i - 1] = ans[i] - (ll)uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]);
        }
        else ans[i - 1] = ans[i];
    }

    rep(i, M) cout << ans[i] << endl;
}

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

const int N = 10;

int id[N], l[N]; double dp[350][1 << 6];

int main() {
    int n, c, frac = 0; scanf("%d%d", &n, &c); double ans = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &l[i]), id[i] = i;
    sort(l + 1, l + n + 1);
    do { // 枚举小数的相对大小
        memset(dp, 0, sizeof(dp));
        dp[l[n] * n][1 << n - 1] = 1;
        for (int i = 1; i <= n * c; i++) {
            int nw = id[(i - 1) % n + 1];
            if (nw == n) continue;
            for (int j = i; j <= n * c; j++)
                for (int s = (1 << n) - 1; s > 0; s--) if (dp[j][s] && !(s & (1 << nw - 1))) 
                    dp[min(n * c, max(j, i + l[nw] * n))][s | (1 << nw - 1)] += dp[j][s];
        }
        ans += dp[n * c][(1 << n) - 1], frac++;
    } while (next_permutation(id + 1, id + n));
    printf("%.12lf\n", ans / frac / pow(c, n - 1));
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    p.sort()

    sum = 0
    for i in range(K):
        sum += p[i]
    print(sum)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include <iostream>

using namespace std;

int main()
{
  char b;
  cin >> b;
  if(b == 'A') cout << "T" << "\n";
  if(b == 'T') cout << "A" << "\n";
  if(b == 'C') cout << "G" << "\n";
  if(b == 'G') cout << "C" << "\n";

  return 0;
}


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

int main()
{
    int n;cin>>n;
    vector<int> d(n);
    int i;for(i=0;i<n;i++)cin>>d.at(i);
    int ans=0;
    int j;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)ans+=d.at(i)*d.at(j);
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i=0; i<s.size(); i++){
        rep(j,n){
            if (s.at(i)=='Z'){
                s.at(i)='A';
                continue;
            }
            s.at(i)++;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>

int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int sz(pin x) { return x.first*x.second; }
void make(int c, int pot, int d, vel &col, vel &max_use,vvel &way) {
	if (max_use[pot] < d) {
		if (col[pot] == 0) { col[pot] = c; }
		max_use[pot] = d;
		for (auto x : way[pot]) {
			make(c, x, d - 1, col, max_use, way);
		}
	}
}
signed main() {
	int n; cin >> n;
	int max1=0, max2=0;
	vel a(n);
	rep(i, n) { 
		cin >> a[i];
		vel ne = { max1,max2,a[i] };
		sor(ne);
		max1 = ne[2];
		max2 = ne[1];
	}
	if (max1 == max2) {
		rep(i, n) { cout << max1 << endl; }
	}
	else {
		rep(i, n) {
			if (max1 == a[i]) { cout << max2 << endl; }
			else { cout << max1 << endl; }
		}
	}
	return 0;
}

Measured memory_bytes: 18816
use std::io;

fn main() {

    let input_str = get_input();
    let st: Vec<&str> = input_str.trim().split_whitespace().collect();
    let mut ab = read_line();
    let u  = get_input();

    let mut a: i32 = ab[0];
    let mut b: i32 = ab[1];
    if u.trim() == st[0] {
        a -= 1;
    } else {
        b -= 1;
    }

    println!("{} {}", a, b);
}

fn read_line() -> Vec<i32> {

    let input_str = get_input();
    let vec: Vec<&str> = input_str.trim().split_whitespace().collect();

    let mut int_vec: Vec<i32> = Vec::new();
    for v in vec {
        int_vec.push(to_i(v));
    }

    int_vec
}

fn get_num() -> i32 {
    to_i(&get_input())
}

fn to_i(s: &str) -> i32 {
    let input_num: i32 = match s.trim().parse() {
        Ok(num) => num ,
        Err(_)  => panic!("input wrong number."),
    };
    input_num
}

fn get_input() -> String {
    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;
    input_str
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	P ans;
	double now = -1.0;
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; (i + a + j * b) * 100 <= f; j++) {
			if (i + j == 0)continue;
			int w = (i*a + j * b) * 100;
			int ms = min(f - w, e*w / 100);
			for (int k = 0; k * c <= ms; k++) {
				int l = (ms - k * c) / d;
				int s = k * c + l * d;
				if (now < 100.0 * s / (s + w)) {
					now = 100.0*s / (s + w);
					ans = P(s + w, s);
				}
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 256
class Dice(object):
    def __init__(self, init_numbers: list):
        self.numbers = dict(zip(("T", "S", "E", "W", "N", "B"), init_numbers))

    def _roll(self, old_part: tuple):
        new_part = old_part[1:] + (old_part[0],)
        new_numbers = [self.numbers[face] for face in new_part]

        for old, new in zip(old_part, new_numbers):
            self.numbers[old] = new

    def vroll(self, reverse=False):
        """北方向に回転"""
        old_part = ("N", "T", "S", "B")
        self._roll(old_part if not reverse else old_part[::-1])

    def hroll(self, reverse=False):
        """時計回りに回転"""
        old_part = ("N", "W", "S", "E")
        self._roll(old_part if not reverse else old_part[::-1])

    def roll_to(self, direction: str):

        if direction == "N":
            self.vroll()
        elif direction == "S":
            self.vroll(reverse=True)
        elif direction == "E":
            self.hroll(reverse=True)
            self.vroll()
            self.hroll()
        elif direction == "W":
            self.hroll()
            self.vroll()
            self.hroll(reverse=True)
        else:
            raise AssertionError


def is_same(dice1: Dice, dice2: Dice):

    result = False

    for direction in ["N", "E"] * 3:
        dice1.roll_to(direction)
        for _ in range(4):
            result |= dice1.numbers == dice2.numbers
            dice1.hroll()

    return result


if __name__ == "__main__":
    from itertools import combinations

    n = int(input())
    dices = []
    for _ in range(n):
        dices.append(Dice(list(map(int, input().split()))))

    all_different = True
    for i, j in combinations(dices, r=2):
        all_different &= not is_same(i, j)

    print("Yes" if all_different else "No")



Measured memory_bytes: 5716
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())

seg_el=1<<(N.bit_length()) # Segment treeの台の要素数
seg_height=1+N.bit_length() # Segment treeの高さ
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化
LAZY=[None]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

def indexes(L,R): # 遅延伝搬すべきノードのリストを返す. （つまり, updateやgetvaluesで見るノードより上にあるノードたち）
    INDLIST=[]

    R-=1
    
    L>>=1
    R>>=1

    while L!=R:
        if L>R:
            INDLIST.append(L)
            L>>=1
        else:
            INDLIST.append(R)
            R>>=1

    while L!=0:
        INDLIST.append(L)
        L>>=1

    return INDLIST

def updates(l,r,x): # 区間[l,r)をxに更新
        
    L=l+seg_el
    R=r+seg_el

    L//=(L & (-L))
    R//=(R & (-R))

    UPIND=indexes(L,R)
    
    for ind in UPIND[::-1]: # 遅延伝搬
        if LAZY[ind]!=None:
            update_lazy = LAZY[ind] *(1<<(seg_height - 1 - (ind.bit_length())))
            LAZY[ind<<1]=LAZY[1+(ind<<1)]=LAZY[ind]
            SEG[ind<<1]=SEG[1+(ind<<1)]=update_lazy
            LAZY[ind]=None

    while L!=R:
        if L > R:
            SEG[L]=x * (1<<(seg_height - (L.bit_length())))
            LAZY[L]=x
            L+=1
            L//=(L & (-L))

        else:
            R-=1
            SEG[R]=x * (1<<(seg_height - (R.bit_length())))
            LAZY[R]=x
            R//=(R & (-R))

    for ind in UPIND:
        SEG[ind]=SEG[ind<<1]+SEG[1+(ind<<1)]

def getvalues(l,r): # 区間[l,r)に関するminを調べる

    L=l+seg_el
    R=r+seg_el

    L//=(L & (-L))
    R//=(R & (-R))

    UPIND=indexes(L,R)
    
    for ind in UPIND[::-1]: # 遅延伝搬
        if LAZY[ind]!=None:
            update_lazy = LAZY[ind] *(1<<(seg_height - 1 - (ind.bit_length())))
            LAZY[ind<<1]=LAZY[1+(ind<<1)]=LAZY[ind]
            SEG[ind<<1]=SEG[1+(ind<<1)]=update_lazy
            LAZY[ind]=None
            
    ANS=0

    while L!=R:
        if L > R:
            ANS+=SEG[L]
            L+=1
            L//=(L & (-L))

        else:
            R-=1
            ANS+=SEG[R]
            R//=(R & (-R))

    return ANS

ANS=[]
for _ in range(Q):
    query=list(map(int,input().split()))

    if query[0]==0:
        updates(query[1],query[2]+1,query[3])

    else:
        ANS.append(getvalues(query[1],query[2]+1))
    
print("\n".join([str(ans) for ans in ANS]))



Measured memory_bytes: 21476
n,k = map(int,input().split(" "))
c = list(map(int,input().split(" ")))
ans = 0
kar = 0
for i in range(n):
    c[i] = (c[i]+1)/2

for i in range(n):
    if i + 1 <= k:
        ans += c[i]
        kar += c[i]
    else:
        kar += c[i] - c[i-k]
        if ans <= kar:
            ans = kar
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef set <int> st;
typedef set <char> stc;
typedef vector<int>::iterator itr;

#define df first
#define ds second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<(b);i++)
#define f22(a,b) for(int j=(a);j<(b);j++)
#define sq(a) a*a
#define cu(a) (sq(a)*a)


const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int inf = 1e9+9;
const ll INF = 1e18;


int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    
    int a,b,c;
    
    cin >> a >> b >> c;
    
    a += b+c;
    
    if(a < 22) cout << "win";
    else cout << "bust";
    
    return 0; 
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> x(M), y(M);
    set<int> sx, sy;
    map<int, vector<int>> g;
    vector<int> in_degree(N);
    for(int i=0 ; i<M; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        x[i] = tmp1 - 1;
        y[i] = tmp2 - 1;
        g[x[i]].push_back(y[i]);
        sx.insert(tmp1-1);
        sy.insert(tmp2-1);
        in_degree[y[i]]++;
    }

    set<int> sources;
    set_difference(sx.begin(), sx.end(), sy.begin(), sy.end(), inserter(sources, sources.end()));

    vector<int> dp(N, 0);
    queue<int> v_queue;

    int ans = 0;
    for(auto s: sources) {
        dp[s] = 0;
        v_queue.push(s);
        while(!v_queue.empty()) {
            int from = v_queue.front();
            v_queue.pop();

            for(auto v: g[from]){
                dp[v] = max(dp[v], dp[from]+1);
                in_degree[v]--;
                if(in_degree[v]==0) {
                    v_queue.push(v);
                }
                if(ans < dp[from]+1) ans = dp[from] + 1;
            }
        }
    }

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

Measured memory_bytes: 22144
from collections import defaultdict
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [None]*N
    A = list(map(int, input().split()))

    Adict = [0]*N
    for a in A:
        Adict[a-1] += 1
    num = len(set(A))

    
    Adict = sorted(Adict,reverse=True)
    count=0
    for _ in range(num - K):
        while True:
            min_num = Adict.pop()
            count += min_num
            if min_num != 0:
                break
    
    print(count)

Measured memory_bytes: 28036
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		String key = "keyence"; 
		char keyset[] = key.toCharArray();
		final int LEN = 7;
		String s = sc.next();
		int slen = s.length();
		for(int i = 0; i < LEN; i++) {
			if(s.substring(0, LEN - i).concat(s.substring(slen - i, slen)).equals(key)){
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23892
N = int(input())
A = list(map(int, input().split()))
counter = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if A[j]<A[minj]:
            minj = j
    if i!=minj:
        counter += 1
        A[i], A[minj] = A[minj], A[i]   
print(' '.join(map(str, A)))
print(counter)


Measured memory_bytes: 5600
#include<iostream>
#include<map>
using namespace std;
map<int,int> f;
int n;
int a[200005];
long long tot;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        f[i-a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        tot+=f[i+a[i]];
    }
    cout<<tot;
    return 0;
}



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

ll calc(ll x, ll y, ll z, ll n) {
	ll val = 0;
	if (n % 2 == 0) val += x;
	else val -= x;
	n /= 2;
	if (n % 2 == 0) val += y;
	else val -= y;
	n /= 2;
	if (n % 2 == 0) val += z;
	else val -= z;
	n /= 2;

	return val;
}

int main() {
	int N, M;  cin >> N >> M;
	vector<ll> x(N), y(N), z(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}

	vector<pair<ll,int>> val(N);
	ll X = 0, Y = 0, Z = 0;
	ll ans = 0;
	for (ll n = 0; n < 8; n++) {
		X = 0; Y = 0; Z = 0;
		for (int i = 0; i < N; i++) {
			val[i].first = calc(x[i], y[i], z[i], n);
			val[i].second = i;
		}
		sort(val.begin(), val.end());
		for (int i = 0; i < M; i++) {
			X += x[val[N - 1 - i].second];
			Y += y[val[N - 1 - i].second];
			Z += z[val[N - 1 - i].second];
		}
		ans = max(abs(X) + abs(Y) + abs(Z), ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;

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

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int n = i;
    int bit = 0;
    while (n > 0) {
      n /= 10;
      bit++;
    }
    if (bit % 2 != 0) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  int left = 0;
  int right = 0;
  rep(i,s.size()-1){
    if(s[i] == s[i+1]){
      ans++;
    }
    else{
      if(s[i] == 'L') left++;
      else right++;
    }
  }
  int lrmin = min(left,right);
  if(k >= lrmin){
    ans += 2*lrmin;
    k -= lrmin;
    left -= lrmin;
    right -= lrmin;
  }
  else{
    ans += k*2;
    k = 0;
  }
  ans += min(k,left);
  ans += min(k,right);
  cout << ans << endl;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

class Plogram
{
    static void Main()
    {
        var rests = new List<Rest>();
        var num = int.Parse(Console.ReadLine());
        int j = 1;

        for(int i =0; i<num;i++)
        {
            var info = Console.ReadLine().Split();
            rests.Add(new Rest(i+1,info[0], int.Parse(info[1])));
        }

        var query = rests.OrderByDescending(x => x.Rate).OrderBy(x => x.Name).Select(x => x.Id);
        foreach (var rest in query)
        {
            Console.WriteLine(rest);
        }
    }

    class Rest
    {
        public string Name { get; set; }
        public int Rate { get; set; }
        public int Id { get; set; }

        public Rest(int id, string name, int rate)
        {
            Name = name;
            Rate = rate;
            Id = id;
        }
    }
}


Measured memory_bytes: 13664
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 300005
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
bool cmp(ll x,ll y)
{
   return x>y;
}
int main(void)
{
   long long int t,n,m,k,x,y,a[200001];
   vector<ll> v,v1,v2;
   vector< pair <ll,ll> >p,p1,p2;
   set<ll> st;
   priority_queue<ll> pq;
   priority_queue< ll,vector<ll>,greater<ll> > lpq;
   priority_queue< pair<ll,ll> > phpq;
   priority_queue< pair<ll,ll>,vector< pair<ll,ll> >,greater< pair <ll,ll> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   {
      cin>>n>>x>>t;
      if(n%x==0)
         cout<<(n/x)*t<<endl;
      else
         cout<<((n/x)+1)*t<<endl;
   }
   return 0;
}


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

using namespace std;
using ll = long long;
#define N (ll)(1e9+7)
ll mypower(ll a, ll b, ll mod = N)
{
    ll ans = 1;
    while(b)
    {
        if(b%2)
            ans = (ans*a)%mod;
        b=b/2;
        a=(a*a)%mod;
    }
    return ans;
}
bool comp(pair<ll,ll> a, pair<ll,ll> b)
{
    return a.first > b.first;
}
int main() {
    int n, x, y;
    cin >> n >> x >> y;
    int i, j;
    int dist[n+1] = {0};
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(i<=x)
            {
                if(j <= x)
                    dist[j-i]++;
                else if(j <= y)
                {
                    dist[x-i + min(j-x, 1+y-j)]++;
                }
                else
                {
                    dist[x-i + 1 + j-y]++;
                }
            }
            else if(i <= y) // i > x
            {
                if(j <= y)
                {
                    dist[min(j-i, i-x+1+y-j)]++;
                }
                else
                {
                    dist[min(j-i, i-x+1+j-y)]++;
                }
            }
            else
                dist[j-i]++;
        }
    }
    for(i=1;i<=(n-1);i++)
        cout << dist[i] << endl;
}

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

const int MAXN = 1e5+10;
int A[MAXN],B[MAXN],C[MAXN];
int n;
//严格小于B[i]的数字个数  和 严格大于B[i]的数字个数
long long lnb[MAXN],unb[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> A[i];
    sort(A,A+n);
    for(int i = 0; i < n; ++i)
        cin >> B[i];
    sort(B,B+n);
    for(int i = 0; i < n; ++i)
        cin >> C[i];
    sort(C,C+n);

    //对于每个b，先统计出来几个a比他小，O(nlog(n))
    for(int i = 0; i < n; ++i)
        lnb[i] = lower_bound(A,A+n,B[i]) - A;
    for(int i = 0; i < n; ++i)
        unb[i] = n - (upper_bound(C,C+n,B[i]) - C);
    long long res = 0;
    for(int i = 0; i < n; ++i)
        res += lnb[i]*unb[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3072
S = input()
n = len(S)
ans = 0
def eval(s):
    ls = s.split("+")
    return sum(map(int,ls))
b = list("x".join(list(S)))
for i in range(2**(n-1)):
    a = b.copy()
    for j in range(n-1):
        if i >> j & 1:
            a[j*2+1] = "+"
        else:
            a[j*2+1] = ""
    ans += eval("".join(a))
print(ans)

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

using namespace std;

const int N = 405;

int n, a[N], u[N][N];
long long dp[N][N], pref[N];

long long get(int l, int r){
      if(l >= r)
            return 0;
      if(u[l][r])
            return dp[l][r];
      u[l][r] = 1;
      dp[l][r] = 1e18;
      get(l, r - 1);
      get(l + 1, r);
      for(int i = l; i < r; i ++){
            dp[l][r] = min(dp[l][r], pref[r] - pref[l - 1] + get(l, i) + get(i + 1, r));
      }
      return dp[l][r];
}

int main(){
      cin >> n;

      for(int i = 1; i <= n; i ++){
            cin >> a[i];
            pref[i] = pref[i - 1] + a[i];
      }

      cout << get(1, n) << endl;
}


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

int main() {
    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    vector<int> b(m);
    int a;
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        int tmp = c;
        for(int j = 0; j < m; j++){
            cin >> a;
            tmp += b[j] * a;
        }
        if(tmp > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n;cin>>n;
    ll ans = 0;
    rep(i,n+1){
        if(i%3==0||i%5==0)continue;
        else ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(x >= a and a+b >= x) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int M = 105;
#define mod   1000000007
int dp[N][M][2];
int n, m;
string num;
int d;
int add(long long a, long long b)
{
    return ((a % mod) + (b % mod)) % mod;
}
long long help(long long idx, long long sum, long long tight)
{
    if (idx == -1)
        return sum == 0;
    if (dp[idx][sum][tight] != -1)
        return dp[idx][sum][tight];
    long long res = 0;
    int biggest;
    if (tight)
     biggest= (num[idx]-'0') ;
     else
        biggest=9;
    for (int i = 0; i <= biggest; i++)
    {
        int newtight = ((num[idx]-'0')== i) ? tight : 0;
        res = add(res,help(idx - 1, (sum + i) % d, newtight));
    }
    return dp[idx][sum][tight] = res;
}
void solve()
{
    memset(dp, -1, sizeof dp);
    cin >> num;
    cin >> d;
    n = num.size();
    reverse(num.begin(),num.end());
    cout << ((help(n-1, 0, 1) % mod - 1 % mod) + mod) % mod << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, int> Pli;

int K, N;
const int MAX_N = 2.0e5 + 10;
int A[MAX_N];

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

    vector<int> dis;
    for (int i = 0; i < N-1; i++) {
        dis.push_back(A[i+1] - A[i]);
    }
    dis.push_back(A[0] + K - A[N-1]);

    sort(dis.begin(), dis.end(), greater<>());

    cout << K - dis[0] << endl;

    
    return 0;
}

Measured memory_bytes: 2168
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	HW   := strings.Split(sc.Text(), " ")
	H, _ := strconv.Atoi(HW[0])
	W, _ := strconv.Atoi(HW[1])
	var grid = make([][]string, H)
	for i := 0; i < H; i++ {
		sc.Scan()
		grid[i] = make([]string, W)
		grid[i] = strings.Split(sc.Text(), "")
	}
	
	cnt := 0
	for i := 0; i < len(grid); i++ {
		for j := 0; j < len(grid[i]); j++ {
			if (grid[i][j] == "#") &&
				(i != 0 && grid[i - 1][j] != "#") &&
				(i != len(grid) - 1 && grid[i + 1][j] != "#") &&
				(j != 0 && grid[i][j - 1] != "#") &&
				(j != len(grid[i]) - 1 && grid[i][j + 1] != "#") {
				cnt++
			}
		}
	}

	if cnt == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

int main() {
	int a, b;
	cin >> a >> b;
	string ans = "Yes";
	
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
string s;
cin>>s;int ans=0;
for(int i=0;(i+1)*2<=s.size();i++)if(s[i]!=s[s.size()-1-i])ans++;
cout<<ans;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

using ll = long long;

ll dp[105][100005];

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> v(N);
  for(ll i = 0LL; i < N; i++) {
    cin >> v.at(i);
  }
  for(ll i = 0LL; i <= v.at(0); i++) {
    dp[0][i] = 1LL;
  }
  for(ll i = 1LL; i < N; i++) {
    for(ll j = 0LL; j <= K; j++) {
      if(j == 0) dp[i][j] = 1;
      else if(j<=v.at(i)) {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]) % 1000000007;
      }
      else {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-v.at(i)-1])%1000000007;
      }
    }
  }
  if(dp[N-1][K]<0) dp[N-1][K]+=1000000007;
  cout << dp[N-1][K] << endl;
}
  

Measured memory_bytes: 80128