akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

#define MAXN 500
#define INF 0x3fffffff

int n,m;
int itor[MAXN+5],level[MAXN+5];
pair<int,int> a[MAXN],b[MAXN];
struct node
{
    int v,d,res;
    node(){}
    node(int a,int b,int c)
    {
        v=a,d=b,res=c;
    }
};
vector <node> E[MAXN+5];

void bfs(int s)
{
    memset(level,-1,sizeof level);
    level[s]=0;
    queue <int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front(); q.pop();
        for(int i=0;i<E[u].size();i++)
        {
            int v=E[u][i].v;
            int d=E[u][i].d;
            if(d>0&&level[v]<0)
            {
                level[v]=level[u]+1;
                q.push(v);
            }
        }
    }
}

int dfs(int u,int e,int f)
{
    if(u==e)
        return f;
    for(int &i=itor[u];i<E[u].size();i++)
    {
        node now=E[u][i];
        if(now.d>0&&level[u]<level[now.v])
        {
            int ex=dfs(now.v,e,min(f,now.d));
            if(ex>0)
            {
                E[u][i].d-=ex;
                E[now.v][now.res].d+=ex;
                return ex;
            }
        }
    }
    return 0;
}

int Dinic(int s,int t)
{
    int ans=0;
    while(1)
    {
        bfs(s);
        if(level[t]<0)
            break;
        memset(itor,0,sizeof itor);
        int f;
        while((f=dfs(s,t,INF))>0)
            ans+=f;
    }
    return ans;
}

void add_edge(int u,int v,int va)
{
    E[u].push_back(node(v,va,E[v].size()));
    E[v].push_back(node(u,0,E[u].size()-1));
}

int main()
{
    scanf("%d",&n);
    m=2*n+2;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].first,&a[i].second);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&b[i].first,&b[i].second);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i].first<b[j].first&&a[i].second<b[j].second)
                add_edge(i,j+n,1);
    for(int i=1;i<=n;i++)
        add_edge(2*n+1,i,1),add_edge(i+n,2*n+2,1);
    printf("%d\n",Dinic(2*n+1,2*n+2));
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
    int a1, a2, a3;

    scanf("%d %d %d", &a1, &a2, &a3);

    if (a1 + a2 + a3 >= 22)
        printf("bust");
    else if (a1 + a2 + a3 <=21)
        printf("win");

    return 0;
}

