akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>

using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
const int M = 1e6 + 5;
const int N = 2e5 + 5;
int n, a, ans, maxx, minn = INT_MAX;
int b[M];
map<int, int>mp;
int main() {
	n = read();
	for_int(i, 1, n) {
		a = read();
		if (b[a] == 0) {
			b[a] = 1;
			maxx = max(a, maxx);
			minn = min(minn, a);
		}
		else b[a] = -2;
	}
	for (int i = minn; i <= maxx; ++i) {
		if (b[i] == 1) {
			ans++;
			for (int j = 2; j * i <= maxx; ++j)
				b[j * i] = -1;
		}
		else if (b[i] == -2) {
			for (int j = 2; j * i <= maxx; ++j)
				b[j * i] = -1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int n, key = 0, k = 0, i, j, flag;
  int *data;

  scanf("%d", &n);

  data = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++) scanf("%d", &data[i]);

  flag = 1;
  while(flag){
    flag = 0;
    for(i = n - 1; i >= 1; i--){
      if(data[i] < data[i - 1]){
	key = data[i - 1];
	data[i - 1] = data[i];
	data[i] = key;
	flag = 1;
	k++;
      }
    }
  }
  for(i = 0; i < n - 1; i++) printf("%d ", data[i]);

  printf("%d\n", data[n - 1]);
  printf("%d\n", k);

  return 0;
}

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

int main(){

  string s1, s2;
  cin >> s1;
  cin >> s2;

  int size1 = (int)s1.size();
  int size2 = (int)s2.size();
  
  for(int i = min(size1, size2); i >= 1; i--){
    set<vector<int>> us;
    
    vector<int> cnt(26, 0);
    for(int j = 0; j < i; j++){
      int index = s1[j] - 'a';
      cnt[index]++;
    }

    for(int j = i; j <= size1; j++){
      us.insert(cnt);

      if(j == size1){
	break;
      }

      int indexMinus = s1[j - i] - 'a';
      cnt[indexMinus]--;
      int indexPlus = s1[j] - 'a';
      cnt[indexPlus]++;
    }

    vector<int> cnt2(26, 0);
    for(int j = 0; j < i; j++){
      int index = s2[j] - 'a';
      cnt2[index]++;
    }

    for(int j = i; j <= size2; j++){
      if(us.find(cnt2) != us.end()){
	cout << i << endl;
	return 0;
      }

      if(j == size2){
	break;
      }

      int indexMinus = s2[j - i] - 'a';
      cnt2[indexMinus]--;
      int indexPlus = s2[j] - 'a';
      cnt2[indexPlus]++;
    }
  }

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



Measured memory_bytes: 3856
# LCS(Longest common subsequence)
s = input()
t = input()

def lcs(str1, str2):
    len1, len2 = len(str1), len(str2)
    lcs_dp = [[0]*(len2+1) for i in range(len1+1)]
    for i in range(len1-1, -1, -1):
        for j in range(len2-1, -1, -1):
            r = max(lcs_dp[i+1][j], lcs_dp[i][j+1])
            if str1[i] == str2[j]:
                r = max(r, lcs_dp[i+1][j+1]+1)
            lcs_dp[i][j] = r
    res = []
    i, j = 0, 0
    while i < len1 and j < len2:
        if str1[i] == str2[j]:
            res.append(str1[i])
            i += 1; j += 1
        elif lcs_dp[i][j] == lcs_dp[i+1][j]:
            i += 1
        elif lcs_dp[i][j] == lcs_dp[i][j+1]:
            j += 1
    return ''.join(res)

print(lcs(s, t))

Measured memory_bytes: 144440
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int h, w, cnt = 0;
	vector<string>slist;
	bool matrix[2002][2002];

	memset(matrix, false, sizeof(matrix));

	cin >> h >> w;

	string sss = "aaaa";
	slist.push_back(sss);

	for (int i = 0; i < h; i++) {
		string s = "a";
		string ss;
		cin >> ss;
		s += ss;
		slist.push_back(s);

		for (int j = 0; j < s.length(); j++) {
			if (s[j] == '.') {
				matrix[i + 1][j] = true;
			}
		}
	}

	const int U = 0;
	const int R = 1;
	const int D = 2;
	const int L = 3;

	int flag[2002][2002][4];
	int maxn = 0;
	//vector<vector<int>>ans(2002, vector<int>(2002, 0));

	for (int i = 0; i <2002; i++) {
		for (int j = 0; j < 2002; j++) {
			for (int k = 0; k < 4; k++) {
				flag[i][j][k] = -1;
			}
		}
	}

	for (int i = 1; i <= h; i++) {
		int ima = 0;
		for (int j = 1; j <= w; j++) {
			if (matrix[i][j] == true) {
				ima++;
				flag[i][j][L] = ima;
			}
			else {
				ima = 0;
			}
		}
	}

	for (int i = 1; i <= h; i++) {
		int ima = 0;
		for (int j = w; j >= 1; j--) {
			if (matrix[i][j] == true) {
				ima++;
				flag[i][j][R] = ima;
			}
			else {
				ima = 0;
			}
		}
	}


	for (int i = 1; i <= w; i++) {
		int ima = 0;
		for (int j = 1; j <= h; j++) {
			if (matrix[j][i] == true) {
				ima++;
				flag[j][i][U] = ima;
			}
			else {
				ima = 0;
			}
		}
	}

	for (int i = 1; i <= w; i++) {
		int ima = 0;
		for (int j = h; j >= 1; j--) {
			if (matrix[j][i] == true) {
				ima++;
				flag[j][i][D] = ima;
			}
			else {
				ima = 0;
			}
		}
	}

	for (int i = 0; i <2002; i++) {
		for (int j = 0; j < 2002; j++) {
			int sum = 0;
			for (int k = 0; k < 4; k++) {
				sum += flag[i][j][k];
			}
			maxn = max(maxn, sum - 3);
		}
	}


	cout << max(maxn, 0 ) << endl;


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 70784
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int[] a = new int[5];
	int mn;

	while(sc.hasNext()){
	    mn = 5000;
	    for(int i = 0; i < 5; ++i)
		a[i] = sc.nextInt();

	    for(int i = 0; i < 3; ++i)
		for(int j = 3; j < 5; ++j)
		    mn = Math.min(mn, a[i]+a[j]-50);

	    System.out.printf("%d\n", mn);
	}
    }

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

Measured memory_bytes: 0
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (Long i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
vector<Long> v;
const int MX = 1000;
void init() {
  fore(i, -MX, MX) {
    Long val = i;
    Long ans = val * val * val;
    ans *= val;
    ans *= val;
    v.pb(ans);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  init();
  sort(all(v));
  Long x;
  cin >> x;
  fore(i, 0, SZ(v)) {
    Long val = v[i];
    Long extra = x + val;
    int p = lower_bound(all(v), extra) - v.begin();
    if (p < SZ(v) && v[p] == extra) {
      cout << p - MX << " " << i - MX << endl;
      return 0;
    }
  }
  assert(false);

  return 0;
}

Measured memory_bytes: 3688
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int x, n; cin >> x >> n;
	
	vector<int> tb(200);
	for (int i = 0; i < n; i++) {
		int v; cin >> v;
		tb[v] = 1;
	}

	int ans = 0;
	int d = 1000;
	for (int i = 0; i < 120; i++) {
		if (tb[i] == 1)continue;

		if (abs(x - i) < d) {
			d = abs(x - i);
			ans = i;
		}
	}

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  ll N,M; cin >> N >> M;
  if ( N==1 && M== 1 ) {
    cout << 1 << endl;
    return 0;
  }
  
  if ( N == 1 || M == 1 ) {
    if ( N == 2 || M == 2 ) cout << 0 << endl;
    else if ( N >= 3 || M >= 3 ) cout << max(N,M)-2 << endl;
    return 0;
  } 

  if ( N  == 2 || M == 2 ) {
    if ( N ==1  || M == 1 ) cout << 0 << endl;
    else  cout << 0 << endl;
    return 0;
  }
  
  cout << (N-2) * (M-2) << endl;
  return 0;
}


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

int main() {

    // https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361#6-bit-%E5%85%A8%E6%8E%A2%E7%B4%A2
    /*
    for(int bit = 0; bit < (1<<5); bit++) {
        vector<int> S;
        for(int i = 0; i < 5; i++) {
            if(bit & (1<<i)) {
                S.push_back(i);
            }
        }

        cout << bit << ": {";
        for(auto x : S) {
            cout << x << ' ';
        }
        cout << "}" << endl;
    }
     */

    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    for(int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int ss; cin >> ss;
            s[i].push_back(ss);
        }
    }

    vector<int> p(m);
    for(int i = 0; i < m; i++) cin >> p[i];

    vector<bool> isOn(n);

    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++) {
        for(int i = 0; i < n; i++) {
            if(bit & (1<<i)) isOn[i] = true;
            else isOn[i] = false;
        }
        
        /*
        cout << bit << ": ";
        for(auto x: isOn) {
            cout << x << ' ';
        }
        cout << endl;
        */
        
        int cnt = 0;
        for(int i = 0; i < m; i++) {
            int on = 0;
            for(int j = 0; j < s[i].size(); j++) {
                if(isOn[s[i][j] - 1]) on++;
            }
            if(on % 2 == p[i]) cnt++;
            else break;
        }

        if(cnt == m) {
            ans++;
            // cout << "Yes" << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import chain
n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
for i in x:
    i.pop(0)
x = list(chain.from_iterable(x))
cnt = 0
for i in range(1,m+1):
    if x.count(i)==n:
            cnt += 1
print(cnt)   

Measured memory_bytes: 3064
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    let mut mat: Vec<Vec<u64>> = Vec::new();
    let nums: Vec<u64> = get_line().trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let (r, c) = (nums[0], nums[1]);
    for _ in 0..r {
        let mut nums: Vec<u64> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let sum = nums.iter().fold(0, |sum, x| sum + x);
        nums.push(sum);
        mat.push(nums);
    }
    let mut v: Vec<u64> = vec![0;(c + 1) as usize];
    for row in &mat {
        for (i, n) in row.iter().enumerate() {
            v[i] += *n;
        }
    }
    mat.push(v);
    for row in &mat {
        for (i, v) in row.iter().enumerate() {
            print!("{}", v);
            if i != row.len() - 1 {
                print!(" ");
            }
        }
        println!("");
    }

}



Measured memory_bytes: 5048
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)

Measured memory_bytes: 24812
#include<iostream>
using namespace std;
#define MAX 25

struct Node{
    int parent,left,right;
};

Node T[MAX];
int s,D[MAX],H[MAX];

void array_init(Node A[],int s){
    for(int i=0;i<s;++i){
        A[i].left=A[i].right=A[i].parent=-1;
    }
}

void get_depth(int u, int p){
    if(u==-1) return;
    D[u]=p;
    get_depth(T[u].left,p+1);
    get_depth(T[u].right,p+1);
}

int get_sibling(int u){
    if(T[u].parent==-1) return -1;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=-1) return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=-1) return T[T[u].parent].right;
    return -1;
}

