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

using namespace std;

typedef long long ll;
const ll INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<ll> A(N); vector<ll> vec(N,INF);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  int cnt  = 0;
  for(int i = 0; i < N; i++){
    int c= lower_bound(vec.begin(),vec.end(),A[i]) - vec.begin();
    vec[c] = A[i];
    cnt = max(cnt, c);}
  
  cout << cnt + 1 << endl; return 0;}


Measured memory_bytes: 4428
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int m,n;
    while(true){
        cin>>m>>n;
        if(m+n==0)break;
        vector<bool> hana(1e7,false);

        //rep(i,10000000)hana[i]=false;

        int count=0;
        int i;
            for(i=m;count<n;i++){
            if(hana[i]==false){
                hana[i]=true;
                count++;
                for(int j=2;j*i<1e7;j++){
                    hana[j*i]=true;
                }
            }else{
            }
        }
        for(int j=m;j<1e7;j++){
            if(hana[j]==false){
                cout<<j<<endl;
                break;
            }
        }
    }


    return 0;
}



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

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(true){
		c-=b;
		a-=d;
		if(c<=0){
			puts("Yes");
			return 0;
		}
		if(a<=0){
			puts("No");
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3572
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){

		String line = scan.nextLine();
		String[] words = line.split(" ");
		int len = words.length;
		int[] counts = new int[len];
		int longest = 0;
		int max = 0;
		String sMax = "";
		String sLong = "";
		for(int i = 0; i < len; i++){
			if(words[i].length() > longest){
				longest = words[i].length();
				sLong = words[i];
			}
			for(int j = i + 1; j < words.length; j++){
				if(words[i].equals(words[j])){
					counts[i]++;
					if(max < counts[i]){
						max = counts[i];
						sMax = words[i];
					}
				}
			}
		}
		System.out.printf("%s %s\n", sMax, sLong);
	}
}

Measured memory_bytes: 26128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int c = 0, f = 0;
	char s[16];
	scanf("%s", s);
	REP(i, strlen(s))if (s[i] == 'o')c++;
	if (c >= 8)f++;
	else if (7 >= strlen(s) - c)f++;
	YES(f);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[12],s;
struct truplet
{ int a,b,c,d;
}v[51];
void bkt(int k,int p)
{ if(p==n+1)
  { int r=0;
    for(int i=1;i<=q;i++)
      if(a[v[i].b]-a[v[i].a]==v[i].c)
         r+=v[i].d;
    s=max(s,r);
    return;
  }
  for(int i=k;i<=m;i++)
    a[p]=i,bkt(i,p+1);
}
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>m>>q;
  for(int i=1;i<=q;i++)
    cin>>v[i].a>>v[i].b>>v[i].c>>v[i].d;
  bkt(1,1);
  cout<<s<<'\n';
  return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
const int INF=2e+9;
int main(){
	int N,W;
	int value[100],weight[100];
	int dp[101][10001];
	int valuemax=0;
	scan(N);scan(W);
	rep(i,N){
		scan(value[i]);scan(weight[i]);
	}
	rep(i,N){
		rep(v,10001){
			dp[i][v]=INF;
		}
	}
	dp[0][0]=0;
	rep(i,N){
		rep(v,10001){
			dp[i+1][v]=min(dp[i+1][v],dp[i][v]);
			if(v+value[i]<=10000){
				dp[i+1][v+value[i]]=min(dp[i][v+value[i]],dp[i][v]+weight[i]);
				if(dp[i+1][v+value[i]]>W) dp[i+1][v+value[i]]=INF;
				else if(v+value[i]>valuemax) valuemax=v+value[i];
			}
		}
		/*printf("i=%d ",i+1);
		rep(v,20){
			printf("%2d ",dp[i+1][v]);
		}
		kaigyo;
		prin(valuemax);*/
	}
	prin(valuemax);
	return 0;
}