Measured memory_bytes: 128
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,a,b; cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var sum, a int
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		sum = sum + a
	}

	if sum <= n {
		fmt.Println(n - sum)
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 2352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,x;
int a[13][13];
int c[13];
int ans=INT_MAX;
void solve(int ind,vector<int> f,int cnt){
if(ind == n)
{
	int flg=0;
	for(int i=0;i<m;i++)
	{
		if(f[i]<x)
		{
			flg=1;
			break;
		}
	}
	if(flg==1)
	return ;
	else
	{   
		
		
		//cout<<cnt<<endl;
		ans=min(ans,cnt);
	}
}

for(int i=ind;i<n;i++)
{
    vector<int>temp(m);
	for(int j=0;j<m;j++)
	{
		temp[j]=f[j];
	}
	
	solve(i+1,temp,cnt);
	
	//vector<int>temp(m);
	for(int j=0;j<m;j++)
	{
		temp[j]=f[j]+a[i][j];
	}
	
	solve(i+1,temp,cnt+c[i]);
	
	
	//cout<<sum<<endl;
}

}
int main(){

cin>>n>>m>>x;

int sum[m]={0};
for(int i=0;i<n;i++)
{
	cin>>c[i];
	for(int j=0;j<m;j++)
	cin>>a[i][j];
}
for(int i=0;i<m;i++)
{
	for(int j=0;j<n;j++)
	{
		sum[i]+=a[j][i];
	}
}
int flg=0;
for(int i=0;i<m;i++)
{
	if(sum[i]<x)
	{
		flg=1;
	    break;
	}
}
if(flg==1)
{
	cout<<"-1";
	return 0;
}
vector<int>f(m);
solve(0,f,0);
cout<<ans;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int X;
    int Y;
    int Ymin;
    int len;
    int n;
    int i;
    char s[11];
    char t[4];

    scanf("%s\n",s);

    len=strlen(s);
    n=len-2;

    Ymin=9999999999;

    for(i=0;i<n;i++){
        t[0]=s[i];
        t[1]=s[i+1];
        t[2]=s[i+2];
        t[3]='\0';
        X=atoi(t);

        if(X>=753){
            Y=X-753;
        }
        else{
            Y=753-X;
        }

        if(Y<Ymin){
            Ymin=Y;
        }
    }

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

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int i,j,k,l;
  i = S.at(0) - 48;
  j = S.at(1) - 48;
  k = S.at(2) - 48;
  l = S.at(3) - 48;
  int sum1;
  int sum2;
  int sum3;
  int ok = 0;
  char x,y,z;
  
  int hu1,hu2,hu3;
  for(hu1 = 0;hu1 <= 1;hu1++){
    if(hu1 == 0){
      sum1 = i + j;
      x = '+';
    }else{
      sum1 = i - j;
      x = '-';
    }
    for(hu2 = 0;hu2 <= 1;hu2++){
      if(hu2 == 0){
        sum2 = sum1 + k;
        y = '+';
      }else{
        sum2 = sum1 - k;
        y = '-';
      }
      for(hu3 = 0;hu3 <= 1;hu3++){
        if(hu3 == 0){
          sum3 = sum2 + l;
          z = '+';
          if(sum3 == 7){
            ok++;
            break;
          }
        }
        else{
          sum3 = sum2 - l;
          z = '-';
          if(sum3 == 7){
            ok++;
            break;
          }
        }
      }
      if(ok == 1){
        break;
      }
    }
    if(ok == 1){
      break;
    }
  }
  
  cout << i << x << j << y << k << z << l << "=7" << endl;
}

Measured memory_bytes: 256
//by rng_59
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

const int MAXN = 0;

int main(void) {
	string s;
	cin >> s;
	if(s.find('A')!=-1 && s.find('B')!=-1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long n,a,b,x;
  scanf("%ld%ld%ld",&n,&a,&b);
  x=b-a;
  if(x%2 == 0) printf("%ld",x/2);
  else{
      if((b-1)<=(n-a)) printf("%ld",a+(x-1)/2);
      else printf("%ld",n-b+1+(x-1)/2);
  }
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from math import atan, pi

def main():
    a, b, x = map(int, input().strip().split())
    if x > a **2 * b / 2:
        print(atan(2 * (a**2*b - x)/ a ** 3) * 180/pi)
    else:
        print(90 - atan(2 * x / (a * b ** 2)) * (180 / pi))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val ts = new Array[Long](n)
    for (i <- 0 until n) {
      ts(i) = sc.nextLong
    }

    var ans = ts(0)
    for (i <- 1 until n) {
      ans = lcm(ans, ts(i))
    }

    println(ans)
  }

  def lcm(x: Long, y: Long): Long = {
    x / gcd(x, y) * y
  }

  def gcd(x: Long, y: Long): Long = {
    if (x == 0) y
    else gcd(y % x, x)
  }

}


Measured memory_bytes: 25536
n = int(input())
a = list(map(int,input().split()))
a.sort()
Amax = a[-1]
dp = [0]*Amax
ans = 0
for i in a:
    for j in range(i,Amax+1,i):
        dp[j-1] += 1
for i in a:
    if dp[i-1] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 32196
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int dp[202020];

int main() {
	string s;
	cin >> s;
	int n = s.size();
	map<int,vector<int>>mp;
	rep(i, 0, s.size())mp[s[i]-'a'].pb(i);
	rep(i, 0, 202020)dp[i] = 303030;

	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		rep(j, 0, 26) {
			if (mp[j].size() == 0 || mp[j][mp[j].size()-1] < i) {
				dp[i] = 1;
			}
			else {
				int nxt = *lower_bound(all(mp[j]), i);
				dp[i] = min(dp[i],dp[nxt+1]+1);
			}
		}
	}

	string ans;
	int cur = 0;
	while (ans.size() < dp[0]) {
		rep(j, 0, 26) {
			auto tmp = mp[j];
			if (tmp.size() == 0 || tmp.back() < cur) {
				ans += 'a' + j;
				break;
			}
			else {
				int idx = tmp[lower_bound(all(tmp), cur) - tmp.begin()];
				if (dp[cur] == dp[idx + 1] + 1) {
					ans += 'a' + j;
					cur = idx + 1;
					break;
				}
			}
		}
	}
	puts(ans);


	return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int n, m, q;
int a[55], b[55], c[55], d[55];
int dfs(int rest, vector<int> v, int next = 0) {
  if(next) {
    v.PB(next);
  } else {
    next = 1;
  }
  if(rest == 0) {
    int tmp = 0;
    REP(i, q) {
      if(v[b[i]] - v[a[i]] == c[i]) {
        tmp += d[i];
      }
    } 
    return tmp;
  }
  int ret = 0;
  REPS(i, next, m+1) {
    ret = max(ret, dfs(rest-1, v, i));
  }
  return ret;
}
/***** MAIN *****/
signed main() {
  cin >> n >> m >> q;
  REP(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --b[i];
  }
  cout << dfs(n, vector<int>());
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3580
#include<string>
#include<iostream>
#include<stdlib.h>
// std::をしなくてよくなる?
using namespace std;

//question
// A: Kind of Refrigerator (0<= i <= A)
// B: Kind of Microwave    (0<= j <= B)
// M: Kind of Coupon
// Condition:  If you buy Xi + Yi at the same time, You can get cheaper Ci yen.

int main(void)
{
  int A, B, M;
  cin >> A >> B >> M;

  int *a = new int[A];
  int *b = new int[B];
  int *ans = new int[M];

  // Get A elements
  for(int i=0; i<A; i++) cin >> a[i];
  // Get B elements
  for(int i=0; i<B; i++) cin >> b[i];

  
  int min_a = a[0];
  int min_b = b[0];
  for(int i=0; i<A; i++) min_a = std::min(min_a, a[i]);
  for(int i=0; i<B; i++) min_b = std::min(min_b, b[i]);


  int min = min_a + min_b;
  // Get M elements
  int t,t2,t3;
  for(int i=0; i<M; i++)
	{
	  cin >> t >> t2 >> t3;
	  ans[i] = a[t-1] + b[t2-1] - t3;
	}
  
  for(int i=0; i<M; i++) min = std::min(min, ans[i]);
  
  cout << min << endl;	

  delete[] a;
  delete[] b;
  delete[] ans;
  
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n) {
		cin >> v[i];
	}
	vi g1(n, v[0]), g2(n, v[n - 1]);
	rep(i, 1, n) {
		g1[i] = __gcd(v[i], g1[i - 1]);
	}
	for (int i = n - 2; i >= 0; i--) {
		g2[i] = __gcd(v[i], g2[i + 1]);
	}
	int mx = max(g2[1], g1[n - 2]);
	rep(i, 1, n - 1) {
		mx = max(mx, __gcd(g2[i + 1], g1[i - 1]));
	}
	cout << mx << "\n";
}



Measured memory_bytes: 2560
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

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

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    vector<pair<int, int>> pre[N + 1];
    for (int i = 0; i < M; ++i) {
        int p, y;
        cin >> p >> y;
        pre[p].push_back(mp(y, i));
    }

    pair<int, int> ans[M];

    for (int i = 1; i <= N; ++i) {
        sort(pre[i].begin(), pre[i].end());
        int cnt = 1;
        for (auto p : pre[i]) {
            ans[p.second] = mp(i, cnt);
            ++cnt;
        }
    }

    for (int i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << ans[i].first;
        cout << setw(6) << setfill('0') << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int s=1;s<=1000;s++)
	{
		if((a*s)%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using usize = std::size_t;

std::vector<int> lis_lds (int n, int a, int b) {
	std::vector<int> res; res.reserve(n);
	std::vector<int> c(b, 1);
	for (int i = 0, s = n - b; i < b; i++) {
		int v = std::min(s, a - 1);
		c[i] += v; s -= v;
	}
	for (int i = 0, s = n; i < b; i++) {
		for (int j = s - c[i]; j < s; j++) res.push_back(j);
		s -= c[i];
	}
	return res;
}

int main() {
	int n, a, b;
	std::cin >> n >> a >> b;
	if (a + b - 1 > n or 1LL * a * b < n) {
		std::cout << -1 << '\n';
	} else {
		std::vector<int> ans = lis_lds(n, a, b);
		for (int i = 0; i < n; i++) {
			std::cout << ans[i] + 1 << " \n"[i + 1 == n];
		}
	}
	return 0;
}

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

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    string s;
    cin >> s;
    if(s=="SUN") co(7);
    if(s=="MON") co(6);
    if(s=="TUE") co(5);
    if(s=="WED") co(4);
    if(s=="THU") co(3);
    if(s=="FRI") co(2);
    if(s=="SAT") co(1);
    return 0;
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N = 1e5 + 5;
const int INF = 1e18L + 5;

int dp[N];

void min_self(int &a,int b)
{
    a = min(a, b);
}

int32_t main()
{
    IOS;
    FOR(i,0,N) dp[i] = INF;
    int n,W;
    cin>>n>>W;
    int v[n+1],w[n+1];
    FOR(i,1,n+1) cin>>w[i]>>v[i];
    int sum_value = 0;
    FOR(i,1,n+1) sum_value+=v[i];
    dp[0] = 0;
    FOR(i,1,n+1)
    {
    	for(int value_already = sum_value - v[i];value_already >= 0;value_already--)
    	{
    		min_self(dp[value_already + v[i]],dp[value_already] + w[i]);
    	}
    }
    int ans = 0;
    FOR(i,0,sum_value+1)
    {
    	if(dp[i] <= W) ans = max(ans,i);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
12 18
---+/
/+---test
420 660
---+/
/+---test
1 2019
---+/

void main(string[] args) {
  long A, B;
  readf(" %d %d ", &A, &B);

  auto C = gcd(A, B);

  int ans = 1;
  for (long i = 2; i*i <= C; ++i) {
    if (C%i == 0) {
      ++ans;
      while (C%i == 0) C /= i;
    }
  }
  if (C != 1) ++ans;
  ans.writeln;
}


Measured memory_bytes: 256
n=int(input())
s=sorted([int(input()) for _ in range(n)])
a=sum(s)
if not a%10==0:
    print(a)
else:
    for i in range(len(s)):
        if not s[i]%10==0:
            print(a-s[i])
            exit()
    print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<string,string>,int>p;
map<pair<string,string>,int>q;
map<int,pair<string,string> >rec;
ll ans;
int main()
{
    int n;
    cin>>n;
    char pi[40];
    string t1;
    string t2;
    //string t3,t4;
    cin>>pi;
    for(int i=0; i<n; i++)
    {
        t1=t1+pi[i];
    }
    int k=0;
    for(int i=2*n-1; i>=n; i--)
    {
        t2=t2+pi[i];
    }
    k=0;
    //cout<<pi<<" "<<t1<<" "<<t2<<endl;
    int po=pow(2,n);
    for(int i=0; i<po; i++)
    {
        string m1;
        string m2;
        int k1=0,k2=0;
        int wer=i;
        for(int j=0; j<n; j++)
        {
            if(wer%2==0)
            {
                m1=m1+t1[j];
            }
            else
            {
                m2=m2+t1[j];
            }
            wer/=2;
        }
        p[make_pair(m1,m2)]++;
        if(p[make_pair(m1,m2)]==1)
        {
            rec[k++]=make_pair(m1,m2);
            //cout<<k<<" "<<m1<<" "<<m2<<endl;
        }
    }
    for(int i=0; i<po; i++)
    {
        string m1;
        string m2;
        int k1=0,k2=0;
        int wer=i;
        for(int j=0; j<n; j++)
        {
            if(wer%2==0)
            {
                m1=m1+t2[j];
            }
            else
            {
                m2=m2+t2[j];
            }
            wer/=2;
        }
        q[make_pair(m1,m2)]++;
    }
    string tr,te;
    for(int i=0;i<k;i++)
    {
       tr=rec[i].first;
       te=rec[i].second;
       //cout<<tr<<" "<<te<<p[make_pair(tr,te)]<<" "<<q[make_pair(te,tr)]<<endl;
       ans+=(ll)p[make_pair(tr,te)]*(ll)q[make_pair(te,tr)];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 120576
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    const ll mod=1e9+7;
    int n;
    cin>>n;
    vector<int>a(n);
    map<int,int>mp;
    set<int>se,se2;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        se.insert(a[i]);
    }
    bool ok=true;
    if(n%2==0){
        for(auto&p:mp){
            if(p.second!=2)ok=false;
        }
    }
    else{
        for(auto&p:mp){
            if(p.first!=0){
                if(p.second!=2)ok=false;
            }
            else{
                if(p.second!=1)ok=false;
            }
        }
    }
    for(int i=n-1; i>=0; i-=2){
        se2.insert(i);
    }
    if(se!=se2)ok=false;
    if(ok==false){cout<<0<<endl; return 0;}
    ll ans=1;
    rep(i,n/2){
        ans*=2;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8960
N, M = map(int, input().split())
AC = [0 for _ in range(N)]
WC = [0 for _ in range(N)]

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and AC[p] == 0:
        AC[p] = 1
    else:
        if AC[p] == 0:
            WC[p] += 1

print(sum(AC), sum([wc if AC[i] == 1 else 0 for i, wc in enumerate(WC)]))


Measured memory_bytes: 5528
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> a(N); 
	int a_max = 0, ans = 0;
	rep(i, 0, N) {
		cin >> a[i];
		a_max = max(a_max, abs(a[i]));
		ans += (a[i] * a[i]);
	}
	
	rep(x, 1, a_max + 1) {
		int positive = 0, negative = 0;
		rep(i, 0, N) {
			positive += pow(a[i] - x, 2);
			negative += pow(a[i] + x, 2);
		}
		int tmp = min(positive, negative);
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int num=0;
	for(int i=0;i<3;++i){
		if(s[i]=='A') ++num;
	}
	if(num==1||num==2) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
integer::a,b
  real::s

  read(*,*)a,b
  
  if(b<10)then
     a=a*10+b
  else
     if(b<100)then
        a=a*100+b
     else
        a=a*1000+b
     end if
  end if

  s=sqrt(real(a))
  a=int(s)
  
  if(s==a)then
     write(*,*)"Yes"
  else
     write(*,*)"No"
  end if
  
end program


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll yen;
  	cin >> yen;
  	ll numofhyen = floor(yen/500), numoffyen = floor((yen % 500)/5);
  cout << 1000 * numofhyen + numoffyen * 5; 
}
  

Measured memory_bytes: 3628
A = input()
B = input()
if len(A) > len(B):
    print('GREATER')
elif len(A) < len(B):
    print('LESS')
else:
    for i in range(len(A)):
        if int(A[i]) > int(B[i]):
            print('GREATER')
            break
        elif int(A[i]) < int(B[i]):
            print('LESS')
            break
    else:
        print('EQUAL')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A,B; cin >> A >> B;
    if(A * B==2) cout << 3 << endl;
    else if(A*B==3) cout << 2 << endl;
    else cout << 1 << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    char s[11],t[11],u[11];
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(u,s)==0)
        a--;
    else
        b--;
    printf("%d %d",a,b);
    return 0;
}

Measured memory_bytes: 128
n, m, k = map(int, input().split())
mod = 10**9 + 7
cum_n = 0
t = 0
for i in range(1, n):
  t += i
  cum_n += t

cum_m = 0
t = 0
for i in range(1, m):
  t += i
  cum_m += t

ans = (cum_n * m**2 + cum_m * n**2) % mod

def nCr(n,r,mod = 10**9+7):
    r = min(n-r,r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n+1-i) %mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) %mod

if n*m-2 == 0:
  p = 1
else:
  p = nCr(n*m-2, k-2)

ans = (ans*p)%mod
print(ans)

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

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << 
    (char)('A' + s1[0] - 'a') << 
    (char)('A' + s2[0] - 'a') << 
    (char)('A' + s3[0] - 'a') << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main(void) {
	int n, x;
	ll c = 0;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n - 1) {
		if (a[i] + a[i + 1] > x) {
			c += (ll)a[i] + a[i + 1] - x;
			a[i + 1] -= a[i] + a[i + 1] - x;
			if (a[i + 1] < 0)a[i] += a[i + 1], a[i + 1] = 0;
		}
	}
	printf("%lld\n", c);
	return 0;
}

Measured memory_bytes: 640
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = collections.Counter(list(map(str, input().rstrip('\n').split())))
    print("Three" if len(s) == 3 else "Four")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int gcd(int p,int q){
  if(p%q==0) return q;
  return gcd(q,p%q);
}
int main(){
  int i,j,k,ans=0,m;
  cin >> m;
  for(i=1;i<m+1;i++)
    for(j=1;j<m+1;j++)
      for(k=1;k<m+1;k++)
        ans+=gcd(i,gcd(j,k));
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	int l, r, d;
	cin >> l >> r >> d;

	cout << r / d - (l - 1) / d;
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
    execute();
    }

    private static void execute() throws IOException {
        BufferedReader br =
                new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        System.out.println(eat(line));
    }

    public static int eat(String symbols) {
        int number = 0;
        for (char ch : symbols.toCharArray()) {
            switch (ch) {
                case '+':
                    number++;
                    break;
                case '-':
                    number--;
                    break;
            }
        }
        return number;
    }
}

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

vector<vector<char>> adj(1002 , vector<char>(1002, '.'));
vector<vector<int>> dis(1002 , vector<int>(1002 , INT_MAX));

void bfs(int ch , int cw , int h , int w) {
    deque<pair<int,int>> q;
    q.push_front({ch , cw});
    dis[ch][cw] = 0;
    while(!q.empty()) {
        auto p = q.front();
        q.pop_front();
        int x = p.first , y = p.second;
        for(int i = max((int)1 , x-2); i <= min(h , x+2); i++) {
            for(int j = max((int)1 , y-2); j <= min(w , y+2); j++) {
                if(adj[i][j] == '.') {   
                    int d = abs(x-i)+abs(y-j);
                    if(d <= 1) {
                        if(dis[i][j] > dis[x][y]) {
                            dis[i][j] = dis[x][y];
                            //cout << i << " " << j << ' ' << dis[i][j] << "\n";
                            q.push_front({i , j});
                        }
                    }
                    else {
                        if(dis[i][j] > 1 + dis[x][y]) {
                            dis[i][j] = 1 + dis[x][y];
                            //cout << i << " " << j << " " << dis[i][j] << "\n";
                            q.push_back({i , j});
                        }
                    }
                }
            }
        }
    }
} 

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

    int h , w , ch , cw , dh , dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    for(int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < w; j++) adj[i+1][j+1] = s[j];
    }
    bfs(ch , cw , h , w);
    if(dis[dh][dw] >= INT_MAX) cout << -1 << "\n";
    else cout << dis[dh][dw] << "\n";
    

    return 0;
}



