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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct RollingHash {
	typedef long long int_type;
	typedef pair<int_type, int_type> hash_type;

	int_type base1;
	int_type base2;
	int_type mod1;
	int_type mod2;

	vector<int_type> hash1;
	vector<int_type> hash2;
	vector<int_type> pow1;
	vector<int_type> pow2;

	RollingHash(const string& s) : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {
		init(s);
	}

	void init(const string& s) {
		int n = s.size();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		pow1.assign(n + 1, 1);
		pow2.assign(n + 1, 1);
		for (int i = 0; i < n; i++) {
			hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
			hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
			pow1[i + 1] = pow1[i] * base1 % mod1;
			pow2[i + 1] = pow2[i] * base2 % mod2;
		}
	}

	hash_type get(int l, int r) const {
		int_type t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
		int_type t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
		return make_pair(t1, t2);
	}

	RollingHash::hash_type concat(hash_type h1, hash_type h2, int h2_len) {
		return make_pair((h1.first * pow1[h2_len] + h2.first) % mod1,
			(h1.second * pow2[h2_len] + h2.second) % mod2);
	}

	int LCP(const RollingHash& other, int l1, int r1, int l2, int r2) {
		int len = min(r1 - l1, r2 - l2);
		int low = -1, high = len + 1;
		while (high - low > 1) {
			int mid = (low + high) / 2;
			if (get(l1, l1 + mid) == other.get(l2, l2 + mid)) low = mid;
			else high = mid;
		}
		return (low);
	}
};

std::vector<int> z_algorithm(string text) {
	int n = text.size();
	vector<int> A(n, 0);
	A[0] = text.size();
	int i = 1, j = 0;
	while (i < text.size()) {
		while (i + j < text.size() && text[j] == text[i + j]) ++j;
		A[i] = j;
		if (j == 0) { ++i; continue; }
		int k = 1;
		while (i + k < text.size() && k + A[k] < j) A[i + k] = A[k], ++k;
		i += k; j -= k;
	}
	return A;
}

int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	n = s.size();
	int u = 0;
	for (int i = 0; i < n; i++) {
		auto t = s.substr(i, n - i);
		auto a = z_algorithm(t);
		for (int j = i + 1; j < n; j++) {
			auto num = min(a[j - i], j - i);
			chmax(u, num);
		}
	}
	cout << u << endl;
	return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m;
int fa[N][20],dep[N];
int dis[N],cnt[N],ret[N];
struct node{int u,co,l;};
vector<node>e[N];
struct ques{int id,co,d,k;};
vector<ques>q[N];
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
void pre(int x,int f){
	fa[x][0]=f,dep[x]=dep[f]+1;
	for(int i=0;i<e[x].size();i++)
		if(e[x][i].u!=f)pre(e[x][i].u,x);
}
int UP(int x,int step){
    for(int i=0;i<=17;i++)if(step&(1<<i))x=fa[x][i];
    return x;
}
int LCA(int a,int b){
    if(dep[a]>dep[b])swap(a,b);
    b=UP(b,dep[b]-dep[a]);
    if(a==b)return a;
    for(int i=17;i>=0;i--)
        if(fa[a][i]!=fa[b][i])a=fa[a][i],b=fa[b][i];
    return fa[a][0];
}
void dfs(int x,int f,int D){
	for(int i=0;i<q[x].size();i++){
		ques now=q[x][i];
		ret[now.id]+=now.k*(D-dis[now.co]+cnt[now.co]*now.d);
	}
	for(int i=0;i<e[x].size();i++){
		node y=e[x][i];
		if(y.u==f)continue;
		cnt[y.co]++,dis[y.co]+=y.l;
		dfs(y.u,x,D+(y.l));
		cnt[y.co]--,dis[y.co]-=y.l;
	}
}
int main(){
    n=read(),m=read();
    for(int i=1,a,b,c,d;i<n;i++){
        a=read(),b=read(),c=read(),d=read();
        e[a].push_back((node){b,c,d});
        e[b].push_back((node){a,c,d});
    }
    
	pre(1,0);
    for(int i=1;i<=17;i++)
        for(int j=1;j<=n;j++)fa[j][i]=fa[fa[j][i-1]][i-1];	
        
    for(int i=1,u,v,c,d;i<=m;i++){
       c=read(),d=read(),u=read(),v=read();
       q[u].push_back((ques){i,c,d,1});
       q[v].push_back((ques){i,c,d,1});
       q[LCA(u,v)].push_back((ques){i,c,d,-2});
    }
	dfs(1,0,0);
	
    for(int i=1;i<=m;i++)printf("%d\n",ret[i]);
} 

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