Measured memory_bytes: 6996
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < t; i++) {
		    int n = sc.nextInt();
		    ArrayList<Unit> front = new ArrayList<>();
		    ArrayList<Unit> rear = new ArrayList<>();
		    for (int j = 0; j < n; j++) {
		        Unit u = new Unit(sc.nextInt(), sc.nextInt(), sc.nextInt());
		        if (u.isPos()) {
		            front.add(u);
		        } else {
		            rear.add(u);
		        }
		    }
	        Unit.type = 1;
	        Collections.sort(front);
	        Unit.type = 2;
	        PriorityQueue<Unit> left = new PriorityQueue<>();
	        long sum = 0;
	        for (Unit u : front) {
	            left.add(u);
	            sum += u.left;
	            if (left.size() > u.idx) {
	                Unit x = left.poll();
	                sum -= x.left - x.right;
	            }
	        }
	        Unit.type = 3;
	        Collections.sort(rear);
	        Unit.type = 4;
	        PriorityQueue<Unit> right = new PriorityQueue<>();
	        for (Unit u : rear) {
	            right.add(u);
	            sum += u.right;
	            if (right.size() > n - u.idx) {
	                Unit x = right.poll();
	                sum -= x.right - x.left;
	            }
	        }
	        sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Unit implements Comparable<Unit> {
	    static int type;
	    int idx;
	    int left;
	    int right;
	    
	    public Unit(int idx, int left, int right) {
	        this.idx = idx;
	        this.left = left;
	        this.right = right;
	    }
	    
	    public int compareTo(Unit another) {
	        if (type == 1) {
	            return idx - another.idx;
	        } else if (type == 3) {
	            return another.idx - idx;
	        } else if (type == 2) {
	            return left - right - (another.left - another.right);
	        } else {
	            return right - left - (another.right - another.left);
	        }
	    }
	    
	    public boolean isPos() {
	        return left >= right;
	    }
	}
}


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

namespace ABC053A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x=int.Parse(Console.ReadLine());
            string s;
            if ( 1<=x && x<1200)
            {
                s = "ABC";
            }
            else
            {
                s = "ARC";
            }
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (m) ; i < (n) ; i++)
#define per(i,n,m) for (int i = (n-1) ; i >= (m) ; i--)
#define all(x)     (x).begin(), (x).end()
#define sz(x)      ((int) (x).size())
ll gcd(ll x,ll y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}
int main(void){
    ll N,val,z=0,len,sum=0;
    cin>>N;
    vector<ll> data;
    for(ll i=2;i<=sqrt(N);i++){
        if(N%i==0){
            data.push_back(i);
            data.push_back(N/i);
        }
    }
    sort(all(data));
    len=sz(data);
    for(ll i=0;i<len;i++){
        int count=0;
        ll x;
        for(ll j=0;j<i;j++){
            if(count>0 && data[i]%data[j]==0 && data[j]%x!=0){
                count++;
            }
            if(count==0 && data[i]%data[j]==0){
                x=data[j];
                count++;
            }
        }
        if((count==0 || count==1) && N/data[i]>=1 && N%data[i]==0){
            sum++;
            N/=data[i];
        }
    }
    if(N>1 && len==0)sum++;
    cout<<sum<<endl;
}


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

int n;
int ans = 0;
void dfs(ll x, int a, int b, int c){
    if(x>n) return;
    if(a&b&c) ans++;
    dfs(10*x+3, 1,b,c);
    dfs(10*x+5, a,1,c);
    dfs(10*x+7, a,b,1);
    
}

int main(){
    cin>>n;
    dfs(0,0,0,0);
    cout << ans << endl;
}


