akhauriyash/Code-Regression huggingface dataset:
// Aizu 2199: Differential Pulse Code Modulation
// 2017.9.21 bal4u@uu

#include <stdio.h>
#include <string.h>

int code[18];			// code book
char y[2][260];			// signal
long long ss[2][260];	// Sum of Squares

int main()
{
	int n, m, i, j, k, x, k1, k2;
	long long ans, s;

	while (scanf("%d%d", &n, &m) && n) {
		for (j = 0; j < m; j++) scanf("%d", code+j);
		memset(ss, -1, sizeof(ss)), memset(y, 0, sizeof(y)); y[0][128] = 1, ss[0][128] = 0;
		for (k1 = 0, k2 = 1, k = 0; k < n; k++, k1 = k2, k2 = !k2) {
			for (i = 0; i < 256; i++) y[k2][i] = 0, ss[k2][i] = -1LL;
			scanf("%d", &x);
			for (i = 0; i < 256; i++) {
				if (!y[k1][i]) continue;
				for (j = 0; j < m; j++) {
					int t = i + code[j];
					if (t < 0) t = 0;
					if (t >= 256) t = 255;
					y[k2][t] = 1;
					s = (t-x)*(t-x) + ss[k1][i];
					if (ss[k2][t] < 0 || s < ss[k2][t])	ss[k2][t] = s;
				}
			}
		}
		for (ans = 1LL << 60, i = 0; i < 256; i++) 
			if (ss[k1][i] >= 0 && ss[k1][i] < ans) {
				ans = ss[k1][i]; if (ans == 0) break;
			}
		printf("%lld\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long int lli;

int main() {
    int n, k, v[50], s[51] = {0};
    priority_queue<pair<int, int>> pq;

    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> v[i];
        s[i+1] += s[i] + v[i];
        if (v[i] < 0) pq.push(make_pair(-v[i], i));
    }

    int ans = -1e9;
    for (int i=1; i<=k; i++) {
        if (i > n) break;
        for (int l=i; l>=0; l--) {
            int r = i - l;
            // int ls = s[l] - s[0], rs = s[n] - s[n-r];
            int tmp = s[l] - s[0] + s[n] - s[n-r];

            // if (ans <= tmp) cout << i << " " << l << " " << tmp << " : first" << endl;

            ans = max(ans, tmp);

            auto tpq = pq;
            int cont = i;
            while (!tpq.empty() && cont < k) {
                auto top = tpq.top();
                tpq.pop();
                if (top.second < l || (n-r) <= top.second) {
                    tmp += top.first;
                    cont++;
                }
            }

            // if (ans <= tmp) cout << i << " " << l << " " << tmp << " : second" << endl;

            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

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

  int ans = 0;
  rep(i, 1, N) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool left = false, right = false;
      rep(j, 0, i) if (S[j] == c) left = true;
      rep(j, i, N) if (S[j] == c) right = true;
      if (left && right) cnt++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


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

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int n;
	vi a;
	int i, j;
	int sum;

	cin >> n;

	a.resize(n);

	rep(n) {
		cin >> a[i];
	}
	sum = 0;
	rep(n) {
		sum += a[i] - 1;
	}

	cout << sum;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int k = 0;
    if(400 <= x && x < 600) k = 8;
    else if(600 <= x && x < 800) k = 7;
    else if(800 <= x && x < 1000) k = 6;
    else if(1000 <= x && x < 1200) k = 5;
    else if(1200 <= x && x < 1400) k = 4;
    else if(1400 <= x && x < 1600) k = 3;
    else if(1600 <= x && x < 1800) k = 2;
    else if(1800 <= x && x <= 1999) k = 1;
    System.out.println(k);
  }
}

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

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<long> l = new List<long> { 2, 1 };
        for (int i = 2; i <= n; i++)
        {
            l.Add(l[i - 1] + l[i - 2]);
        }
        Console.WriteLine(l.Last());
    }
}

Measured memory_bytes: 13268
// #include "../utils.cpp"
/*
Problem

Category
全探索：順列全探索

URL:
https://atcoder.jp/contests/abc145/tasks/abc145_c

考察:


Date: 2020/04/11
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int N;
vector<int> X, Y;


/* ======================== */

signed main(){
    getInput();
    solve();
    return 0;
}

void getInput() {
    cin>>N;
    X = vector<int>(N, 0);
    Y = vector<int>(N, 0);
    for(int i=0; i<N; ++i) {
        cin>>X[i]>>Y[i];
    }
    
}

int64_t calcPermutation(int64_t n, int64_t r){
    int64_t res = 1;
    for(int64_t i = 0; i < r; ++i){
        res *= (n - i);
    }
    return res;
}

void solve() {
    vector<int> indices; for(int i=0; i<N; ++i) indices.push_back(i);
    double d = 0;
    do {
        for(int i=0; i<N-1; ++i) {
            int a = indices[i];
            int b = indices[i + 1];
            int AX = X[a];
            int AY = Y[a];
            int BX = X[b];
            int BY = Y[b];
            d += pow(pow(AX - BX, 2) + pow(AY - BY, 2), 0.5);
        }
    } while(next_permutation(indices.begin(), indices.end()));

    // cout<<d/calcPermutation(N, N)<<endl;
    cout<<std::fixed << std::setprecision(15)<<d/calcPermutation(N, N)<<endl;
    
}






Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,i,j,a,x;
    while(-1){
        scanf("%d",&n);
        if (n==0) break;
        x=0;
        for (i=1;i<=499;i++) {
            if (2*i>n) break;
            for (j=i+1;j<=500;j++) {
                a=(i+j)*(j-i+1)/2;
                if (a==n) {x++; break;}
            }
        }
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 1028
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n, k;
    cin >> n >> k;

    cout << n - (k - 1) << endl;
}


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

struct Edge {
  int to, w;
};

typedef vector<vector<Edge> > Graph;


int dfsB(const Graph &g, int v, int prev, int &times, vector<int> &num,
         vector<Edge> &bridge) {
  int res = num[v] = times++;
  for(int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i].to;
    int t;
    if(num[nv] == -1) {
      t = dfsB(g, nv, v, times, num, bridge);
      if(t > num[v]) {
        bridge.push_back(g[v][i]);
      }
    } else {
      t = num[nv];
    }
    if(nv != prev) {
      res = min(res, t);
    }
  }
  return res;
}

