akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
    string A, B; cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
    } else if (A.size() == B.size()) {
        for (int i = 0; i < A.size(); i++) {
            if (A[i] - '0' > B[i] - '0') {
                cout << "GREATER" << endl;
                return 0;
            } else if (A[i] - '0' < B[i] - '0') {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    } else {
        cout << "LESS" << endl;
    }
}


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

int main()
{
    int k,a,b;
    scanf("%d %d %d",&k,&a,&b);
    for(int i=a;i<=b;i++)
    {
        if(i%k==0){
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}



Measured memory_bytes: 3684
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
dic = {}
A = listintinput()
flag = 0
for i in A:
    if i in dic:
        flag = 1
        break
    else:
        dic[i] = 1

if flag == 0:
    print('YES')
else:
    print('NO')


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

bool isPrime(int x){
  if(x == 2) return true;
  for(int i = 2; i*i <= x; i++){
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
  int n, a, ans = 0;
  cin >> n;
  for(int i = 0 ; i < n; i++){
    cin >> a;
    if(isPrime(a)) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3120
calc :: [String] -> Int
calc [a,op,b]
  | op == "+" = a' + b'
  | op == "-" = a' - b'
  | op == "*" = a' * b'
  | otherwise = a' `div` b'
  where
    a' = read a
    b' = read b

input3 :: IO [Int]
input3 = loop []
  where
    loop :: [Int] -> IO [Int]
    loop list = do
    temp <- getLine
    let [a,op,b] = words temp
    if op == "?"
      then return list
      else loop (list ++ [calc [a,op,b]])

main = input3 >>= (\n -> mapM_ print n)



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string S;
  cin >> S;
  int left = 0, right = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == '('){
      left++;
    }
    else{
      right++;
      if(right > left){
        for(int i = 0; i < right - left; i++){
          cout << '(';
          left++;
        }
      }
    }
  }
  cout << S;
  if(right < left){
    for(int i = 0; i < left - right; i++){
      cout << ')';
    }
  }
  cout << endl;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var s = new int[seqA.Length + 1];
        for (int i = 0; i < seqA.Length; ++i)
        {
            ++s[seqA[i] - 1];
        }

        Console.WriteLine(string.Join(Environment.NewLine, s));
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

class DisjointSet {
 public:
  DisjointSet(int size) : parent_(size), size_(size, 1) {
    for (int i = 0; i < size; ++i) {
      parent_[i] = i;
    }
  }
  int Find(int x) {
    int& p = parent_[x];
    if (p != x) p = Find(p);
    return p;
  }
  void Union(int x, int y) {
    x = Find(x), y = Find(y);
    if (x == y) return;
    if (Size(x) > Size(y)) std::swap(x, y);
    parent_[x] = parent_[y];
    size_[y] += size_[x];
  }
  int Size(int x) { return size_[Find(x)]; }
  bool Same(int x, int y) { return Find(x) == Find(y); }

 private:
  std::vector<int> parent_, size_;
};

struct Point {
  int x, y;
};

int main() {
  in(int, n);
  vector<Point> ps(n);
  rep(i, n) cin >> ps[i].x >> ps[i].y;
  const int kMax = 100001;
  vector<set<int>> xs(kMax), ys(kMax);
  for (const Point& p : ps) {
    xs[p.y].insert(p.x);
    ys[p.x].insert(p.y);
  }

  ll ans = 0;
  {
    DisjointSet dsx(kMax);
    for (const set<int>& s : xs)
      for (int x : s) dsx.Union(x, *s.begin());
    vector<int> y_count(kMax);
    vector<set<int>> y_unique(kMax);
    set<int> roots;
    for (const Point& p : ps) {
      int root = dsx.Find(p.x);
      ++y_count[root];
      y_unique[root].insert(p.y);
      roots.insert(root);
    }
    for (int r : roots) {
      ans += ll(dsx.Size(r)) * ll(y_unique[r].size()) - y_count[r];
    }
  }
  {
    DisjointSet dsy(kMax);
    for (const set<int>& s : ys)
      for (int y : s) dsy.Union(y, *s.begin());
    vector<int> x_count(kMax);
    vector<set<int>> x_unique(kMax);
    set<int> roots;
    for (const Point& p : ps) {
      int root = dsy.Find(p.y);
      ++x_count[root];
      x_unique[root].insert(p.x);
      roots.insert(root);
    }
    for (int r : roots) {
      ans += ll(dsy.Size(r)) * ll(x_unique[r].size()) - x_count[r];
    }
  }
  out(ans / 2);
}


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

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

/*
   ll f(ll x)
   {
   if (x <= 0)
   return 0;
// 2^40 > 10^12
ll acc[40] = {0};
for (int i = 0; i < 40; i++) {
ll mod = (1LL << (i + 1));

acc[i] += x / mod * mod / 2;
ll rem = x % mod - (mod / 2 - 1);
if (rem > 0)
acc[i] += rem;
}

ll ans = 0;
for (int i = 0; i < 40; i++)
if (acc[i] % 2 == 1)
ans |= (1LL << i);
return ans;
}

int main()
{
ll a, b;
scanf("%lld %lld", &a, &b);

printf("%lld\n", f(b) ^ f(a - 1));

return 0;
}
 */

int main()
{
    ll a, b;
    scanf("%lld %lld", &a, &b);

    ll ans = 0;
    if (a % 2 == 0 && b % 2 == 0)
        ans = b;
    else if (a % 2 == 1 && b % 2 == 0)
        ans = a ^ b;
    else if (a % 2 == 0 && b % 2 == 1)
        ans = 0;
    else
        ans = a;

    if (a % 2 == 1)
        a++;
    if (b % 2 == 0)
        b--;
    if (a <= b)
        ans ^= ((b - a + 1) / 2 % 2);
    printf("%lld\n", ans);
    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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int a[5];
	REP(i, 5)cin >> a[i];
	int k;
	cin >> k;
	if (a[4] - a[0] <= k)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(1e6) + 999;
#define int long long int

int spf[N];
int sum[N];

void pre(){

	for(int i=0;i<N;i++)
		spf[i]=i;

	for(int i=2;i<N;i++){
		if(spf[i]==i){
			for(int j=i;j<N;j+=i)
				spf[j]=min(i,spf[j]);
		}
	}

}
void solve(){

	for(int i=2;i<N;i++){
		int tmp = i;
		int ans = 1;
		while(tmp!=1){
			int cnt=1;
			int x = spf[tmp];
			while(spf[tmp]==x){
				tmp/=x;
				cnt++;
			}
			ans*=cnt;
		}
		sum[i] = ans;
	}
	
	sum[1]=1;
	for(int i=0;i<N;i++)
		sum[i]+=sum[i-1];

}



int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    int n;cin>>n;
    pre();
    solve();
    cout<<sum[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 19284
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    ll n=s.size();
    vector<vector<ll>> dp(n+1,vector<ll>(13,0));
    dp[0][0]=1;
    rep(i,n){
        if(s[i]!='?'){
            rep(j,13){
                dp[i+1][(j*10+(s[i]-'0'))%13]+=dp[i][j];
                dp[i+1][(j*10+(s[i]-'0'))%13]%=MOD;
            }
        }
        else{
            rep(j,13)rep(k,10){
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=MOD;
            }
        }
    }
    cout<<(MOD+dp[n][5])%MOD<<endl;
}

Measured memory_bytes: 13696
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i]<=0:
        cnt += 1

for i in range(n):
    if a[i]<0:
        a[i]=a[i]*(-1)

if cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-2*min(a))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  char a;
  cin>>a;
  char b='a';
  if(a<b){
    cout<<'A'<<endl;
  }
  else{
    cout<<'a'<<endl;
  }
}

Measured memory_bytes: 3596
//AC
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0121
//bfs 康托展?
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
#define INF 0x3f3f3f3f
#define N 8
const int fac[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };///?乘  

int s2c(int s[], int n)  //康托
{
	int i, j, cnt, sum;
	sum = 0;
	for (i = 0; i < n; ++i)
	{
		cnt = 0;
		for (j = i + 1; j < n; ++j)
			cnt += (s[j] < s[i]);
		sum += cnt * fac[n - i - 1];
	}
	return sum;
}


//n-1数?，第k个排列  
void c2s(int ans[], int n, int k)  //逆康托
{
	bool vis[10];
	int i, j, t;
	memset(vis, 0, sizeof(vis));
	//--k;
	for (i = 0; i < n; ++i)
	{
		t = k / fac[n - i - 1];
		for (j = 0; j < n; j++)
			if (!vis[j])
			{
				if (t == 0) break;
				--t;
			}
		ans[i] = j, vis[j] = true;
		k %= fac[n - i - 1];
	}
}

enum Move{UP,DOWN,LEFT,RIGHT};
int move(int c, int op) {
	
	int tmp[20];
	c2s(tmp, N, c);
	int zeroPos;

	for (zeroPos = 0; tmp[zeroPos] != 0; ++zeroPos);

	switch (op)
	{
	case UP:
		if (zeroPos <= 3) return -1;
		swap(tmp[zeroPos], tmp[zeroPos - 4]);
		break;
	case DOWN:
		if (zeroPos >= 4) return -1;
		swap(tmp[zeroPos], tmp[zeroPos + 4]);
		break;
	case LEFT:
		if (zeroPos == 0 || zeroPos == 4) return -1;
		swap(tmp[zeroPos], tmp[zeroPos - 1]);
		break;
	case RIGHT:
		if (zeroPos == 3 || zeroPos == 7) return -1;
		swap(tmp[zeroPos], tmp[zeroPos + 1]);
		break;
	default:
		break;
	}
	return s2c(tmp, N);
}
int start = 0;
int vis[50000];
int b(/*int aim*/) {
	memset(vis, 0x3f, sizeof(vis));

	queue<int> qu;
	
	qu.push(start);
	vis[start] = 0;
	while (!qu.empty()) {
		int cur = qu.front(); qu.pop();
		/*if (cur == aim) {
			//printf("a %d\n", vis[cur]);
			return vis[cur];
		}*/
		for (int i = 0; i < 4; i++) {
			int n = move(cur, i);
			//if (n != -1 && INF == vis[n]) {
			if (n != -1 && vis[cur] + 1 < vis[n]) {
				qu.push(n);
				vis[n] = vis[cur]+1;
			}
		}
	}
	return -1;
}

int main() {
	int tmp[N] = { 0,1,2,3,4,5,6,7 };
	b();//打表从goal?始找出全部有解状?

	while (EOF != scanf("%d %d %d %d %d %d %d %d", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6], &tmp[7])) {
		start = s2c(tmp, N);
		printf("%d\n",vis[start]);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

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

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

const ll inf_ll = 1e18 + 7;
const int N = 407;

int n;
vector <int> a;
vector <ll> p;
ll dp[N][N];

ll get(int l, int r) {
  return p[r] - (l > 0 ? p[l - 1] : 0);
}

ll solve(int l, int r) {
  if (l > r) {
    return inf_ll;
  }
  auto &res = dp[l][r];
  if (res != inf_ll) {
    return res;
  }
  if (l == r) {
    return res = 0;
  }
  for (int x = l + 1; x <= r; x++) {
    res = min(res, solve(l, x - 1) + solve(x, r) + get(l, r));
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = inf_ll;
    }
  }
  int n;
  cin >> n;
  a.resize(n);
  p.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[i] = a[i];
    if (i > 0) p[i] += p[i - 1];
  }
  cout << solve(0, n - 1) << '\n';
  return 0;
}

Measured memory_bytes: 1664
import Control.Applicative
import Data.List
import Data.Ord

listToTuple2 [a,b] = (a,b)

main = do
  (n,k) <- listToTuple2 . map read . words <$> getLine :: IO (Int,Int)
  ps <- map (listToTuple2 . map read . words) . lines <$> getContents :: IO [(Integer,Integer)]

  let px = nub $ sort $ map fst ps

  print $ minimum . map area . concat $ (flip map) (filter ((>=k) . length) [filter (\(x,_) -> x>=x1 && x<=x2) ps | x1<-px, x2<-px, x1<=x2]) $
    \pps ->
      let
        py = nub $ sort $ map snd pps
      in
        filter ((>=k) . length) [filter (\(_,y) -> y>=y1 && y<=y2) pps | y1<-py, y2<-py, y1<=y2]

  where
    area ps = (maxx - minx) * (maxy - miny)
      where
        xs = map fst ps
        ys = map snd ps
        minx = minimum xs
        maxx = maximum xs
        miny = minimum ys
        maxy = maximum ys


Measured memory_bytes: 2428
#include <stdio.h>
int main(){
int a,b,i;
char opr;
for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&opr,&b);
        if (opr=='+'){
        printf("%d\n",a+b);
}
        if (opr=='-'){
        printf("%d\n",a-b);
}
        if (opr=='*'){
        printf("%d\n",a*b);
}
        if (opr=='/'){
        printf("%d\n",a/b);
}
        if (opr=='?'){
            break;
        }

}