Measured memory_bytes: 256
(stdin => {

  const I     = v => v
  const K     = v => _ => v
  const join  = sep => array => array.join(sep)
  const split = sep => str => str.split(sep)
  const print = fun => (f, v) => fun(f(v))

  // Define Function
  const getHours = s => Math.floor(s / (60 * 60))
  const getMinutes = s => Math.floor(s % (60 * 60) / 60)
  const getSeconds = s => s % 60

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const S = parseInt(inputs[0], 10)

  // Main
  const result = [getHours(S), getMinutes(S), getSeconds(S)]

  // Display
  const display = print(console.log)
  display(join(':'), result)

})(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
                string[] str = Console.ReadLine().Split(' ');

                var list = new List<int>();
                for (int i = 0; i < 3; i++)
                {
                    list.Add(int.Parse(str[i]));
                }
                list.Sort();
                list.Reverse();

                var k = int.Parse(Console.ReadLine());
                for (int i = 0; i < k; i++)
                {
                    var first = list.First();
                    first = first * 2;
                    list[0] = first;
                }
                Console.WriteLine(list.Sum());
            }
        }
    }


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        String s = next();
        String t = next();

        int tmpC = 0;
        int maxC = 0;
        for(int i=0; i<s.length()-t.length()+1; i++){
            for(int j = 0; j<t.length(); j++){
                //print(j);
                //print(i);
                if(s.charAt(i+j) == t.charAt(j)){
                    tmpC += 1;
                }
            }
            //print(maxC);
            maxC = Math.max(tmpC, maxC);
            tmpC = 0;
        }
        print(t.length()-maxC);
    }


    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 35632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) cout << 1 << '\n';
    else cout << ((H * W) + 1) / 2 << '\n';
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [0 for i in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
result = []
for i in range(H):
    for j in range(W):
        if i == H-1 and j == W-1:
            continue
        if j == W-1 and a[i][j] % 2 == 1 and i < H-1:
            a[i][j] -= 1
            a[i+1][j] += 1
            result.append([i+1, j+1, i+2, j+1])

        elif a[i][j] % 2 == 1:
            a[i][j] -= 1
            a[i][j+1] += 1
            result.append([i+1, j+1,i+1, j+2])
#print(a)
print(len(result))
for i in range(len(result)):
    print('%d %d %d %d' % (result[i][0],result[i][1],result[i][2],result[i][3]))


Measured memory_bytes: 29816
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin>>t;
	while (t--) {
		int n;
		cin >> n;
		string s;
		cin >> s;
		string ans;
		int vv = s.size();
		int mn = min(vv, n);
		for (int i = 0; i < mn; i++) {
			ans += s[i];
		}
		if (n < s.size())
			ans += "...";
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

	int  N,K;
	cin >> N >> K;

	int num = 1;

	for (int i = 1 ; i <= N ; i++) {
		if (num * 2 <= num + K)
			num = num * 2;
		else
			num = num + K;
	}
	cout << num;
	
	return 0;
}


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

    int main(){
        ll  n;
        string s , s2;
        cin >> n >> s;
        ll l = 0 , r = 0;
        for(ll i = 0 ; i < n ; i++){
            if(s[i] == ')' ){
                r += 1;
                if( l < r){
                    s2 = '(' + s2 + ')';
                    l += 1;
                }else{
                    s2 = s2 + ')';
                }
            }else{
                l += 1;
                 s2 = s2 + '(';
            }
        }
        for(ll i = 0 ; i < l - r ; i++){
            s2 = s2 + ')';
        }
        cout << s2 << endl;
        
        return 0;
    }

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

int main(){
  int n,d;
  cin >> n >> d;
  if(n==0 && d==100)cout << 101 <<endl;
  if(n==1 && d==100) cout << 10100 <<endl;
  if(n==2 && d==100) cout <<1010000 <<endl;
  else if( d<=99){
  cout << fixed <<setprecision(0);
  cout << pow(100,n)*d  <<endl;
  }
}

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

    cin >> n >> m;

    vector<ll> h(n+1);
    vector<int> dp(n+1,0);

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

    rep(i,m){
        cin >> a >> b;
        if(h[a] > h[b]){
            dp[b] = 1;
        }else if(h[a] < h[b]){
            dp[a] = 1; 
        }else{
            dp[a] = 1;
            dp[b] = 1;
        }
    }

    for (int i = 1; i < n+1; i++)
    {
        if(dp[i] == 0){
            count++;
        }
    }
    cout << count << endl;

}

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

