akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#define f(a,b) ((double)(a+b)/2)
using namespace std;
int n,a[50];
long double ans;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	if(n==1){cout<<a[0];return 0;}
	sort(a,a+n);
	ans=f(a[0],a[1]);
	for(int i=2;i<n;i++)ans=f(ans,a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n;
  cin >> n;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int tmp=1,ans=0;
    FOR(i,1,n){
        if(a[i-1] != a[i]){
            if(tmp > a[i-1]){
                ans += tmp-a[i-1];
            }
            if(tmp < a[i-1]){
                ans += tmp;
            }
            tmp=1;
        }
        else{
            tmp+=1;
        }
    }
    if(tmp > a[n-1]){
        ans += tmp-a[n-1];
    }
    if(tmp < a[n-1]){
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()) {
        ans += (s[i] - '0');
    }
    cout << (ans % 9 == 0 ? "Yes": "No") << "\n";
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>

#define MAX_SIZE (110)
int P[MAX_SIZE];
int M[MAX_SIZE][MAX_SIZE];

int main()
{
  int N;
  std::cin >> N;
  for (int i = 1; i <= N; ++i)
  {
    std::cin >> P[i - 1] >> P[i];
  }

  for (int i = 0; i <= N; ++i) M[i][i] = 0;
  for (int n = 2; n <= N; ++n)
  {
    for (int i = 1; i <= N - n + 1; ++i)
    {
      int j = i + n - 1;
      M[i][j] = 1 << 30;
      for (int k = i; k < j; ++k)
      {
        M[i][j] = std::min(M[i][j], M[i][k] + M[k + 1][j] + P[i - 1] * P[k] * P[j]);
      }
    }
  }

  std::cout << M[1][N] << std::endl;

  return 0;
}



Measured memory_bytes: 3156
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int32;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    public void Solve()
    {
        N n = rn;
        var x = new List<N>();
        for(int i = 0; i < n; i++) { x.Add(rn); }
        N t = 0;
        N m = 1000000;
        for(int p = 0; p <= 100; p++)
        {
            t = 0;
            for(int i = 0; i < n; i++)
            {
                t += (x[i] - p) * (x[i] - p);
            }
            if (t < m) m = t;
        }
        Write(m);
    }


    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


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

int main(){
	int h,w;
	cin>>h>>w;
	
	REP(i,h){
		string c;
		cin>>c;
		
		cout<<c<<endl;
		cout<<c<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[m];
        long[] y = new long[m];
        Map<Long, Integer> map = new TreeMap<>();
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
            y[i] = sc.nextLong();
            map.put(y[i], i);
        }

        String[] ans = new String[m];
        int[] cnt = new int[n];
        Iterator<Long> it = map.keySet().iterator();
        while (it.hasNext()) {
            int i = map.get(it.next());
            cnt[p[i] - 1]++;
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("%06d", p[i]));
            sb.append(String.format("%06d", cnt[p[i] - 1]));
            ans[i] = sb.toString();
        }
        for (int i = 0; i < m; i++) {
            System.out.println(ans[i]);
        }
    }

}


Measured memory_bytes: 174008
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b,c=get_i.sort
da=c-a
db=c-b
if (da+db).even?
    puts (da+db)/2
else
    if da.odd?
        db+=1
    else
        da+=1
    end
    puts (da+db)/2+1
end

Measured memory_bytes: 1788
s=[input() for _ in range(3)]
j=0
while(len(s[0]) or len(s[1]) or len(s[2])):
    if s[j][0]=='a':
        t=0
    elif s[j][0]=='b':
        t=1
    elif s[j][0]=='c':
        t=2
    s[j]=s[j][1::]
    j=t
    if j==0 and len(s[0])==0:
        print('A')
        break
    elif j==1 and len(s[1])==0:
        print('B')
        break
    elif j==2 and len(s[2])==0:
        print('C')
        break

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  struct node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  

  /* 

   your code 


  */
  x->key = key;
  //番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32988
#include <stdio.h>
#include <stdlib.h>
    
