akhauriyash/Code-Regression huggingface dataset:
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;

public class Main {

	public static void main(String[] args) throws Exception {
		int a = in.i();
		int b = in.i();
		if ( a < b ) {
			out.print(2* b - 1);
		} else if ( a == b) {
			out.print(a + b);
		} else {
			out.print(2 * a -1);
		}
		out.println();
	}


	static PrintStream out = System.out;
	static FastReader in = new FastReader();
}

class FastReader {
	final private int BUF_SIZE = 1 << 16;
	private DataInputStream din;
	private byte[] buffer = new byte[BUF_SIZE];
	private int bufferPointer, bytesRead;

	FastReader() {
		din = new DataInputStream(System.in);
	}

	String s() throws IOException {
		byte[] buf = new byte[64];
		int cnt = 0, c;
		while ((c = read()) != -1) {
			if (c == '\n') break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	int i() throws IOException {
		int ret = 0;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do { ret = ret * 10 + c - '0'; }
		while ((c = read()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	long l() throws IOException {
		long ret = 0;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do { ret = ret * 10 + c - '0'; }
		while ((c = read()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	double d() throws IOException {
		double ret = 0, div = 1;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do { ret = ret * 10 + c - '0'; }
		while ((c = read()) >= '0' && c <= '9');
		if (c == '.')
			while ((c = read()) >= '0' && c <= '9')
				ret += (c - '0') / (div *= 10);
		return neg ? -ret : ret;
	}

	private void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUF_SIZE);
		if (bytesRead == -1) buffer[0] = -1;
	}

	private byte read() throws IOException {
		if (bufferPointer == bytesRead) fillBuffer();
		return buffer[bufferPointer++];
	}

	void close() throws IOException {
		if (din != null) din.close();
	}
}



Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	double r;
	
	cin >> r;

	cout << fixed << setprecision(5) << 3.141592653589 * r * r << " " << 2 * 3.141592653589 * r << endl;

	return 0;
}

Measured memory_bytes: 3188
<?php
  $n = trim(fgets(STDIN));
  $s = str_split($n);
  $cnt = count($s);
  $ans = true;
  $kisu = ['R', 'U', 'D'];
  $gusu = ['L', 'U', 'D'];
  for ($i = 0; $i < $cnt; $i++) {
    if ((($i + 1) % 2 === 1 && in_array($s[$i], $kisu)) ||
        (($i + 1) % 2 === 0 && in_array($s[$i], $gusu))) {
      continue;
    } else {
      $ans = false;
      break;
    }
  }
  $ans = $ans ? 'Yes' : 'No';
  echo $ans . PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,long long> mp;
  long long ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i];
    mp[a[i]]++;
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int b,c;
    cin>>b>>c;
    mp[c]+=mp[b];
    ans-=b*mp[b];
    ans+=c*mp[b];
    mp[b]=0;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 9544
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int field[21][21];

int getFarthest(int p) {
	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (field[p][i]) {
			field[i][p] = 0;
			res = max(res, field[p][i] + getFarthest(i));
		}
	}
	return res;
}

int main () {
	while (cin >> n, n) {
		int dim[n + 1];
		int sum_2t = 0;
		memset(dim, 0, sizeof(dim));
		memset(field, 0, sizeof(field));
		for (int i = 0; i < n - 1; i++) {
			int a, b, t;
			cin >> a >> b >> t;
			field[a][b] = field[b][a] = t;
			dim[a]++; dim[b]++;
			sum_2t += 2 * t;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if ((dim[i] == 1 || dim[j] == 1) && !(i == 1 && dim[i] == 1) && !(j == 1 && dim[j] == 1)) {
					sum_2t -= field[i][j];
					field[i][j] = 0;
				}
			}
		}
		cout << sum_2t - getFarthest(1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[200002];
int cnt[26];
int main(){
  int i;
  long long res;
  N = rd(S);
  res = (long long) N * (N+1) / 2 + 1;
  for(i=(0);i<(N);i++){
    cnt[S[i]-'a']++;
  }
  for(i=(0);i<(26);i++){
    res -= (long long) cnt[i] * (cnt[i]+1) / 2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N;
// char S[200002];
// int cnt[26];
// {
//   ll res;
//   rd(S@N);
//   res = (ll) N * (N+1) / 2 + 1;
//   rep(i,N) cnt[S[i]-'a']++;
//   rep(i,26) res -= (ll) cnt[i] * (cnt[i]+1) / 2;
//   wt(res);
// }


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

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

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

// #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

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  DisjointSet ds(N);
  vector<set<int>> friends(N);
  vector<set<int>> blocks(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    friends[a].insert(b);
    friends[b].insert(a);
    ds.Union(a, b);
    DBG(a, b, ds.Find(a), ds.Find(b), ds.Size(a), ds.Size(b));
  }
  REP(i, K) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    blocks[a].insert(b);
    blocks[b].insert(a);
  }

  REP(i, N) {
    int cnt = ds.Size(i) - 1 - friends[i].size();
    FOR(b, blocks[i]) if (ds.Find(b) == ds.Find(i)) --cnt;
    if (i) cout << " ";
    cout << cnt;
  }
  cout << endl;
}


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

const int64_t MOD = 1000000007;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;


// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
      v[k][j] %= MOD;
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;


signed main() {
  ll n;
  cin >> n;

  vector< pair<int,int> > job(n);
  int a,b;
  for(ll i=0;i<n;i++){
    cin >> a >> b;
    job[i] = make_pair(b,a);
  }
  sort(job.begin(),job.end());
  int now = 0;
  for(auto j: job){
    //cout << j.first << ":" << j.second << endl;
    if(j.first >= now + j.second){
    	now += j.second;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    if((b-1)%(a-1)==0) cout << (b-1)/(a-1) << endl;
    else cout << (b-1)/(a-1)+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
 int n;
  scanf("%d",&n);
  int c=0;
  if(n%10==0){
    printf("%d",10);
    return 0;
  }
  while(n!=0){
   c+=n%10;
    n/=10;
  }
 printf("%d",c);  
  return 0;
}

Measured memory_bytes: 128
N, K, *H = [*gets.split, *gets.split].map(&:to_i)

dp = [0]
1.step(N-1) do |i|
  min = Float::INFINITY
  1.step(K) do |j|
    index = i - j
    break if index < 0
    cost = dp[index] + (H[i]-H[index]).abs
    min = cost if cost < min
  end
  dp[i] = min
end
puts dp.last


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

int main()
{
    int s[4];
    int sum = 0;

    for (int i = 0; i < 4; i++){
        cin >> s[i];
        sum += s[i];
    }

    int i = 0;

    while (sum >= 60){
        sum -= 60;
        i++;
    }

    cout << i << endl << sum % 60 << endl;

    return (0);
}

Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;

vi solve(vi v){
    vi app(3);
    vi even{3,3,3,3,3};

    rep(i,5) v[i]--;
    rep(i,5) app[v[i]]++;
    
    if(app[0] && app[1] && app[2]) return even;
    rep(i,3){
        if(app[i]==0 && app[(i+1)%3]==0){
            return even;
        }
    }

    int win;
    rep(i,3){
        if(app[i] && app[(i+1)%3]) win=i;
    }
    rep(i,5){
        if(v[i]==win) v[i]=1;
        else v[i]=2;
    }
    return v;
}

int main(){
    while(1){
        vi v(5);
        if(cin >> v[0] && v[0]){
            rep(i,4) cin>>v[i+1];
            vi ans=solve(v);
            rep(i,5){
                cout<<ans[i]<<endl;
            }
        }else break;
    }
}

Measured memory_bytes: 1208
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	vi sum(n+1);
	rep(i, n) {
		sum[i+1] = sum[i] ^ (1<<(s[i]-'a'));
	}

	vi dp(1<<26, INF);
	dp[0] = 0;
	rep(i, n-1) {
		rep(j, 26) {
			chmin(dp[sum[i+1]], dp[sum[i+1]^(1<<j)]+1);
		}
	}

	int ans = dp[sum[n]]+1;
	rep(i, 26) {
		chmin(ans, dp[sum[n]^(1<<i)]+1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 266500
#pragma comment(linker, "/STACK:512000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
  string s = FILENAME;
//    assert(!s.empty());
  freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/cryptozoology/output.txt", "w", stdout);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0)
  {
    if (rl.rlim_cur < kStackSize)
    {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0)
      {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
      //cout << "Case #" << testNum++ << ": ";
      solve(true);
  }
  cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cout.flush();
  auto end = clock();

  usleep(10000);
  print_stats(end - start);
  usleep(10000);
#endif

    return 0;
}

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

template<typename T>
void relax_min(T& cur, T val) {
    cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

void precalc() {
}

#define int li
const int mod = 998244353;

const int C = 3010;
int dp[C][C];

void add(int& cur, int val) {
  cur += val;
  cur %= mod;
}

void solve(__attribute__((unused)) bool read) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  dp[a][b] = 1;
  for (int i = a; i < c; ++i) {
    int pref_sum = 0;
    for (int j = b; j <= d; ++j) {
      pref_sum = pref_sum * i % mod;
      add(dp[i + 1][j], dp[i][j] * j + pref_sum);
      add(pref_sum, dp[i][j]);
    }
  }
  int res = 0;
  for (int j = b; j <= d; ++j) {
    res = res * c % mod;
    add(res, dp[c][j]);
  }
  cout << res << "\n";
}

Measured memory_bytes: 74088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n;i++) cin >> a[i];
    int ans = 0;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(a[i] <= a[i-1]) cnt++;
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(cnt, ans);
    cout << ans;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll f(ll a){
  return a*(a+1)/2;
}
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=1;i<=a;i++){
    for(int j=1;j<=b;j++){
      if(i*j+(a-i)*(b-j)==c){
        PRS("Yes");
        return 0;
      }
    }
  }
  if(c%a<1||c%b<1){
    PRS("Yes");
    return 0;
  }
  PRS("No");
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] as = br.readLine().split(" ");
		
		long h = Long.parseLong(as[0]);
		long w = Long.parseLong(as[1]);
		long hw = h*w;
		if(h == 1 || w == 1) {
			System.out.println(1);
		}else if(hw%2 == 1) {
			System.out.println(hw/2 + 1);
		}else {
			System.out.println(hw/2);
		}

	}

}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    string s;
    cin >> s;

    int nb=0;
    int nr=0;
    REP(i,N) {
        if(s[i]=='R') nr++;
        else nb++;
    }

    Yes(nr > nb)

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++) // for loop
#define RREP(x,l,u) for(ll x = l;x>=u;x--) // reverse for loop

/**
 *  debugging stuff
 */
string to_string(string s) {return s;}
string to_string(char c) {return string(1,c);}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

/**
 *  more debugging stuff
 */
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL; 
typedef pair<ll,ll> PLL;
typedef vector<string> VS;

template <typename A, typename B> void in(A & a, B & b) { in(a); in(b); }
template <typename A, typename B, typename C> void in(A & a, B & b, C & c) { in(a); in(b); in(c); }

const ll inf = (ll)1e18 + 5;

ll N;
VLL A,B,C;
VVLL activities;
VVLL memoize;

ll happiness(ll current_activity, ll day) {

    if (memoize[current_activity][day] != -1) return memoize[current_activity][day];

    if (day == 0) return activities[current_activity][day];

    memoize[current_activity][day] = max(happiness((current_activity + 1) % 3, day-1) + activities[current_activity][day], happiness((current_activity + 2) % 3, day-1) + activities[current_activity][day]);

    return memoize[current_activity][day];
}

namespace SOLVE {	
	void main() {
        
        cin >> N;

        REP(i,0,N) { 
            ll a,b,c;

            cin >> a >> b >> c;

            A.push_back(a);
            B.push_back(b);
            C.push_back(c);
        }

        activities.push_back(A);
        activities.push_back(B);
        activities.push_back(C);

        memoize.resize(3,VLL(N,-1));

        ll max_happiness_a = happiness(0, N-1);
        ll max_happiness_b = happiness(1, N-1);
        ll max_happiness_c = happiness(2, N-1);

        ll maxi = max({max_happiness_a, max_happiness_b, max_happiness_c});

        cout << maxi << endl;
	}
}

signed main() {
	ll t;
	t = 1;
    // cin >> t;
	REP(i,0,t) {
		SOLVE::main();
	}

	return 0;
}

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

using namespace std;

int main()
{
	int ans = 0;
	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++)
	{
		switch (S[i])
		{
		case '+':
			ans++;
			break;
		case '-':
			ans--;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  string S; cin >> S; int N = S.size();
  ll cnt=0, ans=0;
  rep(i, N-1){
    if(S[i]=='A') cnt++;
    if(S[i]=='B' && S[i+1]=='C'){
      ans+=cnt; i++; continue;
    }
    if(S[i]!='A') cnt=0;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main()
{
    unsigned short *A,*B;
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);
    for(i=0;i<=VMAX;i++)
        C[i]=0;
    for(i=0;i<n;i++)
    {
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    for(i=1;i<=VMAX;i++){
        C[i]=C[i]+C[i-1];}
    for(j=1;j<=n;j++)
    {
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n;i++)
    {
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 9572
k= int(input())
 
if k % 2 == 0 or k % 5 == 0:
    print("-1")
    
else:
    ans = 1
    s = 7
    while True:
        if s % k == 0:
            print(ans)
            break
        else:
            s = (s % k)*10 + 7
            ans += 1


Measured memory_bytes: 62872
/*
  AOJ #3100
  Strange Plants
  @kankichi57301
 */
#include <stdio.h>
#include <string.h>
#define max(a,b) ((a)>(b)?(a):(b))

int x,a,b,n;
char s[10];
int main()
{
  int i;
  
  scanf("%d %d %d",&x,&a,&b);
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%s",s);
    if(0==strcmp(s,"nobiro"))
      x = max(0,x+a);
    else if(0==strcmp(s,"tidime"))
      x = max(0,x+b);
    else if(0==strcmp(s,"karero"))
      x = 0;
    //printf("%d\n",x);
  }

  printf("%d\n",x);
  return (0);
}



Measured memory_bytes: 2108
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int e;
    while(cin >> e) {
        if(e == 0) break;
        int ans = inf;
        for(int z = 0; z <= 100; ++ z) {
            if(e - z * z * z >= 0) {
                int res = e - z * z * z;
                int y = (int)sqrt(res);
                chmin(ans, z + y + res - y * y);
            }
        }
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
	please AC;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int>arr(n+1);
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	vector<int>dp(n+1,INT_MAX);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;i-j>0&&j<=k;j++){
			if(dp[i-j]!=INT_MAX)dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

typedef long long ll;
const int mx = 1e5 + 5;

int tmp[mx];
void apply(int n, int *send, int *reci){
    for(int i = 0; i < n; i++){
        tmp[i] = reci[send[i]];
    }
    copy(tmp,tmp+n,reci);
}

void powperm(ll k, int n, int *p, int *ret){
    iota(ret,ret+n,0);
    for(;k;k>>=1){
        if(k&1){
            apply(n,p,ret);
        }
        apply(n,p,p);
    }
}

int ans[mx];
int basep[mx];
ll x[mx], dx[mx];
int n, m;
ll k;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        if(i) dx[i-1] = x[i] - x[i-1];
    }
    iota(basep,basep+n,0);
    cin >> m >> k;
    for(int i = 0, j; i < m; i++){
        cin >> j;
        swap(basep[j-2],basep[j-1]);
    }
    powperm(k,n-1,basep,ans);
    ll X = x[0];
    for(int i = 0; i < n; i++){
        cout << X << '\n';
        X += dx[ ans[i] ];
    }
}


Measured memory_bytes: 3968
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}c(200005);

int main(){
    int s;
    cin >> s;
    mint ans=0;
    combination c(2005);
    for(int i=0;i<s/3;i++){
        int temp=s-2*(i+1);
        ans+=c(temp-1,i);
        //cerr<<i<<' '<<c(temp-1,i)<<endl;
    }
    cout<<ans.x<<endl;
    return 0;

}

Measured memory_bytes: 6224
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

bool solve(const vector<string> &S, vector<int> &perm){
    int H = S.size();
    int W = S[0].size();
    vector<vector<int>> T(H, vector<int>(W));
    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            T[i][j] = S[perm[i]][j] - 'a';

//    for(int i=0; i<H; i++){
//        for(int j=0; j<W; j++){
//            cerr << char('a'+T[i][j]) << " ";
//        }
//        cerr << endl;
//    }

    vector<bool> used(W, false);
    for(int i=0; i<W; i++){
        if(used[i]) continue;
        for(int j=i+1; j<W; j++){
            if(used[j]) continue;
            bool ok = true;
            for(int k=0; k<H; k++){
                if(T[k][i] != T[H-1-k][j]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                used[i] = true;
                used[j] = true;
                break;
            }
        }
    }
    int cnt = 0;
    for(int i=0; i<W; i++)
        if(used[i])
            cnt++;

    cnt = W - cnt;

    if(cnt == 0) return true;
    if(cnt > 1) return false;
    int idx = 0;
    for(int i=0; i<W; i++)
        if(!used[i])
            idx = i;
    for(int i=0; i<H; i++)
        if(T[i][idx] != T[H-1-i][idx])
            return false;
    return true;
}



int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0; i<H; i++) cin >> S[i];

    for(int i=0; i<(1<<H); i++){
        if(__builtin_popcount(i) != (H+1)/2) continue;
        vector<string> T;
        for(int j=0; j<H; j++)
            if(i & (1<<j))
                T.push_back(S[j]);
        for(int j=0; j<H; j++)
            if(!(i & (1<<j)))
                T.push_back(S[j]);

        vector<int> perm;
        for(int i=0; i<H; i++)
            perm.push_back(i);
        do{
            if(solve(T, perm)){
                cout << "YES" << endl;
                return 0;
            }
        }while(next_permutation(perm.begin(), perm.begin()+(H+1)/2));
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    string S;
    int ope[4];
    int table[10][10];
    while(1){
        cin >> S;
        if(S=="#"){
            return 0;
        }
        REP(i,4){
            cin >> ope[i];
            ope[i]--;
        }
        REP(i,10){
            REP(j,10){
                table[i][j]=0;
            }
        }
        int nowi=0,nowj=0;
        REP(i,S.size()){
            if(S[i]=='b'){
                table[nowi][nowj]=1;
                nowj++;
            }else if(S[i]=='/'){
                nowj=0;
                nowi++;
            }else{
                nowj+=(int)(S[i]-'0');
            }
        }
        table[ope[0]][ope[1]]=0;
        table[ope[2]][ope[3]]=1;
        
        //REP(i,nowi+1){REP(j,nowj){cout << table[i][j];}cout << endl;}
        
        int str=0;
        REP(i,nowi+1){
            REP(j,nowj){
                if(table[i][j]==1 || j+1==nowj){
                    if(table[i][j]==0){
                        str++;
                    }
                    if(str!=0){
                        cout << str;
                    }
                    if(table[i][j]==1){
                        cout << "b";
                    }
                    str=0;
                }else{
                    str++;
                }
            }
            if(i!=nowi){
                cout << "/";
            }
        }
        cout << endl;
    }
    return 0;
}




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

int main() {
    long long a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if (a < b && (a + v * t) >= (b + w * t))
        cout << "YES";
    else if (a > b && (a - v * t) <= (b - w * t))
        cout << "YES";
    else
        cout << "NO";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
void lcs( string X, string Y )
{
   int L[X.size()+1][Y.size()+1];
   for (int i=0; i<=X.size(); i++)
   {
     for (int j=0; j<=Y.size(); j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (X[i-1] == Y[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
   int index = L[X.size()][Y.size()];
   vector<char> a;
   int i = X.size(), j = Y.size();
   while (i > 0 && j > 0)
   {
      if (X[i-1] == Y[j-1])
      {
          a.push_back(X[i-1]);
          i--; j--; index--;
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
   for(int i = a.size()-1 ; i > -1 ; i--)cout<<a[i];
   cout <<endl;
}
int main(){
    fastIO;
    int t(1);
    //cin >> t;
    while (t--){
        string a, b;
        cin>>a>>b;
        lcs(a,b);
    }
}


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


int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a,a);
}



int lcm(int x, int y){
	if(x == 0 || y==0) return 0;
	return x/gcd(x, y) *y;
}

signed main() {
  int A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
while 1
    n, x = gets.split.map &:to_i
    exit if n == 0 and x == 0
    count = 0
    (1..n).each{ |i|
        ((i+1)..n).each { |j|
            ((j+1)..n).each {|k|
                count += 1 if i != j and j!= k and j != k and i + j + k == x
            }
        }
    }
    puts count
end


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

#define INF 1e9
using namespace std;

int main() {

    string S, T; cin >> S >> T;

    //変換、逆変換のテーブルを-1で初期化
    vector<int> start(26, -1);
    vector<int> goal(26, -1);

    for (int i = 0; i < S.size(); ++i) {
        int a = S[i] - 'a';
        int b = T[i] - 'a';

        if (start[a] != -1 || goal[b] != -1) {
            if (start[a] != b || goal[b] != a) {
                puts("No");
                return 0;
            }
        } else {
            start[a] = b;
            goal[b] = a;
        }
    }

    puts("Yes");
}

Measured memory_bytes: 776
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<set>
using namespace std;

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

	int K;
	cin >> K;

	set<string> dic;
	for(int i=0; i<5; i++)
		for(int j=0; j<(int)s.size()-i; j++)
			dic.insert(s.substr(j, i+1));

	int i;
	set<string>::iterator it;
	for(it=dic.begin(), i=0; it!=dic.end(); it++, i++){
			if(i == K-1){
				cout << *it << endl;
				return 0;
			}
	}
}


Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
int main()
{
	string a;
	int k;
	cin>>k;
	cin>>a;
	int l=a.size()-1;
	if(k>l)
	cout<<a;
	else
	{
		for(int i=0;i<k;i++)
		cout<<a[i];
		cout<<"...";
	}
	
}

Measured memory_bytes: 3624
import Data.List

toDouble :: Int -> Double
toDouble = fromIntegral

step :: Int -> Int -> (Int,Int) -> (Int,Int) -> (Int,Int)
step t a (accIdx,accV) (idx,v)
    | d2 <= d1 = (idx,v)
    | otherwise = (accIdx,accV)
    where
        d1 = abs $ (toDouble a) - (toDouble t - toDouble accV * 0.006)
        d2 = abs $ (toDouble a) - (toDouble t - toDouble v * 0.006)

main = do
    n <- readLn :: IO Int
    [t,a] <- map read . words <$> getLine :: IO [Int]
    hs <- map read . words <$> getLine :: IO [Int]
    print $ fst $ foldl' (step t a) (0,10^9) $ zip [1..n] hs

Measured memory_bytes: 1276
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000

int L[MAX/2+2],R[MAX/2+2];
int count=0;

void merge(int A[],int n,int left, int mid, int right){
  int i,j,k;
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  for (i = 0; i < n1; i++) L[i]=A[left+i];
  for (i = 0; i < n2; i++) R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]) A[k]=L[i++];
    else A[k]=R[j++];
  }
}

void mergesort(int A[],int n,int left,int right){
  int mid;
  if(left+1<right){
  mid=(left+right)/2;
  mergesort(A,n,left,mid);
  mergesort(A,n,mid,right);
  merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
      scanf("%d",&A[i]);
  }
  mergesort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)  printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, n / 2) {
    if (s[i] != s[n / 2 + i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
s = list(input())

rnum = s.count('R')
gnum = s.count('G')
bnum = s.count('B')
ans = rnum * gnum * bnum
for i in range(n):
    for j in range(n):
        d = i+j 
        f = d+j 
        if f>=n:
            break
        if s[i]!=s[d] and s[d]!=s[f] and s[f]!=s[i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9104
# coding: utf-8

import sys
import fractions
import functools

K, M = (int(x) for x in input().split())

A = [int(x) for x in input().split()]

A = [x for x in set(A)]
A.sort()

#print("A = " + str(A))#

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0
a_0 = A[0]
while a_0 % 2 == 0:
	a_0 /= 2
	div += 1

#print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(A)):
	div2 = 0
	a = A[i]
	while a % 2 == 0:
		a /= 2
		div2 += 1
	#print("A[" + str(i) + "] count = " + str(div2))#
	if div2 != div:
		print("0")
		sys.exit()

# Aのすべての整数の最小公倍数を計算する
A = [a // 2 for a in A]
lcm = functools.reduce(lambda a, b: a * b // fractions.gcd(a, b), A, 1)
#print("lcm = " + str(lcm))#

# 1以上M以下の最小公倍数の奇数倍の整数の個数を数える
print(-(-(M // lcm) // 2))

Measured memory_bytes: 16308
#define _USE_MATH_DEFINES
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

double th = M_PI * 60.0 / 180.0;
struct point {
	double x;
	double y;
};

void kochCurve(point left, point right, int n)
{
	point p1, p2, p3;
	if (n == 0)
		return;
	p1.x = (left.x * 2 + right.x) / 3;
	p1.y = (left.y * 2 + right.y) / 3;
	p3.x = (left.x  + right.x*2) / 3;
	p3.y = (left.y  + right.y*2) / 3;

	p2.x = p1.x + (p3.x - p1.x)*cos(th) - (p3.y - p1.y)*sin(th);
	p2.y = p1.y + (p3.x - p1.x)*sin(th) + (p3.y - p1.y)*cos(th);
	
		kochCurve(left, p1, n - 1);
		printf("%lf %lf\n", p1.x, p1.y);
		kochCurve(p1, p2, n - 1);
		printf("%lf %lf\n", p2.x, p2.y);
		kochCurve(p2, p3, n - 1);
		printf("%lf %lf\n", p3.x, p3.y);
		kochCurve(p3, right, n - 1);
}

int main()
{
	int n;
	point l = { 0,0 }, r= { 100,0 };

	cin >> n;
	printf("%lf %lf\n", l.x, l.y);
	kochCurve(l,r,n);
	printf("%lf %lf\n", r.x, r.y);

	return 0;
}


Measured memory_bytes: 3420
N = int(input())

numOfDigit = 1
answer = 0

n = 1
while(N >= n * 10):
    if (numOfDigit % 2):
        answer += n * 9
    numOfDigit += 1
    n *= 10

if (numOfDigit % 2):
    answer += N % (n * 10) - n + 1

print(answer)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005],b[100005],ans[100005];
int low[100005];
int main(){
	int n,i,len,fin;
	int x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(i=1;i<=n;i++){
        a[i]=b[n-i+1];
	}

	len=0; low[++len]=a[1]; ans[1]=len;
	for(i=2;i<=n;i++){//遍历a[i]
		if(a[i]>=low[len])
			low[++len]=a[i];
		else
			*lower_bound(low+1,low+1+len,a[i]+1)=a[i];//第一个大于a[i]的数，替换掉
		ans[i]=len;
	}
	/*
	for(i=1,x=0;i<=n;i++){
        printf("%d ",ans[i]);
	}
	*/
	printf("%d\n",ans[n]);
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int str = s.length();
    int f = 0;
    for(int i = 0;i < s.length()/2;i++)
    {
        if(s[i] != s[s.length() - i - 1])
        {
            if(s[i] != 'x' && s[s.length()-i-1] != 'x')
            {
                cout << "-1";
                return 0;
            }
            if(s[i] == 'x')
            {
                s.insert(s.length()-i,"x");
            } else {
                s.insert(i,"x");
            }
            i--;
            f++;
        }
    }
    cout << f;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif


int lcs(std::string &x, std::string &y) {
    static int dp[1002][1002];

    for (int i = 0; i < x.length() + 2; i++) {
        for (int j = 0; j < y.length() + 2; j++) {
            dp[i][j] = 0;
        }
    }

    for (int i = 1; i <= x.length(); i++) {
        for (int j = 1; j <= y.length(); j++) {
            if (x[i - 1] == y[j - 1]) {
                dp[i][j] = std::max(dp[i - 1][j - 1] + 1, dp[i - 1][j]);
                dp[i][j] = std::max(dp[i][j], dp[i][j - 1]);
            } else {
                dp[i][j] = std::max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    #ifdef DEBUG
    for (int i = 1; i <= x.length(); i++) {
        for (int j = 1; j <= y.length(); j++) {
            std::cout << dp[i][j] << ", ";
        }
        std::cout << std::endl;
    }
    #endif

    return dp[x.length()][y.length()];
}

int main() {
    int q;
    std::cin >> q;

    for (int qi = 0; qi < q; qi++) {
        std::string x, y;
        std::cin >> x >> y;
        std::cout << lcs(x, y) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 7052