int main() {
  int N;
  cin >> N;
  
  cout << fixed << setprecision(10);
  
  if ( N%2 == 0 ) {
    cout << 0.5 << endl;
  }
  else {
    cout << (N+1.0)/(2.0*N) << endl;
  }
  
}


Measured memory_bytes: 256
k,a,b = map(int,input().split())
if a >= b -2:
  print(1+k)
  exit()
if k-1 < a:
  print(1+k)
  exit()
c = k-a+1
d = (k-a+1)//2
if (k-a+1)%2 == 0:
  print(a+d*(b-a))
else:
  print(a+d*(b-a)+1)

Measured memory_bytes: 3060
package main

import "fmt"

func rsp(hand byte, R int, S int, P int) int {
	if string(hand) == "r" {
		return P
	} else if string(hand) == "p" {
		return S
	} else {
		return R
	}
}

func main() {
	var T string
	var N, K, R, S, P int
	fmt.Scan(&N, &K)
	fmt.Scan(&R, &S, &P)
	fmt.Scan(&T)
	lis := []bool{}
	for n := 0; n < N; n++ {
		lis = append(lis, true)
	}
	ans := 0
	for t := 0; t < K; t++ {
		ans += rsp(T[t], R, S, P)
		lis[t] = false
	}
	for t := K; t < N; t++ {
		if T[t] != T[t-K] || lis[t-K] {
			ans += rsp(T[t], R, S, P)
			lis[t] = false
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))
ans = 0

# import math
# from functools import reduce
# def lcm_base(x, y):
#     return int((x * y) / math.gcd(x, y))
# def lcm_list(numbers):
#     ans = 0
#     for i in range(1,len(numbers)):
#         if(i == 1):
#             ans = lcm_base(numbers[0], numbers[1])
#         else:
#             ans = lcm_base(ans, numbers[i])
#     return ans
# min_bin= lcm_list(a)
num = 1
for i in a:
    num = num * i
num = num - 1
for i in a:
    ans += num % i
# for i in range(5000000):
#     tmp = 0
#     for j in a:
#         # print(j)
#         tmp += i % j
#     if(tmp > ans):
#         ans = tmp
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b;
    cin >> a >> b;
    if (a % 2 != b % 2)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n=sc.nextInt();
		long n=sc.nextLong();
		//String s=sc.next();
		//long[] array=new long[n];
		int sum=0,buff,max=0,min=0;
		//int[] array=new int[l];
		//String s="",m="",h="";

		for(long i=0;i<n;i++) {
			sum+=sc.nextInt()*-1+sc.nextInt()+1;
		}
		//Arrays.sort(array)
		System.out.println(sum);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 25300
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        if (a >= 1000) {
            System.out.println("ABD");
        } else {
            System.out.println("ABC");
        }
    }
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;

	vector<vector<int>> vec;

	rep(i, n){
		vector<int> v;

		rep(j, 3){
			int x;
			cin >> x;
			v.push_back(x);
		}

		vec.push_back(v);
	}

	vector<vector<int>> dp;

	rep(i, n){
		vector<int> v;

		rep(i, 3){
			v.push_back(0);
		}

		dp.push_back(v);
	}

	dp[0][0] = vec[0][0];
	dp[0][1] = vec[0][1];
	dp[0][2] = vec[0][2];

	for(int i = 1; i < n; i++){
		dp[i][0] = max(dp[i - 1][1] + vec[i][0], dp[i - 1][2] + vec[i][0]);

		dp[i][1] = max(dp[i - 1][0] + vec[i][1], dp[i - 1][2] + vec[i][1]);

		dp[i][2] = max(dp[i - 1][0] + vec[i][2], dp[i - 1][1] + vec[i][2]);
	}

	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));

	return 0;
}

Measured memory_bytes: 12336
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <utility> //pair
#include <algorithm> //sort
using namespace std;


