akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

bool g(vi &a, vi &b) {
    FOR(i, 0, a.size()) {
        if(a[i] > b[i]) return true;
        if(a[i] < b[i]) return false;
    }
    return false;
}

bool eq(vi &a, vi &b) {
    FOR(i, 0, a.size()) {
        if(a[i] != b[i]) return false;
    }
    return true;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();
    int n; cin>>n;
    vi a(n), b(n);
    FOR(i, 0, n) cin>>a[i];
    FOR(i, 0, n) cin>>b[i];
    if(g(a, b)) swap(a, b);
    int res = 0;
    while(true) {
        if(eq(a, b)) break;
        next_permutation(all(a));
        res++;
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int N;
ll A[100010];
ll B[100010];
ll C[100010];
ll n[100010];
ll ans[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  reverse(A, A+N);
  reverse(B, B+N);
  for (auto i = 0; i < N; i++) {
    C[i] = A[i]%B[i];
    if (C[i] != 0) {
      C[i] = B[i] - C[i];
    }
  }
  ans[0] = C[0];
  n[0] = 0;
  for (auto i = 0; i < N-1; i++) {
    ll temp = C[i+1] - C[i] - B[i] * n[i];
    if (temp >= 0) {
      ans[i+1] = temp;
      n[i+1] = 0;
    } else {
      ll plus = abs(temp) % B[i+1];
      ll sho = abs(temp) / B[i+1];
      if (plus == 0) {
        ans[i+1] = 0;
        n[i+1] = sho;
      } else {
        ans[i+1] = B[i+1] - plus;
        n[i+1] = sho+1;
      }
    }
  }
  ll sum = 0;
  for (auto i = 0; i < N; i++) {
    sum += ans[i];
  }
  cout << sum << endl;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}


signed main(void){
    int x;cin>>x;
    int a=x/500*1000;
    int b=x%500/5*5;
    cout << a+b << endl;

    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            string day = Console.ReadLine();
            List<int> front = new List<int>();
            List<int> back = new List<int>();

            List<int> workday = new List<int>();

            for (int i = 0; i < n; i++)
            {
                if (day[i] == 'o')
                    workday.Add(i);
            }

            front.Add(workday[0]);
            int current = workday[0];

            for (int i = 1; i < workday.Count && front.Count < k; i++)
            {
                if (workday[i] - current > c)
                {
                    front.Add(workday[i]);
                    current = workday[i];
                }
            }

            back.Add(workday[workday.Count - 1]);
            current = workday[workday.Count - 1];

            for (int i = workday.Count - 2; i >= 0 && back.Count < k; i--)
            {
                if (current - workday[i] > c)
                {
                    back.Add(workday[i]);
                    current = workday[i];
                }
            }

            back.Reverse();

            for (int i = 0; i < k; i++)
            {
                if (front[i] == back[i])
                    Console.WriteLine(front[i] + 1);
            }
        }

    }
}


Measured memory_bytes: 22492
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        long[] h = new long[n];
        List<Integer>[] ab = new List[n];

        for(int i=0; i<n; i++){
            h[i] = sc.nextLong();
            ab[i] = new ArrayList<Integer>();
        }
        for(int i=0; i<m; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();

            ab[a-1].add(b-1);
            ab[b-1].add(a-1);
        }

        int total = 0;
        for(int i=0; i<n; i++){
            boolean flag = true;
            int size = ab[i].size();
            for(int j=0; j<size; j++){
                int num = ab[i].get(j);
                if(h[i] <= h[num]){
                    flag = false;
                    break;
                }
            }
            if(flag)total++;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 72968
mod = 10 ** 9 + 7

S = input()
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= mod
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= mod
    mul = mul * 10 % 13

print(dp[len(S)][5])


Measured memory_bytes: 62300
import itertools

T = [1,2,3,4,5,6,7,8,9]
L = list(itertools.product(T, repeat=2))
S = []
for i in range(len(L)):
    S.append(L[i][0]*L[i][1])
    
n = int(input())
if n in S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int n,min = 1000,max = 0;
  scanf("%d",&n);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
    if(min > a[i]){
      min = a[i];
    }
    if(max < a[i]){
      max = a[i];
    }
  }
  printf("%d",max - min);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b, x, c;
	cin >> x >> a >> b;
	c = (x - a) / b;
	cout << x - a - c*b << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[10];