vector<Edge> getBridge(const Graph &g) {
  vector<Edge> res;
  int n = g.size();
  int times = 0;
  vector<int> num(n, -1);
  for(int i = 0; i < n; ++i) {
    if(num[i] == -1) {
      dfsB(g, i, -1, times, num, res);
    }
  }
  return res;
}

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<pair<int, pair<int, int> > > es;
    for (int i = 0; i < M; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a; --b;
      es.push_back(make_pair(c, make_pair(a, b)));
    }
    sort(es.begin(), es.end());
    Graph G(N);
    int A = 0, B = 0;
    for (int i = 0; i < es.size(); ) {
      int W = es[i].first;
      while (i < es.size() && es[i].first == W) {
        G[es[i].second.first].push_back((Edge){es[i].second.second, W});
        G[es[i].second.second].push_back((Edge){es[i].second.first, W});
        ++i;
      }
      vector<Edge> b = getBridge(G);
      for (int k = 0; k < b.size(); ++k) {
        if (b[k].w == W) {
          ++A;
          B += b[k].w;
        }
      }
    }
    cout << A << " " << B << endl;
  }
  return 0;
}

Measured memory_bytes: 2972
def main():
  while True:
    n = int(input())
    if not n: break
    flag = -1
    lst = []
    for i in range(n):
      a = int(input())
      if flag == a:
        lst[-1] += 1
      else:
        if i % 2 == 0:
          lst.append(1)
          flag = a
        else:
          if len(lst) == 1:
            lst[-1] += 1
            flag = a
          elif len(lst) >= 2:
            lst[-2] = lst[-2] + lst[-1] + 1
            lst.pop()
            flag = a
    ans = 0
    if flag == 0:
      for i in range(-1,len(lst) * (-1) - 1,-2):
        ans += lst[i]
    elif flag == 1:
      for i in range(-2,len(lst) * (-1) - 1,-2):
        ans += lst[i]
    print(ans)

main()
 


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