int get_height(int u){
    int h1=0,h2=0;
    if(T[u].left!=-1) h1=get_height(T[u].left)+1;
    if(T[u].right!=-1) h2=get_height(T[u].right)+1;
    H[u]=(h1>h2?h1:h2);
    return H[u];
}

void print(int u){
    int deg=0;
    cout<<"node "<<u<<": parent = "<<T[u].parent<<", sibling = "<<get_sibling(u);
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    cout<<", degree = "<<deg<<", depth = "<<D[u]<<", height = "<<H[u]<<", ";
    if(T[u].parent==-1)cout<<"root"<<endl;
    else if(T[u].left==-1&&T[u].right==-1)cout<<"leaf"<<endl;
    else cout<<"internal node"<<endl;
}
int main(){
    int num,root,left,child,right;
    cin >> s;
    array_init(T,s);
    for(int i=0;i<s;i++){
        cin >> num>>left>>right;
        T[num].left=left;
        T[num].right=right;
        if(T[num].left!=-1)T[left].parent=num;
        if(T[num].right!=-1)T[right].parent=num;
    }
    for(int i=0;i<s;i++){
        if(T[i].parent==-1) root=i;
    }
    get_depth(root,0);
    get_height(root);
    for(int i=0;i<s;++i) print(i);
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

#define pb push_back 

const int mo = 1e9 + 7;
const int N = 1e5 + 10;
int n, k, ans = 1, son[N], f[N];
vector<int> G[N];

void dfs(int u, int fa = 0) {
	f[u] = fa;
	int d = k;
	if(f[u]) d --;
	if(f[f[u]]) d --;
	if(f[u]) d -= son[f[u]] - 1;
	if(d < 0) d = 0;
	ans = 1ll * ans * d % mo;
//	printf("u = %d; d = %d\n", u, d);
	for(int v : G[u]) if(v != fa) {
		son[u] ++; dfs(v, u);
	}
	
}

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i < n; i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
	}
	dfs(1);
	printf("%d\n", ans);
	return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[110];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	int k,mi;
	for(int i=0;i<n-1;i++){
		mi=a[i+1];
		k=i+1;
		for(int j=i+1;j<n;j++){
			if(a[j]<mi){
				k=j;
				mi=a[j];
			}
			
		}
		if(a[i]>mi){
			ans++;
			int l=a[i];
			a[i]=a[k];
			a[k]=l;
			
		}
		
	}
	
	
	for(int i=0;i<n-1;i++)cout<<a[i]<<" ";
	cout<<a[n-1]<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll n;