Measured memory_bytes: 12764
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, w;
    cin >> n >> w;
    vector<vector<ll> >data(n + 1, vector<ll>(2));
    for(int i = 1; i <= n; i++){
        cin >> data.at(i).at(0) >> data.at(i).at(1);
    }
    vector<vector<ll> >dp(n + 1, vector<ll>(w + 1));
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= w; j++){
            if(j < data.at(i).at(0)) dp.at(i).at(j) = dp.at(i - 1).at(j); //iこ目の商品を使ってiこめの商品の重さ以下の状態は実現し得ない
            else{
                    dp.at(i).at(j) = max(dp.at(i - 1).at(j), dp.at(i - 1).at(j - data.at(i).at(0)) + data.at(i).at(1));
            }
        }
        
    }
    
    ll tmp_max = 0;
    for(int i = 0; i <= w; i++){
        tmp_max = max(tmp_max, dp.at(n).at(i));
    }
    cout << tmp_max << endl;
    return 0;
}



Measured memory_bytes: 80256
//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

ll t[101][100001];

ll knapsack(ll wt[],ll val[],ll n,ll W)
{
    for (int i = 0; i < n + 1; i++)
    {
        for (int j = 0; j < W + 1; j++)
        {
            if (i == 0 || j == 0)
                t[i][j] = 0;
        }
    }
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            if (wt[i - 1] <= j)
                t[i][j] = max(val[i - 1] + t[i - 1][j - wt[i - 1]], t[i - 1][j]);
            else
                t[i][j] = t[i - 1][j];
        }
    }
    return t[n][W];
}

