akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	map<char, ll> mcl;
	string st;
	for(ll i=0; i<n; i++){
		cin >> st;
		if(st[0] == 'M' or st[0] == 'A' or st[0] == 'R' or st[0] == 'C' or st[0] == 'H')
			mcl[st[0]] += 1;
	}
	ll ans = 0;
	char ct[] = {'M', 'A', 'R', 'C', 'H'};
	for(ll i=0; i<3; i++){
		for(ll j=i+1; j<4; j++)
			for(ll k=j+1; k<5;k++)
				ans += mcl[ct[i]]*mcl[ct[j]]*mcl[ct[k]];
	}
	cout << ans;
	return 0;
}

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

int main() {
  int num, p;
  int kisuCnt = 0;
  cin >> num >> p;

  for (int i = 0; i < num; i++){
    int tmp;
    cin >> tmp;
    if (tmp % 2 == 1) kisuCnt++;
  }

  if(kisuCnt == 0){
    if (p == 0) cout << (long long)pow(2, num);
    else cout << 0;
  } else {
    cout << (long long)pow(2, num - 1);
  }
}

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

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    int ans = 0;
    int index;
    string tmp;
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            for(int k=0;k<10;++k){
                tmp = "";
                tmp += i+'0';
                tmp += j+'0';
                tmp += k+'0';
                index = 0;
                for(int l=0;l<N;++l){
                    if(tmp[index]==S[l]){
                        if(index<2)index++;
                        else {
                            index++;
                            ans++;
                        }
                    }
                    if(index==3)break;
                }
            }
        }
    }
    cout<<ans<<endl;
}


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

const int mod = (int)1e9 + 7;