int main()
{
	using namespace std;

	int N,counter;
	vector<int> A;
	cin >> N;
	for(int Ai,i = 0;i < N;i++)
	{
		cin >> Ai;
		A.push_back(Ai);
	}
	while(true)
	{
		for(int i = 0;i < N;i++)
		{
			if (A[i] % 2) goto end;
			else A[i] /= 2;
		}
		counter++;
	}
end:
	cout << counter;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,mo=1e9+7;
int n,m,i,j,k,x[N],y[N],f[N],ans,lst,mx;
pair<int,int>a[N];
unordered_map<int,int>bi;
inline void add(int x,int v){for(;x<1<<30;x+=x&-x)bi[x]=(bi[x]+v)%mo;}
inline int ask(int x){int ans=0;for(;x;x-=x&-x)ans=(ans+bi[x])%mo;return ans;}
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",x+i);
	for(i=1;i<=m;++i)scanf("%d",y+i);y[m+1]=1<<30;
	for(i=j=1;i<=n;++i){
		for(;y[j]<x[i];++j);
		a[i].first=j==1?1<<30:x[i]-y[j-1];
		a[i].second=j==m+1?1<<30:y[j]-x[i];
	}
	sort(a+1,a+n+1);n=unique(a+1,a+n+1)-a-1;
	f[0]=1;
	for(j=1;j<=n;++j)if(a[j].first==1<<30)mx=max(mx,a[j].second);
	ans=!mx;
	for(i=1,j=0;i<=n;++i)if(a[i].second<1<<30){
		for(;a[j].first<a[i].first;++j)if(a[j].second<1<<30)add(a[j].second+1,f[j]);
		f[i]=ask(a[i].second);
		if(a[i].second>=mx)ans=(ans+f[i])%mo;
	}
	printf("%d\n",ans);
	return 0;
}

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

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

    for (int i = 0; i < n.length(); i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }

    cout << n << endl;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;

  map<string, int> counts;
  REP(i, N) {
    string s;
    cin >> s;
    counts[s]++;
  }

  int largest = 0;
  for (const auto& kv : counts) {
    chmax(largest, kv.second);
  }

  for (const auto& kv : counts) {
    if (kv.second == largest) {
      cout << kv.first << endl;
    }
  }

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 23808
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		City[] arr = new City[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			City o = new City();
			o.i = i;
			o.x = Integer.parseInt(sa[0]);
			o.y = Integer.parseInt(sa[1]);
			arr[i] = o;
		}
		br.close();

		List<Road> list = new ArrayList<Road>(2 * n);

		Arrays.parallelSort(arr, new Comparator<City>() {
			public int compare(City o1, City o2) {
				return o1.x - o2.x;
			}
		});
		for (int i = 1; i < arr.length; i++) {
			City o1 = arr[i - 1];
			City o2 = arr[i];
			Road e = new Road();
			e.i = o1.i;
			e.j = o2.i;
			e.c = o2.x - o1.x;
			list.add(e);
		}

		Arrays.parallelSort(arr, new Comparator<City>() {
			public int compare(City o1, City o2) {
				return o1.y - o2.y;
			}
		});
		for (int i = 1; i < arr.length; i++) {
			City o1 = arr[i - 1];
			City o2 = arr[i];
			Road e = new Road();
			e.i = o1.i;
			e.j = o2.i;
			e.c = o2.y - o1.y;
			list.add(e);
		}

		Collections.sort(list, new Comparator<Road>() {
			public int compare(Road e1, Road e2) {
				return e1.c - e2.c;
			}
		});

		int[] parent = new int[n];
		for (int i = 0; i < parent.length; i++) {
			parent[i] = i;
		}

		long ans = 0;
		for (Road e : list) {
			if (find(parent, e.i) != find(parent, e.j)) {
				union(parent, e.i, e.j);
				ans += e.c;
			}
		}
		System.out.println(ans);
	}

	static class City {
		int i, x, y;
	}

	static class Road {
		int i, j, c;
	}

	static void union(int[] parent, int x, int y) {
		int px = find(parent, x);
		int py = find(parent, y);
		if (px != py) {
			parent[px] = py;
		}
	}

	static int find(int[] parent, int x) {
		if (parent[x] == x) {
			return x;
		}
		parent[x] = find(parent, parent[x]);
		return parent[x];
	}
}


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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
   
    int n, k;
    cin >> n >> k;

    int ans=0;
    while (n)
    {
        n/=k;
        ans++;
    }

    cout << ans << "\n";    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	cout<<a[0]<<a[1]<<a[2]<<'8'<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<endl;
	return 0;
}

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

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

  if (A % 2 == B % 2) {
    int ans = abs(A - B) / 2 + min(A, B);
    cout << ans << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Solver {
    void solve(Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();

        if (a % 3 == 0 || b % 3 == 0) {
            out.println(0);
            return;
        }

        out.println(Math.min(calc(a, b), calc(b, a)));
    }

    int calc(int a, int b){
        int x1 = (int) Math.round(a / 3.0);
        int x2 = a - x1;

        int[] s;

        boolean vertical;
        if ((x2 & 1) == 0) vertical = true;
        else if ((b & 1) == 0) vertical = false;
        else vertical = x2 > b;

        if (vertical) {
            int x3 = x2 / 2;
            x2 -= x3;

            s = new int[]{x1 * b, x2 * b, x3 * b};
        } else {
            int y1 = (int) Math.round(b / 2.0);
            int y2 = b - y1;

            s = new int[]{x1 * b, x2 * y1, x2 * y2};
        }
        Arrays.sort(s);
        return s[s.length - 1] - s[0];
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        new Solver().solve(in, out);

        in.close();
        out.flush();
    }
}

Measured memory_bytes: 21972
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		int ans = 0;
		
		if(X==1)ans+=300000;
		if(X==2)ans+=200000;
		if(X==3)ans+=100000;
		if(Y==1)ans+=300000;
		if(Y==2)ans+=200000;
		if(Y==3)ans+=100000;
		if(X==1&Y==1)ans+=400000;
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
string s;
bool tmp=1;
int main(){
	cin>>s;
	for(int i=0;i<(s.size()-1)/2;i++)
		if(s[i]!=s[s.size()-i-1])
			tmp=0; 
	for(int i=0;i<(s.size()-1)/2;i++)
		if(s[i]!=s[(s.size()-1)/2-i-1])
			tmp=0;
	for(int i=(s.size()+1)/2;i<s.size();i++)
		if(s[i]!=s[s.size()-i-1])
			tmp=0;
	cout<<(tmp?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = readLine()?.split(" ")?.map { it.toLong() } ?: return

    var by4 = 0
    var by2ButBy4 = 0

    for (a in aList) {
        if (a % 4L == 0L) {
            by4++
        } else if (a % 2L == 0L) {
            by2ButBy4++
        }
    }

    if (by2ButBy4 == n || by4 >= (n - by4)) {
        println("Yes")
        return
    }

    val requireBy4 = n - by4 - if (by2ButBy4 != 0) by2ButBy4 - 1 else 0

    if (by4 >= requireBy4 - 1) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 53732
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		
		long min = Math.min(a, b);
		for (long i = min; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				min = i;
				break;
			}
		}
		
		System.out.println(a * b / min);
	}
}