void solve()
{
    ll n,w;
    cin>>n>>w;
    //memset(dp,-1,sizeof(dp));
    ll wt[n+1];
    ll val[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    ll res=knapsack(wt,val,n,w);
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int k = 1;
    //cin >> t;
    while (k--)
    {
        solve();
    }
    return 0;
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

r = I()
print(2*math.pi*r)

Measured memory_bytes: 65556
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        n: usize,
    }
    let m = n.min(b-1);
    let ans = (a * m) / b - a * (m / b);
    println!("{}", ans);
}


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

int N,a[4000],DP[2001][2001],b[2001][2],bl[2002][2002],wh[2002][2002];
char c[4000];

int main(){
	cin>>N;
	for(int i=0;i<N+N;++i){
		cin>>c[i]>>a[i];
		b[a[i]][c[i]=='W']=i;
	}
	for(int i=1;i<=N;++i){
		for(int j=i+1;j<=N;++j){
			bl[i][N+1]+=(b[j][0]<b[i][0]);
		}
		for(int j=N;j>0;--j){
			bl[i][j]=bl[i][j+1]+(b[j][1]<b[i][0]);
		}
	}
	for(int i=1;i<=N;++i){
		for(int j=i+1;j<=N;++j){
			wh[i][N+1]+=(b[j][1]<b[i][1]);
		}
		for(int j=N;j>0;--j){
			wh[i][j]=wh[i][j+1]+(b[j][0]<b[i][1]);
		}
	}
	DP[1][0]=b[1][0];
	DP[0][1]=b[1][1];
	for(int i=0;i<=N;++i){
		for(int j=0;j<=N;++j){
			if(i+j==1&&i*j==0)continue;
			DP[i][j]=min((i?DP[i-1][j]:0xE869120)+bl[i][j+1],(j?DP[i][j-1]:0xE869120)+wh[j][i+1]);
		}
	}
	cout<<DP[N][N]<<endl;
}


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