int main(){
    int n, d[100010];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d, d+n);
    //cout << d[0] << endl;
    int m = n / 2;
    if (n % 2 == 1 or d[m-1] == d[m])
    {
        cout << 0 << endl;
        return 0;
    }
    
    
    cout << d[m] - d[m-1] << endl;
    return 0;
    
    
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)

	L := make([]int, N)
	rL := make([]int, N)
	for i := 0; i < N; i++ {
		var l int
		fmt.Scan(&l)
		L[i] = l
		rL[i] = l
	}
	sort.Sort(sort.Reverse(sort.IntSlice(rL)))
	sort.Ints(L)

	cnt := 0
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			a := rL[i]
			b := rL[j]
			min := a - b + 1
			l := L[:N-j-1]
			i := sort.SearchInts(l, min)
			if i == len(l) {
				continue
			}
			cnt += len(l[i:])

		}
	}
	fmt.Println(cnt)

}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 3;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
    return (a + b) < (b + a);
}

void solve(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ',')
            cout << ' ';
        else cout << s[i];
    }
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3520
a = input()
A = 0
if a[0] == "A" and a[1].isupper() == False and a[-1].isupper() == False:
    for i in range(2,len(a)-1):
        if a[i] == "C" and A == 0:
	        A = 1
        elif a[i].isupper() == True:
            A = 2
if A == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 38384
import copy
import sys
from collections import deque
H, W = map(int,input().split())
C = list(map(lambda x: int(x) - 1, input().split()))
D = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]
check_visited = [[False] * W for _ in range(H)]
dq = deque([[0, C[0], C[1]]])
while dq:
   d, i, j = dq.popleft()
   if [i, j] == D:
      print(d)
      exit()
   if check_visited[i][j]:
      continue
   check_visited[i][j] = True
   for move_h, move_w in [[-1,0], [1,0], [0,-1], [0,1]]:
      new_i = i + move_h
      new_j = j + move_w
      if 0 <= new_i <= H-1 and 0 <= new_j <= W-1 and S[new_i][new_j] == '.' and (not check_visited[new_i][new_j]) :
         dq.appendleft([d, new_i, new_j])
   for move_h in range(-2, 3):
      for move_w in range(-2, 3):
         if [move_h, move_w] == [0, 0]:
            continue
         new_i = i + move_h
         new_j = j + move_w
         if 0 <= new_i <= H-1 and 0 <= new_j <= W-1 and S[new_i][new_j] == '.' and (not check_visited[new_i][new_j]) :
            dq.append([d+1, new_i, new_j])
print(-1)

Measured memory_bytes: 236684
##!/usr/bin/env python3
import sys
from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int

    # write code
    if W == 2 * x and H == 2 * y:
        ls = 1
    else:
        ls = 0
    print(W*H/2,ls)



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  vector<ll> cnt(N+1,0);
  rep(i,N+1){
    cnt[A[i]]++;
  }
  vector<ll> com(N+1,0);
  rep(i,N+1){
    com[i]  = cnt[i]*(cnt[i]-1)/2;
  }
  ll allsum=0;
  rep(i,N+1){
    allsum += com[i];
  }
  rep(i,N){
    ll num = A[i];
    ll c = cnt[num]-1;
    cout << allsum - com[num] + max((ll)0,c*(c-1)/2) << endl;
  }
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 3e5;

struct Fenwick {
	int ft[N];
  int sum(int r) {
  	int result = 0;
  	for (; r >= 0; r = (r & (r + 1)) - 1)
  		result += ft[r];
  	return result;
  }
  int sum(int l, int r) {
      return (l > r ? 0ll : sum(r) - sum(l - 1));
  }
  void inc(int i, int delta) {
  	for (; i < N; i = (i | (i + 1)))
  		ft[i] += delta;
  }
} ft;

vector<pair<int, int> > add[N];
vector<int> querys[N];
int res[N];

