akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  string s,t;
  cin>>s;
  cin>>t;

  //cout << s << endl;
  //cout << t << endl;

  int t_match=0;
  vector<string> cand(0);

  vector<int> start(0);

  for(int i=0;i<s.size();i++){
    t_match=0;
    for(int j=0;j<t.size() && i+j<s.size();j++){
      if( s[i+j] == t[t_match] || s[i+j]=='?' ){
        if( t_match == t.size()-1 ){
          start.push_back( i+j-t.size()+1 );
        }
        else{
          t_match++;
        }
      }
      else{
        break;
      }
    }
  }

  for(int i=0;i<start.size();i++){
    //cout << start[i] << endl;
  }
  if(!start.size()){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    for(int i=0;i<start.size();i++){
      string tmp_s=s;
      for(int j=0;j<t.size();j++){
        tmp_s[start[i]+j]=t[j];
      }
      for(int j=0;j<s.size();j++){
        if(tmp_s[j]=='?'){
          tmp_s[j]='a';
        }
      }
      //cout << tmp_s << endl;
      cand.push_back(tmp_s);
    }
    sort(cand.begin(),cand.end());
    cout << cand[0] << endl;
  }


  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,m,x,y;cin>>n>>m;
    vector<int> balls(n,1);
    vector<bool> red(n,false);red[0]=true;
    for(int i=0;i<m;i++){
        cin>>x>>y;x--;y--;
        balls[x]--;
        balls[y]++;
        if(red[x]){
            red[y]=true;
            if(balls[x]==0)red[x]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(red[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3700
function Main(input) {
	lines = input.split("\n")
    i = lines[0].split(' ')[1]
    s = lines[1]
    ans = ((i > 1 ) ? s.slice(0, i - 1) : '') + s[i - 1].toLowerCase() + s.slice(i)
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>

int main(int argc, char *argv[])
{
  int n;
  int cnt;
  long long sum = 0;
  
  scanf("%d", &n);
  for(cnt = 1; cnt <= n; cnt++){
    if(((cnt % 3) == 0) || ((cnt % 5) == 0)){
        ;
    }else{
        sum += cnt;
  		//printf("%d ", cnt);
    }
  }

  //sum = (long long)0x1000000000;
  
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, m;cin >> n>> m;
    vector<bool> situ(n,false);
    vector<int> pena(n,0);
    ll penal = 0;

    rep(i,m){
        int q; string s;
        cin >> q >> s; q--;
        if(s == "AC"){
            if(situ[q] == false){
            situ[q] = true;
            penal += pena[q];
            }
        }
        if(s == "WA"){
            pena[q]++;
        }
    }

    ll ac = 0; rep(i,n) if(situ[i]) ac++;

    cout << ac << " " << penal << endl;
}


Measured memory_bytes: 640
a, b = map(int, input().split())
for i in range(2001):
    c = 10000 * i
    if c + (a - i) * 5000 >= b:
        for j in range(2001):
            d = 5000 * j
            e = i + j
            if (b - (c + d)) < 0:
                break
            else:
                if (b - (c + d)) // 1000 == (a - e):
                    print(i, j, (a - e))
                    exit()
print("-1 -1 -1")


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    int ans=0;

    if(n<600)ans=8;
    else if (n<800)ans=7;
    else if(n<1000)ans=6;
    else if(n<1200)ans=5;
    else if(n<1400)ans=4;
    else if(n<1600)ans=3;
    else if(n<1800)ans=2;
    else ans=1;

    cout<<ans<<endl;


}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;
const int MAX = 200000;
int table[MAX], inv_table[MAX];

int pow(int a, int n) {
  int res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res = 1LL * res * a % MOD;
    a = 1LL * a * a % MOD;
  }
  return res;
}

void make_table(int n) {
  table[0] = 1;
  for (int i = 1; i <= n; i++) {
    table[i] = 1LL * table[i-1] * i % MOD;
  }
  inv_table[n] = pow(table[n], MOD-2);
  for (int i = n; i > 0; i--) {
    inv_table[i-1] = 1LL * inv_table[i] * i % MOD;
  }
}

int comb(int x, int y) {
  int a = 1LL * inv_table[x] * inv_table[y] % MOD;
  return 1LL * table[x+y] * a % MOD;
}

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  make_table(h+w-2);
  int ans = 0;
  for (int i = b; i < w; i++) {
    ans += 1LL * comb(h-a-1, i) * comb(a-1, w-1-i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int A, B;
    cin >> A >> B;

    int C = (A + B) / 2;
    if ((A + B) % 2 == 0) {
        cout << C << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


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

#pragma warning( disable: 4996 )

using namespace std;

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

#define INF 100000000
#define EPS 1e-9

#define MAX_W 30
#define MAX_H 30

int W, H;

vector<int> ans_list;

int dp[MAX_H][MAX_W];
int maze[MAX_H][MAX_W];

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, -1, 0, 1 };

void solve(){

	queue<P> que;

	que.push(P(0, 0));

	while (que.size()){
		
		P p = que.front();
		int x = p.first;
		int y = p.second;
		que.pop();

		for (int i = 0; i < 4; i++){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 && nx < W && ny >= 0 && ny < H && dp[ny][nx] == INF && (maze[y][x] >> i) & 1){
				dp[ny][nx] = dp[y][x] + 1;
				que.push(P(nx, ny));
			}
		}

	}


}

int main(){

	while (true){
	
		cin >> W >> H;
		if (W == 0 && H == 0)
			break;

		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				maze[i][j] = 15;
				dp[i][j] = INF;
			}
		}

		dp[0][0] = 1;

		int num[MAX_W];

		for (int i = 0; i < 2 * H - 1; i++){
			//横方向
			if (i % 2 == 0){
				for (int j = 0; j < W - 1; j++){
					cin >> num[j];
					if (num[j] == 1){
						maze[i / 2][j] -= 1;
						maze[i / 2][j + 1] -= 4;
					}
				}
			}

			//縦方向
			if (i % 2 != 0){
				for (int j = 0; j < W; j++){
					cin >> num[j];
					if (num[j] == 1){
						maze[i / 2][j] -= 8;
						maze[(i + 1) / 2][j] -= 2;
					}
				}
			}

		}

		solve();
		int ans = dp[H - 1][W - 1];
		if (ans != INF)
			ans_list.push_back(ans);
		else
			ans_list.push_back(0);
	
	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1228
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()
a= []
for i in range(len(x)):
    a.append(int(x[i]))

z = [1,3,5,7,8,10,12]
y = [4,6,9,11]
if a[0] in [2] or a[1] in [2]:print("No")
elif a[0] in z and a[1] in  z: print("Yes")
elif a[0] in y and a[1] in y:print("Yes")
else:print("No")

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long

using namespace std;
typedef long long ll;

const ll INF = 1e15;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, l;
    cin >> n >> m >> l;
    ll adj[n][n];
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < n; ++ j) {
            adj[i][j] = INF;
            if (i == j) adj[i][j] = 0;
        }
    }
    for (int i = 0; i < m; ++ i) {
        int u, v, c;
        cin >> u >> v >> c;
        -- u, -- v;
        adj[u][v] = adj[v][u] = c;
    }
    for (int k = 0; k < n; ++ k) {
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < n; ++ j) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < n; ++ j) {
            adj[i][j] = adj[i][j] <= l ? 1 : INF;
        }
    }
    for (int k = 0; k < n; ++ k) {
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < n; ++ j) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    while (q --) {
        int s, t;
        cin >> s >> t;
        -- s, -- t;
        if (adj[s][t] >= INF) cout << "-1\n";
        else cout << adj[s][t] - 1 << "\n";
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  ll ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (s == "AC") {
      ++ac;
    } else if (s == "WA") {
      ++wa;
    } else if (s == "TLE") {
      ++tle;
    } else if (s == "RE") {
      ++re;
    }
  }
  printf("AC x %lld\n", ac);
  printf("WA x %lld\n", wa);
  printf("TLE x %lld\n", tle);
  printf("RE x %lld\n", re);
}


