akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    char last = 'D';
    for (int i = 0; i < sz(s); i++) {
        char cur = s[i];
        if (s[i] == '?') cur = 'D';
        if (cur == 'D') {
            ++ans;
            if (last == 'P') ++ans;
        }
        last = cur;
        cout << cur;
    }
    cerr << ans << '\n';
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	cout<<c<<endl;
	cout<<a<<endl;
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}

	ll cnt_total = 0;
	for (int i = 0; i <= n ; i++) {
		if (cnt[i] < 2) continue;
		else cnt_total += (ll)cnt[i] * ((ll)cnt[i] - 1) / 2;
	}
	for (int k = 1; k <= n; k++) {
		if (cnt[a[k - 1]] < 2) cout << cnt_total << endl;
		else cout << cnt_total - cnt[a[k - 1]] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 4852
x = list(map(int, input().split()))
N = int(input())
x[1] = min(x[0] * 2, x[1])
x[2] = min(x[0] * 4, x[1] * 2, x[2])
x[3] = min(x[0] * 8, x[1] * 4, x[2] * 2, x[3])
a = N // 2 * x[3] + (N - 2 * (N // 2)) * x[2]
b = N * x[2]
print(min(a, b))

Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut a: Vec<(usize, usize)> = Vec::new();
    for i in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        a.push((i + 1, ai));
    }

    let mut result: Vec<Vec<usize>> = vec![vec![0; w]; h];

    let mut color = 0;
    let mut ai = 0;
    for i in 0..h {
        for j in 0..w {
            if ai == 0 {
                let pair = a.pop().unwrap();
                color = pair.0;
                ai = pair.1;
            }
            if i % 2 == 0 {
                result[i][j] = color;
            } else {
                result[i][w - j - 1] = color;
            }
            ai -= 1;
        }
    }

    let mut output = String::new();
    for i in 0..h {
        let mut line = String::new();
        for j in 0..w {
            line.push_str(&format!("{} ", result[i][j]))
        }
        output.push_str(&format!("{}\n", line.trim()))
    }
    return output.trim().to_string();
}


Measured memory_bytes: 4352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = map(int,read().split())

class CHT:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = self.funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            self.funcs.popleft()
        return y

dp = [0] * N
cht = CHT()

h = H[0]
add = cht.add
query = cht.query

add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = query(h) + h*h + C
    dp[i] = x
    add(-2*h, h*h + x)

answer = dp[-1]
print(answer)


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

#define llint long long
#define LL(x) (x * 2)
#define RR(x) (x * 2 + 1)
#define fi first
#define se second
#define db(x) cout << #x << " = " << x << endl;
#define BIT(x, i) ((x >> i) & 1)
#define MASK(i) (1ll << i)
#define mini(x, y) (x > y ? x = y, 1 : 0)
#define maxi(x, y) (x < y ? x = y, 1 : 0)

void openFile() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef Tr___
	freopen("test.inp", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif
}

const int maxN = 50 + 5;
const int maxM = 1e6 + 5;
const llint INF = 1e9 + 7;

int N, M;
vector<int> vertex[maxN];
int par[maxN], low[maxN], num[maxN];
int cnt = 0;
struct node {
	int u, v;
	bool ok;
	node() {}
	node(int u, int v, bool ok): u(u), v(v), ok(ok) {}
};
vector<node> E;

void enter() {
	cin >> N >> M;
	for (int i = 1; i <= M; ++i) {
		int u, v;
		cin >> u >> v;
		vertex[u].push_back(E.size());
		E.push_back(node(u, v, 1));
		vertex[v].push_back(E.size());
		E.push_back(node(v, u, 1));
	}
}

void dfs(int u) {
	low[u] = num[u] = ++cnt;

	for (int id : vertex[u]) {
		if (!E[id].ok) continue;
		int v = E[id].v;

		if (par[v] == 0) {
			E[id^1].ok = false;
			par[v] = u;
			dfs(v);
			low[u] = min(low[u], low[v]);
		}
		else {
			low[u] = min(low[u], num[v]);
		}
	}
}