void solve() {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		int l, r; cin >> l >> r;
		add[l].push_back({l, 1});
		add[r + 1].push_back({l, -1});
	}
	for (int d = 1; d <= m; d++) {
		for (int p = d; p <= m; p += d) {
			querys[p].push_back(d);
		}
	}
	for (int x = 1; x <= 2 * m; x++) {
		for (auto e : add[x]) {
			int left = e.first, delta = e.second;
			ft.inc(left, delta);
		}
		for (auto d : querys[x]) {
			int px = x - d;
			res[d] += ft.sum(px + 1, x);
		}
	}
	for (int d = 1; d <= m; d++) {
		cout << res[d] << "\n";
	}
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

struct P {
    bool r;
    bool c;
};

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> m;
    vector<vector<P>> p;
    m.resize(H);
    p.resize(H);
    REP(i, H) {
        m[i].resize(W);
        p[i].resize(W);
    }
    REP(i, H) {
        REP(j, W) {
            cin >> m[i][j];
        }
    }
    REP(i, H) {
        REP(j, W) {
            if(m[i][j] == '#') {
                REP(r, H) {
                    p[r][j].r = true;
                }
                REP(c, W) {
                    p[i][c].c = true;
                }
            }
        }
    }
    REP(i, H) {
        bool x = false;
        REP(j, W) {
            if(p[i][j].r && p[i][j].c) {
                cout << m[i][j];
                x = true;
            }
        }
        if(x) {
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n, -1);
	for (int i = 0; i < m; ++i)
	{
		int c, s;
		cin >> c >> s;
		c --;
		if (a[c] == -1)
			a[c] = s;
		else if (a[c] != s)
			return cout << -1, 0;
	}
	if (n == 1)
	{
		if (a[0] == -1)
			a[0] = 0;
		cout << a[0];
		return 0;
	}
	if (a[0] == 0)
		return cout << -1, 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] == -1)
		{
			if (i)
				a[i] = 0;
			else
				a[i] = 1;
		}
		cout << a[i];
	}
	return 0;
}

Measured memory_bytes: 3620
# 100 C

N =int(input())
a =[int(j) for j in input().split()]
ans = 0
for i in range(N):
    tmp=0
    for j in range(1,30):
        if a[i]%(2 ** j)==0:
            tmp = max(tmp,j)
    ans +=tmp
print(ans)

Measured memory_bytes: 4148
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>




#define f first
#define s second
#define pb push_back
#define sz(a) (int)(a).size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 4000000000000000005ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
//typedef pair<point, point> line;
typedef pair<double , point> Circle;



const int N = 2000002;

int n,a[N];


int main(){
    scanf("%d",&n);

    lp(i, 1, n) scanf("%d",&a[i]);
    sort(a+1, a+n+1);
    
    ll sum = 0;
    lpd(i, n, 1) {
        if((i&1) == (n&1)) sum += a[i];
        else sum -= a[i];
    }
    
    
//    if(sum > 0) printf("Alice\n");
//    else printf("Bob\n");
    printf("%lld\n",sum);
    return 0;
}