int main(){
    int x;
    int y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        if (x > y) {
            swap(x, y);
        }
        cout << x << " " << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3020
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int[] c = new int[26];
        int[] cd = new int[26];
        for (int i = 0; i < 26; i++) {
            c[i] = Integer.parseInt(sc.next());
        }
        int[][] s = new int[d][26];
        int[] max = new int[d];
        for (int i = 0; i < d; i++) {
            int maxd = 0;
            for (int j = 0; j < 26; j++) {
                int temp = Integer.parseInt(sc.next());
                s[i][j] = temp;
                maxd = Math.max(maxd, temp);
            }
            max[i] = maxd;
        }
        int[] t = new int[d];
        StringBuilder sb = new StringBuilder();
        int ans = 0;
        for (int i = 0; i < d; i++) {
            int temp = Integer.parseInt(sc.next());
            t[i] = temp;
            cd[temp - 1] = i + 1;
            ans += s[i][temp - 1] - totalSubC(c, cd, i + 1);
            sb.append(ans);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }

    private static int totalSubC(int[] c, int[] cd, int d) {
        int ans = 0;
        for (int i = 0; i < 26; i++) {
            ans += c[i] * (Math.max(0, d - cd[i]));
        }
        return ans;
    }
}

Measured memory_bytes: 41904
#include<stdio.h>

int Zeller(int,int,int);

int main(void){
  int i,j,sum,a,b;
  
  while(1){
    sum=0;
    scanf("%d %d",&a,&b);
    if(a==0 && b==0)break;

    switch(Zeller(2004,a,b)){

    case 0:
      printf("Sunday\n");
      break;
    case 1:
      printf("Monday\n");
      break;
    case 2:
      printf("Tuesday\n");
      break;
    case 3:
      printf("Wednesday\n");
      break;
    case 4:
      printf("Thursday\n");
      break;
    case 5:
      printf("Friday\n");
      break;
    case 6:
      printf("Saturday\n");
      break;
    }
  }
  return 0;
}

int Zeller(int year, int month, int day){
    if (month == 1 || month == 2) {
        year--;
        month += 12;
    }
    return (year + year/4 - year/100 + year/400
            + (13*month+8)/5 + day) % 7;
}

Measured memory_bytes: 0
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

A_max = max(A)

B = A.copy()
B.sort()
B.reverse()

if B[1] == A_max:
    for i in range(n):
        print(A_max)
else:
    for a in A:
        if a != A_max:
            print(A_max)
        else:
            print(B[1])

