akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<stdio.h>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
int n;
int arr[100005];
struct Node {
	int sum;
	int lowerLimit;
	int upperLimit;
	struct Node* left;
	struct Node* right;
};
Node* makeSegmentTree(int lower, int upper) {


	Node* node = (Node*)malloc(sizeof(Node));
	node->lowerLimit = lower;
	node->upperLimit = upper;

	if (lower == upper) {
		node->left = NULL;
		node->right = NULL;
		node->sum = arr[lower];
		return node;
	}

	int middle = (lower + upper) / 2;
	node->left = makeSegmentTree(lower, middle);
	node->right = makeSegmentTree(middle + 1, upper);
	node->sum = node->left->sum + node->right->sum;

	return node;
}
int findSum(Node* node, int lower, int upper) {
	if (lower <= node->lowerLimit && upper >= node->upperLimit) {
		//printf("[%d,%d]:%d", node->lowerLimit, node->upperLimit,node->min);
		return node->sum;
	}
	int middle = (node->lowerLimit + node->upperLimit) / 2;
	int minLeft = 0;
	int minRight = 0;

	//rintf("middle:%d\n", middle);

	if (lower <= middle) {
		minLeft = findSum(node->left, lower, upper);
	}
	if (upper >= (middle + 1)) {
		minRight = findSum(node->right, lower, upper);
	}
	return minLeft + minRight;
}
void update(Node* node, int position, int value) {
	if (node->lowerLimit == node->upperLimit) {
		node->sum += value;

		return;
	}
	int middle = (node->upperLimit + node->lowerLimit) / 2;
	if (position <= middle) {
		update(node->left, position, value);
	}
	else {
		update(node->right, position, value);
	}
	int leftMin = node->left->sum;
	int rightMin = node->right->sum;
	node->sum = leftMin + rightMin;
}
void preorder(Node* node) {
	if (node == NULL) {
		return;
	}
	printf("[%d,%d]:%d\n", node->lowerLimit, node->upperLimit, node->sum);
	preorder(node->left);
	preorder(node->right);
}
void inorder(Node* node) {
	if (node == NULL) {
		return;
	}
	inorder(node->left);
	printf("[%d,%d]:%d\n", node->lowerLimit, node->upperLimit, node->sum);
	inorder(node->right);
}
int main() {
	int q, op, l, r;
	//freopen("D:\\in.txt", "r", stdin);
	scanf("%d %d", &n, &q);

	for (int i = 1; i <=n; i++) {
		arr[i] = 0;
	}

	Node* root;
	root = makeSegmentTree(1, n);

	while (q--) {
		scanf("%d %d %d", &op, &l, &r);
		if (op == 0) {
			arr[l] = r;
			update(root, l, r);
		}
		else if (op == 1) {
			int minQuery = findSum(root, l, r);
			printf("%d\n", minQuery);
		}
		else if (op == 2) {
			preorder(root);
			printf("\n");
		}
		else if (op == 3) {
			inorder(root);
			printf("\n");
		}
	}
}


Measured memory_bytes: 12948
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

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

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
constexpr int max_n = 100'000 + 5;

int n,m;
vector<int> hs(max_n);
vector<vector<int>> adjs(max_n);
int res;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n>>m;
    rep(i,n) { cin>>hs[i]; }
    rep(j,m) {
        int a,b; cin>>a>>b; a--; b--;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    rep(i,n) {
        for (auto v : adjs[i]) {
            if (hs[i] <= hs[v]) { res++; break; }
        }
    }
    cout << n - res << '\n';

    return 0;
}


Measured memory_bytes: 8724
####処理を記述する箇所#####
import numpy as np

n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
c = [a[i].pop(0) for i in range(n)]
ans = []
for s in range(1<<n):
    cost = 0
    mi = np.array([0]*m)
    for i in range(n):
        if (s>>i)&1:
            cost += c[i]
            mi += np.array(a[i])

    if np.all(mi >= x):
        ans.append(cost)
if ans:
    print(min(ans))
else:
    print('-1')

   

Measured memory_bytes: 27244
#include <stdio.h>

