akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}


int n, a[100001], b[100001], m = 0;

signed main() {

	cin >> n;
	nin(a, n);

	for (int i = 0; i < n; i++) {
		if (a[i] != 0)
			b[a[i] - 1]++;
		b[a[i]]++;
		if (a[i] != n - 1)
			b[a[i] + 1]++;
	}
	rep(i, 100000) {
		m = max(m, b[i]);
	}

	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};

template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};




int main()
{
  go();
  fast_io
  string a,b;cin>>a>>b;
  int n=a.size(),m=b.size();
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      if(a[i-1]==b[j-1])
        dp[i][j]=1+dp[i-1][j-1];
      else 
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  int i=n,j=m;
  string ans="";
  while(i>0 && j>0)
  {
    if(a[i-1]==b[j-1])
    {
      ans+=a[i-1];
      i--;j--;
    }
    else
    {
      if(dp[i-1][j]>dp[i][j-1])
      {
        i--;
      }
      else
        j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans <<"\n";
}
























Measured memory_bytes: 38772
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; int L[N*2];
    rep(i,N*2) cin >> L[i];
    sort(L,L+N*2);
    int ans=0;
    rep(i,N){
        ans+=min(L[i*2],L[i*2+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
AizuOnline A0109
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
char siki[101];
char bin_op1[]="+-";
char bin_op2[]="*/";
//
char * find_bin_op(char * s,int len)
{
  int i,d;
  char *p;
  
  d=0;
  for(i=len-1;i>=0;i--)
    { 
      if(s[i]==')')
	d++;
      else if (s[i]=='(')
	d--;
      else
	{
	  p=strchr(bin_op1,s[i]); //priority low
	  if(p && d==0)
	    return(&s[i]);
	}
    }
  d=0;
  for(i=len-1;i>=0;i--)
    { 
      if(s[i]==')')
	d++;
      else if (s[i]=='(')
	d--;
      else
	{
	  p=strchr(bin_op2,s[i]); //priority high
	  if(p && d==0)
	    return(&s[i]);
	}
    }
  return(NULL);
}
int calc_expr1(int a1,int a2 ,char operator)
{
  //printf("s:%d %d %c",a1,a2,operator);

  switch(operator){
  case '+':
    return(a1+a2);
  case '-':
    return(a1-a2);
  case '*':
    return(a1*a2);
  case '/':
    return(a1/a2);
  default:
    break;
    }
}
int isnumber(char *s,int len)
{
  int i;
  for(i=0;i<len;i++)
    if(s[i] < '0' || s[i] > '9')
      return(0);
  return(-1);
}
int calc_expr(char *s,int len)
{
  char *r;
  int i;
#ifdef DEBUG
  printf("exp:");
  for(i=0;i<len;i++)
    printf("%c",s[i]);
  printf("\n");
#endif
  if(isnumber(s,len))
    {
       return(atoi(s));
    }
    
  r=find_bin_op(s,len);
 
  if(r)
    {
      return(calc_expr1(calc_expr(s,r-s),calc_expr(r+1,len-(r-s+1)),r[0]));
    }
  //if(s[0]=='c')
  //   return(calc_cpl(calc_expr(s+1,len-1)));
  if(s[0]=='(' && s[len-1]==')')
    return(calc_expr(s+1,len-2));

}

main()
{
  int ret;
  int n,i;
  
  scanf("%d ",&n);
  for(i=0;i<n;i++)
    {
      fgets(siki,sizeof(siki),stdin);
      if(!isprint(siki[strlen(siki)-1]))
	siki[strlen(siki)-1]='\0';
      if(siki[strlen(siki)-1]='=')
	siki[strlen(siki)-1]='\0';
       
      ret=calc_expr(siki,strlen(siki));
      printf("%d\n",ret);
    }
return(0);
}

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

N = int(input().strip())
S = input().strip()
#-----

x=0
x_max=0
for w in S:
    if w == "I":
        x += 1
    elif w == "D":
        x -= 1
    
    x_max = max(x_max, x)

print(x_max)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int N = 6;
const int C = 50;

int n, c;
int l[N];
long long f[N * C + 1][1 << (N - 1)][N * C + 1];

void solve()
{
    cin >> n >> c;
    for(int i = 0; i < n; ++ i) {
        cin >> l[i];
    }
    sort(l, l + n);
    reverse(l, l + n);

    long long ret = 0;
    vector<int> order_b;
    for(int i = 1; i < n; ++ i) {
        order_b.push_back(i);
    }

    do {
        memset(f, 0, sizeof f);
        f[0][0][l[0] * n] = 1;
        for(int i = 0; i < n * c; ++ i) {
            for(int s = 0; s < (1 << (n - 1)); ++ s) {
                for(int j = i + 1; j <= n * c; ++ j) {
                    if (f[i][s][j] == 0) continue;
                    f[i + 1][s][j] += f[i][s][j];
                    if ((i + 1) % n == 0) continue;

                    int id = order_b[(i + 1) % n - 1];
                    if (s >> (id - 1) & 1) continue;
                    f[i + 1][s + (1 << (id - 1))][min(n * c, max(j, i + 1 + l[id] * n))] += f[i][s][j];

                }
            }
        }
        ret += f[n * c][(1 << (n - 1)) - 1][n * c];
    } while(next_permutation(order_b.begin(), order_b.end()));

    long long over = 1;
    for(int i = 1; i < n; ++ i) {
        over *= i;
        over *= c;
    }
    printf("%.20f\n", (double)((long double)ret / (long double)over));
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 22912
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Solve()
    {
        var a = sc.Str();
        var b = sc.Str();

        var n = int.Parse(a + b);

        for (int i = 1; i <= 1000; i++)
        {
            if (n == i * i)
            {
                pr.WriteLine("Yes");
                return;
            }
        }

        pr.WriteLine("No");
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n;) {
    bool a = false, b = false, c = false;
    for (int k = 1; k <= i; k *= 10) {
      int x = i / k % 10;
      if (x == 3) {
        a = true;
      } else if (x == 5) {
        b = true;
      } else if (x == 7) {
        c = true;
      } else {
        i = i / k * k + k;
        goto next;
      }
    }
    if (a && b && c) ++res;
    ++i;
  next:;
  }
  cout << res << endl;
}



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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N, M;
    lint K;
    cin >> N >> M >> K;

    vector<lint> A(N + 1);
    for_(i,0,N) cin >> A[i + 1];
    for_(i,0,N) A[i + 1] += A[i];
    A.push_back(1LL << 60);

    vector<lint> B(M + 1);
    for_(i,0,M) cin >> B[i + 1];
    for_(i,0,M) B[i + 1] += B[i];
    B.push_back(1LL << 60);

    int i = 0;
    while (i < N and A[i + 1] <= K) ++i;

    int j = 0;
    while (j < M and A[i] + B[j + 1] <= K) ++j;

    int ans = i + j;
    while (i >= 0) {
        --i;
        while (j < M and A[i] + B[j + 1] <= K) ++j;
        ans = max(ans, i + j);
    }

    cout << ans << endl;
}

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


int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long ans = 0;
  
  if(A == 0) {
    cout << ans << endl;
    return 0;
  }
  
  ans += N/(A+B)*A;
  
  N -= ans/A*(A+B);
  
  if(N > A) {
    ans += A;
  } else {
    ans += N;
  }
  
  cout << ans << endl;
  
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int left = 0, right = 0;
    rep (i, s.size()) {
        if (s[i] == '(') right++;
        else {
            if (right == 0) left++;
            else right--;
        }
    }
    string tmp = "";
    rep (i, left) tmp += '(';
    rep (i, right) s += ')';
    tmp += s;
    cout << tmp << endl;
    
    return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#define MOD 1000000007
#define MAX_N 1100000
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,ans=0;
  cin >> n;
  vector<ll> a(n),pvals(MAX_N,0);
  vector<P> lc;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    ll v = a[i];
    for(int j=2;j*j<=v;j++){
      ll cnt = 0;
      while(v%j==0){
        cnt++;
        v/=j;
      }
      pvals[j] = max(pvals[j],cnt);
    }
    if(v!=0){
      pvals[v] = max(pvals[v],1ll);
    }
  }
  for(int i=2;i<=MAX_N;i++){
    if(pvals[i]>=1){
      lc.push_back(P(i,pvals[i]));
    }
  }
  for(int i=0;i<n;i++){
    ll ad = 1;
    for(auto j:lc){
      ll cnt=0;
      while(a[i]%j.first==0){
        a[i]/=j.first;
        cnt++;
      }
      for(int k=0;k<j.second-cnt;k++){
        ad *= j.first;
        ad %= MOD;
      }
    }
    ans += ad;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 9344
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


a, b = LI()
print(max(a+b, a-b, a*b))


Measured memory_bytes: 9128
n=int(input())
li=list(map(int,input().split()))
count=0
li2=[]
for i in range(n):
  li2.append(abs(li[i]))
  if li[i] < 0:
      count += 1
      
if count % 2==0:
    print(sum(li2))
else:
    print(sum(li2)-2*min(li2))

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

int main(){
    while(1){
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;
        if(m==0) break;

        int cur,prev;
        cin >> prev;
        int pmax=0,gmax=0;
        for(int i=1; i<m; i++){
            cin >> cur;
            if(nmin<=i && i<=nmax){
                int gap = prev-cur;
                if(gap >= gmax){
                    gmax = gap;
                    pmax = i;
                }
            }
            prev = cur;
        }
        cout << pmax << endl;
    }
    return 0;
}

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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main() {
	string str;
	cin >> str;
	int x, y;
	cin >> x >> y;

	int	 s = 0, t = 0;
	bool f = true;
	bool fx = true;
	vector <ll> xx, yy;
	int	tmp = 0;
	rep (i, str.size()) {
		if (f && str[i] == 'F') s++;
		else {
			if (str[i] == 'F') tmp++;
			else {
				if(!f && tmp != 0) (fx ? xx : yy).push_back(tmp);
				tmp = 0;
				fx	= !fx;
			}
			f = false;
		}
	}
	if(tmp != 0) (fx ? xx : yy).push_back(tmp);

	set <ll> stx, sty;
	stx.insert(s);
	sty.insert(t);

	rep(i, xx.size()){
		set<ll> stmp;
		for(auto it : stx){
			stmp.insert(it + xx[i]);
			stmp.insert(it - xx[i]);
		}
		stx = stmp;
	}
	rep(i, yy.size()){
		set<ll> stmp;
		for(auto it : sty){
			stmp.insert(it + yy[i]);
			stmp.insert(it - yy[i]);
		}
		sty = stmp;
	}

	if(stx.find(x) != stx.end() && sty.find(y) != sty.end()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int main(void){
    long long n, m;
    cin >> n >> m;
    
    long long ans = (n * 2 + m) / 4;
    if(n <= ans){
        cout << ans << endl;
    }else{
        cout << m / 2 << endl;
    }
    
    return 0;
}


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

int main(){
  string s; cin>>s;
  string t = "CODEFESTIVAL2016";
  int ans = 0;
  for(int i=0; i<16; i++){
    if(s[i]!=t[i]) ans ++;
  }
  cout << ans << endl;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool is_integer( double x ){
    return std::floor(x)==x;
}

int main() {
    double X;
    cin >> X;
    double challenge = X*100/108;
    if (is_integer(challenge)) {
        cout << challenge << endl;
        exit(0);
    }
    auto c=ceil(challenge);
    // cout << c << endl;
    if (int(c*1.08) == int(X)) {
        cout << c << endl;
        exit(0);
    }
    // cout << challenge << endl;
    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
n,l=map(int,input().split())
a=0
b=300
c=300
for i in range(1,n+1):
    b=min(abs(b),abs(l+i-1))
    if c>b:
        c=b
        d=i
    a+=(l+i-1)
if l+d-1>=0:
    print(a-b)
else:
    print(a+b)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 200005
#define INF 1000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];
ll dp[SIZE][5];

ll score(ll a,int t)
{
	if(t==0||t==4) return a;
	if(t==1||t==3)
	{
		if(a==0) return 2;
		return a%2;
	}
	return (a+1)%2;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	for(int i=0;i<=n;i++) for(int j=0;j<5;j++) dp[i][j]=INF;
	for(int j=0;j<5;j++) dp[0][j]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<5;j++)
		{
			if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+score(A[i],j));
		}
	}
	ll ret=INF;
	for(int j=0;j<5;j++) ret=min(ret,dp[n][j]);
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 9472
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
      mut N:i64
    }
    let mut x: Vec<char> = Vec::new();
    while N > 0 {
        N = N - 1;
        let y = N % 26;
        x.push((y as u8 + 'a' as u8) as char);
        N = N / 26;
    }
    x.reverse();
    for a in x {
        print!("{}", a);
    }
}


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

using namespace std;

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

  int n, k, x, y;
  cin >> n >> k >> x >> y;

  int res = (x * min(k, n)) + y * max(0, (n - k));
  cout << res << "\n";
}


Measured memory_bytes: 3632
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    s = input()
    r = s.count('R') * s.count('G') * s.count('B')

    for i1 in range(n-2):
        for i2 in range(i1 + 1, n-1):
            k = i2 * 2 - i1
            if k < n:
                if s[i1] != s[i2] and s[i1] != s[k] and s[i2] != s[k]:
                    r -= 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
#![allow(unused_variables, dead_code, clippy::many_single_char_names, non_upper_case_globals, unused_imports, unused_macros)]
use std::{
    collections::{BTreeMap, HashSet, HashMap, VecDeque},
    io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, prelude::*},
    mem::swap,
    str::FromStr,
};

struct Reader<'a> {
    stdin: BufReader<StdinLock<'a>>
}

impl<'a> Reader<'a> {
    fn new(stdin: BufReader<StdinLock<'a/*'*/>>) -> Self {
        Self {stdin}
    }
    fn read_str(&mut self) -> String {
        let mut s = String::with_capacity(100);
        self.stdin.read_line(&mut s).unwrap();

        if s.ends_with('\n') { s.pop(); if s.ends_with('\r') { s.pop(); } }
        s
    }
    fn read_int<T: FromStr>(&mut self) -> T {
        match self.read_str().parse::<T>() {
            Ok(n) => n,
            _ => panic!()
        }
    }
}

macro_rules! pipe_read {
    ($r: expr, str, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ');
        $($x = it.next().unwrap();)+
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ').map(|x| x.parse::<$t>().unwrap());
        $($x = it.next().unwrap();)+
    }
}

macro_rules! pipe {
    ($r: expr, str, $($x: ident),+) => {
        pipe_read!($r, str, $($x),+);
    };
    (declare $r: expr, str, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, str, $($x),+);
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        pipe_read!($r, $t, $($x),+);
    };
    (declare $r: expr, $t: ty, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, $t, $($x),+);
    };
}