struct node{
    
int id;
struct node* parentNode;
struct node* leftChild;
struct node* rightChild;
    
};
    
struct node *createNode(int);
void insert(struct node*);
void printNodes(void);
void preOrder(struct node *);
void inOrder(struct node *);
    
struct node* nodes[500001];
struct node* root;
   
int num_nodes=0, n;
   
main(){
    
int i, id;
char command[7];
 struct node* tmpNode;
    
scanf("%d",&n);
    
for(i=0; i<n; i++){
    
scanf("%s",command);
if(command[0]=='i'){
scanf("%d",&id);
insert(createNode(id));
}else if(command[0]=='p'){
printNodes();
}
    
}/* END OF LOOP */
   
 return 0;
    
}
   
struct node *createNode(int id){
  struct node *newNode;
   
  newNode=(struct node*)malloc(sizeof(struct node));
  newNode->id=id;
  newNode->parentNode=NULL;
  newNode->rightChild=NULL;
  newNode->leftChild=NULL;
     
  nodes[num_nodes++]=newNode;
  return newNode;
}
  
void insert(struct node* z){
    
  struct node* y = NULL;
  struct node* x = root;
   
  while(x != NULL){
    y = x;
    if(z->id < x->id){
      x = x->leftChild;
    }else{
      x = x->rightChild;
    }
  }
  z->parentNode = y;
  if(y == NULL){
    root = z;
  }else{
    if(z->id < y->id){
      y->leftChild = z;
    }else{
      y->rightChild = z;
    }
  }
    
}
    
void printNodes(void){
      
  inOrder(root);
  printf("\n");
  preOrder(root);
  printf("\n");
   
}
    
void preOrder(struct node* nd){
  printf(" %d",nd->id);
  if(nd->leftChild){
    preOrder(nd->leftChild);
  }
  if(nd->rightChild){
    preOrder(nd->rightChild);
  }
    
}
    
void inOrder(struct node* nd){
  if(nd->leftChild){
    inOrder(nd->leftChild);
  }
  printf(" %d",nd->id);
  if(nd->rightChild){
    inOrder(nd->rightChild);
  }
    
}

Measured memory_bytes: 13000
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() throws IOException{

		String[] s = br.readLine().split(" ");
		int max = 0;
		String ans1 = "", ans2 = "";
		HashMap<String,Integer> map = new HashMap<String,Integer>();

		for (int i=0; i<s.length; i++) {

			if (map.containsKey(s[i])) {
				int c = map.get(s[i])+1;
				if (max < c) {
					ans1 = s[i];
					max = c;
				}
				map.put(s[i],c);
			} else {
				if (max < 1) {
					ans1 = s[i];
					max = 1;
				}
				map.put(s[i],1);
			}

			if (ans2.length() < s[i].length()) ans2 = s[i];
		}

		out.println(ans1 + " " + ans2);
	}

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		br.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 24436
#include <stdio.h>

int main()
{
	int a , b, c;
	int d = 0;
	scanf("%d" "%d" "%d", &a, &b, &c);
	
	if ((a - b) != 0)
		d += 1;
	if ((a - c) != 0)
		d += 1;
	if ((b - c) != 0)
		d += 1;
	if (d == 2)
		printf("Yes");
	else
		printf("No");
	
	
	
		
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt)

    var flg: Boolean? = null
    var count = 0
    for (i in 0 until an.lastIndex) {
        when {
            flg == null -> {
                when {
                    an[i] < an[i + 1] -> {
                        flg = true
                    }
                    an[i] > an[i + 1] -> {
                        flg = false
                    }
                    else -> {
                        flg = null
                    }
                }
            }
            flg && an[i] <= an[i + 1] -> {
            }
            flg && an[i] > an[i + 1] -> {
                count++
                flg = null
            }
            !flg && an[i] >= an[i + 1] -> {
            }
            !flg && an[i] < an[i + 1] -> {
                count++
                flg = null
            }
        }
    }
    println(count + 1)
}