int main(void) {

	int n,i,j;
	char symbol;
	int number;
	int snum;
	int all[52];
	int cards[52];

	for (i = 0; i < 52; i++) {

		all[i] = 1; 
	}

	scanf("%d", &n);

	for (j = 0; j < n; j++) {

		scanf("\n%c %d", &symbol, &number);

		switch (symbol) {
		
		case 'S':
			snum = 0;
			break;
		case 'H':
			snum = 1;
			break;
		case 'C':
			snum = 2;
			break;
		case 'D':
			snum = 3;
			break;

		}

		cards[j] = snum * 13 + number - 1;
	
	}

	for (j = 0; j < n; j++) {
		int card_index = cards[j];
	
			all[card_index] = 0;
		
	}

	for (i = 0; i < 52; i++) {
		if (all[i] == 1) {
			number = (i + 1) % 13;
			if (number == 0) {
				number = 13;
			}
			snum = (i - number + 1) / 13;

			switch(snum){
			case 0:
				symbol = 'S';
				break;
			case 1:
				symbol = 'H';
				break;
			case 2:
				symbol = 'C';
				break;
			case 3:
				symbol = 'D';
				break;
			}
			
			printf("%c %d\n", symbol, number);

		}
	}

	

	return(0);

}


Measured memory_bytes: 2044
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.siz=[1]*n
        
    def root(self,x):
        while self.par[x]!=x:
            self.par[x]=self.par[self.par[x]]
            x=self.par[x]
        return x
    
    def unite(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.siz[x]<self.siz[y]:
            x,y=y,x
        self.siz[x]+=self.siz[y]
        self.par[y]=x
        return True
    
    def is_same(self,x,y):
        return self.root(x)==self.root(y)
    
    def size(self,x):
        return self.siz[self.root(x)]
    
u=UnionFind(N)

for _ in range(M):
    a,b=map(int1,input().split())
    u.unite(a,b)

roots=set()

for i in range(N):
    roots.add(u.root(i))

ans=0

for v in roots:
    ans=max(ans,u.size(v))
    
print(ans)

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while (cin >> n) {
        map<string,int>mp;
        int mx = 0;
        for (int i = 0 ; i < n ; i++) {
            string x;
            cin >> x;
            mp[x]++;
            mx = max(mx ,mp[x]);
        }
        for (auto i:mp) {
            if (i.S == mx) {
                cout << i.F << '\n';
            }
        }
    }
}