const M: usize = 1_000_000;

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    unsafe {
    solve(&mut Reader::new(BufReader::with_capacity(M, stdin.lock())), &mut BufWriter::with_capacity(M, stdout.lock()));
    }
}

const ROWS: usize = 1;
const COLS: usize = 100001;
// static mut dp: [[usize; COLS]; ROWS] = [[0; COLS]; ROWS];
static mut dp: [usize; COLS] = [0; COLS];

unsafe fn solve(r: &mut Reader, w: &mut BufWriter<StdoutLock>) {
    pipe!(declare r, usize, n, w_cap);
    let mut _w = Vec::with_capacity(n);
    let mut v = Vec::with_capacity(n);

    for _ in 0..n {
        let t = r.read_str();
        let mut t = t.split(' ').map(|x| x.parse::<usize>().unwrap());
        _w.push(t.next().unwrap());
        v.push(t.next().unwrap());
    }

    for (wi, vi) in _w.into_iter().zip(v.into_iter()) {
        for ii in (wi..=w_cap).rev() {
            *dp.get_unchecked_mut(ii) = (*dp.get_unchecked(ii)).max(*dp.get_unchecked(ii-wi)+vi);
        }
    }
    write!(w, "{}", dp[w_cap]);
}


Measured memory_bytes: 2868
use proconio::input;