/*
 
 
 7
 10
 5 7 1
 5 6 2
 7 7 2
 6 7 2
 5 5 1
 3 6 2
 1 3 2
 5 6 1
 1 3 1
 6 7 1
 
 
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);
  if ( A == 1 && B == 2) {
  	printf("3");
  }
  else if ( A == 2 && B == 1) {
  	printf("3");
  }
  else if ( A == 2 && B == 3) {
  	printf("1");
  }
  else if ( A == 3 && B == 2) {
  printf("1");
  }
  else {
  printf("2");
  }
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    int x;
    cin >> x;
    a[x-1]++;
  }
  sort(a.begin(),a.end());
  vector<int> s(n+1); // sum of [0,i)
  rep(i,n) s[i+1] = s[i]+a[i];
  int ans = n, i = n;
  for (int k = 1; k <= n; ++k) {
    while (1) {
      bool ok = [&](int c) {
        while (i >= 1 && a[i-1] >= c) --i;
        int sum = c*(n-i) + s[i];
        return (sum >= c*k);
      }(ans);
      if (ok) break;
      --ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;

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

Measured memory_bytes: 256
#def main(S, b):
if __name__ == '__main__':
    h, w = map(int, input().split())

    ans = h * w // 2
    if (h % 2 == 1 and w % 2 == 1):

        ans += 1
    if (h == 1 or w == 1):
        ans = 1
    print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
 
int main(){
    int a, b, i = 0, aa = 0, ca;
    double ba = 0;
    while(scanf("%d,%d", &a, &b) != EOF){
        i++;
        aa += a * b;
        ba += b;
    }
    ba /= i;
    ba += 0.5;
    ca = ba;
    printf("%d\n%d\n", aa, ca);
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		if(s=="0") break;
		stringstream ss;
		vector<int> a;
		int n,f=0,sum=0;
		ss<<s;
		while(ss>>n){
			if(n==1)f=1;
			a.push_back((n>=10)?10:n);
			if(ss.eof()) break;
		}
		for(int i=0;i<a.size();++i) sum+=a[i];
		if(f&&sum<=11) sum+=10;
		if(sum>21)cout<<0<<endl;
		else cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int n;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    ld res = 0;
    FOR(i,1,n) {
        ld u;
        string v;
        cin >> u >> v;
        if (v == "BTC") {
            res += 380000.0 * u;
        }
        else res += u;
    }
    cout << fixed << setprecision(9) << res;
    return 0;
}

Measured memory_bytes: 256
// atcoder/abc134/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);


  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;

    const int N = 200000 + 5;
    static int b[N];
    fill(b, b + N, 0);
    for (int i = n - 1; 0 <= i; --i) {
      b[i] = max(a[i], b[i + 1]);
    }
    int mx = 0;
    for (int i = 0; i < n; ++i) {
      cout << max(mx, b[i+1]) << endl;
      setmax(mx, a[i]);
    }
  }

  return 0;
}


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

using namespace std;

long frac(long num)
{
    if (num == 1)
        return 1;
    return num * frac(num - 1);
}

int main()
{
    long N;
    string S;
    cin >> N;
    cin >> S;
    char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    int ans = 0;
    for (int i = 0; i <= 9; i++)
    {
        int pos[3] = {-1, -1, -1};
        for (int a = 0; a < S.length() - 2; a++)
        {
            if (S[a] == digits[i])
            {
                pos[0] = a;
                break;
            }
        }
        if (pos[0] == -1)
            continue;
        for (int j = 0; j <= 9; j++)
        {
            pos[1] = -1;
            for (int a = pos[0] + 1; a < S.length() - 1; a++)
            {
                if (S[a] == digits[j])
                {
                    pos[1] = a;
                    break;
                }
            }
            if (pos[1] == -1)
                continue;
            for (int k = 0; k <= 9; k++)
            {
                pos[2] = -1;

                for (int a = pos[1] + 1; a < S.length(); a++)
                {
                    if (S[a] == digits[k])
                    {
                        pos[2] = a;
                        break;
                    }
                }
                if (pos[2] == -1)
                    continue;
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int a, b, c, d;

int main(){
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    cout << min(a, b) + min(c, d) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  long** map = new long*[100];
  long N = 1000000007;
  long* rest = new long[8];
  rest[0] = 1;
  rest[1] = 2;
  rest[2] = 3;
  rest[3] = 5;
  rest[4] = 8;
  rest[5] = 13;
  rest[6] = 21;
  rest[7] = 34;
  for(int i=0;i<h;i++) {
    map[i] = new long[8];
    for(int j=0;j<w;j++){
      map[i][j] = 0;
    }
  }
  map[0][0] = rest[max(0,w-2)];
  map[0][1] = rest[max(0,w-3)];
  for(int i=1;i<h;i++){
    for(int j=0;j<w;j++){
      long sum = map[i-1][j] * rest[max(0,j-1)] * rest[max(0,w-j-2)] % N;
      if(j!=0) sum += map[i-1][j-1] * rest[max(0,j-2)] * rest[max(0,w-j-2)] % N;
      if(j!=w-1) sum += map[i-1][j+1] * rest[max(0,j-1)] * rest[max(0,w-j-3)] % N;
      map[i][j] = sum%=N;
    }
  }

  cout << map[h-1][k-1] << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int a, b;
    char op;
    int x = 0; //結果
    
    while(true) {
      cin >> a >> op >> b;
    
      if (op == '+'){
        x = a + b;
      } else if (op == '-') {
        x = a - b;
      } else if (op == '*') {
        x = a * b;
      } else if (op == '/') {
        x = a / b;
      } else if (op == '?'){
        break; 
      }
    
      printf("%d\n", x);
    }
    
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
/**
 Answer #3
 **/