int main()
{
	int n, m, l;
	int i, j, k;
	int A[100][100] = { 0 };
	int B[100][100] = { 0 };
	long C[100][100] = { 0 };

	cin >> n >> m >> l;

	//行列Aの値入力
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			cin >> A[i][j];
		}
	}
	//行列Bの値入力
	for (j = 0; j < m; j++)
	{
		for (k = 0; k < l; k++)
		{
			cin >> B[j][k];
		}
	}

	//A * B
	for (i = 0; i < n; i++)
	{
		for (k = 0; k < l; k++)
		{
			for (j = 0; j < m; j++)
			{
				C[i][k] += A[i][j] * B[j][k];
			}
			if (k != l - 1) cout << C[i][k] << " ";
			else cout << C[i][k];
		}
		cout << "\n";
	}

	return 0;
}



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

int main() {

    int K, X;
    cin >> K >> X;

    for (int i = max(X - K + 1, -1000000); i <= min(X + K - 1, 1000000); i++) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    string s;
    cin >> s;
    string copy = s;
    reverse(all(s));
    if (s == copy) {
        cout << 0 << endl;
        return 0;
    }

    string remove_x = "";
    rep(i, s.size()) {
        if (copy[i] == 'x')
            continue;
        else
            remove_x += copy[i];
    }
    string remove_copy = remove_x;
    reverse(all(remove_x));
    if (remove_copy != remove_x) {
        cout << -1 << endl;
        return 0;
    }

    int left = 0, right = copy.size() - 1, res = 0;
    while (right - left > 0) {
        if (copy[left] == 'x' && copy[right] != 'x')
            left++, res++;
        if (copy[left] != 'x' && copy[right] == 'x')
            right--, res++;
        if (copy[left] == copy[right])
            left++, right--;
    }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif
const int maxr=2e5+3;
ll bit[maxr];
void update(ll ind,ll val){
	for(;ind<maxr;ind+=(ind&(-ind))){
		bit[ind]+=val;
	}
}
ll query(ll ind){
	ll ans=0;
	for(;ind>0;ind-=(ind&(-ind))){
		ans+=bit[ind];
	}
	return ans;
}
//
int main()
{
	GO
	//fioe();
	ll n;
	cin>>n;
	ll pre[n+1];
	for(ll i=0;i<n;i++){
		cin>>pre[i];
	}
	ll ans=0;
	memset(bit,0,sizeof(bit));
	for(ll i=0;i<n;i++){
		update(pre[i],1);
		if(query(pre[i])==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (D-C > B-A){
        int k,l;
        k = A;
        l = B;
        A = C;
        B = D;
        C = k;
        D = l;
    }
    cout << max(0, min(D-C, min(B-C, D-A))) << endl;
    return 0;
}

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

int main() {
  int64_t N, D;
  cin >> N >> D;
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
  }
  int64_t result = 0;
  for (int i = 0; i < N; i++) {
    if (X.at(i) * X.at(i) + Y.at(i) * Y.at(i) <= D * D) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define INF 100000000
#define pb push_back
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	int D; cin >> D;
	string m;
	if (D == 25){
		m = "Christmas";
	} else if ( D == 24) {
		m = "Christmas Eve";
	} else if ( D == 23) {
		m = "Christmas Eve Eve";
	} else if ( D == 22 ){
		m = "Christmas Eve Eve Eve";
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int H = 0;
		int W = 0;
		
		while ( true ) {
			H = sc.nextInt ();
			W = sc.nextInt ();
			
			if ( H == 0 && W == 0 ) {
				break;
			}

			for ( int i = 1; i <= H; i++ ) {
				for ( int j = 1; j <= W; j++ ) {
					if ( j == 1 || j == W ) {
						System.out.print ( "#" );
					} else if ( i == 1 || i == H ) {
						System.out.print ( "#" );
					} else {
						System.out.print ( "." );
					}
				}
				System.out.println ();
			}
			System.out.println ();
		}
	}
}

Measured memory_bytes: 34076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=998244353;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

bool t[300005][2];
char ca[300005];
int  cn[300005];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	LL s=0;
	int p[5];
	cin>>n;
	cin>>ca;
	n*=3;
	for(i=0;i<n;i++){
		if(ca[i]=='R')cn[i]=0;
		if(ca[i]=='G')cn[i]=1;
		if(ca[i]=='B')cn[i]=2;
	}
	memset(p,0,sizeof(p));
	for(i=0;i<n;i++){
		p[cn[i]]++;
		if(p[0]>0 && p[1]>0 && p[2]>0){
			p[0]--,p[1]--,p[2]--;
			t[i][1]=true;
		}
	}
	memset(p,0,sizeof(p));
	for(i=n-1;i>=0;i--){
		p[cn[i]]++;
		if(p[0]>0 && p[1]>0 && p[2]>0){
			p[0]--,p[1]--,p[2]--;
			t[i][0]=true;
		}
	}
	memset(p,0,sizeof(p));
	s=1;
	a=0;
	for(i=0;i<n;i++){
		if(t[i][0])a++;
		if(t[i][0] || t[i][1])continue;
		s*=a;
		a--;
		if(s>=MAX)s%=MAX;
	}
	a=0;
	for(i=n-1;i>=0;i--){
		if(t[i][1])a++;
		if(t[i][0] || t[i][1])continue;
		s*=a;
		a--;
		if(s>=MAX)s%=MAX;
	}
	for(a=1;a<=n/3;a++){
		s*=a;
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 2304
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int [] X = new int[N];
        int [] Y = new int[N];
        double sum = 0;
        int time = 1;
        int n =1;
        for(int i=N-1;i>0;i--) time*=i;
        for(int i=N;i>0;i--) n*=i;
        time*=2;
        for(int i=0;i<N;i++){
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                double x = Math.pow(X[i]-X[j],2);
                double y = Math.pow(Y[i]-Y[j],2);
                double dis = Math.sqrt(x+y)*time;
                sum+=dis;
            }
        }
        sum/=n;
        System.out.println(sum);
    }
}

Measured memory_bytes: 22612