void solve() {
	for (int i = 1; i <= N; ++i) {
		if (par[i] == 0) {
			par[i] = -1;
			dfs(i);
		}
	}

	int res = 0;
	for (int i = 0; i < E.size(); ++i) {
		if (!E[i].ok) continue;
		if (par[E[i].v] != E[i].u) swap(E[i].u, E[i].v);
		if (par[E[i].v] == E[i].u and low[E[i].v] >= num[E[i].v]) ++ res;
	}
	cout << res << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  
  int N;
  cin >> N;
  bool flag = false;
  vector<char> S(N);
  
  for(int i=0;i<N;i++)
  {
    cin >> S.at(i);
    if(S.at(i) == 'Y')
    {
      flag = true; 
      break;
    }
  }
  if(flag) 
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl; 
  }
}

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

int main() {
	int n;

	std::cin >> n;

	long long sum = 0;
	std::vector<long long> v(n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> v[i];
		sum += v[i];
	}

	int m;

	std::cin >> m;

	for (int i = 0; i < m; i++)
	{
		int p, x;

		std::cin >> p >> x;
		std::cout << sum - v[p - 1] + x << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[][] arr = new int[n][3];
        for(int i = 0; i < n; i++){
            arr[i] = sc.nextIntArray(3);
        }
        int[][] dp = new int[n+1][3];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(j == k) continue;
                    dp[i+1][k] = Math.max(dp[i+1][k],dp[i][j]+arr[i][k]);
                }
            }
        }
        long ans = 0;
        for(int i = 0; i < 3; i++){
            ans = Math.max(ans,dp[n][i]);
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 53424
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
s1=SI()
s2=SI()
i=0
vh=[]
while i<n:
    if s1[i]==s2[i]:
        vh.append(1)
        i+=1
    else:
        vh.append(0)
        i+=2
#print(vh)
if vh[0]==1:
    ans=3
else:
    ans=6
#print(ans)
for i in range(len(vh)-1):
    if vh[i]==1 and vh[i+1]==1:
        ans=ans*2%mod
    elif vh[i]==0 and vh[i+1]==1:
        ans=ans
    elif vh[i]==1 and vh[i+1]==0:
        ans=ans*2%mod
    else:
        ans=ans*3%mod
print(ans)

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


int main(void){
    int n;
    cin >> n;
    vector<int>d;
    rep(i,n){
        int x;
        cin >> x;
        d.push_back(x);
    }
    vector<int>d2;
    bool flag = 0;
    rep(i,n){
        if(i==0){
            if(d[i]!=0){
                flag = 1;
            }
        }
        else{
            if(d[i]==0){
                flag = 1;
                break;
            }
        }
    }
    sort(d.begin(),d.end());
    int cnt = 1;
    rep(i,n){
        if(i!=n-1){
            if(d[i]==d[i+1]){
                cnt++;
            }
            else if(d[i]+1==d[i+1]){
                d2.push_back(cnt);
                cnt = 1;
            }
            else{
                flag = 1;
                break;
            }
        }
        else{
            d2.push_back(cnt);
        }
    }
    ll ans = 1;
    
    for(int i=0;i<d2.size()-1;i++){
        rep(j,d2[i+1]){
            ans *= d2[i];
            ans = ans % 998244353;
        }
    }
    if(flag){
        cout << 0 <<endl;
    }
    else{
        cout << ans << endl;
    }
    
    
    
    return 0;
}































































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

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

    long long n, k;
    cin >> n >> k;

    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    int mini = 1e9;
    for(int i = 0; i <= n - k; i++){
        mini = min(mini, A[i + k - 1] - A[i]);
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
string to_str(ll A){
    stringstream ss;
    ss << A;
    return ss.str();
}
bool kaibun(string s){
    bool flag = true;
    for(int i = 0;i < s.length();i++){
        if(s[i] != s[s.length()-i-1])flag = false;
    }
    return flag;
}
main(){
    int A,B;
    cin >> A >> B;
    int cnt = 0;
    for(int i = A;i <= B;i++){
        if(kaibun(to_str(i)))cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int H = GetInt();
		int N = GetInt();
		int[] A = GetInts(N);
		WriteLine(A.Sum() >= H ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 20832
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;
    boolean A, B, C;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N + 1];
        int[] v = new int[N + 1];
        dp = new long[N+1][W + 1];
        for (int i = 1; i <= N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j < w[i]) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
                }
            }
        }
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 127572
c=[list(map(int,input().split()))for i in range(3)]
x=[0]*3
y=[0]*3
for i in range(3):
    y[i]=c[0][i]-x[0]
    for j in range(3):
        x[i]=c[i][0]-y[0]
jud=True
for i in range(3):
    for j in range(3):
        if x[i]+y[j]!=c[i][j]:
            jud=False
if jud==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int x,n,min=1000000,max=-1000000;
    long int total=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x<min)min=x;
        if(x>max)max=x;
        total+=x;
    }
    cout<<min<<" "<<max<<" "<<total<<endl;
    return 0;
}