Measured memory_bytes: 3756
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct node* Node;
struct node{
  Node right;
  Node left;
  Node parent;
  int key;
};
Node root;

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

  z = (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;
}

Node treeSearch(Node x, int k) {
  while(x != NIL && k != x->key) {
    if(k < x->key) 
      x = x->left;
    else 
      x = x->right;
  }
  return x;
}

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

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

int main() 
{
  int n, i, x;
  char c[10];
  Node t;
  scanf("%d",&n);
  
  for (i=0; i<n; i++){
    scanf("%s",c);
    if (c[0] == 'f'){
      scanf("%d",&x);
      t = treeSearch(root,x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  } 
  return 0;
}

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

int main(){
  string s;
  int n;
  
  n = 7;
  cin >> s;

  if(s[0]=='o'){n++;}
  if(s[1]=='o'){n++;}
  if(s[2]=='o'){n++;}

  cout << n * 100 << endl;
}

Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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,
        a: [i64; n],
    }
    let mut acc = vec![0; n + 1];
    for i in 0 .. n { acc[i + 1] = acc[i] + a[i]; }
    let mut dp = vec![vec![0; n]; n];
    for s in 1 .. n {
        for i in 0 .. n - s {
            let mut mi = 1i64 << 50;
            for j in i .. i + s {
                mi = min(mi, dp[i][j] + dp[j + 1][i + s]
                         + acc[i + s + 1] - acc[i]);
            }
            dp[i][i + s] = mi;
        }
    }
    puts!("{}\n", dp[0][n - 1]);
}

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 <cstdio>