vector<string> ans;
void dfs(ll pos, ll type, string s) {
    if(pos == n) {
        ans.push_back(s);
        return;
    }

    REP(i, type) dfs(pos+1, type, s+(char)(i+'a'));
    dfs(pos+1, type+1, s+(char)(type+'a'));
}

int main(void) {
    cin >> n;
    dfs(1, 1, "a");

    sort(ALL(ans));
    ans.erase(unique(ALL(ans)), ans.end());
    REP(i, ans.size()) cout << ans[i] << "\n";

    return 0;
}

Measured memory_bytes: 7796
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

ll countDivisors(ll n) { 
  ll cnt = 0; 
  for (ll i = 1; i * i <= n; i++) { 
    if (n % i == 0) { 
      if (n / i == i) 
        cnt++; 
      else 
        cnt = cnt + 2; 
    } 
  } 
  return cnt; 
} 

int main(){
  FASTIO;
  ll n; cin >> n;
  ll ans = 0;
  for ( ll a = 1; a < n; a++ ) {
    ll mnc = n / a;
    if (n % a == 0)
      mnc--;
    ans += mnc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

map<ll, ll> m[200002];
map<ll, bool> used[200002];

vector<long long> A(200002);
long long N;

ll rec(ll n, ll k) {
    if (n <= 0 && k == 0) return 0;
    if ((n + 1) / 2 < k || n <= 0 || k < 0) return -99999999999999999;

    if (used[n][k]) {
        return m[n][k];
    }

    m[n][k] = max(A[N - n] + rec(n - 2, k - 1), rec(n - 1, k));
    used[n][k] = true;
    return m[n][k];
}

int main() {
    scanf("%lld", &N);

    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &A[i]);
    }
    // ll res = 0;
    // ll now = 0;
    // if (N % 2 == 0) {
    //     now = 0;
    //     rep(i, N) {
    //         if (i % 2 == 0) now += A[i];
    //     }
    //     res = max(res, now);
    //     now = 0;
    //     rep(i, N) {
    //         if (i % 2 == 1) now += A[i];
    //     }
    //     res = max(res, now);
    //     cout << res << endl;
    // } else {
    //     cout << rec(N, N / 2) << endl;
    // }
    cout << rec(N, N / 2) << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	string s;
	cin >> s;
	char alpha;
	alpha = s[0];
	if (isupper(alpha) )
		cout << 'A' << endl;
	else if (islower(alpha))
		cout << 'a' << endl;
	
	return 0;
}