Measured memory_bytes: 3136
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,t=intLine()
    println(Int(floor(t/a)b))
end
main()

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

def main():
    N = int(input())
    A = sorted([int(v) for v in input().split()])

    over = False
    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            over = True
            break
    
    if over:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21920
fn main() {
    proconio::input!{
        n: usize,
        a: [usize; n]
    }
    const MOD : i64 = 998244353;
    let s: usize = a.iter().sum();
    let mut dp = vec![0; s+1];
    let mut dp2 = vec![0; s+1];
    dp[0] = 3;
    dp2[0] = 1;
    for &t in &a {
        for i in (0..=(s-t)).rev() {
            dp[i+t] = (dp[i+t] + dp[i]) % MOD;
            dp[i] = (2 * dp[i]) % MOD;
            dp2[i+t] = (dp2[i+t] + dp2[i]) % MOD;
        }
    }
    let mut res = 1;
    for _ in 0..n { res = 3 * res % MOD }
    for i in (s+1)/2..=s { res = (res + MOD - dp[i]) % MOD }
    if s%2 == 0 { res = (res + 3 * dp2[s/2]) % MOD }
    println!("{}", res);
}


Measured memory_bytes: 3456
import queue

def resolve():
    n,m = map(int, input().split())
    signs = [0]*(n+1)
    maps = {}
    for _ in range(m):
        a,b = map(int, input().split())
        if a in maps.keys():
            maps[a].append(b)
        else:
            maps[a] = [b]

        if b in maps.keys():
            maps[b].append(a)
        else:
            maps[b] = [a]

        # if a < b:
        #     if a in maps.keys():
        #         maps[a].append(b)
        #     else:
        #         maps[a] = [b]
        # else:
        #     if b in maps.keys():
        #         maps[b].append(a)
        #     else:
        #         maps[b] = [a]
    
    remain = set(list(range(1, n+1)))
    q = queue.Queue()
    q.put(1)
    
    while q.empty() == False:
        curr = q.get()
        for i in maps[curr]:
            if signs[i] != 0:
                continue
            signs[i] = curr
            remain.remove(i)
            q.put(i)
    
    if len(remain) == 0:
        signs[1] = 'Yes'
        for i in range(len(signs)):
            if i == 0:
                continue
            print(signs[i])
    else:
        print('No')
            

resolve()

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