fn main() {
    input! {
        a:i32,
        b:i32,
        c:i32,
        x:i32,
        y:i32,
    }
    let case1: i32 = a * x + b * y;
    let case2 = {
        if x > y {
            y * 2 * c + (x - y) * a
        } else {
            x * 2 * c + (y - x) * b
        }
    };
    let case3 = {
        if x > y {
            x * 2 * c
        } else {
            y * 2 * c
        }
    };

    println!("{}", case1.min(case2).min(case3));
}


Measured memory_bytes: 2140
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
#pragma endregion

int main()
{
  init_main();
  int h, w;
  cin >> h >> w;
  int cnt4 = (h / 2) * (w / 2);
  int cnt2 = (h % 2) * (w / 2) + (h / 2) * (w % 2);
  int cnt1 = (h % 2) * (w % 2);
  int cnt[26] = {};
  rep(i, h * w)
  {
    char c;
    cin >> c;
    cnt[c - 'a']++;
  }
  rep(i, 26)
  {
    while (cnt[i] >= 4 && cnt4 > 0)
    {
      cnt[i] -= 4;
      cnt4--;
    }
    while (cnt[i] >= 2 && cnt2 > 0)
    {
      cnt[i] -= 2;
      cnt2--;
    }
    while (cnt[i] >= 1 && cnt1 > 0)
    {
      cnt[i] -= 1;
      cnt1--;
    }
    if (cnt[i] > 0)
    {
      Yes(0);
      return 0;
    }
  }
  Yes(1);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
double dis(int x1,int x2,int y1,int y2)
{
    double d=sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    return d;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++)
    {
        int a,b; cin>>a>>b; v.pb(mp(a,b));
    }
    vector<int> v1;
    double ans=0;
    for(int i=0;i<n;i++) v1.pb(i);
    do
    {
        for(int i=0;i<n-1;i++)
        {
            int x1=v[v1[i]].first;
            int x2=v[v1[i+1]].first;
            int y1=v[v1[i]].second;
            int y2=v[v1[i+1]].second;
            ans+=dis(x1,x2,y1,y2);
        }
    }while(next_permutation(v1.begin(),v1.end()));
    int t=1;
    for (int i=1;i<=n;i++) t*=i;
    printf("%.10f\n",ans/(double)t);
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        val = b[i] - a[i]
        if a[i+1] - val <= 0:
            ans += a[i] + a[i+1]
            a[i+1] = 0
        else:
            ans += b[i]
            a[i+1] = a[i+1] - val

print(ans)

Measured memory_bytes: 90640
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1e+10
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)

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