Measured memory_bytes: 3624
n=gets.to_i
a=gets.split.map(&:to_i)
s=a.sum
l=[0]*100001
a.each do |i|
  l[i]+=1
end
q=gets.to_i
q.times do
  b,c=gets.split.map(&:to_i)
  s+=(c-b)*l[b]
  puts s
  l[c]+=l[b]
  l[b]=0
end




Measured memory_bytes: 22176
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;


//dp[i][j]はi個残りj番目からの状態での最善
lli dp[3002][3002];

int main(){
	int N;
	cin>>N;
	lli a[3002];
	rep1(i,N)cin>>a[i];
	
	rep1(j,N)dp[1][j]=a[j];
	for(int i=2;i<=N;i++)rep1(j,N){
		if(i+j-1>N)break;
		dp[i][j]=max(a[i+j-1]-dp[i-1][j],a[j]-dp[i-1][j+1]);
	}
	cout<<dp[N][1];
}

Measured memory_bytes: 70016
#include<iostream>
using namespace std;
int main(){
	char a;
	char b;
	cin>>a>>b;
	if(a=='H'&&b=='H'){
	cout<<"H";
}
	else if(a=='D'&&b=='D'){
	cout<<"H";
}
	else {
	cout<<"D";
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int M;

int main() {
	cin >> M;
	cout << 48 - M << endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
int ans=1;
int n;
cin>>n;
    for (int i = 1; i <=n ; ++i) {
        ans=(ans%mod*(i))%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 256
//
// Created by Ильдар Ялалов on 14.01.2020.
//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double dbl;
typedef unsigned int uint;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()


#ifdef zxc

#include "debug.h"

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool debug = 0;
const int MAXN = (1e6) + 100;
const int LOG = 21;
const int mod = 1e9 + 7;
const int MX = (3e7 + 100);


int a[MAXN];

int get(int x, int n) {
    int res = x % n;
    while (res < 0)
        res += n;
    while (res >= n)
        res -= n;
    return res;
}

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
    }
    ll val = 1ll * n * (n + 1) / 2;

    if (sum % val != 0) {
        cout << "NO\n";
        return;
    }
    val = sum / val;
    int cnt = 0;

    for (int i = 0; i < n; ++i) {
        int nxt = (i + 1) % n;
        ll cur = a[nxt] - a[i];

        cur = val - cur;
        
        if (cur < 0 || get(cur,n) != 0) {
            cout << "NO\n";
            return;
        }

    }
    if (cnt > 1) {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
}

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

#ifdef zxc
    freopen("../input.txt", "r", stdin);
//    freopen("../output.txt", "w", stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(15);


    int t = 1;
    while (t--) {
        solve();
    }
    debug(1.0 * clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    int L[2220];
    for(int i = 1;i <= N;i++){
        cin >> L[i];
    }
    sort(L + 1, L + N + 1);
    int ans = 0;
    for(int i = 3;i <= N;i++){
        for(int j = 2;j < i;j++){
            for(int k = j - 1;k > 0;k--){
                if(L[i] < L[j] + L[k])ans++;
                else{break;}
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//g++ -std=c++11
//g++ -std=c++1z 

using namespace std;

typedef long long ll;
const long long INF = 1e18+10;

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

    int a,b;
    cin >> a >> b;

    if(a<=b)
    	cout << "unsafe" << endl;
    else 
    	cout << "safe" << endl;
    
    return 0;
}


Measured memory_bytes: 3652
n = gets(chomp:true).to_i
a = gets.split.map(&:to_i)
q = gets(chomp:true).to_i

q.times do

  b, m, e = gets.split.map(&:to_i)
  k = e - b
  k_temp = a[b,k]

  k.times do |k|
    r_idx = b + (k + (e - m)) % (e - b)
    a[r_idx] = k_temp[k]
  end
end

puts a.join(" ")


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

struct Node{
  int key;
  struct Node *parent, *left, *right;
};

struct Node *root, *NIL;


struct Node *find(struct Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  
  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;

    }
  }
}


void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[10];
  
  scanf("%d",&n);

  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

const int INF = (int)1e9;
VI A, B, C;
int n, ma, mb;

bool chk(int d, int e) {
	if(d == 0 && e == 0) return false;
	int div = __gcd(d, e);
	return d / div == ma && e / div == mb;
}

int DP[50][500][500];
int minPrice(int i, int a, int b)
{
	if(i == n)
		return chk(a, b) ? 0 : INF;
	
	int& ret = DP[i][a][b];
	if(ret != -1)
		return ret;
	
	ret = INF;
	ret = min(minPrice(i + 1, a + A[i], b + B[i]) + C[i],
	 minPrice(i + 1, a, b));
	return ret;
}

int bottomUp()
{
	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> ma >> mb;
	
	A = B = C = VI(n);
	REP(i, 0, n) 
		cin >> A[i] >> B[i] >> C[i];

	CLEAR(DP, -1);
	int ans = minPrice(0, 0, 0);
	cout << (ans == INF ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 49152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
string s;
ll n,dp[100006][120];

int main()
{
    cin>>s;
    n=s.size();
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]!='?'){ 
           for(int k=0;k<13;k++){ 
                dp[i+1][(k*10+(s[i]-'0'))%13]+=dp[i][k];
                dp[i+1][(k*10+(s[i]-'0'))%13]%=mod;
            }
        }
        else if(s[i]=='?'){ 
            for(int j=0;j<=9;j++){ 
                for(int k=0;k<13;k++){ 
                dp[i+1][(k*10+j)%13]+=dp[i][k];
                dp[i+1][(k*10+j)%13]%=mod;
                }
            }
        }
    }
    cout<<dp[n][5]<<'\n';
        
    
        
    return 0;
}


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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n, mean = 0, ans[2] = {};
	cin >> n;
	int X[n];
	for (int i = 0; i < n; ++i) {
		cin >> X[i];
		mean += X[i];
	}
	mean /= n;

	for (int i = 0; i < n; ++i) {
		ans[0] += (mean - X[i]) * (mean - X[i]);
		ans[1] += (mean + 1 - X[i]) * (mean + 1 - X[i]);
	}

	cout << min(ans[0], ans[1]) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
	int a, b;
	cin >> a >> b;

    cout << 100 << " " << 100 << "\n";
	
	int pt = b-1;
	rep(i, 50) {
		rep(j, 100) {
			if(i%2 == 0 && j%2 == 0 && pt > 0) {
                cout << '#';
                pt--;
            }
			else {
                cout << '.';
            }
		}
		cout << "\n";
	}

	pt = a-1;
	rep(i, 50) {
		rep(j, 100) {
			if(i%2 == 1 && j%2 == 0 && pt > 0) {
                cout << '.';
                pt--;
            }
			else {
                cout << '#';
            } 
		}
		cout << "\n";
	}

    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;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}

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

     int n;
     cin>>n;
   vector<int>a(n);
   rep(i,n)cin>>a.at(i);
   
   reverse(a.begin(),a.end());

   rep(i,n-1)cout<<a.at(i)<<" ";
   cout<<a.at(n-1)<<endl;

 
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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


using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    int n; cin >> n;
    vector<string> s(n),c(n);
    vector<int> p(n),w(101);
    priority_queue<int> t;

    rep(i,n){
        cin >> s[i] >> p[i];
        c[i] = s[i];
        w[p[i]] = i;
    }

    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());

    rep(i,s.size()){
        rep(j,c.size()){
            if(s[i] == c[j]) t.push(p[j]);
        }
        while(! t.empty()){
            cout << w[t.top()]+1 << endl;
            t.pop();
        }
    }

    return 0;
}











Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final String varT = sc.next();
        final String varS = sc.next();
        sc.close();

        int Tlen = varT.length();
        int cnt = 0;
        for (int i = 0; i < Tlen; i++) {
            if (varT.charAt(i) != varS.charAt(i)) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 41108
// C - Dubious Document 2
#include <bits/stdc++.h>
using namespace std;
string S, T;

string solve(){
	int sn = S.size(), tn = T.size();
	for(int i=sn-tn; i>=0; --i){
		bool exist = true;
		for(int j=0; j<tn; ++j) if(S[i+j] != '?' && S[i+j] != T[j]){ exist  = false; break; }
		if(exist){
			string ans;
			for(int j=0; j<i; ++j) if(S[j] == '?') ans+='a'; else ans+=S[j];
			ans += T;
			for(int j=i+tn; j<sn; ++j) if(S[j] == '?') ans+='a'; else ans+=S[j];
			return ans;
		}
	}
	return "UNRESTORABLE";
}

int main(){
	cin>>S>>T;
	cout<< solve() <<endl;
}

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

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

const int N = 1010;
const int K = 31;
int n, x[N], y[N];

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
char direction[] = "DURL";

bool valid(ll X, ll Y, int S) {
  if (!X && !Y) return 1;
  return ((X + Y) & 1) &&
         (-S + 1 <= abs(X) + abs(Y) && abs(X) + abs(Y) <= S - 1);
}

int main() {
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  int parity = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &x[i], &y[i]);
    parity |= 1 << ((x[i] + y[i]) & 1);
  }

  if (parity == 3) {
    puts("-1");
    return 0;
  }

  vector<int> d(K);
  for (int i = 0; i < K; ++i) d[i] = 1 << i;

  if (parity == 1) {
    d.push_back(1);
    for (int i = 1; i <= n; ++i) --x[i];
  }

  printf("%d\n", d.size());
  for (int x : d) printf("%d ", x);
  puts("");

  for (int j = 1; j <= n; ++j) {
    ll X = x[j], Y = y[j];
    string S = parity == 1 ? "R" : "";

    for (int i = K - 1; i >= 0; --i) {
      for (int k = 0; k < 4; ++k) {
        ll XX = X + dx[k] * d[i];
        ll YY = Y + dy[k] * d[i];

        if (valid(XX, YY, d[i])) {
          X = XX, Y = YY;
          S += direction[k];
          break;
        }
      }
    }

    reverse(S.begin(), S.end());
    printf("%s\n", S.c_str());
  }

  return 0;
}