Measured memory_bytes: 23892
#include <iostream>
using namespace std;
int main(void){
    long long int N,A,B;
    cin>>N>>A>>B;
    long long int as=A+B;
    long long int asas=N/as;
    long long int asasas=N%as;
    if (asasas>=A){
        cout<<A*asas+A<<endl;
    }
    else if(asasas<A){
        cout<<A*asas+asasas<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    string S;
    cin >> S;

    vector<bool> counter(26, false);
    int number;
    for (int i = 0; i < S.size(); i++)
    {
        number = (unsigned char)S[i] - 'a';
        // printf("%d", number);
        counter[number] = true;
    }

    char ans;
    for (int i = 0; i < 26; i++)
    {
        if (counter[i] == false)
        {
            ans = (char)(i + 'a');
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}
*/

#define	MOD 1000000007

int	main() {
	long N, A, B;
	cin >>N >>A >>B;
	if (0==(B-A)%2) {
		cout <<(B-A)/2 <<endl;
		return 0;
	}
	long D=A+(B-A-1)/2;
	long DD=N-B+1+(B-A-1)/2;
	cout <<min(D, DD) <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    char s[30];
    int a[30]={};
    int tmp=0;
    
    cin >> s;
    
    for(int i=0; i<=25; i++){
        
        tmp = s[i] - 'a';
        a[tmp] += 1;
        
    }
    
    for(int i=0; i<=25; i++){
        
        if(a[i]>=2){
            
            cout << "no" << endl;
            return 0;
            
        }
        
    }
    
    cout << "yes" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<stdio.h>
#include <algorithm>
using namespace std;
int main(void){
    // Here your code !

int a[10];
for(int i=0;i<10;i++){
cin>>a[i];
}
sort(a,a+10);
for(int i=9;i>6;i--){
cout<<a[i]<<endl;
}
return 0;
}

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

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

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

   if ((B - A - 1) % 2 == 1) cout << "Alice" << endl;
   else cout << "Borys" << endl;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<map>
#include<string>
using namespace std;
typedef pair<long long,int> P;
int str[40];
vector<string> se[40];
vector<int> e[40];
map<string,int> ct;
map<long long,int> dp[2];
int main(){
    int n;
    int i,j;
    while(1){
    scanf("%d",&n);
    if(n==0)return 0;
    dp[0].clear();
    dp[1].clear(); 
    ct.clear();
    for(i=0;i<n;i++){
        se[i].clear();
        e[i].clear();
    }
    for(i=0;i<n;i++){
        char s[20];
        string name;
        scanf(" %s",s);
        name.append(s);
        ct[name]=i;
        int a,b;
        scanf("%d %d",&a,&b);
        str[i]=a;
        for(j=0;j<b;j++){
            name.clear();
            scanf(" %s",s);
            name.append(s);
            se[i].push_back(name);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<se[i].size();j++){
            e[i].push_back(ct[se[i][j]]);
        }
    }
    long long use=0;
    for(j=0;j<e[0].size();j++)use|=(long long)1<<(e[0][j]-1);
    dp[1][use]=str[0];
    for(i=1;i<n;i++){
        long long use=0;
        for(j=0;j<e[i].size();j++)if(e[i][j]>=i+1)use|=(long long)1<<(e[i][j]-i-1);
        dp[(i+1)%2].clear();
        map<long long,int>::iterator it;
        for(it=dp[i%2].begin();it!=dp[i%2].end();it++){
            P p=*it;
            long long used=p.first;
            int mx=p.second;
            dp[(i+1)%2][used>>1]=max(dp[(i+1)%2][used>>1],mx);
            if(!(used&1))dp[(i+1)%2][(used>>1)|use]=max(dp[(i+1)%2][(used>>1)|use],mx+str[i]);
        }
    }
    printf("%d\n",dp[n%2][0]);
    }
}

Measured memory_bytes: 7292
while 1:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    sum = m + f

    if m == -1 or f == -1:
        print('F')
    elif sum >= 80:
        print('A')
    elif sum >= 65 and sum < 80:
        print('B')
    elif sum >= 50 and sum < 65:
        print('C')
    elif sum >= 30 and sum < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif sum < 30:
        print('F')



Measured memory_bytes: 5596
#include <stdio.h>
int num[100005],list[100005];
int main()
{
	int n,m,i,i2,t,tt,c=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		num[i]=1;
	list[1]=1;
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&t,&tt);
		if(list[t]==1)
		{
			list[tt]=1;
			if(num[t]==1)
				list[t]=0;
		}
		num[t]--;
		num[tt]++;
	}
	for(i=1;i<=n;i++)
		c+=list[i];
	printf("%d",c);
	return 0;
}

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

int main() {
  for(int N, M, P; cin >> N >> M >> P && (N|M|P); ) {
    --M;
    vector<int> X(N);
    for(int i = 0; i < N; ++i) cin >> X[i];
    int pool = accumulate(X.begin(), X.end(), 0);
    if(X[M] == 0) cout << 0 << endl;
    else cout << pool * (100 - P) / X[M] << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
import java.util.HashSet;
import java.util.Set;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        Set<String> dic = new HashSet<String>();

        int n = sc.nextInt();

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

            String input = sc.next();

            if (input.equals("insert")) {
                dic.add(sc.next());
            }

            if (input.equals("find")) {
                if (dic.contains(sc.next())) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            }
        }

        sc.close();
    }
}



Measured memory_bytes: 217312
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    std::string s;
    std::cin >> s;
    auto cc = 0;
    auto result = true;
    for (auto i = 0; i < s.length(); ++i) {
        if (i == 0) {
            if (s[i] != 'A') {
                result = false;
                break;
            }
        }
        else {
            if (s[i] == 'C') {
                if (++cc > 1 || i < 2 || i > s.length() -2) {
                    result = false;
                    break;
                }
            }
            else if ((97 > (int)s[i]) || ((int)s[i] > 122)) {
                result = false;
                break;
            }
         }
    }
    if (result && cc == 1) {
        std::cout << "AC" << std::endl;
    }
    else {
        std::cout << "WA" << std::endl;
    }
    return 0;
}

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