int N;
int A[200010];
long long res;
int ok;

void solve()
{
	int i;
	ok = 1;
	if(A[0] != 0){
		ok = 0;
		return ;
	}
	int cnt = 0;
	for(i=1; i<N; i++){
		if(A[i] == A[i-1] + 1)
			cnt ++;
		else if(A[i]<=A[i-1]){
			res += cnt;
			cnt = A[i];
		}
		else{
			res += cnt;
			if(A[i] == 0)
				cnt = 0;
			else if(A[i] == 1)
				cnt = 1;
			else{
				ok = 0;
				return ;
			}
		}
	}
	res += cnt;
}

void prt()
{
	if(ok == 0)
		printf("-1\n");
	else
		printf("%lld\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);
	solve();
	prt();
	return 0;
}

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

using namespace std;

int main()
{
  int n; cin >> n;
  long long ans = 0;
  for(int i = 0; i <= n; i++)
    if(i % 3 != 0 && i % 5 != 0) ans += i;
  cout << ans;

  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
long long dp[104][100005];
long long n,w;
vector<long long>peso,val;
long long rec(long long el, long long pe){
    if(dp[el][pe]!=-1)return dp[el][pe];
    if(el==n)return 0;
    if(peso[el]<=pe){
        dp[el][pe]=max(rec(el+1,pe-peso[el])+val[el],rec(el+1,pe));
    }
    else return rec(el+1,pe);
    return dp[el][pe];
}

int main(){
    cin>>n>>w;
    memset(dp,-1,sizeof dp);
    peso.resize(n);
    val.resize(n);
    for(int i=0;i<n;i++){
        cin>>peso[i]>>val[i];
    }
    cout<<rec(0,w);
}


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

long long a, b, mx, mn, a1, a2, a3;

long long ans = 1e18;

int main()
{
    cin >> a >> b;
    for (long long i = 1; i <= a; i++)
    {
        if (a > 2)
        {
            a1 = i * b;
            a2 = (a - i) / 2 * b;
            a3 = (a - i + 1) / 2 * b;
            mx = max(a1, max(a2, a3) );
            mn = min(a1, min(a2, a3) );
            ans = min(ans, mx - mn);
        }
        a1 = i * b;
        a2 = (a - i) * (b / 2);
        a3 = (a - i) * ( (b + 1) / 2);
        mx = max(a1, max(a2, a3) );
        mn = min(a1, min(a2, a3) );
        ans = min(ans, mx - mn);
    }
    for (long long i = 1; i <= b; i++)
    {
        if (b > 2)
        {
            a1 = i * a;
            a2 = (b - i) / 2 * a;
            a3 = (b - i + 1) / 2 * a;

            mx = max(a1, max(a2, a3) );
            mn = min(a1, min(a2, a3) );
            ans = min(ans, mx - mn);
        }
        a1 = i * a;
        a2 = (b - i) * (a / 2);
        a3 = (b - i) * ( (a + 1) / 2);
        mx = max(a1, max(a2, a3) );
        mn = min(a1, min(a2, a3) );
        ans = min(ans, mx - mn);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    ll x;

    scanf("%lld", &x);

    ll mod = 11;
    ll rem = x % mod;
    ll div = x / mod;

    div *= 2;

    if (rem != 0) {
        if (rem <= 6) div += 1;
        else div += 2;
    }

    printf("%lld\n", div);

    return 0;
}


Measured memory_bytes: 128
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
     
X, Y = map(int, input().split(' '))
a = -1
b = -1
 
if (2*Y-X)%3 == 0 and (2*X-Y)%3 == 0:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
 
 
 
if a < 0 or b < 0:
    ans = 0
else:
    ans = cmb(a+b, b)
print(ans % 1000000007)

Measured memory_bytes: 102028
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using ll = long long;

ll X, Y;

int main()
{
  std::cin >> X >> Y;

  std::cout << X+Y/2 << std::endl;

  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;
	lli ans=0;

	REP(i,0,s.size()){
		if(s.at(i)=='o')ans++;
		else ;
	}
	REP(i,s.size(),15)ans++;
	if(ans>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int l, n;
    cin >> n >> l;
    vector<string> S(n);
    rep(i, n) cin >> S[i];

    sort(all(S));

    string k;
    rep(i, n) k += S[i];
    cout << k <<  endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int64_t n,sum;
    sum = 0;
    cin >> n;
    for (int64_t i=1;i<=sqrt(n);i++){
        if ((n%i==0)&&(n/i>1)){
            if (n%(n/i-1)==n/(n/i-1)){
            sum += n/i - 1;
            }
        }
    }
    cout << sum << endl;
}

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for(int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

    vector<int> as(n + 1), bs(n + 1);
    rep(i, n + 1) { cin >> as[i]; }
    rep(i, n) { cin >> bs[i]; }

    ll count = 0;
    rep(i, n) {
        if(as[i] >= bs[i]) {
            as[i] -= bs[i];
            count += bs[i];
            bs[i] = 0;
        } else {
            bs[i] -= as[i];
            count += as[i];
            as[i] = 0;
            if(as[i + 1] >= bs[i]) {
                count += bs[i];
                as[i + 1] -= bs[i];
            } else {
                count += as[i + 1];
                as[i + 1] = 0;
            }
        }
    }

    p(count);

    return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    while(n!=0||k!=0){
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> S(n+1);
    S[0] = 0;
    for(int i=0;i<=n;i++){
        S[i] = S[i-1] + a[i-1];
    }
    int max = 0;
    int tmp = 0;
    for(int i= 0;i<=n-k;i++){
        tmp= S[i+k] - S[i];
        if(max<tmp){
            max = tmp;
        }
    }
    cout<<max<<endl;
    cin>>n>>k;
    }
    return 0;
}


Measured memory_bytes: 3564
def main():
    A, B = (int(i) for i in input().split())

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    def lcm(x, y):
        return x*y//gcd(x, y)
    print(lcm(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
import statistics
for k in range(N):
  A[k], B[k] = map(int, input().split())

if N%2 == 1:
  print(statistics.median(B) - statistics.median(A) +1)
else:
  print(int((statistics.median(B) - statistics.median(A))*2 +1))

Measured memory_bytes: 28892
#include <iostream>
#include <vector>
#include <typeinfo>
using namespace std;
typedef long long ll;
int main(void){
    int n, k;
    cin >> n >> k;
    int ai;
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> ai;
        if(ai >= k){
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,a[mx],i,j;
	cin>>n;
	ll sum=0;
	for(i=1; i< n+1; i++)
	{
	    cin>>a[i];
	    sum+= a[i];
	}
	
	a[0]= a[n];
/*	ll od[mx], ev[mx];
	od[n-2]= a[n-2];
	ev[n-1]= a[n-1];
	for(i=n-4; i>0; i-=2){
	    od[i]= od[i+2]+ a[i];
	}
	for(i=n-3; i>0; i-=2){
	    ev[i]= ev[i+2] + a[i];
	}
	
	ll m[mx];
	for(i=1; i<n+1; i+=2){
	    m[i]= 2*(a[i-1]+ od[i])- sum;
	}
	for(i=2; i<n; i+=2)
	m[i]= 2*(a[i-1] + ev[i])- sum;*/
	
//	ll od[n]= a[n];
    ll od=0;
	for(i=1; i<n+1; i+=2){
	    od+= a[i];
	}
	ll m[mx];
	m[1]= od*2 - sum;
	
	for(i=2; i<n+1; i++){
	    m[i]= 2*a[i-1]- m[i-1];
	}
	for(i=1; i<n+1; i++)
	cout<<m[i]<<" ";
    return 0;
}























Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

bool ok(const vecint& a, int k, int q, int lowest, int highest) {
  int num = 0;
  int len = 0;
  int cnt = 0;
  for(auto&& e:a) {
    if (e < lowest) {
      num += min(cnt, max(0, len-k+1));
      len = 0;
      cnt = 0;
    }
    else {
      ++len;
      if (e <= highest) ++cnt;
    }
  }
  num += min(cnt, max(0, len-k+1));
  return num >= q;
}

int main()
{
  int n,k,q;
  cin>>n>>k>>q;
  vecint a(n);
  for(auto&& e:a) cin>>e;
  set<int> sa;
  for(auto&& e:a) sa.insert(e);
  int ans = 1e9;
  for (auto&& e:sa) {
    int lo = -1;
    int hi = 1e9;
    while (hi-lo > 1) {
      int mid = (hi+lo)/2;
      if (ok(a,k,q,e,e+mid)) {
        hi = mid;
      } else {
        lo = mid;
      }
    }
    ans = min(ans, hi);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll M=2e6+1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i=0;
	map<string,ll> ma;
	for(i=0;i<n;i++){
		string s;cin>>s;
		ma[s]++;
	}
	cout<<ma.size()<<endl;
	return 0;
} 

Measured memory_bytes: 19284
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;

int main() { 

  getline(cin, s);

  if (s[0] == s[1] && s[1] == s[2]) {
    puts("No");
  } else {
    puts("Yes");
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) FOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int alf[30];
int w,h;



void search(int *n,int m){
  rep(i,30){
    int k = min(*n,alf[i]/m);
    alf[i]-=m*k;
    *n-=k;
    if(*n==0) return;
  }

}


int main(){
  cin>>h>>w;
  rep(i,h){
    string s;
    cin>>s;
    rep(j,w){
      alf[s[j]-'a']++;
    }
  }
  int f,t,o;
  f = (w/2)*(h/2);
  t = (w%2)*(h/2)+(h%2)*(w/2);
  o = (w%2)*(h%2);


  search(&f,4);
  search(&t,2);
  search(&o,1);


  if(!f&&!t&&!o){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }


  return 0;
}


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

int main(){
char s[12];
for(int i=0;i<12;i++){
   cin>>s[i];
}
for(int i=0;i<12;i++){
   cout<<s[i];
   if(i==3){cout<<" ";}
}
cout<<endl;
return 0;
}

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

bool judge(int s){
  if(s==2 || s==3){return true;}
  for(int j=2;j*j<=s;j++){
    if(s%j==0){return false;}
    if((j+1)*(j+1)>s){return true;}
  }
}

int main()
{
  while(1){
  int n;
  int cnt=0;

  cin >> n;

  if(n==0){break;}
      
  for(int i = n+1;i <= 2*n;i++)
    {
      if( judge(i) )
	{
	 
		  cnt++;
 
	}
    }
  cout << cnt << endl;
  }
}



Measured memory_bytes: 3068
using static System.Console;
using System.Linq;
using System.Diagnostics;
using System;
using System.Collections.Generic;

public static class Program
{
    public static void Main()
    {
        var stopwatch = new Stopwatch();
        stopwatch.Start();
        var maxD = int.Parse(ReadLine());
        var cArray = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var sTable = new List<List<int>>();
        var lastList = Enumerable.Repeat(0, 26).ToList();
        var sequenceList = Enumerable.Repeat(0, maxD).ToList();
        int happiness = 0;
        for (int i = 0; i < maxD; ++i)
        {
            sTable.Add(ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
        }
        Random random = new Random();
        for(int d = 0; d < maxD; ++d)
        {
            var currentContest = random.Next(26);
            lastList[currentContest] = d;
            sequenceList[d] = currentContest;
            happiness += sTable[d][currentContest];
            happiness -= Enumerable.Range(0, 25).Select(i => cArray[i] * ((d + 1) - lastList[i])).Sum();
        }
        for(int i = 0; i < maxD; ++i)
        {
            WriteLine(sequenceList[i] + 1);
        }
    }
}

Measured memory_bytes: 29012
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int k;
	cin>>s>>k;
	rep(i,0,s.size()){
		if(s[i]=='a')continue;
		if('a'+26-s[i]<=k){
			k-='a'+26-s[i];
			s[i]='a';
		}
	}
	k%=26;
	s[s.size()-1]+=k;
	cout<<s<<'\n';
	RE 0;
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
long long const DIM = 5000004;
long long INF = 100000005;
long long i,a,b,c;
string S;
int main ()
{
    cin >> S;
    for (i = 0; i < 3; i++) {
        if (S[i] == 'a')
            a++;
        if (S[i] == 'b')
            b++;
        if (S[i] == 'c')
            c++;
    }
    if (a == 1 && b == 1 & c == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;
#define forn(i, n) for (ll i = 0; i < n; i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
typedef long long ll;

const ll mod = 1e9 + 7, ma1 = 8, ma = 256 * 1024;

ll n, ans = 1, seg[2 * ma];
vector<int> x;

ll get_min(int l, int r) {
	if (l > r) re 1000000LL;
	if (l % 2)
		re min(seg[l], get_min(l + 1, r));
	if (r % 2 == 0)
		re min(seg[r], get_min(l, r - 1));
	re get_min(l / 2, r / 2);
}

bool ok(ll mid, int i) {
	ll c = ll(get_min(mid + ma, i + ma - 1)) + 2LL * mid;
	if (c > 0)
		re true;
	re false;
}

int main() {
	iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	cin >> n;
	x.resize(n);
	forn (i, n) {
		cin >> x[i];
		seg[i + ma] = x[i] - 2LL * i;
	}
	//ll k = 1LL * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12;
	/*forn (i, 13)
		k = (k * ll(i + 1)) % mod;*/
	//cout << k % mod << "\n";
	for (int i = ma - 1; i; i--)
		seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	forn (i, n) {
		int l = -1, r = i;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (ok(mid, i))
				r = mid;
			else 
				l = mid;
		}
		ans = (ans * ll(i - l)) % mod;
		//cout << i - l << "\n";
	}
	cout << ans;
}

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

int main(){
    int n,r;
    cin >>n>>r;
    if(n<10){
        int tmp = 100*(10-n)+r;
        cout << tmp<<endl;
    }else{
        cout <<r<<endl;
    }
}



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

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, M; cin >> N >> M;
    vector<pair<int, char>> constraints(M);
    for (auto& it : constraints) cin >> it.first >> it.second;

    for (int i = 0; i < 10000; i++) {
        string s = to_string(i);
        if (s.size() != N) continue;
        bool good = true;
        for (auto it : constraints) {
            good = good && s[it.first-1] == it.second;
        }
        if (good) {
            cout << i << '\n';
            exit(0);
        }
    }
    cout << -1 << '\n';
}

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

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

    int res;
    for (int i = 1; i <= 3; i++) {
        if (i != a && i != b) res = i;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3488
#include <stdio.h>

int A[100][100];
int b[100], c[100];

int main(){
  int n,m,a,i,j;
  scanf("%d%d", &n, &m);
  
  for(i=0; i<n; i++)//scan array A
    for(j=0; j<m; j++){
      scanf("%d", &a);
      A[i][j] = a;
    }
  for(j=0; j<m; j++){//scan array b
    scanf("%d", &a);
    b[j] = a;
  }
  for(i=0; i<n; i++)//cal the multiplication
    for(j=0; j<m; j++)
      c[i] += A[i][j] * b[j]; 
    
  for(i=0; i<n; i++)//print the answer
    printf("%d\n", c[i]);
  
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 10000000000000000
#define MAX 200001
#define MOD 1000000007

int main(){
    int Q;
    cin >> Q;
    ll bsum = 0;
    ll zensum = 0;
    ll kousum = 0;
    vector<pair<ll, ll>> ans;
    priority_queue<ll> zen;
    priority_queue<ll, vector<ll>, greater<ll>> kou;
    for(int i = 0; i < Q; i++){
        int type;
        cin >> type;
        if(type == 1){
            ll a, b;
            cin >> a >> b;
            bsum += b;
            if(zen.size() > kou.size()){
                ll c = zen.top();
                if(c <= a){
                    kou.push(a);
                    kousum += a;
                }
                else{
                    zen.pop();
                    kou.push(c);
                    zen.push(a);
                    zensum += a - c;
                    kousum += c;
                }
            }
            else{
                if(zen.size() == 0){
                    zen.push(a);
                    zensum += a;
                    continue;
                }
                ll c = kou.top();
                if(c < a){
                    kou.pop();
                    zen.push(c);
                    kou.push(a);
                    zensum += c;
                    kousum += a - c;
                }
                else{
                    zen.push(a);
                    zensum += a;
                }
            }
        }
        else{
            ll MIN = kousum - zensum + bsum + zen.top() * (zen.size() - kou.size());
            ans.push_back({zen.top(), MIN});
        }
    }
    for(auto Ans: ans){
        cout << Ans.first << ' ' << Ans.second << endl;
    }
}

Measured memory_bytes: 6452
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	vector<int> v(n);
	for(int& o : v) cin >> o;
	int ans = 0;
	for(int i = 1; i < n-1; i++){
		int sum = v[i-1] + v[i] + v[i+1];
		int maior = max({v[i-1], v[i], v[i+1]});
		int menor = min({v[i-1], v[i], v[i+1]});
		int meio = sum-maior-menor;
		if(meio == v[i]) ans++;
	}	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

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

		A[i] -= (i + 1);
	}

	sort(A.begin(), A.end());

	int m = A[N / 2];
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += abs(A[i] - m);
	}

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

Measured memory_bytes: 1024
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int A = ni();
        int B = ni();

        int ans = 0;
        if (A > B) {
            ans = 2 * A - 1;
        } else if (A == B) {
            ans = A + B;
        } else {
            ans = 2 * B - 1;
        }

        out.print(ans);
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }
}


Measured memory_bytes: 23252
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		ll sum=0;
		RANGE(i, 1, N+1) {
			if(i%3!=0 && i%5!=0) sum+=i;
		}
		
		cout<<sum<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int H,W,K;
  cin >> H >> W >> K;
  int cntB = 0;
  vector<vector<bool>> m(H,vector<bool>(W,false));
  int i,j,k;
  char c;
  for(i=0;i<H;i++)for(j=0;j<W;j++) {
    cin >> c;
    if(c == '#')m[i][j] = true;
  }
  int ans = 0,cnt;
  for(i=0;i<(1<<(H+W));i++) {
    cnt = 0;
    for(j=0;j<H;j++)for(k=0;k<W;k++) {
      if((i&(1<<j))==0 && (i&(1<<(H+k)))==0) {
        if(m[j][k])cnt++;
      }
    }
    if(cnt == K)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

samu = sum(a)
num = [0 for i in range(10**5)]
for i in range(n):
    nu = a[i]
    num[nu-1] += 1

for i in range(q):
    b = bc[i][0]
    c = bc[i][1]
    samu += c * num[b-1]
    samu -= b * num[b-1]
    print(samu)
    num[c-1] += num[b-1]
    num[b-1] = 0
    

Measured memory_bytes: 32340
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  ll a[200010];
  
  int num;
  cin >> num;
  
  if(num != 0) {cout << -1 << endl; return 0;}
  a[0] = num;

  for(int i = 1; i<n; i++){
    cin >> a[i];
    if(a[i] - a[i-1] > 1)  {cout << -1 << endl; return 0;}
  }

  ll ans = 0;
   for(int i = 1; i<n; i++){
  if(a[i] != 0){
    ans += a[i];
    while(a[i] == a[i+1] - 1 && i < n) {
      i++; ans++;
      }
    }
  }
     
    
     cout << ans << endl;
     
return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

ll solve(ll x) {
  ll ret = 0ll;
  ll s = 10ll;
  while (s <= x) {
    ret += (x / s);
    s *= 5ll;
  }

  return ret;
};

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

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

  ll N;
  cin >> N;

  if (N < 2ll) {
    cout << 0 << endl;
  } else if (N % 2ll == 1ll) {
    cout << 0 << endl;
  } else {
    cout << solve(N) << endl;
  }

  return 0;
};


Measured memory_bytes: 256
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

#define E5 100000

int main(){
    int N , i;
    int remove = 0;
    int num[E5] = {};
    int e;
    scanf("%d", &N);

    REP(i, N){
        scanf("%d", &e);
        if(e > E5){
            remove++;
        }else{
            num[e - 1]++;
        }
    }

    REP(i, E5){
        if(num[i] < i + 1){
            remove += num[i];
        }else{
            remove += (num[i] - (i + 1));
        }
    }
    
    printf("%d\n", remove);

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int arr[n+3];
    map<long long int,long long int>m;
    long long int sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
        m[arr[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int n1,n2;
        cin>>n1>>n2;
        if(m.find(n1)!= m.end())
        {
           // sum=sum-(m[n1]*n1);
            m[n2]=m[n2]+m[n1];
            sum=sum+(m[n1]*n2)-(m[n1]*n1);
            m.erase(n1);
        }
        cout<<sum<<endl;

    }
    return 0;
}


Measured memory_bytes: 8348
A = list(input())
B = list(input())
C = list(input())

A = A[::-1]#前後ろ逆転
B = B[::-1]
C = C[::-1]

next = A.pop()#リストAの末尾をとってくる

while True:
    if next=="a":
        if len(A)==0:
            print("A")
            break
        next=A.pop()
    elif next=="b":
        if len(B)==0:
            print("B")
            break
        next=B.pop()
    else:
        if len(C)==0:
            print("C")
            break
        next=C.pop()

        

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==b&&c==d&&a!=c&&a!=d)
    {
        cout<<"Yes";
    }
    else if(a==d&&b==c&&a!=b&&a!=c)
    {
        cout<<"Yes";
    }
    else if(a==c&&b==d&&a!=b&&a!=d)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;cin>>N>>M;
  vector<int>V(N+1);
  for(int X=0;X<M;X++){
    int L,R;cin>>L>>R;
    V[L-1]++;V[R]--;
  }
  long long rui=0;
  int S=0;
  for(int X=0;X<N;X++){
    rui+=V[X];
    if(rui==M){
      S++;
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3772
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define SQR(X) ( (X) * (X) )

int main()
{
   long i,j,k,l;
   long n;
   long double s;
   long double sum,nizyou;
   static long double dev[1000];

   for(i=0;;i++) {
      cin >> n;
      if(n==0)
         break;
      sum=0;
      nizyou=0;
      for(j=0;j<n;j++) {
         cin >> s;
         sum += s;
         nizyou += s*s;
      }
      dev[i] = sqrtl(nizyou/n - SQR(sum/n));
   }


   for(j=0;j<i;j++)
      printf("%llf\n",dev[j]);

   return 0;
}

Measured memory_bytes: 1244
n = int(input())
a = list(map(int, input().split()))
x = 0
M = a[0]
if n != 1:
    for i in range(n - 1):
        if M > a[i + 1]:
            x += (M - a[i + 1])
        else:
            M = a[i + 1]
print(x)

Measured memory_bytes: 32380
#include <iostream>
#include <stack>
using namespace std;
 
int main(){
  int n;
  int x;
  stack<int> a;
 
  cin>>n;
 
  for(int i=0; i<n; i++){
    cin>>x;
    a.push(x);
  }
 
  for(int i=0; i<n; i++){
    if(i==n-1){
      cout<<a.top()<<endl;
    }else{
      cout<<a.top()<<" ";
      a.pop();
    }
  }
 
  return 0;
 
}

Measured memory_bytes: 3092
arr = list(map(int, input().split()))
n = arr[0]
m = arr[1]
matrix = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
	arr = list(map(int, input().split()))
	for j in range(m):
		matrix[i][j] = arr[j]

b = [0] * m
for i in range(m):
	b[i] = int(input())

for i in range(n):
	sum = 0
	for j in range(m):
		sum += matrix[i][j] * b[j] 
	print(sum)
	sum = 0



Measured memory_bytes: 5948