int main() {
  int n;
  cin >> n;
  int a = 0;
  bool f = true;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "A") {
      a++;
    } else {
      a--;
      if (a < 0) {
        f = false;
      }
    }
  }
  if (f && a == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;




int n, m, dp[1003][N], a, b, c;

main () {
	cin >> n >> m;
	forn (mask, 1, (1 << n) - 1)
		dp[0][mask] = INF;

	forn (i, 1, m) {
		cin >> a >> b;
		int mask = 0;
		while (b--) {
			cin >> c;
			--c;
			mask |= (1 << c);
		}	
		
		forn (Mask, 0, (1 << n) - 1)
			dp[i][Mask] = dp[i - 1][Mask];
		forn (Mask, 0, (1 << n) - 1)
			dp[i][Mask | mask] = min(dp[i][Mask | mask], dp[i - 1][Mask] + a);
			
	}	

	int ans = dp[m][(1 << n) - 1];
	if (ans == INF)
		ans = -1;

	cout << ans << endl;
}
                        

Measured memory_bytes: 780672
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

typedef long long ll;

int main(int argc, char* argv[])
{
  std::vector< std::string > vstr;
  std::vector< std::string >::iterator it;

  for (int i = 0; i < 3; i++) {
    std::string str;
    std::cin >> str;
    vstr.push_back(str);
  }

  for (it = vstr.begin(); it != vstr.end(); it++) {
    std::cout << (*it)[it - vstr.begin()];
  }
  std::cout << std::endl;

  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll H,W,K;
	cin >> H>>W>>K;
	vector<string> v;
	for(int i = 0; i<H;i++)
	{
		string s;
		cin >>s;
		v.push_back(s);
	}
	int rows = int(pow(2,H));
	int col = int(pow(2,W));
	ll ans = 0;
	for(int i = 0; i<rows;i++)
	{
		for(int j = 0; j<col;j++)
		{
			ll tempans = 0;
			int r[H] = {0};
			int c[W] = {0};
			int ro = i;
			int co = j;
			int temp = 0;
			while(ro > 0)
			{
				r[temp++] = ro%2;
				ro = ro/2;
			}
			temp = 0;
			while(co > 0)
			{
				c[temp++] = co%2;
				co = co/2;
			}
			for(int k = 0; k < H;k++)
			{
				if(r[k] == 0)
				{
					for(int l = 0; l<W;	l++)
					{
						if(c[l] == 0)
						{
							if(v[k][l] == '#')
								tempans++;
						}
					}
				}
			}
			if(tempans == K)
			{
				// cout <<i<<" "<<j<<endl;
				ans++;
			}
		}
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 4088
if __name__ == "__main__":
    k, n = map(int, input().split())
    a = list(map(int, input().split()))

    for i in range(n):
        a.append(a[i] + k)

    ans = 2 * k

    for i in range(n):
        tmp = a[i+n-1] - a[i]
        if tmp < ans:
            ans = tmp

    print(ans)


Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    ll cnt = x;
    while(cnt <= y) {
        ans++;
        cnt *= 2;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
N, K  = map(int, input().split())
A_list = list(map(int, input().split()))
'''
#print(A_list)
ans_list = [ 0 for n in range(N)]
tmp = 1
for k in range(K):
    tmp *= A_list[k]
    #print(tmp)
ans_list[K-1] = tmp
#print(ans_list)
for k in range(K, N):
    ans_list[k] = ans_list[k-1]//A_list[k-K] * A_list[k]
'''
#print(ans_list)

for k in range(K, N):
    if A_list[k] > A_list[k-K]:
        print('Yes')
    else:
        print('No')

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

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

    vector<int> a(n,k-q);
    for(int i = 0; i < q ; ++i){
        int temp;
        cin >> temp;
        ++a[temp-1]; 
    }
    for(int i = 0; i < n; ++i){
        if(a[i] <= 0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;

}

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

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

	int64_t N;
	cin >> N;

	int ans = 0;

	for (int64_t i = 1; i <= N; ++i) {
		for (int64_t j = i; j < N; j += i) {
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(){
    int n, a[100], i;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for(i = n - 1; i > 0; i--){
        printf("%d ", a[i]);
    }printf("%d\n", a[0]);
    return 0;
}


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

class Dinic:
    def __init__(self, v, inf=10**10):
        self.v = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [-1]*v  # 深さ
        self.ite = [0]*v  # DFSでの探索が済んでいるか
    def add_edge(self, fr, to, cap):
        self.G[fr].append([to, cap, len(self.G[to])])
        self.G[to].append([fr, 0, len(self.G[fr])-1])
    def bfs(self, s):  # BFSで深さ決定,sがstart
        self.level = [-1]*self.v  # 必要
        self.level[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            v = Q.popleft()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e[1]>0 and self.level[e[0]]<0: ###capacity>0かつtoの深さ未定
                    self.level[e[0]] = self.level[v]+1
                    Q.append(e[0])
    def dfs(self, v, t, f):  # DFSで増加パス探索,v開始、t終点、総フローf
        if v==t:
            return f
        for i in range(self.ite[v], len(self.G[v])):
            self.ite[v] = i
            e = self.G[v][i]
            if e[1]>0 and self.level[v]<self.level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d  # cap減少
                    self.G[e[0]][e[2]][1] += d  # 逆辺のcap増加
                    return d
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0:
                return flow
            self.ite = [0]*self.v  # DFSでの探索が済んでいるか否か
            f = self.dfs(s,t,self.inf)
            while f>0:
                flow += f
                f = self.dfs(s,t,self.inf)

N = INT()
a = LIST()

D = Dinic(N+2)
s = 0
t = N+1

rw = 0

for i, x in enumerate(a):
    if x <= 0:  # そのまま罰金
        D.add_edge(s, i+1, -x)
    elif x > 0:  # あらかじめxもらっておき，これが破壊されるとxの罰金，
        D.add_edge(i+1, t, x)
        rw += x
    for j in range(2*(i+1), N+1, i+1):  # 「iが破壊かつjが非破壊」はだめ
        D.add_edge(i+1, j, INF)

print(rw - D.max_flow(s, t))


Measured memory_bytes: 18180
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

int main()
{
    int c[105] = { 0 };


    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            c[i * j] = 1;
        }
    }

    int m;
    cin >> m;

    if (c[m] == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
/* ABC112 */
/* A */
#include <iostream>
#include <string>
using namespace std;

int main(void){

    int N;
    cin >> N;

    if (N==1){
        cout << "Hello World" << endl;
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
    };
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split(" ").map((n) => parseInt(n));
	var N = input[0]
	var K = input[1]
	var S = input[2]
	var ans = ""
	for (var i = 1; i <= N; i++) {
		if (i <= K) {
			ans += S + " "	
		} else {
			if (S === 1) {
				ans += (S + 1) + " "
			} else {
				ans += (S - 1) + " "
			}
		}
	}
	ans.replace(/ $/, '')	

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 32076
#include<bits/stdc++.h>
using namespace std;
int n, k;
int main(){
  cin >> n >> k;
  int x;
  int length = 0;
  for(int i = 0; i < n; ++i){
    cin >> x;
    length += 2*min(abs(x), abs(k -x));
  }
  cout << length << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		long start = now();

		long ans = solve(n, a);
		cout.println(ans);

		trace("elapsed", now() - start);
	}

	private static long solve(int n, int[] a) {
		TreeMap<Integer, Integer> map = new TreeMap<>(Collections.reverseOrder());
		for (int x : a)
			map.put(x, 1 + map.getOrDefault(x, 0));
		long area = 1;
		long sides = 0;
		outer: for (Map.Entry<Integer, Integer> e : map.entrySet()) {
			int len = e.getKey();
			int cnt = e.getValue();
			for (int i = 0; i < 2; i++) {
				if (cnt < 2)
					break;
				cnt -= 2;
				sides += 2;
				area *= len;
				if (sides == 4)
					break outer;
			}
		}
		if (sides != 4)
			return 0;
		return area;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 46020
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
typedef long long int ll;

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

int main(){
    int N,T;
    cin >> N >> T ;
    ll sum = T,tmp1,tmp2;
    REP(i,N){
        if(i == 0){
            cin >> tmp1;
            continue;
        }
        cin >> tmp2;
        if(tmp2 - tmp1 > T) sum += T;
        else sum += (tmp2 - tmp1);
        tmp1 = tmp2;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

const string MINUSINF = "-";


void chmax(string &a,string b) {
	if (a == MINUSINF) a = b;
	else if (a.size() < b.size())a = b;
	else if (a.size() == b.size()) {
		if (a < b)a = b;
	}
}

ll match[9] = { 2,5,5,4,5,6,3,7,6 };
string dp[10101];



int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	rep(i, 0, M)cin >> A[i];


	rep(i, 0, 10101) {
		dp[i] = MINUSINF;
	}
	dp[0] = "";

	rep(i, 0, N + 1) {
		if (dp[i] == MINUSINF)continue;
		for (auto a : A)chmax(dp[i+match[a-1]],dp[i]+(char)('0'+a));
	}
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 43776
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	long long n, p, ans = 0, e = 0, o = 0;
	cin >> n >> p;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2 == 0){
			e++;
		}else{
			o++;
		}
	}
	if(o == 0 && p == 1){
		ans = 0;
	}else{
		ans = max((long long)pow(2, o - 1), 1LL) * pow(2, e);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
// const int INF=4e18+10;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    int n, m;
    cin>>n>>m;
    vector<int> x, y;
    for(int i=0;i<n;i++)
    {
        int b;
        cin>>b;
        x.pb(b);
    } 
    for(int i=0;i<m;i++)
    {
        int b;
        cin>>b;
        y.pb(b);
    } 

    sort(all(x));
    sort(all(y));

    int ans=0;
    //precomputer the vector;
    int vec=0;
    for(int i=1;i<n;i++)
    {
        vec += i*(n-i)%mod * (x[i]-x[i-1]);
        vec%=mod;
    }
    for(int i=1;i<m;i++)
    {
        ans += i*(m-i)%mod *vec%mod * (y[i]-y[i-1]); 
        ans%=mod;

    }
    cout<<ans<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 2548
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main() {
  int P, Q, R;
  std::cin >> P >> Q >> R;
  std::cout << std::min(P + Q, std::min(P + R, Q + R)) << std::endl;
  return 0;
}



Measured memory_bytes: 256