int main() {
    int a, b; cin >> a >> b;
    if (a%2 == 1 && b%2 == 1) {
        cout << "Odd" << endl;
        return 0;
    }

    else {
        cout << "Even" << endl;
        return 0;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

/*??????????????¢?????????*/
int p[105], q[105], r[105], b[105];
int dp[105];
bool root[105];
int dfs(int num) {
  if(num == -1) return 1;
  if(dp[num] != -1) return dp[num];
  // dfs(r) * const : dfs(b) * const = q[i] : p[i]
  int left = dfs(r[num]), right = dfs(b[num]);
  // right * q[i] * ?????°(lv) = left * p[i] * ?????°(rv) ??¨???????????????????°?????????°?????????????????????
  // lv : rv = l*p : r*q
  int lv = right*q[num], rv = left*p[num], g = __gcd(lv, rv);
  lv /= g, rv /= g;
  return dp[num] = right * rv + left * lv;
}

signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    // cout << "n:" << n << endl;
    REP(i, n) cin >> p[i] >> q[i] >> r[i] >> b[i],r[i]--,b[i]--;

    memset(root, true, sizeof(root));
    REP(i, n) root[r[i]] = root[b[i]] = false;
    int rt = -1;
    REP(i, n) if(root[i]) rt = i;
    if(rt == -1) assert(false);

    memset(dp, -1, sizeof(dp));
    REP(i, n) if(dp[i] == -1) dfs(i);
    // REP(i, n) cout << dp[i] << ","; cout << endl;
    cout << dp[rt] << endl;
  }
  // cout << "b" << endl;
  return 0;
}