Measured memory_bytes: 52284
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

template <typename T>
void print_array(const vector<T>& a) {
    for (int i = 0; i < a.size(); ++i) {
        if (0 < i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

template <typename T>
int selection_sort(vector<T>& a) {
    int swap_count = 0;
    for (int i = 0; i < a.size() - 1; ++i) {
        auto min_j = i;
        for (int j = i; j < a.size(); ++j) {
            if (a[j] < a[min_j]) min_j = j;
        }

        swap(a[i], a[min_j]);
        if (i != min_j) swap_count++;
    }
    return swap_count;
}

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(6
5 6 4 2 1 3
)");
#endif
    int n;
    in >> n;
    vector<int> a;
    for (int i = 0; i < n; ++i) {
        int temp;
        in >> temp;
        a.push_back(temp);
    }

    auto swap_count = selection_sort(a);
    print_array(a);
    cout << swap_count << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(S=="Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 3568
#include<iostream>
#include<stdio.h>
using namespace std;
int jikan(int s,int f){
	return f-s;
	}
int main(){
	int t,n,s[10],f[10],gokei;
	while(cin>>t){
	if(t==0) break;
	gokei=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i]>>f[i];
		gokei+=jikan(s[i],f[i]);
		}
		if(gokei>=t){
			cout<<"OK"<<endl;
			}
			else cout<<t-gokei<<endl;
			}
	return 0;
}

Measured memory_bytes: 1160
import math
N = int(input())
ans = 0
s=0
for i in range(1,N+1):
    ans += i

for k in range(1,N+1):
    for i in range(k+1,N+1):
        ans += (math.gcd(k,i)*6)

if(N>2):
    for i in range(1,N+1):
        for k in range(i+1,N+1):
            for j in range(k+1,N+1):
                s=math.gcd(k,i)
                ans += (math.gcd(s,j)*6)
print(ans)

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

int main() {
    int N, M, mx = 0; cin >> N;
    map<string, int> val;
    vector<string> key;
    for (int i = 0; i < N; i++) {
        string x; cin >> x;
        if (val.count(x)) {
            val[x]++;
        } else {
            val[x] = 1;
            key.push_back(x);
        }
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        string x; cin >> x;
        if (val.count(x)) {
            val[x]--;
        } else {
            val[x] = -1;
            key.push_back(x);
        }
    }
    for (int i = 0; i < val.size(); i++) {
        mx = max(mx, val.at(key.at(i)));
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<stack>
#include<queue>
int main()
{
int s;
long long ans[2001];
scanf("%d",&s);
for(int i=0;i<2001;i++)
{
ans[i]=0;
}

for(int i=0;i<2001;i++)
{
	for(int j=0;j<=i-3;j++)
	{
		ans[i]=ans[i]+ans[j];
		ans[i]=ans[i]%1000000007;
	}
	if(i>=3){ans[i]++; ans[i]=ans[i]%1000000007;}
}
printf("%lld",ans[s]);
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++) {
    if (N % 2 == 0) {
      if (i % 2 == 0) {
        int j = i / 2 + 1;
        cout << j << ' ' << N + 1 - j << endl;
      } else {
        int c = N / 2 + 1;
        int d = (i + 1) / 2;
        cout << c - d << ' ' << c + d << endl;
      }
    } else {
      cout << i + 1 << ' ' << N - i << endl;
    }
  }
}
  


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m,k,ans=0,fl=0;
	string s;
	cin>>n;
	if(n>=30)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
long long dp[1000010][2];
//status unsolved
long long solve(string s){

    fill((long long*)dp,(long long*)dp+sizeof(dp)/sizeof(long long),INF);

    int L=s.size();
    //dp[i][k]:=i桁目において、状態kになるための最小枚数
    //i:=桁数　
    //k=0 繰り上下がりなし　
    //k=1 繰り下がりあり
    dp[0][0]=0;

    for(int i=0;i<L;i++){

        //繰り下がり
        for(int j=0;j<2;j++){
        int D=s[i]-'0';
        D+=j;
            for(int d=0;d<10;d++){
                int b=d-D;
                int nj=0;
                if(b<0){
                    nj=1;
                    b+=10;
                }
                //次の桁の繰り下がり状態nj
                //=min(現在の値,今の桁の状態j+お客が払うコイン+お店が払うコイン)
                dp[i+1][nj]=min(dp[i+1][nj],dp[i][j]+b+d);

            }
        }
    }

    return dp[L][0];
}
int main(){
    
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    s+='0';
    cout<<solve(s)<<endl;;

    
    return 0;

}
/*


*/


Measured memory_bytes: 17924
import math
import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()

print (math.pi * 2 * n)


Measured memory_bytes: 8968
n = int(input())
a = input()
b= input()
c= input()
de_lis = [0]*n

for i in range(n):
    if a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
        de_lis[i] = 2
    elif a[i]==b[i] and b[i]==c[i] and c[i]==a[i]:
        de_lis[i] = 0
    else:
        de_lis[i] = 1

print(sum(de_lis))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

// 頂点数n, 木g
int n;
vector<vector<int>> g;

// 入力の受け取り
void input() {
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int ai, bi; cin >> ai >> bi;
		g[--ai].push_back(--bi);
		g[bi].push_back(ai);
	}
	return;
}

// sから最も遠い頂点とその距離を求める
pair<int, int> farthest(int s, bool rst = true, int d = 0) {
	static vector<bool> visited;
	if (rst) visited = vector<bool>(n, false);
	visited[s] = true;
	pair<int, int> res = make_pair(s, d);
	for (int nx : g[s]) {
		if (!visited[nx]) {
			pair<int, int> tmp = farthest(nx, false, d + 1);
			if (res.second < tmp.second)
				res = tmp;
		}
	}
	return res;
}

// 木の直径を求める
int diameter() {
	return farthest(farthest(0).first).second;
}

// メイン関数
int main() {
	input();
	int d = diameter();
	if (d % 3 == 1) cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 29952
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_to,int arg_time){
		to = arg_to;
		time = arg_time;
	}
	int to,time;
};

struct Data{
	Data(int arg_node_id,int arg_current_time){
		node_id = arg_node_id;
		current_time = arg_current_time;
	}
	bool operator<(const struct Data &arg) const{
		return current_time > arg.current_time;
	}
	int node_id,current_time;
};

vector<Info> V[100000];
int min_time[100000];

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int from,to,time;
	for(int i = 0; i < M; i++){
		scanf("%d %d %d",&from,&to,&time);
		from--;
		to--;
		V[from].push_back(Info(to,time));
	}

	for(int i = 0; i < N; i++)min_time[i] = BIG_NUM;

	min_time[0] = 0;

	priority_queue<Data> Q;
	Q.push(Data(0,0));

	int ans = -1;

	while(!Q.empty()){

		if(Q.top().node_id == N-1){
			ans = max(ans,Q.top().current_time);
			Q.pop();
		}else if(Q.top().current_time > min_time[Q.top().node_id]){
			Q.pop();
		}else{

			for(int i = 0; i < V[Q.top().node_id].size(); i++){
				if(Q.top().current_time > V[Q.top().node_id][i].time)continue;

				if(min_time[V[Q.top().node_id][i].to] > V[Q.top().node_id][i].time){
					min_time[V[Q.top().node_id][i].to] = V[Q.top().node_id][i].time;
					Q.push(Data(V[Q.top().node_id][i].to,V[Q.top().node_id][i].time));
				}else if(V[Q.top().node_id][i].to == N-1){
					Q.push(Data(V[Q.top().node_id][i].to,V[Q.top().node_id][i].time));
				}
			}
			Q.pop();
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  vl in(3);
  rep(i, 3) cin >> in[i];

  stable_sort(in.begin(), in.end());

  ll ans = 0;

  if((in[1] - in[0]) % 2 == 1){
    in[0]++;
    in[2]++;
    ans++;
  }

  ans += (in[1] - in[0]) / 2;
  ans += in[2] - in[1];

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;
    int N = s.length();
    REP(i, N - 1){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }else if(i < N - 1 && s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" <<endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import math
def main():
    N = int(input())
    ans = []
    for i in range(1,int(math.sqrt(N)+1)):
        if (N % i)==0:
            ans.append((N//i)+i-2)
    print(min(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import Counter
N=int(input())
L=list(map(int,input().split()))
s=[(i+1)+L[i] for i in range(N)]
s=Counter(s)
d=[(i+1)-L[i] for i in range(N)]
d=Counter(d)
ans=0
for i in s:
  if i in d:
    ans+=s[i]*d[i]
print(ans)

Measured memory_bytes: 61564
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[5];
  scanf("%s", s);
  int ans=0;
  for (int i=0; i<3; i++) if (s[i] == '1') ans++;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(){
	int x, y;
	scanf("%i %i", &x, &y);
	if(y % 2 == 1 || x * 4 < y || x * 2 > y){
		puts("No");
		return 0;
	}else{
		for(int i = 0; i <= x; i++){
			if(y - i * 4 - 2 * (x - i) == 0){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("NO");
	return 0;
}


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

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

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int a,b,c; cin >> a >> b >> c;
    int r = a + b + c;
    if (r > 21) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize, // odds,
        a_vec: [usize; n],
    }

    let mut map: BTreeMap<usize, usize> = BTreeMap::new();
    
    for a in a_vec.into_iter() {
        *map.entry(a).or_insert(0) += 1;
    }

    let mut cnt = 0;

    for v in map.values() {
        cnt += v - 1
    }

    let ans = if cnt % 2 == 0 { map.len() } else { map.len() - 1 };

    println!("{}", ans);
}


Measured memory_bytes: 6884
i, o, t, j, l, s, z = map(int, input().split())
jil = i//2*2 + j//2*2 + l//2*2
if min(j, i, l) > 0:
    jil = max(jil, 3 + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2)
print(o + jil)

Measured memory_bytes: 3316
#include<stdio.h>

int n, A[20];

int solve (int i, int m) {
    if (m==0) return 1;
    if (i>=n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++){
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2604
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

T = [[0]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            T[i+1][j+1] = 9

for i in range(1,H+1):
    for j in range(1,W+1):
        if T[i][j] >= 9:
            T[i-1][j-1] += 1
            T[i-1][j+0] += 1
            T[i-1][j+1] += 1
            T[i+0][j-1] += 1
            T[i+0][j+0] += 1
            T[i+0][j+1] += 1
            T[i+1][j-1] += 1
            T[i+1][j+0] += 1
            T[i+1][j+1] += 1

for i in range(1,H+1):
    ans = ""
    for j in range(1,W+1):
        if T[i][j] >= 9:
            T[i][j] = "#"
        ans += str(T[i][j])
    print(ans)


Measured memory_bytes: 9224
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		long A = Long.parseLong(Ws[0]);
		long B = Long.parseLong(Ws[1]);
		long K = A+B;

		if(K%2 == 1){
			System.out.println("IMPOSSIBLE ");
		}else{
			System.out.println(K/2);
		}




	}

}


Measured memory_bytes: 23124
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()

count = 0
for i in range(len(S)):
    t = int(S[i])
    if i==0:
        b = int(t)
    else:
        if b==0 and t==0:
            count += 1
            b = 1
        elif b==1 and t==1:
            count += 1
            b = 0
        else:
            b = t
print(count)

Measured memory_bytes: 41324
use std::io;


/// https://beta.atcoder.jp/contests/abc080/tasks/abc080_b
fn main() {
    let n = read_one::<usize>();
    let mut ans = 0;
    let mut x = n;
    while x > 0 {
        ans += x % 10;
        x /= 10;
    }
    if n % ans == 0 { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
#define PI 3.14159265359
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  int count = 0;
  IN1(s);
  FOR(i,3){
    if (s[i] == s[i+1]) count++;
  }
  if (count >= 1){
    OUT("Bad");
  }
  else{
    OUT("Good");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
using namespace std;
int main(){
  long long a , b,ans;
  bool Ok=false;
  cin>>a>>b;
  for(int i=a;i>=2;i--){
    if(a%i==0){if(b%i==0){ans =i;Ok=true; break;}}
  }
  if(Ok==false) cout<<a*b<<endl;
  else cout<<(a/ans)*(b/ans)*ans<<endl;
}


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

using namespace std;

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;

    vector<int> path[N];

    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    int nc[N][2];
    fill(nc[0], nc[N], 0);
    // neighbor color
    // nc[v] = {vに隣接するAの数, vに隣接するBの数}

    vector<int> del;
    // nc[v][0] = 0かnc[v][1] = 0を満たす頂点集合

    for (int v = 0; v < N; ++v) {
        for (int sv : path[v]) {
            ++nc[v][S[sv] - 'A'];
        }
        if (nc[v][0] * nc[v][1] == 0) {
            del.push_back(v);
        }
    }

    bool remain[N];
    fill(remain, remain + N, true);
    // まだ取り除かれてない頂点集合

    while (!del.empty()) {
        int v = del.back();
        del.pop_back();
        if (!remain[v]) continue;

        remain[v] = false;

        for (int sv : path[v]) {
            --nc[sv][S[v] - 'A'];
            if (nc[sv][0] * nc[sv][1] == 0) {
                del.push_back(sv);
            }
        }
    }

    for (int v = 0; v < N; ++v) {
        if (remain[v]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 12416
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2112
n, d = gets.chomp.split.map(&:to_i)
x = []
n.times do |i|
  x[i] = gets.chomp.split.map(&:to_i)
end

count = 0
(0..(n-2)).each do |i|
  (i+1..(n-1)).each do |j|
    distdist = 0
    d.times do |k|
      distdist += (x[i][k] - x[j][k])**2
    end
    count += 1 if ((distdist**0.5).round)**2 == distdist
  end
end

puts(count)

Measured memory_bytes: 1916
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n; cin >> n;
    int f = 0;
    rep(i, n)
    {
        int a; cin >> a;
        if (a & 1 ^ 1)
        {
            if (a % 3 == 0 or a % 5 == 0) continue;
            else f = 1;

        }
    }
    if (f) cout << "DENIED" << endll;
    else cout << "APPROVED" << endll;

}

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

LL a;
void solve() {
    LL b = sqrt(a);

    for(LL i = b; i > 0; i--) {
        if(a % i == 0) {
            cout << ((a / i) + i - 2) << endl;
            break;
        }
    }

}

int main() {
    cin >> a;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  int S = 0, tmp = N;
  while (tmp != 0) {
    S += (tmp % 10);
    tmp /= 10;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

D,N = I()
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
else:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi v(n);
	int cnt = 0;
	rep(i, 0, n - 1) {
		cin >> v[i];
		while (v[i] % 2 == 0) {
			cnt++;
			v[i] /= 2;
		}
	}
	cout << cnt;
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif

	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<pii, vector<pii>, greater<pii> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
const ll inf = 1e18;


ll mul(ll a, ll b) {
	ll res = 0;
	while (b) {
		if (b % 2) res += a;
		b /= 2;
		if (a > inf) return -1;
		a *= 2;
		if (res > inf) return -1;
	}
	return res > inf ? -1 : res;
}
int n;
vl seq;
void input() {
	cin >> n;
	seq = vl(n);
	for (int i = 0; i < n; ++i) cin >> seq[i];
}
void solve() {
	sort(seq.begin(), seq.end());
	ll res = seq[0];
	for (int i = 1; i < n; ++i) {
		ll x = seq[i];
		res = mul(res, x);
		if (res == -1) {
			cout << -1;
			return;
		}
	}
	if (res == -1) {
		cout << -1;
		return;
	}
	cout << res;

	return;
}

int main() {
	cin.tie(NULL); ios_base::sync_with_stdio(false);

	//int tc; cin >> tc;
	//while (tc--) {
	input();
	solve();
	//}
}

Measured memory_bytes: 3964
n,a,b=map(int,input().split())
s=input()
p=q=0
v=[]
for c in s:
    if c == 'a':
        v.append(p < a+b)
        if p < a+b:
            p += 1
    elif c == 'b':
        v.append(p < a+b and q < b)
        if p < a+b and q < b:
            p += 1
            q += 1
    else:
        v.append(False)
for x in v:
    print('Yes' if x else 'No')

Measured memory_bytes: 4884
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vl vector<ll>
#define mp make_pair
#define sz size()
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define maxx 1000005
#define mod 1000000007
#define edge pair<ll,ll>
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦

int main()
{
	ll n;
	cin>>n;
	ll x;
	ll i;
	ll sum=0;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
	
}



	//cout<<ans<<endl;
 
	//cout<<ans<<endl;
	
	//cout<<fixed<<setprecision(10)<<sum<<endl;


Measured memory_bytes: 3636
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
#include <limits.h>
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
const int N=2005;
int g[N][N],c[N];
int n,x,y;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>x>>y;
    memset(g, 0x7f7f7f7f,sizeof g);
    for(int i = 1;i <= n;++i) g[i][i]=0, g[i][i+1]=g[i+1][i]=1;
    g[x][y]=g[y][x]=1;
    for(int i=1;i< n;++i){
        for(int j=i+1; j<=n;++j){
            g[i][j]=min(j-i, abs(x-i)+1+abs(y-j));
            g[j][i]=g[i][j];
        }
    }
    /*
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            cout<<g[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            c[g[i][j]]++;
        }
    }
    for(int i = 1; i < n; ++i) cout<<c[i]/2<<"\n";
    return 0;
}



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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') count ++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n,m = map(int,raw_input().split(" "))

pos = []
for a in range(100001):
  pos.append([a,0])

def check(i):
  k,x = pos[i]
  if k != i:
    k2,x2 = check(k)
    pos[i] = [k2,x+x2]
  return pos[i]

for a in range(m):
  l,r,d = map(int,raw_input().split(" "))

  lk,lx = check(l)
  rk,rx = check(r)

  if lk != rk:
    t = d+lx-rx
    if t >= 0:
      pos[rk] = (lk,t)
    else:
      pos[lk] = (rk,-t)
  else:
    if rx - lx != d:
      print "No"
      exit(0)
print "Yes"


Measured memory_bytes: 22516
import java.util.*;

public class Main {
    
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            int[] a = new int[4];

            int hit = 0;
            int blow = 0;
            
            for (int i = 0; i < a.length; i++) {
                a[i] = scanner.nextInt();
            }
            
            for (int i = 0; i < a.length; i++) {
                int b = scanner.nextInt();
                for (int j = 0; j < a.length; j++) {
                    if (a[i] == b) {
                        hit++;
                        break;
                    } else if (a[j] == b) {
                        blow++;
                        break;
                    }
                }
            }
            System.out.println(hit + " " + blow);
        }
    }
}

Measured memory_bytes: 18128
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
#include<map>
using namespace std;
 
int main(void)
{
	int N;
	cin >> N;
 
	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];
 
	//if(A[0] != 0){
	//	cout << -1 << endl;
	//	return 0;
	//}
	//for(int i=0; i<N-1; i++){
	//	if(A[i+1]>A[i]+1){
	//		cout << -1 << endl;
	//		return 0;
	//	}
	//}
 
	map<int, int> mp;
	for(int i=0; i<N; i++){
		int seed = i - A[i];
 
		if(seed < 0 || (i>0 && A[i]>A[i-1]+1)){
			cout << -1 << endl;
			return 0;
		}
 
		mp[seed] = i - seed;
	}
 
	long long ret = 0;
	for(auto it=mp.begin(); it!=mp.end(); it++)
		ret += it->second;
 
	cout << ret << endl;
 
	return 0;
}


Measured memory_bytes: 10368