Measured memory_bytes: 23808
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {

        var nmc = Input.ar;
        var bs = Input.ar;
        var ct = 0;
        for (var i = 0; i < nmc[0]; i++)
        {
            var ar = Input.ar;
            var pro = nmc[2];
            for(var j = 0; j < nmc[1]; j++)
            {
                pro += ar[j] * bs[j];
            }
            if (pro > 0) ct++;
        }
        WriteLine(ct);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13140
n=gets.chomp.to_i
dp=Array.new(10000+1){false}
dp[0]=true
n.times do
  v=gets.chomp.to_i
  10000.downto 0 do |i|
    if dp[i] and i+v<=dp.size
      dp[i+v]|=dp[i]
    end
  end
end
10000.downto 0 do |i|
  if i%10>0 and dp[i]
    puts i
    exit 0
  end  
end
puts 0

Measured memory_bytes: 3836
#include <stdio.h>

int main( void ){
    int N, i, j, k, v;
    int A[100];

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    for(k = 0; k < N; k++){
        printf("%d", A[k]);
        if(k < N - 1){
            printf(" ");
        }
    }
    printf("\n");
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        for(k = 0; k < N; k++){
            printf("%d", A[k]);
            if(k < N - 1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2036
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  var i = 0
  var judge = true
  var before = Array.fill[Int](3)(0)
  while (judge && i < n) {
    val ts = StdIn.readLine().split(' ').map(_.toInt)
    val ti = ts(0) - before(0)
    val di = scala.math.abs(before(1) - ts(1)) + scala.math.abs(before(2) - ts(2))
    judge = ti >= di && ti % 2 == di % 2
    before = ts
    i += 1
  }

  println(if (judge) "Yes" else "No")
}


Measured memory_bytes: 47368
let f(a,b)=(b,a)and s=ref(Scanf.scanf"%d %d %d %d %d %d
"(fun a b c d e f->[(a,f);(b,e);(c,d)]));;Bytes.iter(fun c->s:=match!s with[x;y;z]->(match c with|'N'->[y;f x;z]|'S'->[f y;x;z]|'E'->[f z;y;x]|'W'->[z;y;f x]|_->[])|_->[])(Scanf.scanf"%s"(fun l->l));Printf.printf"%d
"(fst(List.nth!s 0))

Measured memory_bytes: 2448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int A = int.Parse(s.Split(' ')[0]);
            int B = int.Parse(s.Split(' ')[1]);
            int C = int.Parse(s.Split(' ')[2]);

            List<int> ans = new List<int>();

            ans.Add(10 * A + B + C);
            ans.Add(A + 10 * B + C);
            ans.Add(A + B + 10 * C);

            Console.WriteLine(ans.Max());
        }
    }
}


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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans;
	if (k <= a) {
		ans = k;
	} else if (k <= a + b) {
		ans = a;
	} else {
		ans = a - (k - a - b);
	}
	cout << ans;

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll p(n);
  rep(i, n) {
    cin >> p[i];
  }
  ll ans = 0;
  auto max_itr = max_element(all(p));
  FORm(it, p) {
    if (it == max_itr) {
      ans += *it / 2;
    } else {
      ans += *it;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 18/07/2020
 * 14:45:55.34
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    long long a, b;
    cin >> a >> b;
    long long lcm = a * b / __gcd(a, b);
    cout << lcm << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
#define rep(i, a, b) for (long long(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

using ll = long long;
using P = std::pair<ll, ll>;
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

  struct Line{
    long double l,r,v;

    long double val(long double x){
      if(x<=l)return v+l-x;
      else if(l<x&&x<=r) return v;
      else return v+x-r;
    }
  };

  ll n;
  std::cin>>n;

  long double sum=0;

  std::vector<Line> lines(n+2);
  rep(i,0,n){
    long double t;
    std::cin>>t;
    lines[i].l=sum;
    lines[i].r=sum+t;
    sum+=t;
  }

  rep(i,0,n){
    long double v;
    std::cin>>v;
    lines[i].v=v;
  }

  lines[n].l=0;lines[n].r=0;lines[n].v=0;
  lines[n+1].l=sum;lines[n+1].r=sum;lines[n+1].v=0;

  long double ans=0;

  long double prv=100.0l;

  rep(i,0,n+2){
    chmin(prv,lines[i].val(0));
  }

  for(long double i=0.5l;i<=sum;i+=0.5l){
    long double temp=100.0l;
    rep(j,0,n+2)chmin(temp,lines[j].val(i));
    ans+=(prv+temp)*0.25l;
    prv=temp;
  }

  std::cout<<std::setprecision(10)<<std::fixed<<ans<<"\n";

  return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string s;
    cin >> s;
    int ans = 1;
    if(s[0] == s.back()) ans = 0;
    if((s.size() % 2) != ans) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  sort(S.begin(), S.end());
  
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  
  if (S < T) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

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

"""
とりあえず，数字ではなく，数字の出現回数C[i]を持つ．

Kが変化すると色々と変わるので，Kごとに見ようとすると割と大変そう，1つのkごとにO(N)すらかけられない，というか計算大変そう．
(カードがT種類あるとして，k>Tは全部0だったりする．Kの区間に対して一気に答えを出す方法はありそう．)

食べる回数をmとして，mごとに最大のKを求める．

m回食べるということは，各数字につき最大m回までしか食べられないということ
食べられる枚数の総数はΣ(min(m,C[i]))．このときの最大のKは，総数//m

C[i]を昇順に並べておけば二分探索で
min(m,C[i])=C[i]の範囲がわかり，累積和をとっておればこの区間の合計がO(1)で求まる
"""
def main():
    import bisect
    
    N=I()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(N):
        dd[A[i]]+=1
        
    L=[]
    for k,v in dd.items():
        L.append(v)
        
    L.sort()
    nl=len(L)
    S=[0]*(nl+1)
    for i in range(nl):
        S[i+1]=S[i]+L[i]
        
    ans=[0]*(N+1)
    
    for m in range(1,N+1):
        temp=0
        num=bisect.bisect_left(L,m)
        temp+=S[num]
        temp+=(nl-num)*m
        
        maxk=temp//m
        ans[maxk]=max(ans[maxk],m)
        # print(m,temp,maxk)
        
    # print(ans)
        
    M=0
    for i in range(N,-1,-1):
        M=max(M,ans[i])
        ans[i]=M
        
    for i in range(1,N+1):
        print(ans[i])
        
        
        
    
    

main()


Measured memory_bytes: 160348
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int ans=0;
  int n,x,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    if(i){
      if(c>x){
        ans+=(c-x);
      }
      else c=x;
    }
    else c=x;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    int n,k,sum=0;
    cin>>n>>k;
    vector<int> vec(n,0);
    for(auto v:vec){
        cin>>v;
        sum+=(k/2>=v?2*v:2*(k-v));
    }
    cout<<sum;
    
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

typedef long long ll;
int main() {
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> la(n);
  for (ll &a: la) cin >> a;
  sort(la.begin(), la.end(), greater<ll>());

  ll l = 1, r = n+1;
  while (r-l > 1) {
    ll c = (l+r)/2;
    // cerr << l << " " <<  c << " " << r << endl;
    auto check = [&]() {
      if (c < p) return true;
      // cerr << "i1" << endl;
      // cerr << "i2" << endl;
      ll rev = n-(c-p);
      ll score = la[c-1]+m;
      ll cnt = 0;
      for (ll i = p-1; i < c-1; ++i) { 
        // cerr << i << " " << la[i] << endl;
        if (la[i] > score) return false;
        cnt += score-la[i];
      }
      // cerr << c << " " << score << " " << rev << " " << cnt << " " << m*(v-rev) << " " << endl;
      return cnt >= m*(v-rev);
    };
    if(check()) l = c;
    else r = c;
  }
  cout << l << endl;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n+2];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   int dp[n][2];
   dp[0][0]=0;
   dp[0][1]=0;
   dp[1][0]=abs(a[1]-a[0]);
   dp[1][1]=100000000;
   for(int i=2;i<n;i++)
   {
       dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(a[i]-a[i-1]);
       dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(a[i]-a[i-2]);

   }
   cout<<min(dp[n-1][0],dp[n-1][1]);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
 
  string data;
  cin >> data;
  
  for(int i=0;i<(int)data.size();i++){
	if(data.substr(i, 1)=="?"){
		data.replace(i, 1, "D");
    }
  }
 
  cout << data << endl;
  return 0;
}

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

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const long long INF = 1LL<<60;

int N, M;
vector<long long> a, b;
vector<int> c;


long long dp[1100][5000];

int main() {
    while (cin >> N >> M) {
        a.resize(M); b.resize(M);
        c.assign(M, 0);
        for (int i = 0; i < M; ++i) {
            cin >> a[i] >> b[i];
            for (int j = 0; j < b[i]; ++j){
                int t; cin >> t; --t;
                c[i] += (1<<t);
            }
        }

        for (int i = 0; i < 1100; ++i) for (int j = 0; j < 5000; ++j)
                                           dp[i][j] = INF;
        dp[0][0] = 0;
        for (int i = 0; i < M; ++i) {
            for (int j = 0; j < (1<<N); ++j) {
                chmin(dp[i+1][j], dp[i][j]);

                int nj = j | c[i];
                chmin(dp[i+1][nj], dp[i][j] + a[i]);
            }
        }

        cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;
    }                
}


Measured memory_bytes: 43264
n = int(input())
arr = [int(a) for a in input().split()]

summ = sum(arr)
ans = 0
for i in range(n-1):
    a = arr[i]
    summ -= arr[i]
    b = summ
    ans += (a*b)%(int(1e9+7))

print(ans%(int(1e9+7)))

Measured memory_bytes: 31760
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    cout << *min_element(a.begin(), a.end()) << ' '
        << *max_element(a.begin(), a.end()) << ' '
        << accumulate(a.begin(), a.end(), 0LL) << endl;
    return 0;
}



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

int main(){
	
	int a,b,c,d,e;

	cin >> a >> b >> c >> d >> e;

	int x;

	if(a > 0){
		x = e*(b-a);
	}
	if(a == 0){
		x = e*b + d;
	}
	if(a < 0){
		x = -c*a + e*b + d;
	}

	cout << x << endl;


	return 0;
}



Measured memory_bytes: 3100
n, m = [int(i) for i in input().split()]
drink = [[int(i) for i in input().split()] for _ in range(n)]

drink.sort()
i = price = 0
remaining = m
while remaining > 0:
    a, b = drink[i]
    if remaining >= b:
        price += a * b
    else:
        price += a * remaining
    remaining -= b
    i += 1

print(price)


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

signed main() {
  string s; cin >> s;
  for(int i = (s.size()-2)/2; i >= 0; i --) {
    if(s.substr(0, i) == s.substr(i, i)) {
      cout << i*2 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	var s string
	fmt.Fscan(read, &s)

	if n%2 != 0 {
		fmt.Fprintln(write, "No")
	} else {
		if s[:n/2] == s[n/2:] {
			fmt.Fprintln(write, "Yes")
		} else {
			fmt.Fprintln(write, "No")
		}
	}

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(auto &i:a) cin >> i;
  int ans = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans+=a[i]*a[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
class Qsort
{
    public void Sort(int[] data, int start, int end)
    {
        if (end - start <= 1)  //要素数が1個以下。end=data.Lengthよりdata[end-1]が最後の要素であることに注意する。
        {
            return;
        }

        int p = data[start];                   //データの1番目をピボットする
        int i = start - 1;
        int j = end;

        while (true)
        {
            //データのstart(1番目、左端)から一つずつ調べて、p以上ならbreakしてiの値を保存。次に調べるのはi+1番目から
            for (i = i + 1; i < data.Length; i++)
            {
                if (p <= data[i])
                    break;
            }
            //データのend-1(最後、右端)から一つずつ調べて、p以下ならbreakしてjの値を保存。次に調べるのはj-1番目から
            for (j = j - 1; j > 0; j--)
            {
                if (p >= data[j])
                    break;
            }

            if (j < i)　　　　　//iとjの値が逆転したなら、whileから抜け出す。
                break;
            else        //そうでないなら、i番目とj番目を交代
            {
                int tmp = data[i];
                data[i] = data[j];
                data[j] = tmp;
            }
        }
        //i-1番目とi番目の間を境界にして分けて再帰。data[end-1]がデータの最後であるので前半(start～i-1)、後半(i～end-1)
        Sort(data, start, i);
        Sort(data, i, end);
    }
}

class a
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(str[i]);
        }
        
        Qsort qsort = new Qsort();
        qsort.Sort(d, 0, d.Length);
        
        Console.WriteLine(d[n/2]-d[n/2-1]);
    }
}

Measured memory_bytes: 16864
#include<stdio.h>

long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}

int main(void){
	long long int q,i,o,t,j,l,s,z,r1=0,r2=0;
	scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
	r1+=(o+(i/2)*2+(j/2)*2+(l/2)*2);
	if(i%2==1 && j%2==1 && l%2==1){r1+=3;}
	if(i!=0 && j!=0 && l!=0){i--;j--;l--;r2+=3;}
	r2+=(o+(i/2)*2+(j/2)*2+(l/2)*2);
	printf("%lld\n",llmax(r1,r2));
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	int r;
	scanf("%d", &r);
	printf("%d", 3 * r*r);
}


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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve()
{
    ll n,r;
    cin>>n>>r;
    if(n >= 10) cout<<r<<endl;
    else cout<<(r +100*(10 - n))<<endl;
}


int main()
{
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

const int _INT_MAX_ = 0x3fffffff;

const int MOD = int(1e9) + 7;

int fpow(int base, int exp) {
	int result = 1;
	for (; exp; exp >>= 1) {
		if (exp & 1)
			result = (long long)result * base % MOD;
		base = (long long)base * base % MOD;
	}
	return result;
}

int n, h[110];

pair<int, int> solve(int l, int r, int limit) {
	int min_height = _INT_MAX_;
	for (int i = l; i < r; ++i) {
		min_height = min(min_height, h[i]);
	}
	
	pair<int, int> result = {2, 1};
	int tot = -1;
	for (int i = l; i <= r; ++i) {
		if (i == r || min_height == h[i]) {
			++tot;
			if (i > l) {
				pair<int, int> tmp = solve(l, i, min_height);
				result.first = (long long)result.first * tmp.first % MOD;
				result.second =
					(long long)result.second * (tmp.first + tmp.second) % MOD;
			}
			l = i + 1;
		}
	}
	
	result.second = (long long)result.second * fpow(2, tot) % MOD;
	result.second = (result.second - result.first + MOD) % MOD;
	result.first = (long long)result.first * fpow(2, min_height - limit - 1) % MOD;
	result.second = (result.first + result.second) % MOD;
	return result;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &h[i]);
	}
	pair<int, int> ans = solve(0, n, 0);
	printf("%d\n", ans.second);
}

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