int main(){
    int N;
    int A=0;
    cin >> N;
    vector<int>vec(N,0);
    vector<int>check(N,0);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    for(int i=0;i<N;i++){
        if(i == 0){
            check[0]=vec[0];
        }
        else{
            check[i] = min(check[i-1],vec[i]);
        }
    }
    for(int i=0;i<N;i++){
        if(vec[i] <= check[i]){
            A++;
        }
    }
    cout << A << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    int N;
    cin>>N;
    
    int nums[100009]; mem(nums,0);
    
    rep(i,N){
        int x; cin>>x;
        nums[x]++;
    }
    
    int cut=0, extra=0;
    rep1(i,100000){
        if(nums[i]>1){
            cut += nums[i]-1;
            if(nums[i]%2==0){
                extra = 1 - extra;
            }
        }
    }
    cut += extra;
    cout1(N-cut);
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 16, B = 60, mod = 1000000007;

int good[1 << maxN], bad[1 << maxN];
bool vis[1 << maxN];

int cnt[B];

void go(int v)
{
	if (vis[v])
		return;
	int m = good[v];
	good[v] |= good[m];
	bad[v] |= bad[m];
	if (good[v] & bad[v])
	{
		good[v] = 0;
		vis[v] = true;
		return;
	}
	
	m = good[v];

	if (m != v)
		go(m);
	good[v] = good[m];
	vis[v] = true;
}

void solve()
{
	int n;
	scanf ("%d", &n);
	FOR(i, 0, n)
	{
		long long a;
		scanf ("%lld", &a);
		FOR(j, 0, 60)
			if (a & (1ll << j))
				cnt[j]++;
	}
	
	long long res = 0;
	
	FOR(i, 0, B)
	{
		long long a = (1ll << i) % mod;
		a = a * cnt[i] % mod;
		a = a * (n-cnt[i]) % mod;
		res = (res + a) % mod;		
	}	
	
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [int(i) for i in input().split()]
count = 0
for i in range(len(s)):
    if s[i] <0:
        count += 1

s = list(map(abs, s))
if count%2 == 0:
    print(sum(s))
else:
    print(sum(s)-min(s)*2)

Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[200001];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<int>ways(200005,INT_MAX);
    ways[1]=0;
    for(int i=2;i<=n;i++){
       for(int j=i-1;j>=1 && (i-j)<=k;j--){
             ways[i]=min(ways[i],abs(a[i]-a[j])+ways[j]);
       }
    }
    cout<<ways[n];
    return 0;
}
        
    

Measured memory_bytes: 1408
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {

  int a, b;

  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int getGreatestCommonDivisor(int a, int b)
{
    int bigger   = a >= b ? a : b;
    int smaller  = a <= b ? a : b;
    int reminder = bigger % smaller;
    int gcd = 1;

    if (reminder == 0) return smaller;
    else
    {
        for (int i = reminder; i >= 2; i--)
        {
            if (bigger % i == 0 && smaller % i == 0)
            {
                gcd = i;
                break;
            }
        }
    }

    return gcd;
}

int main()
{
    int a, b;

    std::cin >> a >> b;

    std::cout << getGreatestCommonDivisor(a, b) << std::endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define INF 1e15
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, int> p;

struct Link {
    int to;
    int c;
    Link(int to, int c) {
        this -> to = to;
        this -> c = c;
    }
};

int n, m;
vector<ll> cost;
vector<vector<Link>> w;
priority_queue<p, vector<p>, greater<p>> pq;

void input() {
    cin >> n >> m;
    w = vector<vector<Link>>(n+1);
    for (int i = 2; i <= n; i++) w[i].push_back(Link(i-1, 0));
    rep(i, m) {
        int l, r, c;
        cin >> l >> r >> c;
        w[l].push_back(Link(r, c));
    }
}

void dijkstra() {
    vector<bool> visit(n+1, false);
    cost = vector<ll>(n+1, INF);
    cost[1] = 0;
    pq.push(make_pair(0, 1));
    while (!pq.empty()) {
        auto x = pq.top();
        pq.pop();
        if (visit[x.second]) continue;
        visit[x.second] = true;
        for (Link y : w[x.second]) {
            if (visit[y.to]) continue;
            if (cost[y.to] > cost[x.second] + y.c) {
                cost[y.to] = cost[x.second] + y.c;
                pq.push(make_pair(cost[y.to], y.to));
            }
        }
    }
}

int main() {
    input();
    dijkstra();
    ll ans =  (cost[n] == INF)? -1 : cost[n];
    cout << ans << endl;
}


Measured memory_bytes: 8440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
}

Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int dist[108][108];
int main() {
	int N,M;
	cin>>N>>M;
	rep(i,N)rep(j,N){
		if(i == j)dist[i][j] = 0;
		else dist[i][j] = INF;
	}
	vector<int> a(M),b(M),c(M);
	rep(i,M){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
		dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
	}
	/*
	多点間最短距離を求めるO(V^3)のアルゴリズム。
	距離行列dist[MAX_N][MAX_N]が必要。
	※0-indexにしておく。
	*/
	rep(k,N)rep(i,N)rep(j,N){
			dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
	}
	int ans = M;
	for (int i = 0; i < M; ++i){
		bool shortest = false;
		for (int j = 0; j < N; ++j){
			if(dist[j][a[i]] + c[i] ==dist[j][b[i]]){
				shortest = true;
			}
		}
		if(shortest){
			ans--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) { cin >> A[i] >> B[i]; }
    sort(All(A));
    sort(All(B));
    if(N % 2 == 1) {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    } else {
        int a = A[N / 2] + A[N / 2 - 1];
        int b = B[N / 2] + B[N / 2 - 1];
        cout << b - a + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4832
ls, lt = map(int, input().split())
s = list(input())
t = list(input())
def gcd(m,n):
    if n == 0:
        return m
    else:
        return gcd(n,m%n)
g = gcd(ls,lt)
m = ls // g
n = lt // g
ret = g*m*n
for i in range(g):
    if s[i*m] != t[i*n]:
        ret = -1
        break
print(ret)

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

int N, d[10], field;
char c[128];

int main(){
    while(scanf("%d", &N), N){
        scanf(" %s", c);
        int p = 0;
        fill(d, d+N, 0);
        field = 0;
        for(int i = 0; i < 100;++i, p = ++p%N){
            if(c[i] == 'M'){
                 ++d[p];
            }else if(c[i] == 'S'){
                field += d[p]+1;
                d[p] = 0;
            }else if(c[i] == 'L'){
                d[p] += field+1;
                field = 0;
            }
        }
        sort(d, d+N);
        for(int i = 0; i < N; ++i){
            printf("%d ", d[i]);
        }
        printf("%d", field);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

int n,k;
int res,mx,res1;

int r1[100100];
vector<int>p1[5010];
vector<int>p2[5010];

int main()  {
    cin>>n>>k;
    char t,c;
    int x,y;
    for(int i=0 ;i <n ; i++){
        scanf("%d%d%c%c",&x,&y,&t,&c);
        int r = x/k;
        r %= 2;
        r += (y/k)%2;
        r %= 2;
        if(c == 'B')
            r1[i] = 0;
        else
            r1[i] = 1;
        r1[i] = r1[i] == r;
        int x1 = k-(x%k);
        int y1 = k-(y%k);
        p1[x1].push_back(i);
        p2[y1].push_back(i);
        res +=r1[i];
        res1 +=!r1[i];
    }
    mx = max(mx,res);
    mx = max(mx,res1);
    for(int i=0 ;i <k ;i ++){
        for(int k=0 ;k <p1[i].size() ; k++){
            if(r1[p1[i][k]])res--,res1++;
            else res1--,res++;
            r1[p1[i][k]] = !r1[p1[i][k]];
        }
        for(int j=0 ;j <k; j ++){

            for(int k=0 ;k <p2[j].size() ; k++){
                if(r1[p2[j][k]])res--,res1++;
                else res1--,res++;
                r1[p2[j][k]] = !r1[p2[j][k]];
            }
          //  cout<<res<<" "<<res1<<endl;
            mx = max(mx,res);
            mx = max(mx,res1);
        }
        for(int j=0 ;j <k; j ++){

            for(int k=0 ;k <p2[j].size() ; k++){
                if(r1[p2[j][k]])res--,res1++;
                else res1--,res++;
                r1[p2[j][k]] = !r1[p2[j][k]];
            }
        }
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
 ll a,b,k=0;
 cin>>a>>b;
 for(int i=0;i<b;i++)
 {
   int out;
   cin>>out;
   k=k+out;
 }
  if(k>a)
  {
      cout<<"-1";
  }
  else
  {
      cout<<a-k<<endl;
  }
  
}

Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

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

class CVacation {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;cin >>n;
        vector<vector<int>> data(100010, vector<int>(3));
        vector<vector<int>> dp(100010, vector<int>(3,0));

        rep(i,n){
            cin>>data[i][0]>>data[i][1]>>data[i][2];
        }
        dp[0][0]=data[0][0];
        dp[0][1]=data[0][1];
        dp[0][2]=data[0][2];


        for(int i =1;i<n;++i){
            chmax(dp[i][0],dp[i-1][1]+data[i][0]);
            chmax(dp[i][0],dp[i-1][2]+data[i][0]);
            chmax(dp[i][1],dp[i-1][0]+data[i][1]);
            chmax(dp[i][1],dp[i-1][2]+data[i][1]);
            chmax(dp[i][2],dp[i-1][0]+data[i][2]);
            chmax(dp[i][2],dp[i-1][1]+data[i][2]);
        }

        int maxans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
        cout<<maxans<<endl;

	}
};


int main() {
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(ab[0] * ab[1] == 15)
        {
            Console.WriteLine("*");
        }
        else if (ab[0] + ab[1] == 15)
        {
            Console.WriteLine("+");
        }
        else
        {
            Console.WriteLine("x");
        }
    }
}

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

int main() 
{
	ll n;
	cin >> n;
    ll ans=1e18;
	for(ll i=1; i*i<=n ; i++)
	{
		if( n%i != 0 )
			continue;
		ll j = n/i;
		ans = min(ans,i+ j-2);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define N 2005
using namespace std;

vector<int> a[N];
int n, mx, k, s, c;
void f(int p, int q, int w) {
	int i;
	s++;
	if (q == 0) return;
	for (i = 0; i < a[p].size(); i++) {
		if (a[p][i] != w) f(a[p][i], q - 1, p);
	}
}
int main()
{
	int i, j, t1, t2;
	cin >> n >> k;
	for (i = 0; i < n - 1; i++) {
		scanf ("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	for (c = 1; c <= n; c++){
		if (k % 2 == 0) {
			s = 0;
			f(c, k / 2, -1);
			mx = max(mx, s);
		} else {
			for (j = 0; j < a[c].size(); j++) {
				s = 0;
				f(c, k / 2, a[c][j]);
				f(a[c][j], k / 2, c);
				mx = max(mx, s);
			}
		}
	}
	cout << n - mx;
    return 0;
}


Measured memory_bytes: 384
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	_, m := nextInt(), nextInt()
	score, penalty := 0, 0
	ac := map[int]bool{}
	wa := map[int]int{}

	for i := 0; i < m; i++ {
		p := nextInt()
		s := next()

		if !ac[p] {
			if s == "AC" {
				score++
				penalty += wa[p]
				ac[p] = true
			} else {
				wa[p]++
			}
		}
	}

	fmt.Println(score, penalty)
}


Measured memory_bytes: 7424
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        N: usize,
        s: [i32;N],
    }
    let mut sum = 0;
    let mut non_zero = false;
    let mut non_zero_min = 1_000_000;
    for i in 0..N{
       if s[i] % 10 != 0{
          non_zero = true;
          non_zero_min = min(non_zero_min, s[i]);
       }
       sum += s[i];
    }
    if sum % 10 != 0{
        puts!("{}\n", sum);
    }else if non_zero{
        puts!("{}\n", sum - non_zero_min);
    }else{
        puts!("{}\n", 0);
    }
    


}
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

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

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

	int maxv = 0;
	int minv = 1e9 + 1;

	while (n--) {
		cin >> v;
		maxv = max(maxv, v);
		minv = min(minv, v); 
	}
	cout << maxv - minv;
	return 0;
}

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

int main() {
  
  int a,even,odd;
  cin >> a;
  
  even = a/2;
  if(a%2 == 0) odd = a/2;
  else odd = a/2 + 1;
  
  cout << even*odd << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <list>
#include <queue>
//#include <unordered_map>
#include <algorithm>
//#include <string>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
	int n;
	int i,j,k,m;
	int x,y,z;
	cin>>n;
	int a[n][3];
	int dp[n][3];
	memset(dp,0,sizeof(dp));

	for(i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	if(n < 2)
	{
		x=max(a[0][0],max(a[0][1],a[0][2]));
		cout<<x<<"\n";
		return 0;
	}
	for(i=0;i<3;i++)
	{
		dp[0][i]=a[0][i];
	}
	/*for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<"\n";
	}

	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][0],a[i][0]+max(dp[i-1][1],dp[i-1][2]));
		dp[i][1]=max(dp[i-1][1],a[i][1]+max(dp[i-1][0],dp[i-1][2]));
		dp[i][2]=max(dp[i-1][2],a[i][2]+max(dp[i-1][0],dp[i-1][1]));
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";	
	}
	x=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	/*for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	cout<<x<<"\n";
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			String t=in.nextLine();
			ArrayList<String> AL=new ArrayList<String>();
			if(n==0)
				return;
			for(int i=0;i<n;i++)
			{
				String s[]=in.nextLine().split(" ");
				for(int j=0;j<s.length;j++)
					AL.add(s[j]);
			}
			String se=in.next();
			for(int i=0;i<AL.size();i++)
				if(se.charAt(0)!=AL.get(i).charAt(0))
				{
					AL.remove(i);
					i--;
				}
			if(AL.isEmpty())
			{
				System.out.println("NA");
				continue;
			}
			Collections.sort(AL);
			int count[]=new int[AL.size()];
			for(int i=0;i<AL.size()-1;i++)
			{
				while(i+1<AL.size()&&AL.get(i).equals(AL.get(i+1)))
				{
					count[i]++;
					AL.remove(i);
				}
			}
			ArrayList<Integer> cou=new ArrayList<Integer>();
			for(int i=0;i<count.length;i++)
				cou.add(count[i]);

			ArrayList<String> ANS=new ArrayList<String>();
			while(!AL.isEmpty())
			{
				int m=0;
				for(int j=0;j<cou.size();j++)
				{
					if(cou.get(m)<cou.get(j))
						m=j;
				}
				ANS.add(AL.get(m));
				AL.remove(m);
				cou.remove(m);
			}
			int p=0;
			for(int i=0;i<ANS.size();i++)
			{
				if(p==0)
					System.out.print(ANS.get(i));
				else
					System.out.print(" "+ANS.get(i));
				if(i>3)
					break;
				p=1;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

int main(){

	string table[10] = { "#", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

	int n;

	cin >> n;

	for(int i=0;i<n;i++){
		string str;
		int count=0;
		cin >> str;

		for(int k=0;k<str.length();k++){
			if(str[k] == str[k+1]){
				count++;
			}else{
				string str2 = table[(str[k]-'0')];
				char word = str2[ count % (str2.length()) ];
				if(word != '#'){ cout << word; }
				count=0;
			}
		}

		cout << endl;
	}


}

Measured memory_bytes: 1216
#include "bits/stdc++.h"

using namespace std;

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

    queue<string> name_que;
    queue<int> time_que;
    for (int i = 0; i < n; i++) {
        string name;
        int t;
        cin >> name >> t;
        name_que.push(name);
        time_que.push(t);
    }

    int elapsed_time = 0;
    while (!name_que.empty()) {
        string name = name_que.front();
        name_que.pop();
        int t = time_que.front();
        time_que.pop();

        if (t > q) {
            elapsed_time += q;
            int r = t - q;
            name_que.push(name);
            time_que.push(r);
        } else {
            elapsed_time += t;
            cout << name << " " << elapsed_time << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
const int maxn=10050;
const double eps=1e-8;
const double pi = acos(-1);

struct point{
	double x,y;
	int id;
	point(double x0=0,double y0=0,int id0=0){
		x=x0;y=y0;id=id0;
	}
};

typedef point vctor;

vctor operator + (vctor a,vctor b){
	return vctor(a.x+b.x,a.y+b.y);
}
vctor operator - (vctor a,vctor b){
	return vctor(a.x-b.x,a.y-b.y);
}
vctor operator * (vctor a,double k){
	return vctor(a.x*k,a.y*k);
}
vctor operator / (vctor a,double k){
	return vctor(a.x/k,a.y/k);
}
bool operator == (point a,point b){
	return a.x==b.x&&a.y==b.y;
}

point p[maxn],res[maxn],d[maxn],tmp[maxn],q;
int cnt,n,m,r;

int sig(double x){
	return fabs(x)<eps?0:(x>0)?1:-1;
}

double dot(point a,point b,point c){
	return (b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y);
}

double cross(point a,point b,point c){
	return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}

double dist(point a,point b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

double angle(point a,point b,point c){
	return acos(dot(a,b,c)/(dist(a,b)*(dist(a,c))));
}

int cmp2(point a,point b){
	return a.y<b.y||a.y==b.y&&a.x<b.x;
}
int convex(int n,point p[]){
	 int now=1;
	 for(int i=1;i<=n;i++){
	 	while(now>2&&sig(cross(res[now-2],p[i],res[now-1]))>0)now--;
	 	res[now++]=p[i];
	 }
	 int k=now;
	 for(int i=n-1;i>=1;i--){
	 	while(now>k&&sig(cross(res[now-2],p[i],res[now-1]))>0)now--;
	 	res[now++]=p[i];
	 }
	 if(n>1)now--;
	 return now-1;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
        p[i].id=i;
        cin>>p[i].x>>p[i].y;
    }
	if(n==2)
        return cout<<0.5<<"\n"<<0.5<<endl,0;
	sort(p+1,p+1+n,cmp2);
	int howmany=convex(n,p);
	double ans[200]={0};
	for(int i=1;i<=howmany;i++){
        int j=i+1,k=i-1;
        if(j>howmany)j=1;
        if(k==0)k=howmany;
        ans[res[i].id] = max(angle( res[i],res[j],res[k] )-pi,pi - angle( res[i],res[j],res[k] ));
    }
    double all =2*pi;
    for(int i=1;i<=n;i++){
        printf("%.8f\n",ans[i]/all);
    }
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> B(n-1), A(n);
  for (int i = 0; i < n-1; i++){
    cin >> B[i];
    A[i] = 0;
  }
  A[0] = B[0];
  for (int i = 1 ; i < n-1; i++){
    if (B[i] < B[i-1]) A[i] = B[i];
    else A[i] = B[i-1];
  }
  A[n-1] = B[n-2];
  int cnt = 0;
  for (int i = 0; i < n; i++){
    cnt += A[i];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256