using ll = long long int;
ll modPow(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modPow(N, P/2, M);
        return t*t % M;
    }
    return N * modPow(N, P-1, M);
}

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

	vector<long long> A(N);
	for(int i=0; i<N; ++i){
		cin >> A[i];
	}

	vector<long long> r(N), l(N);
	for(int i=0; i<N; ++i){
		for(int k=i-1; k>=0; --k){
			l[i] += A[i] > A[k];
		}
		for(int k=i+1; k<N; ++k){
			r[i] += A[i] > A[k];
		}
	}

	long long ans = 0;
	for(int i=0 ;i<N; ++i){
		ans += r[i]*K % mod + (((l[i] + r[i])*K % mod)*(K-1) % mod)*modPow(2, mod-2, mod) % mod;
		ans %= mod;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
n = int(input())
S = set()
for i in "abcdefghijklmnopqrstuvwxyz":
    for j in range(len(s)):
        if i == s[j]:
            for k in range(n):
                S.add(s[j:j+k+1])
    if len(S) >= 5:break
S = sorted(S)
print(S[n-1])

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 X,Y;
    cin >> X >> Y;

    if(abs(X-Y)<=1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

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

    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d) print("Left");
    else if(a+b<c+d) print("Right");
    else print("Balanced");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class V{
	int x,y;
	V(int x1,int y1,int x2,int y2){
		this.x=x2-x1;
		this.y=y2-y1;
	}
	boolean eq(int x1,int y1){
		if(this.x==x1 && this.y==y1) return true;
		else return false;
	}
}

public class Main {

	static V var0[];
	static V var1[];
	static V var[];
	static int px[],py[];
	static boolean flag;
	static int count;

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,m0,m,i,j;


		while(true){
			count=1;
			n=sc.nextInt();
			if(n==0) break;
			m0=sc.nextInt();
			px=new int[m0];
			py=new int[m0];
			for(i=0;i<m0;i++){
				px[i]=sc.nextInt();
				py[i]=sc.nextInt();
			}
			var0=new V[m0-1];
			var1=new V[m0-1];
			for(i=1;i<m0;i++){
				var0[i-1]=new V(px[i-1],py[i-1],px[i],py[i]);
			}
			//けつ追い
			j=0;
			for(i=m0-1;0<i;i--){
				var1[j]=new V(px[i],py[i],px[i-1],py[i-1]);
				j++;
			}

			for(i=0;i<n;i++){
				m=sc.nextInt();
				px=new int[m];
				py=new int[m];
				for(j=0;j<m;j++){
					px[j]=sc.nextInt();
					py[j]=sc.nextInt();
				}
				flag=false;
				for(int k=0;k<4;k++){
					var=new V[m-1];
					for(j=1;j<m;j++){
						var[j-1]=new V(px[j-1],py[j-1],px[j],py[j]);
					}
					check(m0,m);
					check1(m0,m);
					turn(m);
				}
				if(flag){
					System.out.println(count);
				}
				count++;
			}//i for
			System.out.println("+++++");
		}//while

	}//main
	static void check(int m0,int m){
		int i;
		if(flag) return;
		if(m0!=m){
			flag=false;
			return;
		}
		for(i=0;i<m-1;i++){
			if(!var0[i].eq(var[i].x, var[i].y)){
				flag=false;
				break;
			}
		}
		if(i==m-1) flag=true;;
	}
	static void check1(int m0,int m){
		int i;
		if(flag) return;
		if(m0!=m){
			flag=false;
			return;
		}
		for(i=0;i<m-1;i++){
			if(!var1[i].eq(var[i].x, var[i].y)){
				flag=false;
				break;
			}
		}
		if(i==m-1) flag=true;;
	}
	static void turn(int m){
		int i,temp;
		for(i=0;i<m;i++){
			temp=px[i];
			px[i]=(-1*py[i]);
			py[i]=temp;
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include<math.h>
using namespace std;

int main() {
        int D,N;
        int ans=0;
        cin >> D >> N;

        if(N==100) ans=pow(100,D)*N+pow(100,D);
        else ans=pow(100,D)*N;

        cout << ans << endl;

        return 0;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> H[i];
    }
    const ll INF = 1LL<<60;
    vector<ll> dp(N, INF);
    dp[0] = 0;
    for ( int i = 1; i < N; i++ ) {
        for ( int j = 1; j <= K; j++ ) {
            int k = i - j;
            if ( k < 0 ) continue;
            dp[i] = min(dp[i], dp[k] + abs(H[i]-H[k]));
        }
    }
    return dp[N-1];
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll n,m,ans=0,f=0,count=1;
   cin>>n>>m;
   ll a[n],b[n];
   for(int i=0;i<n;i++)
   {
     a[i]=1;
     b[i]=0;
   }
   b[0]=1;
   for(int i=0;i<m;i++)
    {
      ll x,y;
      cin>>x>>y;
      x--,y--;
      
      if(x==0)
        f=1;

      if(b[x]==1&&b[y]==0)
      {
        count++;
        b[y]=1;
        a[x]--;
        a[y]++;
        if(a[x]==0&&b[x]==1)
        {
          count--;
          b[x]=0;
        }

      }
      else
      {


      a[x]--;
      if(a[x]==0&&b[x]==1)
        {
          count--;
          b[x]=0;
        }
      a[y]++;
    }
    }
    /*if(f)
    {
      for(int i=1;i<n;i++)
      {
           if(a[i]!=0)
            ans++;
      }
      cout<<ans<<endl;
    }
    else
     cout<<1<<endl;*/
    //if(f)
   cout<<count<<endl;

}
return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std; 
int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int &c : a) {
    cin >> c;
  }
  long long length = 0;
  for(int i = 0; i < n -1; i++) {
    if(a.at(i) > a.at(i +1)) {
      length += a.at(i) - a.at(i +1);
      a.at(i +1) = a.at(i);
    }
  }
  cout << length << endl;
}

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

template <typename T>
T gcd(const T x, const T y) {
  if (x == 0) {
    return y;
  } else if (y == 0) {
    return x;
  } else if (x < y) {
    return gcd(x, y % x);
  } else if (y < x) {
    return gcd(y, y % x);
  } else {
    return x;
  }
}