int main() {
    int h, y;

    cin >> h >> y;

    while (h != 0 || y != 0) {
        for (int i = 0; i < h; i++) {
            for (int s = 0; s < y; s++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> y;
    }

    return 0;
}

Measured memory_bytes: 3072
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(Fibonacci(n));
    }

    const int MaxN = 44;
    static int[] F = new int[MaxN + 1];
    static int Fibonacci(int i)
    {
        if(F[i] != 0) return F[i];
        else if(i == 0 || i == 1) return F[i] = 1;
        else return F[i] = Fibonacci(i - 1) + Fibonacci(i - 2);
    }
}

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

int main()
{
  std::string str;
  std::cin >> str;
  int cnt = 0;
  int max_cnt = 0;
  for (int i=0; i<str.length(); i++) {
    if (str[i] != 'A' && str[i] != 'C' && str[i] != 'G' && str[i] != 'T') cnt = 0;
    else { cnt++; max_cnt = std::max(max_cnt, cnt); }
  }
  std::cout << max_cnt << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int main(){
    int n;
    ll h;
    cin >> n >> h;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    int cnt = 0;
    ll damage = 0;
    rep(i, 0, n){
        if(a[0] > b[i])break;
        damage += b[i];
        cnt++;
        if(damage >= h)break;
    }
    if(damage >= h){
        cout << cnt << endl;
    }
    else if((h-damage)%a[0] == 0)cout << cnt + (h-damage)/a[0] << endl;
    else{
            cout << cnt + ((h-damage)/a[0]) +1 << endl;
        }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"0\n"; return 0;}
#define yup {cout<<"YES\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}

int main() {

	get(n);
	ll ans = 1000*(n/500);
	n = n%500;
	ans += 5*(n/5);
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);
    REP(i, n) { cin >> as[i]; }
    for (int i = k; i < n; i++) {
        if (as[i - k] < as[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a - b + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//snippet
#define N 100009

int main() {
	int n, ac = 0, wa = 0, tle = 0, re = 0;
	char s[5];
	scanf("%d", &n);
	rep(i, n) {
		scanf("%s", s);
		if (s[0]=='A')ac++;
		else if (s[0]=='W')wa++;
		else if (s[0]=='T')tle++;
		else if (s[0]=='R')re++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac, wa, tle, re);

	return 0;
}

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


using namespace std;

/* macros */
#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

/*typedefs*/
typedef long long ll;

/*functions*/
bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str) {
    int num;
    istringstream iss(str); //put string in input stream
    iss>>num; return num; //read from stream as integer
}

template <class T> string toStr(T par) {
    ostringstream oss;  //output stream string
    oss<<par;    //write par to the stream
    return oss.str(); //return string of output
}

const int MAXN = 100;
int arr[MAXN] = {0};

int main() {
    IOS();

    //summation of (Xi - Ans)^2 = min
    //take dervative
    //2*Summation(Xi-Ans) = 0
    //Summation(Xi-Ans) = 0
    //Summation(Xi) = Ans*N
    //this is the mean
    int n;
    double sm = 0;
    cin>>n;
    REP(i,n)
    {
        cin>>arr[i];
        sm+=arr[i];

    }
    int st = round(sm/n);
    int ans = 0;
    REP(i,n)
    {
        ans+= (arr[i]-st)*(arr[i]-st);
    }
    cout<<ans<<endl;
    return 0;
}


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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl '\n'

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

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

int a[100005];
signed main()
{
  int n = in();
  bool f = false;
  for (int i = 0; i < n; i++) a[i] = in();

  int i = 0, cnt = 0;
  while (!f) {
    if (i == 1) {
      f = true;
      break;
    }
    if (a[i] == -1) break;

    int t = i;
    i = a[i] - 1;
    a[t] = -1;
    cnt++;
  }

  if (f) print(cnt);
  else print(-1);

  return (0);
}

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

int main() {
	int n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<bool> s;
	while (n) {
		s.insert(s.begin(), n % 2);
		if (n < 0)
			n = (n - 1) / -2;
		else
			n /= -2;
	}
	for (int i = 0; i < (int) s.size(); i++) {
		cout << s[i];
	}
	cout << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
  {
    cout << s;
  }
  else
  {
    cout << s.substr(0, k) << "...";
  }

  // cout << ans << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int h, w;
    cin >> h >> w;
    char c;
    string a[110];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++){
            cin >> c;
            a[i] += c;
        }
    }
    
    for(int i = 0; i < h; i++){
        a[i].append("#");
        a[i].insert(0, "#");
    }
    for(int i = 0; i <= w+1; i++) cout << "#";
    cout << endl;
    for(int i = 0; i < h; i++) {
        cout << a[i] << endl;
    }
    for(int i = 0; i <= w+1; i++) cout << "#";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632