Measured memory_bytes: 3016
import Text.Printf

main :: IO ()
main = do
    getLine
    vectX <- fmap (map read . words) getLine
    vectY <- fmap (map read . words) getLine
    mapM_ (printf "%.6f\n" . md vectX vectY) ps
    where ps = [1, 2, 3, read "Infinity"]

md :: [Double] -> [Double] -> Double -> Double
md xs ys p | isInfinite p = maximum [abs (x-y)  | (x,y) <- zip xs ys]
           | otherwise    = sum [abs (x-y) ** p | (x,y) <- zip xs ys] ** (1/p)


Measured memory_bytes: 4532
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
need = [0,2,5,5,4,5,6,3,7,6]
 
dp = [-1] * (N + 1)
dp[0] = 0
 
for i in range(N + 1):
        for a in A:
                if i + need[a] <= N:
                        dp[i + need[a]] = max(dp[i + need[a]], dp[i] * 10 + a)
 
print(dp[-1])

Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
vector<int> edges[100005];
void dfs(vector<int>& dp, int k){
	if(edges[k].size() == 0){
		dp[k] = 0;
		return ;
	}
	for(int i=0; i<edges[k].size(); i++){
		if(dp[edges[k][i]] == -1)
			dfs(dp, edges[k][i]);
		dp[k] = max(dp[edges[k][i]] + 1, dp[k] );
	}
}
int main()
{
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		edges[a].push_back(b);
	}
	int ans = 0;
	vector<int> dp(n+1, -1);
	for(int i=1; i<=n; i++){
	// 	edges[0].push_back(i);
		if(dp[i] == -1)
		dfs(dp, i);
	}
	for(int i : dp)
	 ans = max(ans, i);
	cout<<ans;
}


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

int main() {
  int N, P;
  string S;
  cin >> N >> P >> S;
  ll ans = 0;
  if (P == 2 || P == 5) {
    rep(i, N) {
      if ((S[i] - '0') % P == 0) ans += i + 1;
    }
  } else {
    vector<int> mod(N + 1);
    int ten = 1;
    for (int i = N - 1; i >= 0; i--) {
      int a = (S[i] - '0') * ten % P;
      mod[i] = (mod[i + 1] + a) % P;
      ten = ten * 10 % P;
    }
    vector<int> cnt(P);
    rep(i, N) {
      ans += cnt[mod[i]];
      cnt[mod[i]]++;
    }
    ans += cnt[0];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1284
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B = il()
    ans = A - B + 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 23152
[n,k],li = [list(map(int,i.split())) for i in open(0)] 
ans = 0
for i in range(1,min(n+1,k+1)):
    for j in range(i+1):
        l = li[:(i-j)] + li[n-j:]
        re_num = min(k-i,len(l))
        l.sort()
        f = 0
        for p in range(re_num):
            if l[p] > 0:
                break
            f += 1
        l = l[f:]
        ans = max(ans,sum(l))
print(ans)

Measured memory_bytes: 69680
w, h, n = map(int, input().split())
rect = [[1 for _ in range(w)] for _ in range(h)]
for _ in range(n):
    x, y, a = map(int, input().split())
    for i in range(h):
        for j in range(w):
            if (a == 1 and j < x) or (a == 2 and x <= j) \
                or (a == 3 and i < y) or (a == 4 and y <= i):
                rect[i][j] = 0
else:
    print(sum(sum(r) for r in rect))

Measured memory_bytes: 3064
a, b, c, d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
A = []
w = a * c
x = a * d
y = b * c
z = b * d
A.append(w)
A.append(x)
A.append(y)
A.append(z)
B = max(A)
print(B)

Measured memory_bytes: 9168
#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() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()) {
    s[i] += n;
    if (s[i] > 'Z') {
      s[i] -= 26;
    }
  }
  cout << s << endl;
  return 0;
}

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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