return 0;

}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli a,b;
	cin>>a>>b;

	if(a>=13)cout<<b<<endl;
	else if(a>=6)cout<<b/2<<endl;
	else cout<<0<<endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int ab = sc.nextInt();
			ab += sc.nextInt();

			if (ab >= 10) {
				System.out.println("error");
			} else {
				System.out.println(ab);
			}
		} finally {
			sc.close();
		}
	}
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector <bool> dp(k + 1);
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int stone = 0; stone <= k; ++stone) {
        for (int i : a) {
            if (stone - i >= 0 && !dp[stone - i]) {
                dp[stone] = true;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second") << "\n";
    return 0;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned int  ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
	        res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
vi pr;
void sieve(int n){ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true){ 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 

    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          pr.pb(p); 
} 

bool comp(pii a, pii b){
	if(a.first == b.first)
		return a.second < b.second;
	return a.first < b.first;
}


signed main(){
	FASTIO
	int n;
	cin >> n;
	// pii p[n];
	int u, v, mn = LLONG_MAX, mx = LLONG_MIN,  mn2 = LLONG_MAX, mx2 = LLONG_MIN;
	rep(i, 0, n){
		cin >> u >> v;
		mn = min(mn, u + v);
		mx = max(mx, u + v);
		mn2 = min(mn2, u - v);
		mx2 = max(mx2, u - v);
	}
	
	cout << max(abs(mx - mn), abs(mx2 -mn2));
    return 0;
}


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

int main(){
 int time=0,dest,temp,C,D,E;
 cin>>temp>>dest>>C>>D>>E;
 if(temp<0)time=-temp*C;
 if(temp<0){
 	time=time+D;
	temp=0;
 }
 cout<<time+(dest-temp)*E<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
sort(begin(ret), end(ret));
return (ret);
}

int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll s=0;
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    //aの合計sは一定,sの約数が答えの候補
    auto d=divisor(s);
    ll ans=1;
    for (int x:d){
        //ll c=0;
        vll rl;
        rep(i,n){
            rl.push_back(a[i]%x);
        }
        sort(all(rl));
        ll right=n-1,left=0;
        ll c=0;
        ll now=0;
        while(left<right || now>0){
            if (now==0){
                now+=rl[left];
                left+=1;
            }
            if (now+rl[right]>x){
                now-=(x-rl[right]);
                c+=x-rl[right];
                right-=1;
            }
            else{
                rl[right]+=now;
                c+=now;
                now=0;
            }
        }
        if (c<=k){
            ans=x;
        }

    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#define ll long long int
using namespace std;
const int INF=2000000000;
const int SIZE=200000;

int L[SIZE/2+2],R[SIZE/2+2];

ll merge(int A[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int i,j;
	ll a=0;
	for(i=0;i<n1;i++)L[i]=A[left+i];
	for(i=0;i<n2;i++)R[i]=A[mid+i];
	L[n1]=R[n2]=INF;
	i=j=0;
	for(int k=left;k<right;k++)
	{
		if(L[i]<R[j])A[k]=L[i++];
		else
		{
			A[k]=R[j++];
			a+=n1-i;
		}
	}
	return a;
}

ll mergesort(int A[],int left,int right)
{
	ll a=0,b=0,c=0;
	if(left+1<right)
	{
		int mid=(left+right)/2;
		a=mergesort(A,left,mid);
		b=mergesort(A,mid,right);
		c=merge(A,left,mid,right);
	}
	return a+b+c;
}

int main()
{
	int A[SIZE],n,i;
	cin>>n;
	for(i=0;i<n;i++)cin>>A[i];
	cout<<mergesort(A,0,n)<<endl;
	return 0;
}

Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 2e3 + 7;
int n, pos[2][N];
struct Fenwick {
	static const int N = ::N << 1;
	int a[N], n;
	void ini(int _n) { fill_n(a + 1, n = _n, 0); }
	void add(int p, int v) { for (; p <= n; p += p & -p) a[p] += v; }
	int qry(int p) { int r = 0; for (; p; p -= p & -p) r += a[p]; assert(r >= 0); return r; }
}	fen;
int dp[N << 1][N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 1, n << 1 | 1) {
		char ch; int id; cin >> ch >> id;
		pos[ch == 'B'][id] = i;
	}
	dp[0][0] = 0;
	fen.ini(n << 1);
	rep(i, 1, n << 1 | 1) fen.add(i, 1);
	rep(i, 1, n << 1 | 1) {
		rep(j, 1, min(n, i) + 1) fen.add(pos[0][j], -1);
		rep(j, 0, min(n, i) + 1) { // j black balls
			if (j > 0) fen.add(pos[1][j], -1);
			if (i - j <= n) {
				int &d = dp[i][j]; d = INT_MAX;
				if (j - 1 >= 0) d = min(d, dp[i - 1][j - 1] + fen.qry(pos[1][j]));
				if (i - 1 >= j) d = min(d, dp[i - 1][j] + fen.qry(pos[0][i - j]));
			}
			if (i - j > 0 && i - j <= n) fen.add(pos[0][i - j], 1);
		}
		rep(j, min(n, i) + 1, i) fen.add(pos[0][i - j], 1);
		rep(j, 1, min(n, i) + 1) fen.add(pos[1][j], 1);
	}
	cout << dp[n << 1][n];
	return 0;
}

Measured memory_bytes: 30464
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, M;
  cin >> A >> B >> M;
  VI a(A), b(B);
  INPUT(a);
  INPUT(b);
  int ans = MIN(a) + MIN(b);
  REP(int, i, M)
  {
    int x, y, c;
    cin >> x >> y >> c;
    chmin(ans, a[x-1]+b[y-1]-c);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

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

  int total = 0;

  for (int i = 1; i < n + 2; i++) {
    total += abs(a[i] - a[i - 1]);
  }

  for (int i = 1; i <= n; i++) {
    int curr = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    int next = abs(a[i + 1] - a[i - 1]);

    int diff = abs(next - curr);

    cout << total - diff << endl;
  }

  return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_N = 100;
ll N, x, a[MAX_N], dp[MAX_N + 1];

void solve() {
    sort(a, a + N);
    ll ans = 0, res = x;
    REP(i, N) {
        if (i == N - 1) {
            if (res - a[i] == 0) {
                ans++;
                break;
            } else {
                break;
            }
        }
        if (res >= a[i]) {
            ans++;
            res -= a[i];
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> x;
    dp[0] = 0;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
 
 
int main (void)
{
    int h, w;
    int i, j;
 
    while (scanf("%d %d", &h, &w) != EOF && h != 0 || w != 0){
        for (i=0; i<h; i++){
            for (j=0; j<w; j++){
                if (j!=0 && j!=w-1){
                    if(i!=0 && i!=h-1)
                        printf(".");
                    else
                        printf("#");
                }
                else
                    printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
 
    return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 0;
  
  for (int i = 0; i < N; i++){
    if (S.at(i) == '.'){
     count++;
    }
  }
  
  int ans = count;
  
  for (int i = 0; i < N; i++){
    if (S.at(i) == '.'){
      count--;
    } else {
      count++;
    }
    ans = min(ans, count);
  }

     
  cout << ans << endl;

}

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

using namespace std;

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

	map<char, int> cn;
	string w;
	cin >> w;
	for (char c : w) {
		cn[c]++;
	}
	for (auto &p : cn) {
		if (p.second & 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

	return 0;
}



Measured memory_bytes: 256
#abc083b

n,a,b=map(int,raw_input().split())
res=0
l=[]
for i in xrange(1,n+1):
 s=str(i)
 sums=0
 for j in xrange(len(s)):
  sums+=int(s[j])
 l.append(sums)
for i in xrange(len(l)):
 if l[i]>=a and l[i]<=b:
  res+=i+1
print res


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

N, A, B = map(int, input().split())
if A + B - 1 > N:
    print(-1)
    exit()

a = []
b = []
while N > 0:
    if A == 0 or B == 0:
        print(-1)
        exit()
    if B >= N:
        b = list(range(N, 0, -1)) + b
        N = 0
    else:
        b = list(range(N, N-B, -1)) + b
        N -= B
        if A - 1 >= N:
            a += list(range(1, N+1))
            N = 0
        else:
            a += list(range(N-A+2, N+1))
            N -= A - 1
    A -= 1
    B -= 1
ans = a + b
print(*ans)

Measured memory_bytes: 132184
/**
 * author:dhakad_123
**/
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m;
    cin >> n >> m;
    int sum1,sum2,n1,n2;
  
    if(n == 1 && m == 1){
        cout << 0 <<"\n";
        exit(0);
    }
   else{
         n1 = n-1;
         sum1 = n1*(n1+1)/2;
         
         n2 = m-1;
         sum2 = n2*(n2+1)/2;
         cout << sum1+sum2 <<"\n";
    }
   return 0;    
}

Measured memory_bytes: 256
#include <iostream>

int main(){

   std::string S;
   int Q;
   std::cin >> S >> Q;
   int T[Q], F[Q];
   char C[Q];
   bool reverse = false;
   //std::string S_test = S;
   for(int i=0; i<Q; ++i){
      std::cin >> T[i];
      if(T[i]==1) reverse = !reverse;
      else if(T[i]==2) std::cin >> F[i] >> C[i];
     
      /*
      if(T[i]==1){
	 std::string S_tmp;
	 for(int j=S_test.size()-1; j>=0; --j) S_tmp = S_tmp + S_test[j];
	 S_test = S_tmp;
      }else if(T[i]==2){
	 if(F[i]==1) S_test = C[i] + S_test;
	 else S_test = S_test + C[i];
      }
      */
   }
   //std::cout << "reverse : " << (reverse ? "true" : "false") << std::endl;
   bool status = !reverse;
   std::string S_front, S_back;
   for(int i=Q-1; i>=0; --i){
      if(T[i]==1){
	 status = !status;
      }else{
	 //std::cout << "current status : " << (status ? "forward" : "reversed") << std::endl;
	 //std::cout << F[i] << ' ' << C[i] << std::endl;
	 if(reverse){//finally reversed.
	    if(status) {//not reversed now
	       if(F[i]==1) S_back = C[i] + S_back;
	       else S_front = S_front + C[i];
	    }else {
	       if(F[i]==1) S_front = S_front + C[i];
	       else S_back = C[i] + S_back;
	    }
	 }else{
	    if(status) {//not reversed now
	       if(F[i]==1) S_front = S_front + C[i];
	       else S_back = C[i] + S_back;
	    }else {
	       if(F[i]==1) S_back = C[i] + S_back;
	       else S_front = S_front + C[i];
	    }
	 }
      }
   }
   std::cout << S_front;
   for(int i=0; i<S.size(); ++i){
      if(reverse) std::cout << S[S.size()-1-i];
      else std::cout << S[i];
   }
   std::cout << S_back << std::endl;

   //std::cout << S_test << std::endl;
   return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
    	if(b<c){
	        printf("Yes\n");
  	}else {
  		printf("No\n");
  	}
    } else {
    	printf("No\n");
    }

	return 0;
}

Measured memory_bytes: 580
MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
c = [0] * n
for v in d:
    c[v] += 1
res = 0 if d[0] != 0 or c[0] != 1 else 1
for i in range(n - 1):
    res = res * c[i] ** c[i + 1] % MOD
print(res)

Measured memory_bytes: 53300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  string s;
  int a,b,c,d;
  while(cin>>s){
    if(s=="#")break;
    cin>>a>>b>>c>>d;
    char ma[11][11];
    int h=0,w=0;
    for(int i=0;i<s.size();i++){
	 if(s[i]=='/'){
	   h++;
	   w=0;
	 }else if(s[i]=='b'){
	   ma[h][w++]='b';
	 }else{
	   int k=s[i]-'0';
	   for(int j=0;j<k;j++){
		ma[h][w++]='.';
	   }
	 }
    }
  
    swap(ma[a-1][b-1],ma[c-1][d-1]);
    string tmp="";
    for(int i=0;i<=h;i++){
	 if(i)tmp+='/';
	 for(int j=0;j<w;j++){
	   tmp+=ma[i][j];
	 }
    }
    
    //cout<<tmp<<endl;//<<" "<<h<<" "<<w<<endl;
    /*
	 for(int i=0;i<=h;i++){
	 for(int j=0;j<w;j++){
	 cout<<ma[i][j];
	 }
	 cout<<endl;
	 }*/
    for(int i=0;i<tmp.size();i++){
	 if(tmp[i]=='.'){
	   int cnt=0;
	   while(i<tmp.size()&&tmp[i]=='.'){
		i++;
		cnt++;
	   }
	   cout<<cnt;
	   i--;
	   continue;
	 }
	 cout<<tmp[i];
    }
    cout<<endl;
  }
  return 0;
}



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

int main(){
    int tasks[3];
    int sum = 0;

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

    sort(tasks, tasks + 3, greater<int>());

    //sum += tasks[0];

    for(int i = 1; i < 3; i++){
        sum += abs(tasks[i] - tasks[i - 1]);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int n;
int a[1000005];
bool ans[1000005];
 
int balls = 0;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  
  for(int i = n; i >= 1; i--) {
    int cnt = 0;
    for(int j = i; j <= n; j += i)
      cnt += ans[j];
    
    if(cnt % 2 != a[i] % 2) {
      ans[i] = true;
      balls++;
    }
  }
  cout << balls << endl;
  for(int i = 1; i <= n; i++)
    if(ans[i]) cout << i << " ";
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0 ; i<N ; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(N-1)-a.at(0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long m=1000000000+7;
int main(void)
{
	long long n,a,b,d,c,cnt=1,u=0,h=0,t=0;
	scanf("%lld",&n);
	a=1; b=1; c=1; d=1;
	while(1){
		a=(a*10)%m;
		b=(b*9)%m;
		c=(c*9)%m;
		d=(d*8)%m;
		u=((a+m+m)-(b+c-d))%m;
		if(cnt==n) break;
		cnt++;
	}
	printf("%lld\n",u);
	return 0;
}

Measured memory_bytes: 1732
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
struct _RLE{ char c; ll len; };
vector<_RLE> RLE(string S){
    ll N=S.size();
    vector<_RLE> v;
    char prev=S[0];
    for(ll i=1,cnt=1;i<=N;i++){
        if(i==N){//最後
            v.push_back({prev,cnt});
            break;
        }
        while(S[i]==prev){cnt++;i++;}//数え上げ
        v.push_back({prev,cnt});
        cnt=1;prev=S[i];//初期化
    }
    return v;
}
int main(void){
    string S;ll K;cin>>S>>K;
    
    ll c1=0;
    vector<_RLE> v=RLE(S);
    for(auto r:v){
        if(r.len>=2){
            c1+=r.len/2;
        }
    }
    
    ll c2=0;
    if(v[v.size()-1].c==v[0].c){
        c2+=v[v.size()-1].len/2+v[0].len/2-(v[v.size()-1].len+v[0].len)/2;
    }
    //cout<<c1<<" "<<c2;

    ll ans=0;
    if(v.size()==1)ans=S.size()*K/2;
    else{
        ans-=c2*(K-1);
        ans+=c1*K;
    }
    
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define INFINITE 1e9 + 5
#define MOD 1000000007
#define MAXN 100001 
#define pll pair<ll,ll>
#define pii pair<int,int>
#define debugArray(arr) cout << #arr<<" : "<<endl;for(int i : arr){cout << i <<", ";} cout <<endl;
#define debugVariable(x) cout <<#x<<"="<<x<<"\n";
#define check(x) cout<<"CHECK="<<#x<<"\n";
int X[4]={1,0,-1,0};
int Y[4]={0,1,0,-1};
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout.tie(0);
    int test;
    cin>>test;
     int ac=0,wa=0,tle=0,re=0;
    while(test--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        {
            ac++;
        }
        else if(s=="WA")
        {
            wa++;
        }
        else if(s=="TLE")
        {
            tle++;
        }
        else
        {
            re++;
        }
        

    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3624
let N = Int(readLine()!)!

let a = readLine()!.split(separator: " ").map { Int($0)! }

var dp: [[Int]] = .init(repeating: .init(repeating: -1, count: N), count: N)
var sum: [Int] = .init(repeating: 0, count: N+1)
for i in 1..<sum.count {
  sum[i] = sum[i-1] + a[i-1] 
}

func backtrack(_ l: Int, _ r: Int) -> Int {
  if l == r {
    return 0
  }
  if dp[l][r] != -1 {
    return dp[l][r]
  }
  
  var ans = sum[r+1] - sum[l]
  var minCost = Int.max
  for i in l..<r {
    minCost = min(minCost, backtrack(l, i) + backtrack(i+1, r))
  }
  dp[l][r] = ans + minCost
  return dp[l][r]
}
print(backtrack(0, N-1))

Measured memory_bytes: 9516
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string S; cin >> S;
  bool easy = 1;
  for(int i = 0; i < S.size(); i+=2){
    if(S[i] == 'L') easy = 0;
  }
  for(int i = 1; i < S.size(); i+=2){
    if(S[i] == 'R') easy = 0;
  }
  cout << (easy ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll n,m,k,fact[200005],inv[200005];
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
ll C(int n,int m)
{
	if(n<m)return 0;
	return fact[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	fact[0]=1;
	for(int i=1;i<=n*m;i++)fact[i]=fact[i-1]*i%MOD;
	inv[n*m]=quick_pow(fact[n*m],MOD-2);
	for(int i=n*m;i>=1;i--)inv[i-1]=inv[i]*i%MOD;
	ll ans=0;
	for(int i=1;i<n;i++)
		ans+=C(n*m-2,k-2)*i*m%MOD*(n-i)*m%MOD;
	swap(n,m);
	for(int i=1;i<n;i++)
		ans+=C(n*m-2,k-2)*i*m%MOD*(n-i)*m%MOD;
	printf("%lld\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 3328
#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<double, double>;

double distance(P p1)
{
    return sqrt(p1.first * p1.first + p1.second * p1.second);
}

int main()
{
    double N, D;
    cin >> N >> D;

    P pos;
    int res = 0;
    rep(i, N)
    {
        cin >> pos.first >> pos.second;
        if (distance(pos) <= D)
            res++;
    }

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

Measured memory_bytes: 3840
#include<iostream>
#include<cstring>
using namespace std;
char a[100001];
long long n;
int main(){
	cin>>a;
	n=strlen(a)-1;
	for(int i=0;i<=n;i++){
		if(i%2==0) cout<<a[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

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

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

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

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, long long A, long long B) {
  cout<<min(A*N, B)<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String s = scanner.next();
			
			String s1 = s.substring(0, 4).toUpperCase();
			String s2 = s.substring(s1.length(),s.length()).toUpperCase();

			System.out.println(s1+" "+s2);
		}
	}
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 8 && b <= 8) {
    cout << "Yay!";
  } else {
    cout << ":(";
  }
}


Measured memory_bytes: 256