template <typename T>
T lcm(const T x, const T y) {
  if (x == 0 || y == 0) {
    return 0;
  } else {
    return x / gcd(x, y) * y;
  }
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> xi(n);

  for (auto &i : xi) {
    int64_t tmp;
    std::cin >> tmp;
    i = std::abs(tmp - x);
  }

  if (n == 1) {
    std::cout << xi[0] << std::endl;
    return 0;
  }
  auto g = gcd(xi[0], xi[1]);

  for (int64_t i = 2; i < n; i++) {
    g = gcd(g, xi[i]);
    if (g == 1) {
      break;
    }
  }

  std::cout << g << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {

  int i, n = 0;
  char a[1201];

  while(scanf("%s", a) != EOF){
    if(n != 0) printf(" ");
    else n++;
    for(i=0;;i++){
      if(a[i] == '\0') break;
      if(a[i] >= 'A' && a[i] <= 'Z'){
	a[i] += 'a' - 'A';
      } else if(a[i] >= 'a' && a[i] <= 'z'){
	a[i] -= 'a' - 'A';
      }
    }
    printf("%s",a);
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int k;cin >> k;
  ll now = 7;
  int cnt = 1;
  rep(i, 1e6) {
    if (now % k == 0) {
      cout << cnt << endl;
      return 0;
    }
    (now *= 10) %= k;
    (now += 7) %= k;
    cnt++;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> snuke(n,0);
    rep(i,k){
        int d;
        cin >> d;
        rep(i,d){
            int p;
            cin >> p;
            snuke[p-1] = 1;
        }
    }
    int ans = 0;
    rep(i,n){
        if(snuke[i] ==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  double r;
  fscanf(stdin, "%lf", &r);
  double area = M_PI * r * r;
  double circum = 2.0 * M_PI * r;
  fprintf(stdout, "%f %f", area, circum);
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 1240
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	if (k <= a) {
		cout << a - k << " " << b << endl;
	}
	else if (k <= a + b) {
		cout << 0 << " " << b - (k - a) << endl;
	}
	else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int r, d, a[19];
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);
    cin >> r >> d >> a[1];
    for(int i = 2; i <= 11; ++ i)
    {
        a[i] = r * a[i - 1] - d;
        cout << a[i] << '\n';
    }
    return 0;
}


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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D EPS = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll dp[MAX];
int main(void) {
  cin >> n;
  vll a;
  tmp = 6;
  while (tmp < MAX) {
	a.pb(tmp);
	tmp *= 6;
  }
  tmp = 9;
  while (tmp < MAX) {
	a.pb(tmp);
	tmp *= 9;
  }
  a.pb(1);
  sort(ALL(a));
  rep(i, MAX) dp[i] = inf;
  dp[0] = 0;

  rep(i, a.size()) {
	rep(j, MAX - a[i]) dp[j + a[i]] = min(dp[j + a[i]], dp[j] + 1);
  }


  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1152
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

hoge s n = [s!!(mod (n-1) (length s))]

f :: Char -> Int -> String
f '0' = flip replicate ' ' . subtract 1
f '1' = hoge "',.!?"
f '2' = hoge "abcABC"
f '3' = hoge "defDEF"
f '4' = hoge "ghiGHI"
f '5' = hoge "jklJKL"
f '6' = hoge "mnoMNO"
f '7' = hoge "pqrsPQRS"
f '8' = hoge "tuvTUV"
f '9' = hoge "wxyzWXYZ"


main = map (concat . map (uncurry f . fnTuple (head, length)) . group) . lines <$> getContents >>= mapM_ putStrLn


Measured memory_bytes: 4068
program dm
    implicit none
    integer::X
    integer(16)::i,j
    read*,X
    do i=0,int(sqrt(sqrt(real(X))))+1
        do j=i,int(sqrt(sqrt(real(X))))+1
            if(j**5+i**5==X)then
                print"(i0)",j,-i
                stop
            endif
            if(j**5-i**5==X)then
                print"(i0)",j,i
                stop
            endif
        end do
    end do
contains
end program dm

Measured memory_bytes: 2924
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<P> v;
bool used[100100];
ll f[100100];
priority_queue<ll, vector<ll>, greater<ll> > pq;

int main(void){
	int k,n,t,l=0,r,i;
	ll d,tmp=0ll,ans=-INFLL;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> t >> d; --t;
		v.push_back(P(d,t));
	}
	sort(v.begin(),v.end(),greater<P>());
	for(i=0; i<k; ++i){
		t = v[i].second;
		d = v[i].first;
		tmp += d;
		if(used[t]){
			pq.push(d);
		}else{
			++l;
			used[t] = true;
		}
	}
	r = l;
	f[r] = tmp;
	for(i=k; i<n; ++i){
		if(pq.empty()){
			break;
		}
		t = v[i].second;
		d = v[i].first;
		if(used[t]){
			continue;
		}
		used[t] = true;
		tmp -= pq.top(); pq.pop();
		tmp += d;
		++r;
		f[r] = tmp;
	}
	for(i=l; i<=r; ++i){
		ans = max(ans,f[i]+1ll*i*i);
	}
	cout << ans << endl;
	return 0;
}


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

void print_comp(char x, char y) {
  if(x > y) {
    std::cout << ">" << std::endl;
  } else if(x < y) {
    std::cout << "<" << std::endl;
  } else {
    std::cout << "=" << std::endl;
  }
}
int main(void) {
  int X,Y, Z;
  std::cin >> X >> Y >> Z;
  std::cout << (X - Z)/(Y + Z) << std::endl;
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> rid;
	for (int i = 0; i < n; i++){
		if(s[i] == 'R'){
			rid.push_back(i);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'W'){
			if (rid.empty() || rid.back() < i){
				break;
			}else{
				ans++;
				swap(s[i], s[rid.back()]);
				rid.pop_back();
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 4484
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int[][] dp = new int[s.length() + 3][t.length() + 3];
		for(int i = 0 ; i < s.length() ; i++) {
			for(int j = 0 ; j < t.length() ; j++){
				if(s.charAt(i) == t.charAt(j)) {
					dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i][j] + 1);
				}
				dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i][j + 1]);
				dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i + 1][j]);
			}
		}
		String ans = "";
		StringBuilder sb = new StringBuilder(ans);
 
		int i = s.length();
		int j = t.length();
 
		while(i > 0 && j > 0) {
			if(dp[i][j] == dp[i - 1][j])
				i--;
			else if(dp[i][j] == dp[i][j - 1])
				j--;
			else {
				sb.append(s.charAt(i - 1));
				i--;
				j--;
			}
 
		}
		System.out.println(sb.reverse().toString());
 
	}
}

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