vector<long long int> divisor(long long int n) {
	vector<long long int> res;
	for (long long int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}
int main() {
	int N,M;cin>>N>>M;
	vector<long long int>as(N),bs(M);
	for (int i = 0; i < N; ++i) {
		cin>>as[i];
	}
	for (int i = 0; i < M; ++i) {
		cin>>bs[i];
	}
	long long int ag=as[0];
	for (int i = 1; i < N; ++i) {
		ag=gcd(ag,as[i]);
	}
	bool ok=true;
	long long int bl=bs[0];
	for (int i = 1; i < M; ++i) {
		double k=bl;
		k*=bs[i];
		k/=gcd(bl,bs[i]);
		if (k > 1e15) {
			ok=false;
		}
		else {
			bl=bl/gcd(bl,bs[i])*bs[i];
		}
	}
	int ans=0;
	if (ok) {
		if (ag%bl == 0) {
			long long int tt=ag/bl;
			auto divs=divisor(tt);
			ans=divs.size();
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3288
using System;
using System.Collections.Generic;

public static class Program
{   
  public static void Main(string[] args)
  {
    // input
    string[] firstStr = Console.ReadLine().Split(' ');
    int processNum = int.Parse(firstStr[0]);
    int quantum = int.Parse(firstStr[1]);
    
    Queue<KeyValuePair<string, int>> queue = new Queue<KeyValuePair<string, int>>();
    for(int i = 0; i < processNum; i++)
    {
      string[] inputLine = Console.ReadLine().Split(' ');
      queue.Enqueue(new KeyValuePair<string, int>(inputLine[0], int.Parse(inputLine[1])));
    }
    
    //logic
    int totalProcessTime = 0;
    while(queue.Count > 0)
    {
      var process = queue.Dequeue();
      string currentProcessName = process.Key;
      int currentProcessTime = process.Value;
      if(currentProcessTime > quantum)
      {
        totalProcessTime += quantum;
        queue.Enqueue(new KeyValuePair<string, int>(currentProcessName, currentProcessTime - quantum));
      }
      else
      {
        totalProcessTime += currentProcessTime;
        Console.WriteLine(process.Key + " " + totalProcessTime.ToString());
      }
    }
  }
}


Measured memory_bytes: 14704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
constexpr int MOD = 998244353;
 
int main(void){
    Cin(int, n, s);
    Cins(int, n, a);
    
    vc<vc<ll>> dp(n+1, vc<ll>(s+1));
    dp[0][0] = 1;
    Rep(n) dp[0][0] = (dp[0][0] * 2) % MOD;
    
    For(i, n) For(j, s+1){
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
        if(int k = j+a[i]; k <= s){
            ll half = (dp[i][j] % 2 == 0) ? dp[i][j]/2 : ((dp[i][j] + MOD)/2) % MOD;
            dp[i+1][k] = (dp[i+1][k] + half) % MOD;
        }
    }
    Cout(dp[n][s]);
}


Measured memory_bytes: 73748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000000
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,k;
	cin >> n >> m >>k;
	n = n - k;
	if( n < 0) {
		m = m + n;
		n = 0;
		if (m < 0)
			m = 0;
	}
	cout << n << " " << m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,cur=1;
    ll ans=0;
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        if (!(cur%3==0||cur%5==0))
        {
            ans+=cur;
        }
        ++cur;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int sum = 0;
void judge(vector<int>& x)
{rep(i,sz(x))
{
	if (x[i] == 0)continue;
	rep(j, x[i]) {
		int a = i;
		while (a < sz(x)&&x[a] != 0)
		{
			x[a]--; a++;
		}
		sum++;
	}
}
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	ll h, w, ans;
	cin >> h >> w;
	if (h == 1 || w == 1)
		cout << 1 << endl;
	else cout << (h * w + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 #include <iomanip>
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;
void solve(istream& cin, ostream& cout) {
	string S,T;
	cin>>S>>T;
	if(S.size()+1 == T.size() && T.substr(0, S.size()) == S) 
		cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3028
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;


int main()
{
	long long int n, s, i, j, k, l, m, sum,N,a,b,ans,cc,cnt;
	sum = 0;
	
	int flag = 0;
	char S[1001];
	cin >> S;
	int w;
	cin >> w;
	n = strlen(S);
	for (i = 0; i < strlen(S); i += w) {
		cout << S[i];
	}



    return 0;
}



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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> X(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i];
    }
    ll ans = 1e9;
    for ( int i = 1; i <= 100; i++ ) {
        ll s = 0;
        for ( int j = 0; j < N; j++ ) {
            s += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans, s);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int meirei(char c[]){
  char print[8]="print",reverse[8]="reverse",replace[8]="replace";
  int i;
  for(i=0;i<8; i++){
    if(c[i]!=print[i])break;
    if(c[i]=='\0')return 1;
  }
  for(i=0;i<8; i++){
    if(c[i]!=reverse[i])break;
    if(c[i]=='\0')return 2;
  }
  for(i=0;i<8; i++){
    if(c[i]!=replace[i])break;
    if(c[i]=='\0')return 3;
  }
  return 0;
}
int main(){
  char str[1002],p[1002],fanc[8];
  int q,a,b,i,j,x;
scanf("%s",&str);
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%s",&fanc);
    x=meirei(fanc);
    if(x==1){
      scanf("%d %d",&a,&b);
      for(j=a;j<=b; j++)printf("%c",str[j]);
      printf("\n");
    }
    if(x==2){
      scanf("%d %d",&a,&b);
      for(j=0; j<=b-a; j++)p[a+j]=str[b-j];
      for(j=a; j<=b; j++)str[j]=p[j];
    }
    if(x==3){
      scanf("%d %d",&a,&b);
      scanf("%s",&p);
      for(j=0; j<=b-a; j++)str[a+j]=p[j];
    }
  }
return 0;
}

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

int main(){
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a>=0 && d>=0) cout << b*d << endl;
  if(a>=0 && d<0) cout << a*d << endl;
  if(a<0 && b>=0 && c>=0) cout << b*d << endl;
  if(a<0 && b>=0 && c<0 && d>=0){
    if(a*c >= b*d) cout << a*c << endl;
    else cout << b*d << endl;
  }
  if(a<0 && b>=0 && d<0) cout << a*c << endl;
  if(b<0 && c>=0) cout << b*c << endl;
  if(b<0 && c<0 && d>=0) cout << a*c << endl;
  if(b<0 && d<0) cout << a*c << endl;
}

Measured memory_bytes: 3588
program main
  implicit none

  integer                :: n, odd
  
  read *, n

!  select case ( n )
!     
!  case ( 1:9 )
!     odd = n
!  case ( 10:99 )
!     odd = 9
!  case ( 100:999 )
!     odd = 9 + n - 99
!  case ( 1000:9999 )
!     odd = 9 + 900
!  case ( 10000:99999 )
!     odd = 9 + 900 + n - 9999
!  case ( 100000:999999 )
!     odd = 9 + 900 + 90000
!     
!  end select
!

  if ( n <= 9 ) then
     odd = n
  else if ( 10 <= n .and. n <= 99 ) then
     odd = 9
  else if ( 100 <= n .and. n <= 999 ) then
     odd = 9 + n - 99
  else if ( 1000 <= n .and. n <= 9999 ) then
     odd = 9 + 900
  else if ( 10000 <= n .and. n <= 99999 ) then
     odd = 9 + 900 + n - 9999
  else if ( 100000 <= n .and. n <= 999999 ) then
     odd = 9 + 900 + 90000
     
  end if
  
  print *, odd
  
end program main


Measured memory_bytes: 384
import math
import copy
# import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

a = getInputNum()
b = getInputListInt()

c = sorted(b)

mean = c[int(a/2)-1]
next = c[int(a/2 + 1)-1]

ans = next - mean

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll r, D, x;
    cin >> r >> D >> x;
    for(int i=0;i<10;i++){
        x = r*x-D;
        cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#B 
a, b, c, k = map(int, input().split())

card0 = 0
card_1 = 0

if k <= a:
    card1 = k
else:
    card1 = a
    if k-a <= b:
        card0 = k-b 
    else:
        card0 = b
        if k-a-b <= c:
            card_1 = k-a-b
        else:
            card_1 = c

print((card1)*1 + (card0)*0 + (card_1)*(-1))

Measured memory_bytes: 9200
#include <stdio.h>
int main(int argc, char *argv[])
{   int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
    if((a+b)<10)
    printf("%d\n",a+b);
    else if((a+b)>=10)
    printf("error");
    }
    return 0;
}


Measured memory_bytes: 128