Measured memory_bytes: 14108
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  ll x;
  cin >> x;

  if(x <= 6) {
    cout << 1 << endl;
  } else if(x <= 11) {
    cout << 2 << endl;
  } else {
    ll a = x / 11;
    ll b = (x%11 == 0 ? 0 : (x%11 <= 6 ? 1 : 2));
    cout << 2*a + b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L, R;
    cin >> L >> R;
    int j = 2;
    for (int i = 2019; i <= R; i += 2019) {
        if (L <= i && i <= R) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 2018;
    for (int i = L % 2019; i < R % 2019; ++i) {
        for (int j = i + 1; j <= R % 2019; ++j) {
            ans = min((i*j) % 2019, ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n, d = gets_i_list

dd = d * d
ans = 0

n.times do
  x, y = gets_i_list
  ans += 1 if dd >= x * x + y * y
end

puts ans

Measured memory_bytes: 14464
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

int main() {
	
	int a,b;
	cin >>a >>b;
	if (a == b)cout << "Draw" << endl;
	else if (a == 1) cout << "Alice" << endl;
	else if (b == 1)cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;


	return 0;
}

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

ll dis[100000] = {};

int main(){
    int n, i, j;
    ll a, tem, res = 0, count[60][2] = {};
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a;
        tem = 1;
        for(j=0; j<60; j++){
            count[j][(int)((tem & a) > 0)]++;
            tem <<= 1;
        }
    }
    tem = 1;
    for(i=0; i<60; i++){
        res += ((tem%MOD)*(count[i][0]*count[i][1]%MOD))%MOD;
        res %= MOD;
        tem <<= 1;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int n; cin>>n;
	int a[n]; rep(i,n) cin>>a[i];
	long long dp[110][25]; rep(i,110)rep(j,25) dp[i][j]=0;
	dp[1][a[0]]=1;

	for(int pick=2;pick<n;pick++){
		for(int sum=0;sum<25;sum++){
			if(0<=sum-a[pick-1]&&sum-a[pick-1]<=20&&0<=sum+a[pick-1]&&sum+a[pick-1]<=20) dp[pick][sum]=dp[pick-1][sum-a[pick-1]]+dp[pick-1][sum+a[pick-1]];
			else if(0<=sum-a[pick-1]&&sum-a[pick-1]<=20) dp[pick][sum]=dp[pick-1][sum-a[pick-1]];
			else if(0<=sum+a[pick-1]&&sum+a[pick-1]<=20) dp[pick][sum]=dp[pick-1][sum+a[pick-1]];
		}
	}
	cout<<dp[n-1][a[n-1]]<<endl;
	return 0;
}



Measured memory_bytes: 3104
#include<iostream>
int p(int x){for(int i=2;i*i<=x;i++)if(x%i==0)return 0;return 1;}
main() {
  int n;
  while(std::cin>>n,n) {
    int a=0;
    for(int s=-1;s<2;s+=2)for(int i=0;!p(n+i*s);i++,a++);
    std::cout<<a<<'\n';
  }
}

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

int main() {
  map<string, int> a;
  a["SUN"] = 7;
  a["MON"] = 6;
  a["TUE"] = 5;
  a["WED"] = 4;
  a["THU"] = 3;
  a["FRI"] = 2;
  a["SAT"] = 1;
  string s;
  cin >> s;
  cout << a[s] << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	int p=1;
	for(int i=0;i<b;i++)p*=2;
	printf("%d\n",p*(1900*b+100*(a-b)));
}

Measured memory_bytes: 128
/*
      author : nishi5451
      created: 12.08.2020 00:26:56
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    string s;
    cin >> s;
    string code = "CODEFESTIVAL2016";
    int ans=0;
    rep(i,16) if(s[i] != code[i]) ans++;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int main() {
  int A, B, m;
  cin >> A >> B >> m;
  vector<int> a(A);
  vector<int> b(A);
  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  vector<int> ans;
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    ans.push_back(a[x] + b[y] - z);
  }
  sort(ALL(a));
  sort(ALL(b));
  ans.push_back(a[0] + b[0]);
  sort(ALL(ans));
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n, m;
  int count = 0;
  cin >> n >> m;
  vector<int> h(n), a(m), b(m);
  vector<vector<int> > data(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    data.at(a[i]-1).push_back(b[i]-1);
    data.at(b[i]-1).push_back(a[i]-1);
  }
  for (int i = 0; i < n; i++) {
    int check = 0;
    for (int j = 0; j < data.at(i).size(); j++) {
      if (h[i]<=h[data.at(i).at(j)]) check = 1;
    }
    if (check==0) {
      // cout << i <<endl;
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 9216
function Main(input) {
	var S = input.split('\n');
	var K = S[0].split(" ");
	
	var A = parseInt(K[0]);
	var B = parseInt(K[1]);
	var C = A - B * 2;
	
	if (C <= 0) {
		console.log(0);
	} else {
		console.log(C);
	}
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a = 0, b = 0, c = 0, d = 0;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC") {
			a++;
		}
		if (s == "WA") {
			b++;
		}
		if (s == "TLE") {
			c++;
		}
		if (s == "RE") {
			d++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
}

Measured memory_bytes: 3628
import numpy as np

H, W = map(int, input().split())
lst1 = []
lst2 = []
for _ in range(H):
    lst1.append([int(i) for i in input().split()])
for _ in range(H):
    lst2.append([int(i) for i in input().split()])
arr1, arr2 = np.array(lst1), np.array(lst2)
arr = np.abs(arr1 - arr2)

d = [[0] * W for _ in range(H)]
m = 80 * (H + W)
d[0][0] = 1 << m
for h in range(H):
    for w in range(W):
        x = arr[h][w]
        if h > 0:
            d[h][w] |= d[h - 1][w]
        if w > 0:
            d[h][w] |= d[h][w - 1]
        d[h][w] = d[h][w] << x | d[h][w] >> x

x, y= 1 << m, 1 << m
for i in range(m + 1):
    if d[H - 1][W - 1] & x or d[H - 1][W - 1] & y:
        print(i)
        quit()
    x<<=1
    y>>=1

Measured memory_bytes: 29932
#include <cstdio>
#include <iostream>
#include <stack>

using namespace std;
typedef pair<int, int> pii;

#define W_MAX 20
#define H_MAX 20

#define B '.'
#define R '#'
#define M '@'

char map[W_MAX][H_MAX];

int main(){

  while(true){
    int W,H;
    cin >> W >> H;

    if(W==0 && H==0) break;

    pii s; //start

    for(int i=0; i<H; i++){
      getchar();
      for(int j=0; j<W; j++){
	scanf("%c", &map[i][j]);
	if(map[i][j]==M){
	  s = make_pair(i,j);
	  map[i][j] = R;
	}
      }
    }

    stack<pii> st;
    st.push(s);
    int dx[] = {-1,0,0,1}; int dy[] = {0,1,-1,0};
    int ans=0;
    while(!st.empty()){
      pii p = st.top(); st.pop();
      int x = p.first; int y = p.second;
      ans++;
      for(int i=0; i<4; i++){
	int nx = x+dx[i]; int ny = y+dy[i];
	if(nx>=0 && nx<H &&
	   ny>=0 && ny<W &&
	   map[nx][ny]==B){
	  st.push(make_pair(nx,ny));
	  map[nx][ny] = R;
	}
      }
    }

    cout << ans << endl;

  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<string, int> M;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      string key;
      cin >> key;
      int x;
      cin >> x;
      M[key] = x;
    }
    if (t == 1){
      string key;
      cin >> key;
      if (!M.count(key)){
        cout << 0 << endl;
      } else {
        cout << M.at(key) << endl;
      }
    }
    if (t == 2){
      string key;
      cin >> key;
      M.erase(key);
    }
    if (t == 3){
      string L, R;
      cin >> L >> R;
      auto itr = M.lower_bound(L);
      while (1){
        if (itr == M.end()){
          break;
        }
        if (R < (*itr).first){
          break;
        }
        cout << (*itr).first << ' ' << (*itr).second << endl;
        itr++;
      }
    }
  }
}


Measured memory_bytes: 27684
# -*- coding: utf-8 -*-
s = input()
t = input()
n = len(s)

def check(idx):
    for i in range(len(t)):
        ii = idx+i
        if ii>=n:
            return False
        if s[ii]!="?" and s[ii]!=t[i]:
            return False
    return True

def restore(idx):
    res = list(s)
    for i in range(len(t)):
        ii = idx+i
        res[ii] = t[i]
    for i in range(n):
        if res[i]=="?":
            res[i] = "a"
    return "".join(res)

res = []
for i in range(n):
    if check(i):
        res.append(restore(i))
# print(res)
if len(res)==0:
    print("UNRESTORABLE")
else:
    res.sort()
    print(res[0])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    string s;
    cin >> s;
    reverse(all(s));
    cout << s << endl;
}



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int ans=0,n=0;
char c;
string s;

int main(){
    while(cin>>s){
	int cur=0;
	while(cur<s.size()){
	    if(isdigit(s[cur]))n=n*10+s[cur]-'0';
	    else {ans+=n;n=0;}
	    cur++;
	}
	ans+=n;n=0;
    }
    cout<<ans+n<<endl;
}

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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b;cin>>a>>b;
  int ans=a+b;
  ans%=24;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
  int n,tot=1,s,ans=0;;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
  	scanf("%d",&s);
  	if(s==tot){tot++;continue;}
  	ans++;
  }
  if(ans==n){cout<<"-1";return 0;}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <tuple>

using namespace std;

typedef long long ll;

struct w {
    ll a,b;
};

int main(void){
    ll n;
    cin >> n;
    vector<pair<ll,ll> > vec(n);
    for (ll i = 0;i < n;i++){
        cin >> vec[i].second >> vec[i].first;
    }
    sort(vec.begin(), vec.end());
    ll t = 0;
    for(ll i = 0;i < n;i++){
        if(t <= vec[i].first){
            t += vec[i].second;
        }
        if(t > vec[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	ll n,m;
	cin>>n>>m;
	if(n > m)swap(n,m);
	if(m == 1)cout << 1 << '\n';
	else if(n == 1)cout << max(0ll,m-2) << '\n';
	else cout << max(0ll,(n - 2)) * max(0ll,(m - 2)) << '\n';
}	

Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
//#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define res resize
const llint mod=1000000007;
const llint big=1e18;
//0.... 縦
//1.... 横
//2.0.. i総合
//2.1.. j総合
//20200 s
//20201 t


struct edge{int to,cap,rev;};
vector<edge> G[20202];
bool used[20202];
int dfs(int v,int t,int f){
	if(v==t){return f;}
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	while(-1){
		for(int i=0;i<20202;i++){
			used[i]=0;
		}
		int f=dfs(s,t,mod);
		if(f==0){return flow;}
		flow+=f;
	}
}
void add_edge(int from,int to,int cap){
	edge E;
	E.to=to,E.cap=cap;E.rev=(int)G[to].size();
	G[from].pub(E);
	E.to=from,E.cap=0;E.rev=(int)G[from].size()-1;
	G[to].pub(E);
}
void Radd_edge(int a,int b,int c){
	add_edge(a,b,c);
	add_edge(b,a,c);
}
int main(void){
	int i,j,H,W;
	vector<string> ike;
	cin>>H>>W;
	ike.res(H);
	for(i=0;i<H;i++){
		cin>>ike[i];
	}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(ike[i][j]!='.'){
				Radd_edge(i*100+j,10000+i*100+j,1);
				Radd_edge(i*100+j,20000+i,10000);
				Radd_edge(10000+i*100+j,20100+j,10000);
			}
			if(ike[i][j]=='S'){Radd_edge(20200,i*100+j,10000);Radd_edge(20200,10000+i*100+j,10000);}
			if(ike[i][j]=='T'){Radd_edge(20201,i*100+j,10000);Radd_edge(20201,10000+i*100+j,10000);}
		}
	}
	i=max_flow(20200,20201);
	if(i>=10000){i=-1;}
	cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <unordered_set>

using namespace std;

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

	unordered_set<char> cList;

	bool dup = false;
	for (char c : S) {
		if (cList.count(c) != 0) {
			dup = true;
			break;
		}
		cList.insert(c);
	}

	cout << (dup ? "no" : "yes") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int N,M;
vector<vector<int>> G;
int dp[101010];

int rec(int v){
    if(dp[v]!=-1) return dp[v];

    int res = 0;
    for(auto nv:G[v]) chmax(res,rec(nv)+1);
    return dp[v] = res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>M;
    G.assign(N,vector<int>());
    REP(i,M){
        int x,y;
        cin>>x>>y;
        --x,--y;
        G[x].push_back(y);
    }
    REP(i,101010) dp[i] = -1;

    int res = 0;
    for(int v=0;v<N;v++) chmax(res,rec(v));
    cout<<res<<endl;

}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
bool option(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}
int32_t main(){ fast;
	int n,k; cin>>n>>k;
	int cnt = 0;
	vector<int> map(200005, 0);
	rep(i, n){
		int x; cin>>x;
		if(map[x] == 0){
			cnt++;
		}
		map[x]++;
	}
	if(cnt <= k){
		cout<<0<<endl;
		return 0;
	}
	vector<int> a;
	for(int i = 1; i <= 200000; i++){
		if(map[i] != 0){
			a.push_back(map[i]);
		}
	}
	int need = cnt - k;
	sort(all(a));
	int ans = 0;
	for(int i = 0; i < need; i++){
		ans += a[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2168
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String submit = sc.next();
        int L = submit.length();
        boolean accepted = false;
        for(int i=0;i<L-1;i++){
        	if(submit.charAt(i)=='A'&&submit.charAt(i+1)=='C') accepted = true;
        }
        System.out.println(accepted?"Yes":"No");
    }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
signed main()
{
    int n;
    cin>>n;

    int a[n];
    int sum=0,avg=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
        //avg=ceil(sum/(n*1.0));
    //cout<<avg;
    int ans=0,ansmin=INT_MAX;
   for(int i=a[0];i<=a[n-1];i++)
   {
        int mn=0;
        for(int j=0;j<n;j++)
        {
            mn+=pow(abs(i-a[j]),2);
        }
        ansmin=min(ansmin,mn);
   }
    cout<<ansmin<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const ll INF = 1000000000000000000LL;
const double EPS = 1e-8;
const int MOD = 1000000007;

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(int i = 2; (ll)i * i <= n; i++){
		while(n % i == 0){
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}
int main(){
	int N;
	string M;
	while(cin>>N>>M){
		if(N == 0 && M == "0")break;
		if(M == "0"){
			cout<<0<<endl;
			continue;
		}
		map<ll, ll> factor = prime_factor(N);
		map<ll, ll> cnt;
		ll L = strtoll(M.c_str(), NULL, N);
		if(L == 0) while(true);
		ll ans = LLONG_MAX;
		for(map<ll,ll>::iterator it = factor.begin(); it!=factor.end(); it++){
			for(ll i = it->first; i <= L ; i *= it->first){
				cnt[it->first] += L / i;
				if(L / i < it->first) break;
			}
			cnt[it->first] /= it->second;
			ans = min(cnt[it->first], ans);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const int INF = 100100100;

int main() {
    int n,m; cin >> n >> m;
    string s; cin >> s;
    int dp[n+1]; rep(i,n+1) dp[i] = INF;
    dp[0] = 0;
    int check = 0;
    int last[n+1]; rep(i,n+1) last[i] = -1;
    rep(i,n) {
        check = max(check, i);
        if (s[i] == '1') continue;
        for (int j = max(check, i)+1; (j <= m+i && j <= n); j++) {
            check = max(check, j);
            if (s[j] == '1') continue;
            if (dp[j] > dp[i]+1) {
                dp[j] = dp[i]+1;
                last[j] = i;
            }
        }
    }
    if (dp[n] == INF) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int now = n;
    while (now != -1) {
        ans.push_back(now);
        now = last[now];
    }
    reverse(all(ans));
    rep(i,sz(ans)-1) {
        printf("%d ", ans[i+1] - ans[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 4732
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<string> se;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    se.insert(s);
  }
  cout << se.size() << endl;
}

Measured memory_bytes: 19132
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
using namespace std; 

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, 0, N) cin >> h[i];
  
  vector<int> dp(N, 2000000000);
  dp[0] = 0;
  rep(i, 0, N) {
    rep(j, 1, K + 1) {
      if (i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
n = io.read("*n")
a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
v = true
for i = 1, n do
  if a[i] % 2 == 0 then
    if a[i] % 3 ~= 0 and a[i] % 5 ~= 0 then
      v = false break
    end
  end
end
print(v and "APPROVED" or "DENIED")


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include<vector>
#include <algorithm>
#include <map>

using namespace std;
#define pb push_back
#define mp make_pair



int main()
{
        long long n,k;
        long long a[100010],c[50];
        long long step[50];
        long long best[50];

        step[0]=1;
        for(int i=1;i<40;i++){
                best[i]=0;
                step[i]=step[i-1]*2;
        }
        cin>>n>>k;
        for(int i=0;i<n;i++){
            cin>>a[i];
            for( int j=0; ( 1ULL << j ) <= a[i];j++ ){
                if( a[i]&( 1ULL << j ) ) c[j]++;
            }
        }
        best[0] = max( c[0], n -c[0] );
        for( int i = 1;i<40;i++ ){
                best[i]=best[i-1] + step[i]*max( c[i], n-c[i] ); /// za prvih n bitova, optimalno je kad svaki namjestimo tako da je vise keceva nego nula u xoru
        }
        int exp;
        for(  exp = 0;  ( 1<<exp ) <= k;exp++  );
            exp--;
            long long sol=0,curr=0;
            for( int i = 39; i >=0;i-- ){
                if( ( 1ULL << i ) & k ){ /// ako je ukljucen, mozemo ga ukljuciti u rjesenje, ili iskljuciti a uzeti sve druge optimalne
                if( i>0 ) sol=max( sol, curr + step[i]*c[i] + best[ i-1 ]  );
                    curr+= ( n-c[i])*step[i];
                }
                else curr+= step[i]*c[i];
            }
        sol=max( sol, curr );
  /*      cout << exp <<endl;
        cout << best[1] <<endl;
        cout << best[0] <<endl;*/
        cout<<sol<<endl;
        return 0;
}

/*
001
110
010
*/

/*
1001

0111
0100
0000
0011
*/













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


int a[2][200];

int main()
{
    int n;
    scanf("%d", &n);
    for(int j = 0; j < 2; j ++)
        for(int i = 0; i < n; i ++)
            scanf("%d", &a[j][i]);
    int ans = 0;
    for(int k = 0; k < n; k ++) {
        int sum = 0;
        for(int i = 0; i <= k; i ++)
            sum += a[0][i];
        for(int i = k; i < n; i ++)
            sum += a[1][i];
        ans = max(ans, sum);
    }
    printf("%d\n", ans);
    return 0;
}


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

string s;

signed main()
{
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int maxVal = 0, maxIdx = -1;
    rep(i, N) {
        if(abs(A[i]) >= maxVal) {
            maxVal = abs(A[i]);
            maxIdx = i;
        }
    }
    vector<pii> operation;
    if(A[maxIdx] == 0) {
        
    } else if(A[maxIdx] > 0) {
        rep(i, N) {
            if(A[i] < 0) {
                A[i] += A[maxIdx];
                operation.push_back({maxIdx+1, i+1});
            }
        }
        rep(i, N - 1) {
            A[i+1] += A[i];
            operation.push_back({i+1, i+2});
        }
    } else {
        for(int i = N-1; i >= 0; --i) {
            if(A[i] > 0) {
                A[i] += A[maxIdx];
                operation.push_back({maxIdx+1, i+1});
            }
        }
        for(int i =N-1; i> 0; --i) {
            A[i-1] += A[i];
            operation.push_back({i+1, i});
        }
    }
    cout << sz(operation) << "\n";
    for(auto &p : operation) {
        cout << p.first << " " << p.second << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
xyh = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda p: -p[2])

def ok(cx, cy):
    x, y, h = xyh[0]
    H1 = h + abs(x - cx) + abs(y - cy)
    for x, y, h in xyh[1:]:
        H2 = h + abs(x - cx) + abs(y - cy)
        if h > 0 and H1 != H2:
            return -1
        if H1 > H2:
            return -1
    return H1

for cx in range(101):
    for cy in range(101):
        H = ok(cx, cy)
        if H >= 0:
            print(cx, cy, H)
            exit(0)


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

string a;

int main() {
  cin >> a;
  int res = 0, ans = 0;
  for(int i = 0; i < a.size(); i++) {
    res = max(res, (int)(ans + a[i] - '0' - 1 + 9 * (a.size() - i - 1)));
    ans += a[i] - '0';
  }
  printf("%d\n", max(res, ans));
}

Measured memory_bytes: 256
n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)

INF = float('inf')
for cx in range(101):
    for cy in range(101):
        H = INF
        Hmax = INF
        for i in range(n):
            if h[i] > 0 and H == INF:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            elif h[i] > 0 and H != h[i] + abs(x[i] - cx) + abs(y[i] - cy):
                break
            elif h[i] == 0:
                Hmax = min(Hmax, abs(x[i] - cx) + abs(y[i] - cy))
        else:
            if H <= Hmax:
                print(cx, cy, H)
                exit()
            elif H == INF and Hmax == 1:
                print(cx, cy, 1)
                exit()

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

int main() {

  vector<string> divide = {"dream", "dreamer", "erase", "eraser"};
  
  string S;
  cin >> S;
  
  reverse(S.begin(), S.end());
  for(int i =0; i < 4; i++) reverse(divide.at(i).begin(), divide.at(i).end());
  
  bool can = true;
  for(int i =0; i < S.size();){
    bool can2 = false;
    for(int j =0; j < 4; j++){
      string d = divide.at(j);
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    } 
         if(!can2){
           can = false;
           break;
         }
   }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
  
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    long long r=0,g=0,b=0;
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            r++;
        }else if(S[i]=='G'){
            g++;
        }else{
            b++;
        }
    }
    long long count =0;
    for(int i=1;i<N;i++){
        for(int j=i;j+i<N;j++){
            if(S[j-i]!=S[j+i]){
                if(S[j]!=S[j+i]){
                    if(S[j]!=S[j-i]){
                        count++;
                    }
                }
            }
        }
    }
    cout << r*g*b-count;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    i64 n;
    while (read(n)) {
        llvec a(n);
        int q;
        read(a, q);
        map<i64, i64> cc;
        i64 sum = 0;
        fore(ai, a) {
            cc[ai]++;
            sum += ai;
        }

        while (q--) {
            i64 b, c;
            read(b, c);
            i64 bc = cc[b];
            sum -= bc * b;
            sum += bc * c;
            cc[b] = 0;
            cc[c] += bc;
            cout << sum << "\n";
        }
    }

}

Measured memory_bytes: 10020
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int n;
   cin>>n;
   long long int first;
   cin>>first;
   long long int min=first;
   n--;
   long long int max=-1000000000;
   long long int result;
   while(n--)
   {
     long long int x;
     cin>>x;
     result=x-min;
     if(x<min) min=x;
     //cout<<min<<endl;
     if(result>max) max=result;          
   }
   cout<<max<<endl;
   //while(1);
   return 0;
 }
 

Measured memory_bytes: 3088
#include<stdio.h>
int main(){
  int n,a,b,p[100],i,A=0,B=0,C=0;
  scanf("%d%d%d",&n,&a,&b);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    if(p[i] <= a) A++;
    else if(p[i] <= b) B++;
    else C++;
  }
  if(A>B)A=B;
  if(A>C)A=C;
  printf("%d",A);
}

