akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define rep(i,N) for(i=0;i<(ll)N;i++)
#define print(a) cout<<a<<endl
#define pb push_back
vec prime(ll N){
  ll i=2;
  vec res;
  while(i*i<=N){
    while(!(N%i)){
      res.pb(i);
      N/=i;
    }
    i++;
  }
  if(N!=1)res.pb(N);
  return res;
}
int main(){
  ll i,Q,N;
  cin>>Q;
  vec x(100001,0);
  For(i,12,100001){
    vec v=prime(i);
    if(v.size()<3)x[i]=x[i-1];
    else if(v.size()>3)x[i]=x[i-1]+1;
    else if(v[0]==v[2]){
      x[i]=x[i-1];
    }else{
      x[i]=x[i-1]+1;
    }
  }
  while(Q--){
    cin>>N;
    print(x[N]);
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  vector<int> v(n+1);
  rep(i,n) cin>>a[i];
  int mx = -1;
  for(int i=1; i<n;i++) {
    v[i] = a[i] - a[i-1];
  }
  v[n] = k - a[n-1] + a[0];
  ll ans = accumulate( all(v) , 0);
  for(auto dis : v) {
    mx = max(mx, dis);
  }
  ans -= mx;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll div10 = 10;
    if (n%2 != 1){
        while(n/div10 > 0){
            ans += n/div10;
            div10 *= 5;
        }
    }

    cout << ans << endl; 
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    for (int i = 0; i < 100010; ++i) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        chmin(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
// ALDS1_10_A Fibonacci Number
#include <iostream>
#include <vector>
bool debug = false;

std::vector<int> dp_array;

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

    dp_array.push_back(1); // i == 0
    dp_array.push_back(1); // i == 1
    for (int i=2; i<=target; i++) {
        dp_array.push_back(dp_array.at(i-1)+dp_array.at(i-2));
    }

    std::cout << dp_array.back() << "\n";
}


Measured memory_bytes: 3140
#include <iostream>
#include <cstring>

using ll = long long;
int n, k;
int a[5010];
bool stat[5010];

ll dp[5010][5100];

ll dfs(int idx, ll sum) {
    if(sum >= k) {
        return sum;
    }
    if(idx >= n) {
        return 0;
    }
    if(dp[idx][sum] != -1) {
        return dp[idx][sum];
    }

    ll min = 1e18;
    auto r = dfs(idx + 1, sum + a[idx]);

    if(r != 0) {
        if(r - a[idx] < k) {
            stat[idx] = true;
        }
        min = std::min(min, r);
    }
    r = dfs(idx + 1, sum);
    if(r != 0) {
        min = std::min(min, r);
    }

    if(min == 1e18) {
        return dp[idx][sum] = 0;
    }
    return dp[idx][sum] = min;
}

int main() {
    memset(dp, -1, sizeof(dp));
    std::cin >> n >> k;

    for(int i = 0; i < n; ++i)
        std::cin >> a[i];

    dfs(0, 0);

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(stat[i])
            ++cnt;
    }

    std::cout << n - cnt << std::endl;
}

Measured memory_bytes: 200064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, k, D[MAXN];

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

    cin >> n >> k;
    for (ll i = 0; i < k; i++) {
        ll x;
        cin >> x;
        D[x] = 1;
    }
    for (ll i = n; i < MAXN; i++) {
        ll x = i, t = 0;
        while (x) {
            t |= D[x % 10];
            x /= 10;
        }
        if (t == 0) return cout << i << endl, 0;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;

int main(){
  LL N, A, B;
  cin >> N >> A >> B;
  LL ret = N / (A + B) * A;
  N %= A + B;
  ret += A < N ? A : N;
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  //cout<<ceil((double)7/3);return 0;
  ll n,a,b;cin>>n>>a>>b;
  ll sum=0;
  ll h[n];for(ll i=0;i<n;i++){
    cin>>h[i];
    sum+=h[i];
  }
  ll k=ceil((double)sum/(b*(n-1)+a));
 // cout<<k;return 0;
  ll u=sum/b+1;ll d=k-1;
  while(u-d>1){
    ll mid=(u+d)/2;
    ll hm[n];for(ll i=0;i<n;i++)hm[i]=h[i]-mid*b;
    ll summ=0;
    for(ll j=0;j<n;j++){
      if(hm[j]>0)
      summ+=ceil((double)hm[j]/(a-b));
     // cout<<summ<<endl;
    }
    if(summ<=mid){
      u=mid;
    }
    else{
      d=mid;
    }
  }
  cout<<u<<endl;
}
  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC144A()
{
	int A, B;
	cin >> A >> B;
	if (A < 10 && B < 10)
	{
		cout << A * B << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
}

int main()
{
	ABC144A();
	return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val x = readInt()
    println(when {
        x >= 1800 -> 1
        x >= 1600 -> 2
        x >= 1400 -> 3
        x >= 1200 -> 4
        x >= 1000 -> 5
        x >= 800 -> 6
        x >= 600 -> 7
        else -> 8
    })
}


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

int main(){

    int a,b;
    cin >> a >>b;
    int t;

    if(b<10){
        t=a*10+b;
    }else if(b<100){
        t=a*100+b;
    }else{
        t=a*1000+b;
    }

    for(int i=0;i*i<=t;i++){
        if(i*i==t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

int main(void){
    int a,b,c,d,i;
    i=0;
    cin >> a >> b >> c >> d;
    while(a>0 &&  c>0){
        i++;
        if(i%2==0){
            a = a - d;
        }else{
            c = c - b;
        }
    }
    if(a > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 55;
const int def = 51;

int n, i, j, a, b, bit;
int from[maxN], to[maxN];
bool can[maxN][maxN][maxN], aux[maxN];
bool act[maxN][maxN];
ll ans;

int main()
{
 //   freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) cin >> from[i];
    for (i = 1; i <= n; i++) cin >> to[i];

    for (i = 0; i <= def; i++) can[0][i][i] = true;
    for (i = 1; i <= def; i++) {
        for (a = 0; a <= def; a++) {
            for (b = 0; b <= a; b++) {
                can[i][a][b] |= can[i - 1][a][b];
                can[i][a][b] |= can[i - 1][a % i][b];
            }
        }
    }

    for (i = 1; i <= n; i++) {
        if (!can[def][from[i]][to[i]]) {
            printf("-1");
            return 0;
        }
    }

    for (i = 1; i <= n; i++) act[i][from[i]] = true;
    for (bit = def; bit > 0; bit--) {
        bool need = false;

        for (i = 1; i <= n; i++) {
            bool any = false;

            for (j = 0; j <= def; j++)
                if (act[i][j] && can[bit - 1][j][to[i]])
                    any = true;

            if (!any) need = true;
        }


        if (!need) {

            for (i = 1; i <= n; i++) {
                memcpy(aux, act[i], sizeof(aux));
                memset(act[i], 0, sizeof(aux));

                for (j = 0; j <= def; j++)
                    if (aux[j] && can[bit - 1][j][to[i]])
                        act[i][j] = true;
            }

        } else {
            ans |= 1LL << bit;

            for (i = 1; i <= n; i++) {
                memcpy(aux, act[i], sizeof(aux));
                memset(act[i], 0, sizeof(aux));

                for (j = 0; j <= def; j++) {
                    if (aux[j] && can[bit - 1][j][to[i]])
                        act[i][j] = true;

                    if (aux[j] && can[bit - 1][j % bit][to[i]])
                        act[i][j % bit] = true;
                }
            }
        }
    }

    cout << ans;



    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
LL N, K;
vector<LL> A(N);

bool check(double x) {
  LL cnt = 0;
  for (double a : A) {
    LL cut = (a <= x) ? 0 : a/x;
    cnt += cut;
  }
//  cout << x << ":" << cnt << endl;
  return (cnt <= K);
}

int main() {
  cin >> N >> K;
  A.resize(N); cin >> A;

#if  0
  if (K == 0) {
    LL vmax = 0;
    for (LL a : A) vmax = max(vmax, a);
    cout << vmax << endl;
    return 0;
  }
#endif

  LL ng = 0, ok = 1e18;
  while (abs(ng - ok) > 1) {
    LL mid = (ng + ok) / 2;
    if (check(mid)) ok = mid;
    else            ng = mid;
//   cout << mid << ", " << ok << ", " << ng << endl;
  }
  LL x = ceil(ok);
  cout << x << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <math.h>                                                               
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c, d, e;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;

    int n[5] = {a, b, c, d, e};
    int min = 9;
    int index = 0;
    for (int i = 0; i < 5; i++)
    {
        int num = n[i];
        num %= 10;
        
        if (num != 0 && min > num)
        {
            min = num;
            index = i;
        }
    }

    int sum = 0;
    for (int i = 0; i < 5; i++)
    {
        if (i == index)
        {
            sum += n[i];
        }
        else
        {
            int f = (int)(ceil((float)n[i] / 10.f) * 10);
            sum += f;
        }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int n,C;
int s[100001],t[100001],c[100001];
PP p[100001];
int fr[31];
int ch[31];
bool check(int v){
	memset(fr,0,sizeof(fr));
	memset(ch,0,sizeof(ch));
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<v;j++){
			if(fr[j]<=p[i].first.first && ch[j]==p[i].second){
				flag=true;
				fr[j]=p[i].first.second;
				break;
			}
		}
		if(!flag){
			for(int j=0;j<v;j++){
				if(fr[j]<p[i].first.first){
					flag=true;
					fr[j]=p[i].first.second;
					ch[j]=p[i].second;
					flag=true;
					break;
				}
			}
		}
		if(!flag)return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&C);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&s[i],&t[i],&c[i]);
		p[i]=PP(P(s[i],t[i]),c[i]);
	}
	sort(p,p+n);
	int lb=0,rb=C;
	while(lb+1<rb){
		int mid=(lb+rb)/2;
		if(check(mid))rb=mid;
		else lb=mid;
	}
	printf("%d\n",rb);
	return 0;
}


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

typedef long long ll;

int main(){
    ll X, Y;
    cin >> X >> Y;
    
    ll u=X; int cnt=1;
    while(1){
        u *= 2;
        if(u>Y) break;
        cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
//#define fastIO 
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); }
int arr[2];
int main() {
	fastIO();
	int n; in(n); while (n--) {
		int t; in(t); arr[t& 1]++;
	}
	std::cout << (arr[1] & 1 ?"NO":"YES");
}


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

int main() {
	string s;
    cin >> s;
    int ca = 0, cb = 0, cc = 0;
    for (int i = 0; i < s.size(); i++){
        if (s.at(i) == 'a'){
            ca++;
        }
        else if (s.at(i) == 'b'){
            cb++;
        }
        else{
            cc++;
        }
    }

    int num = 0;
    if (ca > cb && ca > cc){
        if (cb > cc){
            num = ca - cc;
        }
        else{
            num = ca - cb;
        }
    }
    else if (cb > ca && cb > cc){
        if (ca > cc){
            num = cb - cc;
        }
        else{
            num = cb - ca;
        }
    }
    else{
        if (ca > cb){
            num = cc - cb;
        }
        else{
            num = cc - ca;
        }
    }
    cout << (num <= 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const long long inf=(1ll<<60);
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline long long read(){
    long long x=0,f=1;char ch;ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
    if(f)return x;else return -x;
}
const int N=5e5+10;
long long sum[N],F,ans=inf,n,op,x,ed;
int main()
{
    n=read();x=read();
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+read();
    for(long long j=1;j<=n;j++){
        F=(n+j)*x+5ll*sum[n];ed=(n-j-1)/j+1;
        for(long long v=2;v<=ed;v++){
            F+=2*sum[n-v*j];
            if(F<=0ll){F=inf;break;}
        }
        ans=min(ans,F);
    }
  printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

char str[100000];
char ans[100000];

void sort();

int main(){

  int n;
  while (1){
    scanf("%d", &n);
    if (n == 0){ break; }
    scanf("%s", str);
    while( n>0 ){
      sort();
      memcpy(str, ans, sizeof(ans));
      n--;
    }
    printf("%s\n", ans);
  }

  return 0;
}
void sort(){

  int	i, j, len;
  char	c = '\0';
  char	countbuf[10], valuebuf[10];
  int	count;

  len = strlen(str);
  memset(ans, '\0', sizeof(ans));
  for (i = 0; i < len; i++){
    if (c != str[i]){
      count = 0;
      for (j = i; j < len; j++){
	if (str[i] == str[j]){
	  count++;
	}
	else{ break; }
      }
      memset(valuebuf, '\0', sizeof(valuebuf));
      sprintf(countbuf, "%d", count);
      valuebuf[0] = str[i];
      strcat(ans, countbuf);
      strcat(ans, valuebuf);
      memset(countbuf, '\0', sizeof(countbuf));
      c = str[i];
    }
  }
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, m;
    string s[100], t[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    cin >> m;
    for (int i = 0; i < m; i++)
        cin >> t[i];

    map<string, ll> mp;
    for (int i = 0; i < n; i++)
    {
        // mp.insert(make_pair(s[i], 1));
        mp[s[i]]++;
    }
    for (int i = 0; i < m; i++)
    {
        mp[t[i]]--;
    }

    int mx = 0;
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        mx = max(mx, it->second);
    }
    cout << mx << endl;
}


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

int main(void){
  int n,k,a,b,tile;
  
  cin >> n >> k;
  
  for( int i = 0 ; i < k ; i++ ){
      
      cin >> a >> b;

      a = min( a , n - a + 1 );
      b = min( b , n - b + 1 );    
      tile = min( a , b ) % 3;

      if( tile == 0 ) tile = 3;

      cout << tile << endl;    

}

return 0;

}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

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

  ll r = 0, g = 0, b = 0;
  for (auto c : S) {
    if (c == 'R') r++;
    else if (c == 'G') g++;
    else b++;
  }

  ll ans = r * g *  b;
  REP(i, N) {
    FOR(j, i+1, N-1) {
      if (S[i] == S[j]) continue;
      ll k = j * 2 - i;
      if (N <= k || S[i] == S[j] || S[i] == S[k] || S[j] == S[k]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long int ll;


bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}
// use case
//sort(V.begin(), V.end(), compare_function);



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector <ll> A(n,0);
    for (ll i=0; i<n; i++)
    {
        cin>>A[i];
        A[i]=A[i]-1;
    }
    vector <int> B(n,-1);
    B[0]=0;
    int i=1;
    int a=0;
    int x=0;
    while (x==0 &&k>0)
    {
        a=A[a];
        k--;
       // cout<<a<<" "<<i<<" "<<B[a]<<endl;
        if (B[a]!=-1)
        {
            x=1;
            //cout<<a<<" "<<i<<" "<<B[a]<<" "<<k<<" "<<k%(i-B[a])<<endl;
        }
        else
        {
            B[a]=i;
            i++;
        }
    }
    if (k==0 || a==A[a])
    {
        cout<<a+1<<endl;
    }
    else
    {
        k=k%(i-B[a]);
        while (k>0)
        {
            a=A[a];
            k--;
        }
        cout<<a+1<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

  string s, t;
  cin >> s >> t;

  vector<vector<int>> a(26, vector<int>());
  vector<vector<int>> b(26, vector<int>());
  for (int i = 0; i < t.size(); i++) {
    a[s[i] - 'a'].push_back(i);
    b[t[i] - 'a'].push_back(i);
  }

  for (int i = 0; i < 26; i++) {
    for (auto j : a[i]) {
      if (t[a[i][0]] != t[j]) {
        cout << "No" << endl;
        return 0;
      }
    }

    for (auto j : b[i]) {
      if (s[b[i][0]] != s[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
ll max(ll a, ll b){
    return a > b? a: b;
}
const ll INF = 1e18L+7;
int main() {
    int n, W;
    ll tv = 0;
    cin >> n >> W;
    vector<ll> wt(n), val(n);
    for(int i = 0; i < n; i++) { 
        cin >> wt[i] >> val[i];
        tv += val[i];
    }

    vector< vector<ll> > dp(n+1, vector<ll> (tv+1, INF));
    // dp[i][j] = min total weight of items with total val j with i items 
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int v = 0; v <= tv; v++) {
            if(v == 0) {
                dp[i][v] = 0;
                continue;
            }
            dp[i][v] = dp[i-1][v];
            if(v >= val[i-1])
                dp[i][v] = min(dp[i][v], wt[i-1] + dp[i-1][v-val[i-1]]);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= tv; i++){
        if(dp[n][i] <= W)
            ans = max(i, ans);
    }
    cout << ans << endl;
}


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

using ll = long long;
using namespace std;


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int res = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j + i <= n; j++){
            string sb = s.substr(i,j);
            bool f = 1;
            for(auto k : sb)if(k != 'A' && k != 'C' && k != 'G' && k != 'T')f = 0;
            if(f){
            res = max(res,(int)sb.size());
            }
        }
    }
    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long n;
  cin >> n;
  vector<long> A(n);
  long total = 1;
  for (long i = 0; i < n; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (long i = 0; i < n; i++) {
    if (total != 0 and A[i] > 1000000000000000000 / total) {
      cout << -1 << endl;
      return 0;
    }
    total *= A[i];
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 4024
#include<stdio.h>

int main(void)
{
   int n,m,a[100],x,i,b,c;
   double y;
   b=0; c=0;
   scanf("%d%d",&n,&m);
   x=4*m;
   for(i=0; i<n; i++){
      scanf("%d",&a[i]);
      b+=a[i];
   }
   y=(double)b/(double)x;
   for(i=0; i<n; i++){
      if(a[i]>=y)
        c=c+1;
   }

   if(c>=m)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}


Measured memory_bytes: 1632
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

long long cnt = 0;
vector<int> g;

void insertionSort(int a[], int n, int g) {
  int v;
  for (int i = g; i < n; i++) {
    v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
}

void shellSort(int a[], int n) {
  for (int h = 1;;) {
    if (h > n) break;
    g.push_back(h);
    h = 3 * h + 1;
  }
  for (int i = g.size() - 1; 0 <= i; --i) {
    insertionSort(a, n, g[i]);
  }
}

int main() {
  int n;
  cin >> n;
  int a[n];
  // for (int i = 0; i < n; ++i) {
  //   cin >> a[i];
  // }
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  shellSort(a, n);
  cout << g.size() << endl;
  for (int i = g.size() - 1; 0 <= i; --i) {
    cout << g[i] << ((i == 0) ? '\n' : ' ');
  }
  cout << cnt << endl;
  for (int i = 0; i < n; ++i) {
    cout << a[i] << endl;
  }
}



Measured memory_bytes: 7096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int d = in.nextInt();
        int[][] points = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                points[i][j] = in.nextInt();
            }
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int result = 0;
                for (int k = 0; k < d; k++) {
                    result += Math.pow(Math.abs(points[i][k] - points[j][k]), 2);
                }
                double sqrt = Math.sqrt(result);
                if(Math.floor(sqrt) == sqrt){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22356
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] arg) {

        try (Scanner scanner = new Scanner(System.in)){
            int[] in = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            int n = in[0];
            int d = in[1];
            int[][] x = new int[n][d];
            for (int i = 0; i < n; i++) {
                x[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            }
            int count = 0;
            for (int i = 1; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    double l = 0;
                    for (int k = 0; k < d; k++) {
                        int tmp = x[j][k] - x[i][k];
                        l += tmp * tmp;
                    }
                    if (Math.sqrt(l) % 1 == 0) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

    }
}


Measured memory_bytes: 27092
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int k, x;
	cin >> k >> x;
	for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1);i++)
	{
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int cnt1,cnt2,i;
	char s[10001];
	while(scanf("%s",s)!=EOF){
		cnt1=0; cnt2=0;
		for(i=0;i<strlen(s);i++){
			if(s[i]=='J'){
				if(s[i+1]=='O'&&s[i+2]=='I') cnt1++;
			}
			if(s[i]=='I'){
				if(s[i+1]=='O'&&s[i+2]=='I') cnt2++;
			}
		}
		printf("%d\n%d\n",cnt1,cnt2);
	}
	return 0;
}

Measured memory_bytes: 2760
#include<stdio.h>
#include<stdlib.h>
 
#define INF 2000000000
#define N 100
 
 
int main() {
  int n, M[N+1],m[N+1][N+1];
  int l, i, j, k, q;
   
  scanf("%d",&n);

  for ( i = 1; i <= n; i++ ) {
    scanf("%d%d", &M[i-1], &M[i]);
  }
   
  for ( i = 1; i <= n; i++ ){
    m[i][i] = 0;
  }
  for ( l = 2; l <= n; l++ ) {
    for ( i = 1; i <= n - l + 1; i++ ) {
      j = i + l - 1;
      m[i][j] = INF;
      
      for ( k = i; k <= j - 1; k++ ) {
	q =  m[i][k] + m[k + 1][j] + M[i - 1] * M[k] * M[j];
	
	m[i][j] = (m[i][j] < q ? m[i][j] : q );
      }
    }
  }
   
  printf("%d\n", m[1][n]);
   
  return 0;
}

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

using namespace std;
#define INF 1e10

void warshallFloyd(vector<vector<long> > &min_d,
                   const int &V,
                   const int &E)
{
    for(int k = 0; k < V;k++){
        for(int i = 0;i < V;i++){
            if(min_d[i][k] == INF) continue; // 計算の節約（無駄にループ回さない）
            for(int j = 0;j < V;j++){
                if(min_d[k][j] == INF) continue; // 計算の節約（無駄にループ回さない）
                min_d[i][j] = min(min_d[i][j],min_d[i][k] + min_d[k][j]);
            }
        }
    }
}

int main()
{
    // ----- Input ----- //
    int V,E;
    int s,t;
    long d;
    cin >> V >> E;
    vector<vector<long> > min_d(V,vector<long>(V,INF) );
    
    for(int i = 0;i < E;i++){
        cin >> s >> t >> d;
        min_d[s][t] = d;
    }
    for(int i = 0;i < V;i++) min_d[i][i] = 0;

    warshallFloyd(min_d,V,E);
    bool is_negative_cycle = false;

    for(int i = 0;i < V;i++){
        if(min_d[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << "\n";
            is_negative_cycle = true;
            break;
        }    
    }
    if(is_negative_cycle == false){
        for(int i = 0;i < V;i++){
            for(int j = 0;j < V-1;j++){
                if(min_d[i][j] == INF) cout << "INF" << " ";
                else cout << min_d[i][j] << " ";
            }
            if(min_d[i][V-1] == INF) cout << "INF" << "\n";
            else cout << min_d[i][V-1] << "\n";
        }
    }
    


    return 0;
}




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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod? a : a - mod; }

string S;
int d, n;
ll dp[10005][101][2];

ll f(int i, int sum, bool ok){
	if(i == n) return sum % d == 0;
	if(dp[i][sum][ok] != -1) return dp[i][sum][ok];
	ll ret = 0;
	for(int k = 0; k <= (!ok ? S[i] - '0' : 9); k++){
		ret = add(ret, f(i + 1, (sum + k) % d, (k == S[i] - '0' ? ok : 1)));
	}
	return dp[i][sum][ok] = ret;
}

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

	cin >> S >> d;
	n = S.size();
	memset(dp, -1, sizeof dp);
	cout << (f(0, 0, 0) - 1 + mod) % mod; 
}

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

int main() {
	int N, K;
	cin >> N >> K;
	bool hasOkashi[110];
	for (int i = 0; i < N; i++) {
		hasOkashi[i] = false;
	}
	int count = 0;


	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int A;
			cin >> A;
			hasOkashi[A-1] = true;
		}
	}

	for (int i = 0; i < N; i++) {
		if (hasOkashi[i] == false) count++;
	}

	cout << count;
	
	return 0;
}

Measured memory_bytes: 3184
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define NUM 1000000
typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int dp[NUM+1];

int dfs(int n) {
    if (dp[n] != -1) return dp[n];
    if (n < 10) return 0;
    int ma = 0;
    int digit = 0, tmp = n;
    while (tmp) {
        tmp /= 10;
        digit++;
    }
    for (int i = 1; i < digit; i++) {
        int pow = 1;
        for (int j = 0; j < i; j++) pow *= 10;
        ma = max(ma, ((n%pow) * (n/pow)));
    }
    if (ma == n) return dp[n] = INF;
    else return dp[n] = dfs(ma) + 1;
}

int main(void) {
    for (int i = 0; i <= NUM; i++) dp[i] = -1;
    int N;
    cin >> N;
    while (N--) {
        int p;
        cin >> p;
        int ans = dfs(p);
        if (ans >= INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5064
// aribon3-3_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

struct BIT { // 1-index
    int sz;
    vector<int> tree;

    BIT(int n) {
        sz = n;
        tree.resize(n+1);
    }

    ll sum(int i){
        ll sm = 0;
        while (i > 0){
            sm += tree[i];
            i -= i & -i;
        }
        return sm;
    }

    void add(int i, int x){
        while (i <= sz){
            tree[i] += x;
            i += i & -i;
        }
    }
};

typedef enum {
    LEFT = 1,
    MIDDLE,
    RIGHT
} ePOS;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;
    int n = S.size();

    map<char, int> mp;
    for (auto c: S){ mp[c]++; }

    // できるかどうかcheck
    int odd_cnt = 0;
    for (auto p: mp){ if (p.second % 2 == 1) odd_cnt++; }
    if ((n % 2 == 0 && odd_cnt > 0) || (n % 2 == 1 && odd_cnt > 1)) {
        print(-1);
        return 0;
    }

    // 左側と右側に分ける
    map<char, int> mp_tmp;
    vector<int> pos(n);
    deque<char> left, right;
    REP(i, n){
        char c = S[i];
        mp_tmp[c]++;
        if (2 * mp_tmp[c] - 1  < mp[c]) {
            pos[i] = LEFT;
            left.emplace_back(c);
        } else if (2 * mp_tmp[c] - 1  == mp[c]) {
            pos[i] = MIDDLE;
        } else {
            pos[i] = RIGHT;
            right.emplace_front(c);
        }
    }

    ll ans = 0;

    // 000012222 となるまでの転倒数カウント
    auto bit = BIT(n+1);
    REP_REV(i, n){
        ans += bit.sum(pos[i] - 1);
        bit.add(pos[i], 1);
    }

    int n2 = left.size();

    // left->rightのindexテーブル
    map<char, deque<int>> mp_table;
    REP(i, n2){
        mp_table[right[i]].emplace_back(i+1); // あとでbitが1-indexでいけるようにi+1
    }
    vector<int> table(n2);
    REP(i, n2){
        table[i] = mp_table[left[i]][0];
        mp_table[left[i]].pop_front();
    }

    // left -> rightの転倒数カウント
    auto bit2 = BIT(n2+1);
    REP_REV(i, n2){
        ans += bit2.sum(table[i] - 1);
        bit2.add(table[i], 1);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3476
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    string S,T;
    in >> S >> T;

    string ans{};

    REP(i, N) {
        ans.append(1, S[i]);
        ans.append(1, T[i]);
    }
    out << ans << endl;
    return 0;
}
int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ld a, b, c;std::cin >> a >> b >> c;
  ld t = a + b + 2*sqrt(a*b);
  std::cout << (t<c?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>

#define MAX_N 20

using namespace std;

int N, R;
int lx[MAX_N], rx[MAX_N], h[MAX_N];
int inf = 100000000;

bool judge(double t){
	for (int x = -R+1; x < R; x++)
	{
		int l = inf, r = inf, m = 0;
		int y;
		for (int i = 0; i < N; i++)
		{
			if(lx[i] == x){
				r = min(h[i], r);
			}else if(rx[i] == x){
				l = min(h[i], l);
			}else if(lx[i] < x && x < rx[i]){
				m = max(h[i], m);
			}
		}
		if(l == inf || r == inf) y = 0;
		else y = min(l, r);
		if(m > y) y = m;
		if(y < (double)sqrt(R*R-x*x)-R+t) return true;
	}
	return false;
}

void solve() {
	double maxT = 21;
	double minT = 0;
	while(maxT - minT > 0.0001){
		double t = (maxT+minT)/2;
		if(judge(t)){// ???????????????
			maxT = t;
		}else{// ????????????
			minT = t;
		}
	}
	printf("%.4lf\n", (maxT+minT)/2);
	return;
}

int main(){
	while(1){
		cin >> R >> N;
		if(R == 0 && N == 0) break;
		for (int i = 0; i < N; i++)
		{
			cin >> lx[i] >> rx[i] >> h[i];
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <math.h>

static int true = 1;
static int false = 0;

int isprime(int x);

int
main(void)
{
        int i;
        int n, num;
        int flag = 0;

        scanf("%d", &n);

        for (i = 0; i < n; i++) {
                scanf("%d", &num);
                if (isprime(num) == true)
                        flag++;
        }

        printf("%d\n", flag);

        return 0;
}

int
isprime(int x)
{
        int i = 3;

        if (x == 2) {
                return true;
        }
        if (x < 2 || x % 2 == 0) {
                return false;
        }
        while (i <= sqrt(x)) {
                if (x % i == 0)
                        return false;
                i = i + 2;
        }

        return true;
}




Measured memory_bytes: 2040
#include <string>
#include <iostream>
#include <utility>

template<typename T>
struct Node
{
    T value;
    Node* left;
    Node* right;
    Node()
    {
        left = right = NULL;
    }
};

template<typename T>
class MySet
{
    Node<T>* root_;
    std::pair<Node<T>*, bool> insert(const T& value, Node<T>* node)
    {
        if(node->value == value){
            return std::make_pair(node, false);
        }
        Node<T>*& p = node->value < value ? node->right : node->left;
        if(p) return insert(value, p);
        p = new Node<T>;
        p->value = value;
        return std::make_pair(p, true);
    }
    Node<T>* find(const T& value, Node<T>* node)
    {
        if(node->value == value){
            return node;
        }
        Node<T>* p = node->value < value ? node->right : node->left;
        if(p) return find(value, p);
        return NULL;
    }
    void delete_node(Node<T>* node)
    {
        if(node == NULL) return;
        delete_node(node->left);
        delete_node(node->right);
        delete node;
    }
public:
    MySet() : root_(NULL){}
    ~MySet()
    {
        delete_node(root_);
    }
    std::pair<Node<T>*, bool> insert(const T& value)
    {
        if(root_) return insert(value, root_);
        root_ = new Node<T>;
        root_->value = value;
        return std::make_pair(root_, true);
    }
    Node<T>* find(const T& value)
    {
        if(root_) return find(value, root_);
        return NULL;
    }
    Node<T>* end()
    {
        return NULL;
    }
};


int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    // std::set<std::string> dic;
    MySet<std::string> dic;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        std::string command, str;
        std::cin >> command >> str;
        if(command == "insert"){
            dic.insert(str);
        }else
        if(command == "find"){
            std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
        }
    }
    return 0;
 }

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

int main() {
	int a, b;
	cin >> a >> b;

	int sum = 0;

	for (int i = 1; i <= 998; ++i) {
		sum += i;
		if (sum + i + 1 - sum == b - a) {
			cout << sum - a << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int j,i=0; int con=0;
	int count[1000]={0};
	char word[1000][33]={0};
	int maxlen,maxcon,len;
	
	while( scanf("%s", &word[i])!= EOF){
		con++; /*単語数*/
		for(j=0; j<i-1;j++)
			if(strcmp(&word[i][0],&word[j][0])==0) {count[j]++; break;};
		i++;
	};

	maxlen=strlen(&word[0][0]);
	maxcon=count[0];
	for(i=1; i<con; i++) {
		len=strlen(&word[i][0]);
		if(maxlen<len) maxlen=len;
		if(maxcon<count[i]) maxcon=count[i];
	};
	
	for(i=0;i<con;i++){
		len=strlen(&word[i][0]);
		if(len==maxlen) break;
	};
	for(j=0;j<con;j++) if(maxcon==count[j]) break;
	printf("%s %s\n", &word[j][0],&word[i][0]);
	return (0);
}

Measured memory_bytes: 596
var  a,b,c,ans:longint;
begin
  readln(a,b,c);
  if  (a<=c)and(b<=c)then  ans:=a+b;
  if  (a<=b)and(c<=b)then  ans:=a+c;
  if  (b<=a)and(c<=a)then  ans:=b+c;
  writeln(ans);
end.


Measured memory_bytes: 128
# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

N,M = map(int,input().split())
S = [input() for i in range(N)]

G = Dinic(N*M+2)

for i in range(N):
    for j in range(M):
        node = i*M + j + 1
        if (i+j)%2 and S[i][j]==".":
            G.add_edge(0,node,1)
            if i!=0 and S[i-1][j]==".":
                G.add_edge(node,node-M,1)
            if i!=N-1 and S[i+1][j]==".":
                G.add_edge(node,node+M,1)
            if j!=0 and S[i][j-1]==".":
                G.add_edge(node,node-1,1)
            if j!=M-1 and S[i][j+1]==".":
                G.add_edge(node,node+1,1)
        else:
            G.add_edge(node,N*M+1,1)

ans = G.flow(0,N*M+1)
print(ans)

res = [[S[i][j] for j in range(M)] for i in range(N)]

for i in range(N):
    for j in range(M):
        node = i*M + j + 1
        if (i+j)%2 and S[i][j]==".":
            for w,cap,rev in G.G[node]:
                if cap==0 and w!=0 and w!=N*M+1:
                    ni,nj = (w-1)//M,(w-1)%M
                    if ni==i-1:
                        res[ni][nj] = "v"
                        res[i][j] = "^"
                    elif ni==i+1:
                        res[i][j] = "v"
                        res[ni][nj] = "^"
                    elif nj==j-1:
                        res[ni][nj] = ">"
                        res[i][j] = "<"
                    else:
                        res[i][j] = ">"
                        res[ni][nj] = "<"

for i in range(N):
    print("".join(res[i]))


Measured memory_bytes: 84024
#include <stdio.h>

int main(){

int A,B,i=0,n=0;
scanf("%d%d",&A,&B);

if(A<B)
{

n=B/A;

if(B%A!=0)
{
printf("%d\n",n+1);

}

else
printf("%d\n",n);



return 0;

}






if(A>=B){

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







}


Measured memory_bytes: 2092
s = input()

l = 0
r = len(s) - 1
answer = 0

while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        answer += 1
    elif s[r] == 'x':
        r -= 1
        answer += 1
    else:
        print(-1)
        exit()

print(answer)

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
const double pi = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll sx, sy, tx, ty, N;
	cin >> sx >> sy >> tx >> ty >> N;
	if (sx > tx) {
		swap(sx, tx);
		swap(sy, ty);
	}
	vector<pii> v;
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		if (x >= sx&&x <= tx&&y >= min(sy, ty) && y <= max(sy, ty))v.push_back({ x,y });
	}
	sort(ALL(v));

	int n = v.size();
	vi dp(n + 1, INF);
	if (sy < ty) {

		REP(i, n) {
			int c = lower_bound(ALL(dp), v[i].second) - dp.begin();
			dp[c] = v[i].second;
		}
	}
	else {
		REP(i, n) {
			int c = lower_bound(ALL(dp), -v[i].second) - dp.begin();
			dp[c] = -v[i].second;
		}
	}
	int k = lower_bound(ALL(dp), INF) - dp.begin();
	double ans;
	if (k == min(abs(ty - sy), abs(tx - sx)) + 1) {
		ans = 100 * (abs(tx - sx) + abs(sy - ty)) - (k - 1)*(20 - 5 * pi) + (10 * pi - 20);
	}
	else ans = 100 * (abs(tx - sx) + abs(sy - ty)) - k*(20 - 5 * pi);
	cout << fixed << setprecision(18) << ans << endl;
}


Measured memory_bytes: 2672