int main(){
int n,d;
  cin>>n>>d;
  int x,y,count = 0;
  for(int i = 0;i<n;i++){
    cin>>x>>y;
    if(sqrt(pow(x,2) + pow(y,2)) <=d){
      count++;}
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
//#include<stdio.h>
using namespace std;
int main() {
    bool a=0,b=0,c=0;
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='a')a=1;
        if(s[i]=='b')b=1;
        if(s[i]=='c')c=1;
    }
    if(a==1&&b==1&&c==1&&s.length()==3){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

int main(){


  int n,ans=0,x=0;
  cin >> n;

  bool f = true;
  for(int i = 0; i < n; i++){
    string tmp;
    cin >> tmp >> x;
    if(tmp[0] =='(') ans += x;
    else ans -= x;
    if(ans < 0) f = false;
  }
  if(ans == 0 && f == true) cout << "YES" << endl;
  else cout << "NO" << endl;
 
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
X, N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(102):
    if p.count(X-i) == 0:
        print(X-i)
        break
    if p.count(X+i) == 0:
        print(X+i)
        break
    

Measured memory_bytes: 9172
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q, H, S, D; cin >> Q >> H >> S >> D;
    int N; cin >> N;
    H = min(H, Q * 2);
    S = min(S, H * 2);
    D = min(D, S * 2);
    cout << (N / 2) * D + (S * (N % 2)) << endl;


    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
    ll n;
    cin>>n;
    
    ll a=n*(n-1)/2;
    cout<<a<<endl;
    
}


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

using int64 = long long;

int64 f(int64 b, int64 n)
{
    if (n < b) return n;
    else return n % b + f(b, n / b);
}

int main()
{
    int64 n, s;
    cin >> n >> s;

    int64 ans = (n == s) ? (n + 1) : -1;
    for (int64 b = 2; b <= min(1000000LL, n); b++)
    {
        if (f(b, n) == s and (ans < 0 or b < ans))
        {
            ans = b;
            break;
        }
    }

    // xy
    for (int64 x = 1; x <= min(1000000LL, s); x++)
    {
        int64 y = s - x;
        // x*b+y==nを満たすbがあるかどうか
        if (n - y < 0 or (n - y) % x != 0)
        {
            continue;
        }
        int64 b = (n - y) / x;
        if (b > x and b > y and f(b, n) == s and (ans < 0 or b < ans))
        {
            ans = b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
 	long double a, b, c;
	string result = "No";

	cin >> a >> b >> c;

	long double d = 2 * sqrt(a*b);

	if ((a+b+d) < c) {
		result = "Yes";
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e2+10,mod=1e9+7;
ll n , m , x;
vector<ll> a[15];

ll check(ll mask){
    vector<ll> v(m+1,0);
    for(int i=0;i<n;i++){
        bool b = (mask&(1ll<<i));
        if(b){
            for(int j=0;j<=m;j++){
                v[j] += a[i][j];
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(v[i]<x)return oo;
    }
    return v[0];
}

int main ()
{
    FASTIO
    cin >> n >> m >> x;
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            ll x;
            cin >> x;
            a[i].pb(x);
        }
    }
    ll mn = oo;
    for(ll mask=0;mask<=(1<<n)-1;mask++){
        mn = min(mn,check(mask));
    }
    cout << (mn==oo ? -1 : mn) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
string str;
int n;
int main(){
    cin >> str;
    n = str.size();
    str = " " + str;
    stack < char > s;
    s.push(str[1]);
    for(int i = 2 ; i <= n ; ++i){
        if(str[i] == 'T'){
            if(!s.empty()){
                if(s.top() == 'S'){
                    s.pop();
                    continue;
                }
            }
        }
        s.push(str[i]);
    }
    printf("%d\n" , int(s.size()));
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    long[] a = new long[n];
    String[] data = br.readLine().split(" ");
    br.close();
    for(int i = 0; i < n; i++){
      a[i] = Long.parseLong(data[i]);
    }
    long answer = 0;
    long sum = 0;
    long mod = 1_000_000_007;
    for(int idx = n - 1; idx > 0; idx--){
      sum = sum + a[idx];
      sum %= mod;
      long temp = sum * a[idx - 1] % mod;
      answer += temp;
      answer %= mod;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 63564
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
    string ans= "Yes";
    int n,max=0;
    cin >> n;
    vi h(n);
    rep(i,n)  cin >> h[i];

    rep(i,n){
      if(max<h[i]){
        max= h[i];
      }
      if(max-h[i]>=2){
        ans= "No";
        break;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main()
{
    ll n, m;
    cin >> n >> m;
    if (n == 1 and m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    else if (n == 1 or m == 1)
    {
        cout << max(n, m) - 2 << endl;
        return 0;
    }
    else
    {
        cout << (n - 2) * (m - 2) << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	// fmt.Println(a)
	b := make([]int, m)
	for i := range b {
		fmt.Scan(&b[i])
	}
	// fmt.Println(b)
	ans := make([]int, n)
	for k := 0; k < n; k++ {
		for i := 0; i < m; i ++ {
			// fmt.Printf("a[k][i]: %d, b[i]: %d\n", a[k][i], b[i])
			ans[k] += a[k][i] * b[i]
		}
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string S;
  cin >> S;
  
  bool a = false;
  bool b = false;
  bool c = false;
  rep(i, S.size()) {
    switch(S[i]) {
    case 'a':
      a = true;
      break;
    case 'b':
      b = true;
      break;
    case 'c':
      c = true;
      break;
    }
  }

  if (a && b && c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
  int a,b,c;
  int tmp;
  std::cin >> a >> b >> c;
  if (a > b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  if (b > c) {
    tmp = b;
    b = c;
    c = tmp;
  }
  if (a > b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  std::cout << a << ' ';
  std::cout << b << ' ';
  std::cout << c << '\n';

  return 0;
}

Measured memory_bytes: 3068
<?php
$N = (int)fgets(STDIN);
$P_array = [];
foreach(range(1,$N) as $n){
    array_push($P_array,(int)fgets(STDIN));
}
sort($P_array);
$P_max = array_pop($P_array);
$sum = array_sum($P_array) + $P_max/2;
echo $sum;

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

int h[100][100];
bool lef[100][100], rig[100][100];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		memset(lef, 0, sizeof(lef));
		memset(rig, 0, sizeof(rig));
		rep(i, n)rep(j, n)scanf("%d", &h[i][j]);
		rep(i, n) {
			int Min = *min_element(h[i], h[i] + n);
			rep(j, n) {
				if (h[i][j] == Min)lef[i][j] = true;
			}
		}
		rep(i, n) {
			int Max = 0;
			rep(j, n) {
				if (Max < h[j][i])Max = h[j][i];
			}
			rep(j, n) {
				if (h[j][i] == Max)rig[j][i] = true;
			}
		}
		rep(i, n)rep(j, n) {
			if (lef[i][j] && rig[i][j]) {
				printf("%d\n", h[i][j]); goto g;
			}
		}
		puts("0");
		g:;
	}
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int INF=1e9;
    int H, W; string S[101];
    int dp[101][101];
    int main() {
        cin >> H >> W;
        for(ll y=0;y<H;y++) 
        cin >> S[y];
     
        for(ll y=0;y<101;y++) 
        {for(ll x=0;x<101;x++) dp[y][x]=INF;
        }
        dp[0][0] = 0;
        if (S[0][0] == '#') 
          dp[0][0] = 1;
     
        for(ll y=0;y<H;y++) 
        {for(ll x=0;x<W;x++)
        {
            if (y + 1 < H) {
                if (S[y][x] == '.' && S[y + 1][x] == '#') 
                  dp[y+1][x]=min(dp[y + 1][x], dp[y][x] + 1);
                else 
                  dp[y+1][x]=min(dp[y + 1][x], dp[y][x]);
            }
            if (x + 1 < W) {
                if (S[y][x] == '.' && S[y][x + 1] == '#') 
                dp[y][x+1]=min(dp[y][x + 1], dp[y][x] + 1);
                else 
                dp[y][x+1]=min(dp[y][x + 1], dp[y][x]);
            }
        }
        }
     
      
    
     
        cout << dp[H-1][W-1] << endl;
        return 0;
    }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long a;
string s;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> s;
	long long ans = a * (s[0] - '0'), cur = 0;
	for (int i = 2; i < 4; i++) {
		int tmp = s[i] - '0';
		cur += a * tmp;
		if (i == 2) cur *= 10;
	}
	cur /= 100;
	ans += cur;
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x_cou[ohara],y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,co;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

bool check(){
    bool ok=true;
    rep(i,Size(s)){
        if(s[i]!='x')co+=s[i];
    }
    rep(i,Size(co)/2){
        if(co[i]!=co[Size(co)-i-1])ok=false;
    }
    return ok;
}

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>s;
    if(!check())Cout(-1);
    else{
        ll cntt=0;
        rep(i,Size(s)){
            if(s[i]=='x')cnt++;
            else{
                x_cou[cntt++]=cnt;
                cnt=0;
            }
        }
        x_cou[cntt++]=cnt;
        rep(i,cntt/2){
            ans+=abs(x_cou[i]-x_cou[cntt-i-1]);
        }
        Cout(ans);
    }
    return 0;
}


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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int maxn=(int)(2e5+5);

int a[maxn];

vector< pii > al[maxn];

int res[maxn];

void dfs(int u,int p,int above)
{
    int curr=1;

    for(pii x:al[u])
    {
        if(x.second!=p)
        {
            if(curr==above)
            {
                curr++;
            }    

            res[x.first]=curr;

            dfs(x.second,u,curr);

            curr++;
        }
    }
}

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

    int n;cin>>n;

    for(int i=1;i<n;i++)
    {
        int u,v;cin>>u>>v;

        u--;v--;

        al[u].pb({i,v});al[v].pb({i,u});
    }

    int k=0;

    for(int i=0;i<n;i++)
    {
        k=max(k,(int)al[i].size());
    }

    dfs(0,-1,0);

    cout<<k<<endl;

    for(int i=1;i<n;i++)
    {
        cout<<res[i]<<endl;
    }
    
    return 0;

}

Measured memory_bytes: 12288
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int set;
		int cardA = 0;
		int cardB = 0;
		int scoreA = 0;
		int scoreB = 0;
		String[] cards;
		ArrayList<String> result = new ArrayList<String>();

		for (;;)
		{
			set = Integer.parseInt(br.readLine());
			if (set == 0)
				break;

			scoreA = scoreB = 0;
			for (int i = 0; i < set; ++i)
			{
				cards = br.readLine().split(" ");
				cardA = Integer.parseInt(cards[0]);
				cardB = Integer.parseInt(cards[1]);

				if (cardA == cardB)
				{
					scoreA += cardA;
					scoreB += cardB;
					continue;
				}

				if (cardA > cardB)
					scoreA += cardA + cardB;
				else
					scoreB += cardA + cardB;
			}
			
			result.add(String.format("%d %d%n", scoreA, scoreB));
		}

		for(String item : result)
			System.out.print(item);

	}

}

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll num = n % k;
    cout << min(num, abs(num-k)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll M, A[Nmax];

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

	vector<ll> cum(N+1);
	for(int i=0; i<N; i++) cum[i+1] = (cum[i]+A[i])%M;
	map<ll, int> cnt;
	for(int i=0; i<=N; i++) cnt[cum[i]]++;

	ll ans = 0;
	for(auto p: cnt){
		ll m = p.second;
		ans += m*(m-1)/2;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
	int university[4][3][10] = { 0 }, n, a, b, c, d;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
		university[a - 1][b - 1][c - 1] += d;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << university[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) puts("####################");
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
   int n,m,i;
   double a,b;
   while(scanf("%d",&m)!=EOF)
   {
   	  a=sqrt(m);
   	  for(i=m;;i--)
   	  {
  	   	a=sqrt(i);
  	   	if(a==(int)a)
  	   	{
	   	  	printf("%d\n",i);
	   	  	break;
	   	  }
  	   }
   	
   	
   }
   

		
}

Measured memory_bytes: 128
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
if A == B:
    print('Draw')
elif A == 1:
    print('Alice')
elif B == 1:
    print('Bob')
elif A > B:
    print('Alice')
else:
    print('Bob')

Measured memory_bytes: 77276
#include<iostream>
#include<algorithm>

using namespace std;

int  func( int a,int  b,int  c ,int  d){
    int  x,y;
    x = a - c;
    y = b - d;

    if(x < 0)x = -x;
    if(y < 0)y = -y;

    return x + y;
}
int main(){
    int n,m;
    int  a[55],b[55],c[55],d[55];
    cin >> n >> m;

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

    for(int i = 0;i< n;i++){
        int ans = 0;
        for(int j = 1;j< m;j++){
            if(func(a[i],b[i],c[j],d[j]) < func(a[i],b[i],c[ans],d[ans]))ans = j;
        }
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 256
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        #2値入れ替え
        if random.randint(0,1):           
            d1 = random.randint(0,D-35) 
            d2 = random.randint(d1+1,d1+17)
            d3 = random.randint(d2+1,d2+17) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
                ans[d3] = tmp3
            else:
                ans[d1] = tmp1
                ans[d2] = tmp3
                ans[d3] = tmp2
        #3値入れ替え
        else:
            d1 = random.randint(0,D-17) 
            d2 = random.randint(d1+1,d1+8)
            d3 = random.randint(d2+1,d2+8) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9688
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x,k,d,a,b;
signed main()
{
	scanf("%lld %lld %lld",&x,&k,&d);
	x=abs(x);
	a=x/d;
	b=x%d;
	if(k<=a)
		cout<<x-k*d<<endl;
	else
	{
		a-=k;
		if(a&1)
			cout<<d-b<<endl;
		else
			cout<<b<<endl;
	}
	return 0;
} 

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

int main() {
	int numbers[3];
	cin >> numbers[0] >> numbers[1] >> numbers[2];
	sort(numbers, numbers + 3);
	cout << numbers[0] << ' ' << numbers[1] << ' ' << numbers[2] << endl;
	return 0;
}


Measured memory_bytes: 3112