Measured memory_bytes: 128
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[4];
  scanf("%s", s);
  int ans = 700;
  for (int i=0; i<3; i++) {
    if (s[i] == 'o') ans += 100;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int N, M, K, a[20009]; long long dp[20009];
int main() {
	cin >> N >> M >> K;
	for(int i = 0; i < N; i++) cin >> a[i];
	dp[0] = 0;
	for(int i = 1; i <= N; i++) {
		int l = 1999999999, r = -l;
		dp[i] = 1LL << 60;
		for(int j = 1; j <= M && i - j >= 0; j++) {
			l = min(l, a[i - j]);
			r = max(r, a[i - j]);
			dp[i] = min(dp[i], dp[i - j] + K + 1LL * j * (r - l));
		}
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3284
(* Vicfred
 * https://atcoder.jp/contests/abc139/tasks/abc139_a
 * implementation
 * *)
Scanf.scanf "%s\n%s\n" (fun s t ->
    let ans = ref 0 in
    for i = 0 to (String.length s - 1) do
        if s.[i] = t.[i] then
            ans := !ans + 1
    done;
    Printf.printf "%d\n" !ans
)



Measured memory_bytes: 3760
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10)
        cout << a * b << endl;
    else
        cout << "-1" << endl;
}

Measured memory_bytes: 3616
import java.util.*;

import sun.font.TrueTypeFont;

import static java.lang.System.out;

public class Main{
   public static Scanner sc = new Scanner(System.in);
   public static void main(String args[]){
      char[] str = sc.next().toCharArray();
      int count = 700;
      for (char c : str){
        count +=  c == 'o' ? 100 : 0;
      }
      out.println(count);

   }
}

Measured memory_bytes: 21844
using System.Linq;
using System.Text;
using static System.Console;

namespace For_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Yard = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ans = (Yard[0] - 1) * (Yard[1] - 1);
            WriteLine(ans);
            ReadLine();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
using namespace std;
int col[200005],p[200005],cnt0,cnt1;
vector<int> e[200005];
void dfs(int u,int fa)
{
 col[u]=!col[fa];
 if(col[u])cnt1++;
 else cnt0++;
 for(auto v:e[u])
  if(v!=fa)dfs(v,u);
}
int main()
{
 int n;
 cin>>n;
 for(int i=1;i<n;i++)
 {
  int u,v;
  cin>>u>>v;
  e[u].push_back(v);
  e[v].push_back(u);
 }
 dfs(1,1);
 int p1=1,p2=2,p3=3;
 if(cnt0>n/3&&cnt1>n/3)
 {
  for(int i=1;i<=n;i++)
   if(col[i]==0)
   {
    if(p1<=n)p[i]=p1,p1+=3;
    else p[i]=p3,p3+=3;
   }
   else
   {
    if(p2<=n)p[i]=p2,p2+=3;
    else p[i]=p3,p3+=3;
   }
 }
 else if(cnt1<=n/3)
 {
  for(int i=1;i<=n;i++)
   if(col[i]==0)
   {
    if(p1<=n)p[i]=p1,p1+=3;
    else if(p2<=n)p[i]=p2,p2+=3;
    else p[i]=p3,p3+=3;
   }
   else
    p[i]=p3,p3+=3;
 }
 else if(cnt0<=n/3)
 {
  for(int i=1;i<=n;i++)
   if(col[i]==1)
   {
    if(p1<=n)p[i]=p1,p1+=3;
    else if(p2<=n)p[i]=p2,p2+=3;
    else p[i]=p3,p3+=3;
   }
   else
    p[i]=p3,p3+=3;
 }
 for(int i=1;i<=n;i++)
  cout<<p[i]<<' ';
 cout<<endl;
 return 0;
}

Measured memory_bytes: 19200
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

ans = 0

while h.any?{|e| e != 0}
    flag = true
    n.times do |i|
        if h[i] == 0
            if flag
                next
            else
                break
            end
        else
            flag = false
            h[i] -= 1
        end
    end
    ans += 1
end

puts ans

Measured memory_bytes: 1788