using namespace std;

struct indexes{
    indexes(int _i, int _j, int _k, long long _val){
        i = _i;
        j = _j;
        k = _k;
        val = _val;
    }
    int i,j,k;
    long long val;
};

bool operator < (const indexes& l, const indexes &r){
    return l.val < r.val;
}

long long hash_index(const indexes& obj){
    return obj.i * 1000000 + obj.j * 1000 + obj.k;
}

int main()
{

    //    cout << " a" << endl;
    long long X, Y, Z;
    long long K;
    long long A[1000], B[1000], C[1000];

    cin >> X >> Y >> Z >> K;
    for (int i = 0; i < X; ++i)
    {
        cin >> A[i];
    }
    sort(A, A + X, greater<long long>());

    for (int i = 0; i < Y; ++i)
    {
        cin >> B[i];
    }
    sort(B, B + Y, greater<long long>());

    for (int i = 0; i < Z; ++i)
    {
        cin >> C[i];
    }
    sort(C, C+ Z, greater<long long>());

    priority_queue<indexes> que;
    set<long long> st;

    indexes greatest(0,0,0,A[0]+B[0]+C[0]);
    que.push(greatest);
    st.insert(hash_index(greatest));
    for(int rep = 0; rep <K; ++rep){
        int i, j, k;
        i = que.top().i;
        j = que.top().j;
        k = que.top().k;
        cout << que.top().val << endl;
        que.pop();
        if(i < X-1){
            indexes tmp(i+1, j, k, A[i+1]+B[j]+C[k]);
            if(st.find(hash_index(tmp)) == st.end()){
                st.insert(hash_index(tmp));
                que.push(tmp);
            }
        }
        if(j < Y-1){
            indexes tmp(i, j+1, k, A[i]+B[j+1]+C[k]);
            if(st.find(hash_index(tmp)) == st.end()){
                st.insert(hash_index(tmp));
                que.push(tmp);
            }
        }
        if(k <Z-1){
            indexes tmp(i, j, k+1, A[i]+B[j]+C[k+1]);
            if(st.find(hash_index(tmp)) == st.end()){
                st.insert(hash_index(tmp));
                que.push(tmp);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(i<n&&a[i]&&a[i+1])
        {
            ans++;
            a[i]--;
            a[i+1]--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 100;

char s[N];

int n;

bool inline check(int m) {
	for (int i = 1; i <= m; i++)
		if (s[i] != s[m - i + 1]) return false;
	return true;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (check(n) && check((n - 1) / 2)) puts("Yes");
	else puts("No");
	return 0;
}

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

string s, t;

int main(){
	cin >> s >> t;
	int lens = s.size(), lent = t.size();
	bool flag = false;
	for (int i = lens - 1; i >= 0; i--){
		if (s[i] == '?'||s[i]==t[lent-1]){
			int j, k, m = 0;
			for (k = lent - 1, j = i; k >= 0 && j >= 0; j--, k--){
				if (s[j] == '?' || s[j] == t[k]){
					m++;
				}
				else break;
			}
			if (m == lent){
				flag = true;
				for (k = lent - 1, j = i; k >= 0 && j >= 0; j--, k--){
					s[j] = t[k];
				}
				break;
			}
		}
	}
	if (flag == true){
		for (int i = 0; i < lens; i++){
			if (s[i] == '?'){
				cout << 'a';
			}
			else cout << s[i];
		}
		cout << endl;
	}
	else{
		cout << "UNRESTORABLE" << endl;
	}
}

Measured memory_bytes: 256