int main()
{
    REP(i, 7)
    {
        cin >> A[i];
    }

    ll k = 0;
    k += A[1];
    ll i = A[0] - A[0] % 2;
    k += i;
    A[0] -= i;
    ll j = A[3] - A[3] % 2;
    k += j;
    A[3] -= j;
    ll l = A[4] - A[4] % 2;
    k += l;
    A[4] -= l;
    if (A[0] + A[3] + A[4] == 2)
    {
        if ((A[0] == 0 && i > 0) || (A[3] == 0 && j > 0) || (A[4] == 0 && l > 0))
            k += 1;
    }
    else if (A[0] + A[3] + A[4] == 3)
    {
        k += 3;
    }

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

Measured memory_bytes: 256
X = int(input())

if 400 <= X <= 599:
  print(8)
elif 600 <= X <= 799:
  print(7)
elif 800 <= X <= 999:
  print(6)
elif 1000 <= X <= 1199:
  print(5)
elif 1200 <= X <= 1399:
  print(4)
elif 1400 <= X <= 1599:
  print(3)
elif 1600 <= X <= 1799:
  print(2)
elif 1800 <= X <= 1999:
  print(1)


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = n; i >= 0; i--) {
        if (s.substr(n-i, i) == t.substr(0, i)) {
            cout << 2*n-i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct RMQ{
  int n;
  vector<int> dat;
  const int def=0;
  RMQ(){}
  RMQ(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
int dp[114514];
int sum[114514];
int x[114514];
typedef pair<int,int> P;
int mceil(int p,int q){
  return (p+q-1)/q;
}
signed main(){
  int w,n;
  while(cin>>w>>n,w||n){
    for(int i=0;i<n;i++) cin>>x[i];
    fill(dp,dp+114514,w);
    priority_queue<P,vector<P>,greater<P> > q;
    q.push(P(0,0));
    dp[0]=0;
    sum[0]=0;
    for(int i=0;i<n;i++) sum[i+1]=sum[i]+x[i];
    RMQ rmq(n+1);
    while(!q.empty()){
      P p=q.top();q.pop();
      int s=p.first,k=p.second;
      if(dp[k]<s) continue;
      if(k==n) break;
      int y=max(k,rmq.query(0,k)),z=0;
      for(int i=y;i<n;i++){
	int tmp=sum[i+1]-sum[k];
	if(i!=n-1&&i==k) continue;
	if(w<tmp+i-k) break;
	int res;
	if(i==n-1) res=max(s,1LL);
	else res=max(s,mceil(w-tmp,i-k));
	//cout<<i<<":"<<res<<endl;
	if(res<dp[i+1]&&res<dp[n]){
	  dp[i+1]=res;
	  q.push(P(dp[i+1],i+1));
	}
	z=i;
      }
      rmq.update(k,z);
    }
    //for(int i=0;i<n;i++) cout<<i<<" "<<dp[i]<<endl;
    cout<<dp[n]<<endl;;
  }
  return 0;
}

Measured memory_bytes: 7144
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
	
void solve(){
  char x, c, y;
  map<char, bool> m = { {'A', true}, {'B', false}, {'C', false}};
  while(cin >> x >> c >> y){
	  swap(m[x], m[y]);  
	}
  for(auto it : m){
	  if(it.s == true) 
	    cout << it.f << endl;  
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3024
N = int(input())
ls = list(map(int,input().split()))
import collections
c = collections.Counter(ls)
unique_ls = list(reversed(sorted(([i[0] for i in c.items() if i[1] >= 2]))))

square_max = 0
rectan_a = 0
rectan_b =0

if len(unique_ls) >=2:
  if ls.count(unique_ls[0]) >=4:
    print(unique_ls[0]**2)
  else:
    print(unique_ls[0]*unique_ls[1])
elif len(unique_ls) ==1:
  if ls.count(unique_ls[0]) >=4:
    print(unique_ls[0]**2)
  else:
    print(0)
else:
  print(0)

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

int a,b,c;
int x,y,z;

int main()
{
	cin>>a>>b>>c;
	x = min(a,min(b,c));
	z = max(a,max(b,c));
	y = a + b + c - x - z;
	if((x == y && y != z ) || ( x != y && y == z))
	cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int uni[100010];
long long dat[100010];

void init(){
    for(int i = 0;i < 100010;i++){
        uni[i] = i;
        dat[i] = 1;
    }
    return;
}

int root(int i){
    if(i == uni[i]) return i;
    return uni[i] = root(uni[i]);
}

long long unite(int i, int j){
    i = root(i);
    j = root(j);

    if(i == j){
        return 0;
    }else{
        long long ans = dat[i] * dat[j];
        uni[max(i, j)] = min(i, j);
        dat[min(i, j)] += dat[max(i, j)];
        return ans;
    }
}

int a[100010], b[100010];

int main(){
    long long n, m;
    cin >> n >> m;
    init();

    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
    }

    long long ans[100010];

    ans[m-1] = (n-1)*(n)/2;

    for(int i = m-2;i >= 0;i--){
        ans[i] = ans[i+1] - unite(a[i+1], b[i+1]);
    }

    for(int i = 0;i < m;i++){
        cout << ans[i] << endl;
    }

    return 0;
}


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

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

long long int ans[2][1000001];
int main(){
  int n;
  cin >> n;
  priority_queue<P, vector<P>, greater<P>> que;
  for(int i=0; i<n; i++){
    long long int x,l;
    cin >> x >> l;
    que.push(P(x+l,x-l));
  }
  ans[0][0] = 0;
  ans[1][0] = -100000000001;
  int i = 0;
  for(int i=1; i<=n; i++){
    P p = que.top(); que.pop();
    if(ans[1][i-1]<=p.second){
      ans[0][i]+=ans[0][i-1]+1;
      ans[1][i]=p.first;
    }else{
      ans[0][i]=ans[0][i-1];
      ans[1][i]=ans[1][i-1];
    }
  }
  cout << ans[0][n] << endl;
  return 0;
}

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

using ll = long long;

const ll MOD = 1e9 + 7;

int main() {
    int N, x, j = 0;
    cin >> N;
    ll ans = 1;
    rep(i, N) {
        cin >> x;
        if (x < (i - j) * 2 + 1) {
            ans = (ans * (i - j + 1)) % MOD;
            //cout << i << j << ans << endl;
            j++;
        }
    }
    for (int i = 1; i <= N - j; ++i) {
        ans = (ans * i) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ps(N);
  vector<int> qs(N);
  vector<int> sorteds(N);
  vector<int> indexs(N);
  for (int i = 0; i < N; i++) {
    cin >> ps.at(i);
    sorteds.at(i) = ps.at(i);
    indexs[i] = i;
  }
  for (int i = 0; i < N; i++) {
    cin >> qs.at(i);
  }
  sort(sorteds.begin(), sorteds.end());
  int count = 0;
  int a = -1;
  int b = -1;
  do {
    int pcnt = 0;
    int qcnt = 0;
    for (int i = 0; i < N; i++) {
      if (sorteds.at(indexs[i]) == ps.at(i)) {
        pcnt++;
      }
      if (sorteds.at(indexs[i]) == qs.at(i)) {
        qcnt++;
      }
    }
    if (pcnt == (int)ps.size()) {
      a = count;
    }
    if (qcnt == (int)qs.size()) {
      b = count;
    }

    if (a != -1 && b != -1) {
      break;
    }
    count++;
  } while (next_permutation(indexs.begin(), indexs.end()));
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 3632
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  if (a == 1) {
    a = 14;
  }
  if (b == 1) {
    b = 14;
  }
  if (a > b) {
    writeln("Alice");
  } else if (b > a) {
    writeln("Bob");
  } else {
    writeln("Draw");
  }
}


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

class Baseball
{
   public Baseball()
   {
      scoreList.Add(0);
      runnerList[0] = true;
   }

   private List<int> scoreList = new List<int>();
   public List<bool> runnerList = new List<bool>(Enumerable.Repeat(false, 4));

   public int Inning { get; private set; }
   public int[] Score { get { return scoreList.ToArray();} }
   public int OutCount { get; private set; }
   public bool[] Runner { get { return runnerList.ToArray(); } }

   public void Hit()
   {
      int Third = runnerList.Count - 1;
      if (runnerList[Third])
      {
         scoreList[Inning]++;
         runnerList[Third] = false;
      }

      for (int i = Third - 1; i >= 0; i--)
      {
         if (!runnerList[i]) { continue; }

         runnerList[i + 1] = true;
         runnerList[i] = false;
      }
         
      runnerList[0] = true;
   }   

   public void Homerun()
   {
      int Third = runnerList.Count - 1;
      for (int i = 0; i <= Third; i++)
      {
         if (!runnerList[i]) { continue; }

         scoreList[Inning]++;
         runnerList[i] = false;
      }

      runnerList[0] = true;
   }

   public void Out()
   {
      OutCount++;
      if (OutCount < 3) { return; }

      int Third = runnerList.Count - 1;
      for (int i = 1; i <= Third; i++)
      {
         runnerList[i] = false;
      }
      scoreList.Add(0);
      Inning++;
      OutCount = 0;
   }   
}

class MainClass
{
   static void Main(string[] args)
   {
      var stringbuilder = new StringBuilder();

      var baseboll = new Baseball();

      int n = int.Parse(Console.ReadLine());
      while (baseboll.Inning < n)
      {   
         string evnt = Console.ReadLine();
         switch (evnt)
         {
         case "HIT":
            baseboll.Hit();
            break;
         case "HOMERUN":
            baseboll.Homerun();
            break;
         case "OUT":
            baseboll.Out();
            break;
         }
      }

      var scores = baseboll.Score;
      for (int i = 0; i < baseboll.Inning; i++)
      {
         stringbuilder.AppendLine(scores[i].ToString());
      }

      Console.Write(stringbuilder.ToString());
   }
}

Measured memory_bytes: 9524
#include<stdio.h>
#include<stdlib.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m[1010],i,j,k,d[510][510]={};
  while(scanf("%d",&n),n){
    for(i=0;i<310*310;i++)d[i/310][i%310]=0;
    for(i=0;i<n;i++)scanf("%d",&m[i]);
    for(i=0;i<=n;i++){
      for(j=0;i+j<=n;j++){
	if(i<2)d[j][j+i]=0;
	else if(d[j+1][j+i-1]+2==i&&abs(m[j]-m[j+i-1])<2)d[j][j+i]=i;
	else{
	  for(k=j+1;k<i+j;k++)d[j][j+i]=MAX(d[j][j+i],d[j][k]+d[k][j+i]);
	}//printf("%d %d %d\n",j,j+i,d[j][j+i]);
      }
    }
    /*for(i=0;i<=n;i++){
      for(j=0;j<=n;j++)printf("%2d ",d[i][j]);printf("\n");
      }//*/
    printf("%d\n",d[0][n]);
  }
  return 0;
}



Measured memory_bytes: 2820
#include <iostream>

using namespace std;

int main(){
    int N;
    string stones;
    cin >> N >> stones;
    int count = 0;
    for(int i=0; i<stones.length(); ++i){
        if(stones[i]=='.') ++count;
    }
    int res = count;
    for(int i=0; i<stones.length(); ++i){
        if(stones[i]=='#') ++count;
        else --count;
        res = min(res, count);
    }
    cout << res << endl;
}


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

int main(){
  string s;
  cin>>s;
  int dp[200000][2]={0};
  dp[0][0]=1;
  if (s[0]==s[1]) dp[1][1]=1;
  for (int i(0);i<s.size();i++){
    if (s[i]!=s[i+1] && i <= s.size()-2) dp[i+1][0] = max(dp[i+1][0],dp[i][0]+1);
    dp[i+1][0] = max(dp[i+1][0],dp[i][1]+1);
    if (i == 0){
      dp[i+2][1] = max(dp[i+2][1],dp[i][0]+1);
      continue;
    }
    if (i <= s.size()-3&& s[i-1]+s[i] != s[i+1]+s[i+2]){
      dp[i+2][1] = max(dp[i+2][1],dp[i][1]+1);
    }
    dp[i+2][1] = max(dp[i+2][1],dp[i][0]+1);
  }
  // for (int i(0);i<s.size();i++) cout << dp[i] << " ";
  cout << max(dp[s.size()-1][0],dp[s.size()-1][1]) << endl;
  return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    
    a.push_back(a[0]);
    vector<int> b(N, 0);
    rep(i, N) b[i] = a[i] ^ a[i + 1];
    vector<int> ans(N + 1, 0);
    int all = 0;
    rep(i, N) {
        if (i & 1) all ^= b[i];
    }
    rep(i, N) cout << (all ^ a[i]) << "\n";
    return 0;
}



Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi p(N);
  rep(i,N) {
    cin >> p[i];
  }
  int diff = 0;
  rep(i,N) {
    if(p[i] != i+1) {
      diff++;
    }
  }
  if(diff <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" <<endl; 
  }
  return 0;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans += n / (a + b) * a;
	n -= n / (a + b) * (a + b);
	ans += min(n, a);
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i{st};i<(ed);++i)
#define FC(i,n)       for(int i{n};i;--i)
#define FZU(i,n)      for(ust i{0};i!=(n);++i)
#define FVU(i,st,ed)  for(ust i{st};i<(ed);++i)
#define FCU(i,n)      for(ust i{n};i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
int n;
int a[N];
int main(){
    RI(n);
    FZ(i,n){RI(a[i]);--a[i];}
    int s(0);
    FZ(i,n)s+= a[a[i]]==i;
    printf("%d\n",s/2);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  long x,k,d,ans,memo;  cin>>x>>k>>d;
  //string s; cin>>s;
  
  if(x<0)x=(-1)*x;
  
  if(d<x){
    if(d<=x/k){
      cout<<x-d*k<<endl;
      return 0;
    }
    
    memo=x/d;
    x-=d*memo;
    k-=memo;  
  }
  
  cout<<(k%2==1? abs(x-d):x)<<endl;

}


Measured memory_bytes: 3632
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramC a = new ProgramC();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {

            string[] s = Console.ReadLine().Split(' ');

            Console.WriteLine((int.Parse(s[0]) - 1) * (int.Parse(s[1]) - 1));


        }
    }

    class ProgramB
    {
        public void main()
        {

            string s = Console.ReadLine();

            Console.WriteLine(s[0] + (s.Length - 2).ToString() +s[s.Length -1]);


        }
    }

    class ProgramC
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            int count4 = 0;
            int count2 = 0;

            for (int i = 0; i < n;i++)
            {
                if (long.Parse(a[i]) % 4 == 0)
                    count4++;
                else if(long.Parse(a[i]) % 2 == 0)
                    count2++;
            }


            if (count4 >= n / 2)
            {
                Console.WriteLine("Yes");
                return;
            }


            if (2 * count4 + count2 >= n)
            {
                Console.WriteLine("Yes");
                return;
            }
            

            Console.WriteLine("No");


        }
    }

}






Measured memory_bytes: 20064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int R = sc.nextInt();
            System.out.println(N < 10 ? R + (100 * (10 - N)) : R);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  for(int i=1;i<=1000;i++){
    if((int)floor(i*0.08)==a && (int)floor(i*0.1)==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  string S; cin >> S;
  int sum = 0;
  for (char c : S) sum += c - '0';
  if (sum % 9 == 0) cout << "Yes" << endl;
  else              cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,p;
	cin>>s>>p;
	bool a=false;
	for(int i=0;i<s.size();i++){
		int count=0;
		for(int j=0;j<p.size();j++){
			if(s[(i+j)%s.size()]==p[j%p.size()])
				count++;
		}
		if(count==p.size())
			a=true;
	}
	if(a==true)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  string s; cin >> s;
  int ret = 0;
  for (char c : s) {
    if (c == 'R') ret++;
  }
  if (s[1] == 'S') ret = min(ret, 1);
  cout << ret << '\n';






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


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

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;
  for(int i = 0;i < S.size(); i++) {
    if(S.at(i) == T.at(i)) {
      count = count + 1;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, a) = readIntList()
    val ans = h / a + if (h % a != 0) 1 else 0
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int N, arr[2010], tot=0;

int main () {
	cin >> N;
	for(int i=1; i<=N; i++)
		cin >> arr[i];
	sort(arr+1, arr+N+1);
	for(int i=1; i<=N; i++)
		for(int j=i+1; j<=N; j++) {
			int l = j+1;
			int r = N;
			int ans = j;
			while (l <= r) {
				int mid = (l+r)/2;
				if (arr[i]+arr[j] > arr[mid]) {
					ans = mid;
					l = mid+1;
				} else {
					r = mid-1;
				}
			}
			tot += ans-j;
		}
	cout << tot << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
string s;

int main(){
	cin >> n >> s;
	REP(i, 2){
		REP(j, 2){
			vector<bool> vb(n + 1);
			vb[0] = i, vb[1] = j, vb[n] = vb[0];
			FOR(k, 1, n - 1){
				if (vb[k] == 0){
					if (s[k] == 'o')vb[k + 1] = vb[k - 1];
					else vb[k + 1] = !vb[k - 1];
				}
				else{
					if (s[k] == 'o')vb[k + 1] = !vb[k - 1];
					else vb[k + 1] = vb[k - 1];
				}
			}
			bool ok = 1;
			if (vb[n - 1] == 0){
				if (s[n - 1] == 'o'&&vb[n - 2] != vb[0]){
					ok = 0;
				}
				if (s[n - 1] == 'x'&&vb[n - 2] == vb[0]){
					ok = 0;
				}
			}
			else{
				if (s[n - 1] == 'o'&&vb[n - 2] == vb[0]){
					ok = 0;
				}
				if (s[n - 1] == 'x'&&vb[n - 2] != vb[0]){
					ok = 0;
				}
			}
			if (vb[0] == 0){
				if (s[0] == 'o'&&vb[1] != vb[n - 1]){
					ok = 0;
				}
				if (s[0] == 'x'&&vb[n - 1] == vb[1]){
					ok = 0;
				}
			}
			else{
				if (s[0] == 'o'&&vb[n - 1] == vb[1]){
					ok = 0;
				}
				if (s[0] == 'x'&&vb[n - 1] != vb[1]){
					ok = 0;
				}
			}
			if (ok){
				REP(i, n){
					if (!vb[i])cout << "S";
					else cout << "W";
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 512
if __name__ == '__main__':
    keyword = input()
    sentence = ''
    while(True):
        cont = input()
        if cont == 'END_OF_TEXT':
            break
        sentence = sentence + cont + '\r'
    sentence = sentence.lower()
    senten_list = sentence.split()
    num = 0
    for sentence in senten_list:
        if sentence == keyword:
            num += 1
    print(num)



Measured memory_bytes: 5556
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int[] h = new int[N];
    int hmax = 0;
    for (int i = 0; i < N; i++) {
      h[i] = scanner.nextInt();
      hmax = Math.max(hmax, h[i]);
    }

    long left = -1;
    long right = (hmax - 1) / B + 1;
    while (right - left > 1) {
      long mid = (left + right) / 2;
      if (possible(A, B, h, mid)) {
        right = mid;
      } else {
        left = mid;
      }
    }
    System.out.println(right);
  }

  private static boolean possible(int A, int B, int[] harray, long pmax) {
    long p = 0;
    for (int h : harray) {
      if (h <= pmax * B) continue;
      long pi = (h - pmax * B - 1) / (A - B) + 1;
      p += pi;
      if (p > pmax) return false;
    }
    return true;
  }
}


Measured memory_bytes: 50336
#include<stdio.h>
int main(void)
{
    static int i,n,A[2000000],C[10000],B[2000000];

    for(i=0;i<10000;i++) C[i]=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d", &A[i]);
    for(i=0;i<n;i++) C[A[i]]++;
    for(i=1;i<10000;i++) C[i]+=C[i-1];
    for(i=n-1;i>=0;i--){
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }
    printf("%d",B[0]);
    for(i=1;i<n;i++) printf(" %d",B[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 16268
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 100000;
static const long long INFTYL = 9223372036854775807;
static const int INFTY = 2147483647;
ll mod = 1000000007;

int prime[100001];
bool is_prime[100001];
int primeCount = 0;

int sieve(int n)
{
	int p = 0;
	primeCount = 0;
	for (int i = 0; i <= n; i++) {
		is_prime[i] = true;
		prime[i] = 0;
	}
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			primeCount++;
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}

	return p;
}

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

int main()
{
	//sieve(15);
	int Q;
	cin >> Q;

	int count;

	vector<int> count_v;

	sieve(MAX);
	vector<int>prime_v;
	int x = 0;

	for (int j = 0; j < MAX + 1; j++) {
		int t = (j + 1) / 2;

		if (is_prime[j] && is_prime[t]) {
			prime_v.push_back(j);
		}
	}

	rep(i, Q) {
		int L, R;
		cin >> L >> R;
		count = 0;
		for (vector<int>::iterator it = prime_v.begin(); it != prime_v.end(); it++) {
			if (*it >= L && *it <= R) {
				count++;
			}
		}
		count_v.push_back(count);
	}

	for (vector<int>::iterator it = count_v.begin(); it != count_v.end(); it++) {
		cout << *it << endl;
	}
	//rep(i, Q) {
	//	int L, R;
	//	cin >> L >> R;

	//	count = 0;
	//	for (int j = 0; j < primeCount; j++) {
	//		if (prime[j] >= L && prime[j] <= R) {
	//			int t = (prime[j] + 1) / 2;

	//			if (isprime(t)) {
	//				count++;
	//			}
	//		}
	//	}
	//	count_v.push_back(count);
	//}
	//for (vector<int>::iterator it = count_v.begin(); it != count_v.end(); it++) {
	//	cout << *it << endl;
	//}
	return 0;
}

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

int n;
int candiesMap[2 + 1][100 + 1]; // 1based acsess

int max(int a, int b)
{
	if (a < b)
	{
		return b;
	}
	else
	{
		return a;
	}
}

int func(int i, int j, int score)
{
	int now_score = candiesMap[i][j];
	if (i == 2 && j == n) return score + now_score;

	int i_score = -1;
	int j_score = -1;
	if (j < n) i_score = func(i, j + 1, score + now_score);
	if (i < 2) j_score = func(i + 1, j, score + now_score);

	return max(i_score, j_score);
}

int main()
{
	cin >> n;

	for (int i = 1; i <= 2; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> candiesMap[i][j];
		}
	}

	cout << func(1, 1, 0) << endl;;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);

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

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



int main() 
{
  ll N,M; cin>>N>>M;
  string S,T; cin>>S>>T;
  ll hoge=gcd(N,M);
  rep(i,hoge)
  {
    if(S.at(i*(N/hoge))!=T.at(i*(M/hoge))) {cout<<-1<<endl; return 0;}
  }
  cout<<lcm(N,M)<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 5e3 + 10;

int n, A, B, p[N];
ll dp[N];

int main() {
  scanf("%d %d %d", &n, &A, &B);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  p[++n] = n;
  for (int i = 1; i <= n; i++) {
    dp[i] = (ll) 1e18;
    ll tmp = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (p[j] < p[i]) {
        dp[i] = min(dp[i], dp[j] + tmp);
        tmp += B;
      } else {
        tmp += A;
      }
    }
  }
  printf("%lld\n", dp[n]);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
const long long INF = 1LL<<60;

int N, K;
vector<long long> V;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> K) {
        V.resize(N);
        for (int i = 0; i < N; ++i) cin >> V[i];

        long long res = 0;
        for (int p = 0; p <= min(K, N); ++p) {
            for (int q = 0; p + q <= min(K, N); ++q) {
                vector<long long> v;
                long long cur = 0;
                for (int i = 0; i < p; ++i) v.push_back(V[i]), cur += V[i];
                for (int i = 0; i < q; ++i) v.push_back(V[N-1-i]), cur += V[N-1-i];

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

                //cout << p << ", " << q << ": " << v << endl;
                for (int i = 0; i < min(K - p - q, (int)v.size()); ++i) {
                    if (v[i] < 0) cur -= v[i];
                }
                chmax(res, cur);
            }
        }
        cout << res << endl;
                
    }
}


















Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())
a=abs(x1-x2)
b=abs(y1-y2)
if(y1<=y2):
  if(x1<=x2):
    print(x2-b,y2+a,x1-b,y1+a)
    #print('a')
  else:
    print(x2-b,y2-a,x1-b,y1-a)
    #print('b')
else:
  if(x1<=x2):
    print(x2+b,y2+a,x1+b,y1+a)
    #print('c')
  else:
    print(x2+b,y2-a,x1+b,y1-a)
    #print('d')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

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


int main(){
    int p, q,r; cin>>p>>q>>r; cout<<(p*q)/2<<endl;
}

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

using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
const int M=51;
int n,m,x,y,i,a[M],b[M];
bool vis[M],vis1[M];
vector<int>sad;
vector<vector<int> >v;
bool dfs(int i){
    vis[i]=true;
    if(i==x)return true;
    bool f=false;
    for(auto u:v[i])
        if(!vis[u])f|=dfs(u);
    return f;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
        if(b[i]>a[i])return cout<<-1,0;
    }
    for(int i=51;i>=0;i--){
        v.clear();
        v.resize(51);
        for(int j=1;j<=50;j++){
            for(int k=1;k<=50;k++){
                if(vis1[k]||k<i)v[j].pb(j%k);
            }
        }
        bool f=true;
        for(int j=0;j<n;j++){
            memset(vis,0,sizeof vis);
            x=b[j];
            f&=dfs(a[j]);
        }
        if(!f&&i==51)return cout<<-1,0;
        if(!f)sad.pb(i),vis1[i]=true;
    }
    ll ans=0;
    for(auto i:sad){
        ans+=(1LL<<i);
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        long n = Long.parseLong(br.readLine());
        
        br.close();

        StringBuilder ans = new StringBuilder();

        while (n > 0) {
            n--;
            ans.append((char)('a' + n % 26));
            n /= 26;
        }
        
        ans.reverse();
        
        bw.write(ans.toString());

        bw.flush();

    }
}

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

using namespace std;
#define PROBLEM "A"

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	int n;
	while(cin >> n){

		cout << n*n*n << endl;
	}
	return 0;
}

Measured memory_bytes: 256