Measured memory_bytes: 3776
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int BIG = 1e9;
bool counted[103][103][103];
int jar[103][103][103];

int f(int a, int b, int c)
{
	if(a < 0 || b < 0 || c < 0 || a > 100 || b > 100 || c > 100)
		return BIG;
	else if(counted[a][b][c])
		return jar[a][b][c];
	else
	{
		counted[a][b][c] = 1;
		jar[a][b][c] = min(f(a-1,b-1,c),f(a,b-1,c-1));
		jar[a][b][c] = min(jar[a][b][c],f(a-1,b,c-1));
		jar[a][b][c] = min(jar[a][b][c],f(a,b,c-2));
		jar[a][b][c] = min(jar[a][b][c],f(a,b-2,c));
		jar[a][b][c] = min(jar[a][b][c],f(a-2,b,c));
		return jar[a][b][c] = jar[a][b][c] + 1;
	}

}

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	counted[a][b][c] = 1;
	jar[a][b][c] = 0;
	int mn = BIG;
	for(int i = 0; i <= 100; i++)
		mn = min(f(i,i,i), mn);
	printf("%d\n", mn);
}





Measured memory_bytes: 5504
#include <cstdio>
#include <cstring>
int data[200];
int main()
{
    memset(data, 0, sizeof(data));
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    for (int i = a; i <= b; i++) data[i]++;
    for (int i = c; i <= d; i++) data[i]++;
    int ans = 0;
    for (int i = 0; i <= 100; i++) if (data[i] == 2) ans++;
    ans--;
    if (ans < 0) ans = 0;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct segment{
  point a,b;
};

double areaPol(vector<point> t, int n){
  t.push_back(t[0]);
  int tsz=t.size();
  double area=0;
  for(int i=0;i<tsz-1;i++){
    area+=(t[i].x-t[i+1].x)*(t[i].y+t[i+1].y);
  }
  return abs(area)/2.0;
}

int main(void){
  point p;
  vector<point>t;
  int n=0;
  double x,y;
  char k;

  while(cin>>x>>k>>y){
    p.x = x;
    p.y = y;
    t.push_back(p);
    n++;
 }

  printf("%.6f\n",areaPol(t,n));

  return 0;
}

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

int n;
int h[200010];
int a[200010];
long long int loga[200010];

void update(int x, long long int y) {
    x ++;
    for (x; x <= n; x += x & -x) loga[x] = max(loga[x], y);
}

long long int query(int x) {
    long long int out = 0;
    x ++;
    for (x; x > 0; x -= x & -x) out = max(out, loga[x]);
    return out;
}

int main () {

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

    long long int maxi = 0;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        long long int sol = query(h[i]-1);
        sol += a[i];
        maxi = max(maxi, sol);

        update(h[i], sol);
    }

    cout << maxi;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int main(int argc, char *argv[])
{
    int a, b;
    vector<tuple<int, int>> input_list;
    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        input_list.push_back(tuple<int, int>(a, b));
    }

    for (tuple<int, int> t : input_list)
    {
        if (get<0>(t) > get<1>(t))
            cout << get<1>(t) << " " << get<0>(t) << endl;
        else
            cout << get<0>(t) << " " << get<1>(t) << endl;
    }

    return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=105;
int n;
int a[Maxn*Maxn];
int res[Maxn][Maxn];
int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int nowx=1,nowcnt=0;
	for (int i=0;i<h;i++){
		if (i%2==0){
			for (int j=0;j<w;j++){
				if (nowcnt==a[nowx]){
					nowx++;
					nowcnt=0;
				}
				res[i][j]=nowx;
				nowcnt++;
			}
		}
		else{
			for (int j=w-1;j>=0;j--){
				if (nowcnt==a[nowx]){
					nowx++;
					nowcnt=0;
				}
				res[i][j]=nowx;
				nowcnt++;
			}
		}
	}
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			printf("%d ",res[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 a[4][4];
i32 oy[4] = { 0, -1, 0, 1 };
i32 ox[4] = { -1, 0, 1, 0 };

bool solve() {
    indef(str, n);
    return n[0] == n[2];
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    out(solve() ? "Yes" : "No");

#ifdef _MSC_VER
    /**/
    /**/
#endif
    return 0;
}

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

int first[4], second[4], ans[4];

int table[4][4] = {
    {1, 2, 3, 4},
    {2, -1, 4, -3},
    {3, -4, -1, 2},
    {4, 3, -2, -1}
};

void calc(){
    for(int i = 0; i < 4; i++)  ans[i] = 0;
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            int judge = table[i][j];
            if(judge < 0)   ans[abs(judge)-1] -= first[i]*second[j];
            else            ans[abs(judge)-1] += first[i]*second[j];
        }
    }
}
int main(){
    while(1){
        int n;
        cin >> n;
        
        if(n == 0)  break;
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 4; j++)  cin >> first[j];
            for(int j = 0; j < 4; j++)  cin >> second[j];
            calc();
            for(int j = 0; j < 4; j++){
                if(j)   cout << " ";
                cout << ans[j];
            }
            cout << endl;
        }
        
    }
    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  ll ans = 1;
  REP(i,N){
    if(ans<=K){
      ans *= 2;
    }else{
      ans += K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	string S; cin >> S;
	map<char, int> cnt;
	rep(i, 0, S.length())cnt[S[i]]++;
	bool flag1 = false, flag2 = false;
	if ((cnt['S'] > 0 && cnt['N'] > 0) || (cnt['S'] == 0 && cnt['N'] == 0))flag1 = true;
	if ((cnt['W'] > 0 && cnt['E'] > 0) || (cnt['W'] == 0 && cnt['E'] == 0))flag2 = true;
	
	if (flag1&&flag2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256