akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#define SQ(x) ((x) * (x))

typedef struct {
	double x;
	double y;
} POINT;

double area(double x, double y, double z)
{
    double s;
    s = (x + y + z) / 2.00;
    return (sqrt(s * (s - x) * (s - y) * (s - z)));
}

int main(void)
{
	POINT array[100];
    POINT a, b, c, p;
    char flag[100], p_flag, m_flag;
    int count;
    int i, j, k, l;
    int n;
    double ab, bc, ca, ap, bp, cp;
    
    while (1){
        scanf("%d", &n);
		
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%lf,%lf", &array[i].x, &array[i].y);
        }
        
        memset(flag, 0, sizeof(flag));
        
        for (i = 0; i < n; i++){
            if (flag[i] == 1){
                continue;
            }
            a = array[i];
            for (j = 0; j < n; j++){
                if (i == j || flag[j] == 1){
                    continue;
                }
                b = array[j];
                for (k = 0; k < n; k++){
                    if (i == k || j == k ||flag[k] == 1){
                        continue;
                    }
                    c = array[k];
                    ab = sqrt(SQ(a.x - b.x) + SQ(a.y - b.y));
		            bc = sqrt(SQ(b.x - c.x) + SQ(b.y - c.y));
            		ca = sqrt(SQ(c.x - a.x) + SQ(c.y - a.y));
                    for (l = 0; l < n; l++){
                        if (l == i || l == j || l == k || flag[l] == 1){
                            continue;
                        }
                        p = array[l];
                        ap = sqrt(SQ(a.x - p.x) + SQ(a.y - p.y));
		                bp = sqrt(SQ(b.x - p.x) + SQ(b.y - p.y));
		                cp = sqrt(SQ(c.x - p.x) + SQ(c.y - p.y));
		                
		                if (fabs(area(ab ,bc ,ca) - area(ap, bp, ab) - area(ap, cp, ca) - area(bp, cp, bc)) < 1e-5){
                            flag[l] = 1;
                        }
                    }
                }
            }
        }
        
        count = 0;
        
        for (i = 0; i < n; i++){
            if (flag[i] == 1){
                count++;
            }
        }
        
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 0
N = int(input())
T, A = map(int, input().split())
list_H = list(map(int, input().split()))
best = float('inf')
for i, H in enumerate(list_H):
    cost = abs(A - (T - H * 0.006))
    if cost < best:
        best = cost
        ind = i + 1
print(ind)


Measured memory_bytes: 3060
u = 10**9
d = 0
N,A,B = map(int,input().split())
s = A - B
H = []
import math
for i in range(N):
    h = int(input())
    H.append(h)
for i in range(30):
    x = (u+d)//2
    a = 0
    for j in range(N):
        h = H[j]
        h -= B*x
        if h > 0:
            a += math.ceil(h/s)
    if a > x:
        d = x
    else:
        u = x
print(u)

Measured memory_bytes: 7132
import java.util.Scanner;

public class Main {

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

        String S = sc.next();
        String x = "";

        for (int i = 0; i < S.length(); i++) {
            x += "x";
        }

        System.out.println(x);

        sc.close();
    }

}

Measured memory_bytes: 22612
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s; cin >> s;
    int l = 0, r = s.length()-1;
    int ans = 0;
    while(l < r)
    {
        if(s[l] == 'x' && s[r] != 'x')
        {
            ans++;
            l++;
        }
        else if(s[l] != 'x' && s[r] == 'x')
        {
            ans++;
            r--;
        }
        else if(s[l] != s[r])
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            l++;
            r--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int total = 0;
	for(int n = 105; n<=N; n=n+2) {
	    int nClone = n;
	    int cnt = 1;
	    for(int i = 2; i<=n; i++) {
		if(nClone%i==0) {
			cnt++;
		}
	    }
	    if(cnt == 8) {
		total++;
	    }
	}
	System.out.println(total);
    }
}

Measured memory_bytes: 22228
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-04-19 21:11:23 +0900
# LastModified: 2020-04-19 21:15:31 +0900
#


import os
import sys

def main():
    n,m=map(int,input().split())
    a = list(map(int,input().split()))
    if n-sum(a)<0:
        print(-1)
        return 

    print(n-sum(a))
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 10192
#include <stdio.h>

int main(void)
{
	int a[101];
	int n;
	int i;

	for (i = 0; i < 101; i++){
		a[i] = 0;
	}

	while (scanf("%d", &n) != EOF){
		a[n]++;

		if (a[0] < a[n]){
			a[0] = a[n];
		}
	}

	for (i = 1; i <= 100; i++){
		if (a[i] == a[0]){
			printf("%d\n", i);
		}
	}

	return (0);
}

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

int main()
{
  int N, M; 
  cin >> N >> M;
  
  vector<int> vec(N, 0);
  int a, b;
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  for (int i = 0; i < N; i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int n,m;
vvint vv;
vvint ww;
bool foo(int a,int b){
	reep(i,a,a+m){
		reep(j,b,b+m){
			if(ww[i-a][j-b]==-1) continue;
			if(ww[i-a][j-b]!=vv[i][j]) return false;
		}
	}
	return true;
}
void mainmain(){
	while(cin>>n>>m,n||m){
		initvv(vv,n,n);
		initvv(ww,m,m);
		rep(i,n){
			rep(j,n){
				cin>>vv[i][j];
			}
		}
		rep(i,m){
			rep(j,m){
				cin>>ww[i][j];
			}
		}
		vector<pii> ans;
		rep(i,4){
			vvint tmp=ww;
			pii t;
			rep(j,m){
				rep(k,m){
					tmp[j][k]=ww[k][m-1-j];
				}
			}
			ww=tmp;
			bool f=false;
			rep(j,m){
				rep(k,m){
					if(ww[j][k]!=-1){
						// cout<<ww[j][k]<<endl;
						t=pii(j,k);
						f=true;
						break;
					}
				}
				if(f) break;
			}
			// cout<<"t "<<t.F<<" "<<t.S<<endl;
			rep(j,n-m+1){
				rep(k,n-m+1){
					if(foo(j,k)){
						// cout<<"ans "<<j<<" "<<k<<endl;
						ans.PB(pii(j+t.F,k+t.S));
					}
				}
			}
		}
		sort(ALL(ans));
		if(ans.size()==0){
			cout<<"NA"<<endl;
		}
		else{
			cout<<ans[0].S+1<<" "<<ans[0].F+1<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1388
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        String ans="";
        String[] s=new String[n];
        int[][] al=new int[n+1][26];
        for (char i = 'a'; i <= 'z'; i++) {
            al[n][(int)(i-97)]=50;
        }
        for (int i = 0; i < n; i++) {
            s[i]=sc.next();
            for (int j = 0; j < s[i].length(); j++) {
                al[i][(int)(s[i].charAt(j)-97)]++;
            }
            for (char j = 'a'; j <= 'z'; j++) {
                al[n][(int)(j-97)]=min(al[i][(int)(j-97)],al[n][(int)(j-97)]);
            }
        }
        for (char i = 'a'; i <= 'z'; i++) {
            for (int j = 0; j < al[n][(int)(i-97)]; j++) {
                ans+=Character.toString(i);
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21844
T = input() + "E"
ans = "S"

for i in range(len(T)-1):
    if T[i] == "?":
        if ans[i] == "P":
            ans += "D"
        else:
            if T[i+1] == "P" or T[i+1] == "E":
                ans += "D"
            else:
                ans += "P"
    else:
        ans += T[i]        
    
print(ans[1:])

Measured memory_bytes: 9480
#include <stdio.h>
#include <math.h>
int main(){
  int x;
  int ans=0;
  scanf("%d",&x);
  for(int i=0;i<x;i++){
    int judge_num = x-i; //判定する数を1ずつ小さくしていく
    for(int j=2;j<10;j++){
      if((int)pow(ceil(pow(judge_num,(double)1/j)),j)==judge_num){ 
        //n乗根の整数部分をn乗してjudge_numに戻ればそれはべき乗数
        printf("%d",judge_num);
        return 0;
      }
    }
  }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(ll i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(arg),key)-begin(arg)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

using namespace std;

using R=long double;
const R EPS = 1E-11;
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}

using P=complex<R>;

constexpr P O = P(0,0);

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

//?????? dot ?????? det
inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

using L=struct{P s,t;};

// ?°???± verify AOJ CGL_1_A
P proj(P o,P a,P b){ a-=o,b-=o; return a*real(b/a);}
P proj(L l,P p){ return l.s+proj(l.s,l.t,p);}
// ????°? verify AOJ CGL_1_B
P refl(L l,P p){ return R(2.0)*proj(l,p)-p;}
// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {//???a??¨???b???????????????????????????
	if (sgn(det(o,a,b)) > 0) return LEFT;    // counter clockwise
	if (sgn(det(o,a,b)) < 0) return RIGHT;   // clockwise
	if (sgn(dot(o,a,b)) < 0) return BACK;    // b--base--a on line
	if (sgn(norm(a)-norm(b)) < 0) return FRONT;   // base--a--b on line
	return ON;// base--b--a on line  a??¨b????????????????????????
}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	rep(i,n){
		cin >> p;
		int res=ccw(a,b,p);
		if(res==LEFT) cout << "COUNTER_CLOCKWISE" << endl;
		if(res==RIGHT) cout << "CLOCKWISE" << endl;
		if(res==BACK) cout << "ONLINE_BACK" << endl;
		if(res==FRONT) cout << "ONLINE_FRONT" << endl;
		if(res==ON) cout << "ON_SEGMENT" << endl;
	}
	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    string s;
    cin >> s;
    int len=s.size();
    ll ans=0;
    map<int,int>mp;
    mp[0]++;
	int t=0;
    int x=1;
	for(int i=len-1;i>=0;i--) {
		t=(t+(s[i]-'0')*x)%2019;
		ans+=mp[t];
		mp[t]++;
		x=x*10%2019;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

// ワ―シャルフロイド法 O(V^3)
void warshall_floyd(vector<vector<ll>> &M) { // 隣接行列Mを書き換える
  int n = M.size();
  for (int i = 0; i < n; i++) // 経由する頂点
    for (int j = 0; j < n; j++) // 始点
      for (int k = 0; k < n; k++) // 終点
        M[j][k] = min(M[j][k], M[j][i] + M[i][k]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<vector<ll>> a(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<ll>> b = a;
  warshall_floyd(b);
  if (a != b) {
    cout << "-1\n";
    return 0;
  }
  
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += a.at(i).at(j);
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (k == i || k == j) continue;
        if (a.at(i).at(j) == a.at(i).at(k) + a.at(k).at(j)) {
          sum -= a.at(i).at(j);
          break;
        }
      }
    }
  }
  
  cout << sum << '\n';
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#include<stdio.h>
#include <sstream>
#define pi 3.141592653589793238462
#define limit 100005
#define mo 1000000007;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli mod=9999999999999983;
lli primes[6]={1125899906842597,1495921043,1005985879,1495921043,1005985879,1495921043};
using namespace std;
vector<lli>adj[2000009];
lli parent[2000009];
lli vis[2000009];
lli level[2000009];
lli dist[2000009];
lli dp[2000009];
lli arr[2000009];
lli brr[2000009];
lli crr[2000009];
lli hashing[2000009];
lli ar[509][509];
lli br[509][509];
lli cr[509][509];
lli k;
lli res=100000000000000;


lli solve(lli n)
{
    lli i,val;

    if(n<=0)
        return 0;

    if(dp[n]!=-1)
        return dp[n];

        for(i=1;i<=k;i++)
        {
            if(n-i<0)
                val=INT_MAX;
            else
                val=arr[n];

            res=min(res,(abs(val-arr[n-i])+solve(n-i)));
        }
        int temp=res;
        res=100000000000000000;
    return dp[n]=temp;
}


int main()
{
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int start_s = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    vector<lli>vect,vt,vct;
    vector<lli>::iterator itt;
    set<lli>st;
    set<lli>::iterator itr;
    map<lli,lli>mp;
    map<lli,lli>::iterator it;
    string str;

    lli i,j,n,m,q,t,a,b,c,maxi=INT_MIN,mini=INT_MAX,sum=0,ans=0,res=0,val=0,ans1=0,ans2=0,rem=0,diff=0,cnt=0,l,r,flag=0,e,index,val1=0,val2=0,x,y,z,h=0,u,v,mid,len,tot,fl=0;

    cin>>n>>k;

    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }

    arr[0]=arr[1];

    memset(dp,-1,sizeof(dp));
    cout<<solve(n);

    //for(i=1;i<=n;i++)
        //cout<<"i="<<i<<" "<<"dp="<<dp[i]<<endl;

}


Measured memory_bytes: 75648
var
	k,n,p,q,i,j:Longint;
	s:array[1..500,1..500]of Longint;
	c:array[1..500]of Longint;
begin
	read(n);
	k:=1;
	while k*(k-1)<n*2 do inc(k);
	if k*(k-1)<>n*2 then begin
		writeln('No');
		exit;
	end;
	writeln('Yes');
	writeln(k);
	p:=1;
	q:=2;
	for i:=1 to n do begin
		inc(c[p]);
		inc(c[q]);
		s[p,c[p]]:=i;
		s[q,c[q]]:=i;
		inc(q);
		if q>k then begin
			inc(p);
			q:=p+1;
		end;
	end;
	for i:=1 to k do begin
		write(k-1);
		for j:=1 to k-1 do write(' ',s[i,j]);
		writeln;
	end;
end.

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int ans=0;
	cin>>s;
	int len=s.length();
	for(int i=1;i<len;i++)
	   if(s[i]!=s[i-1])
	     ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,m,sum = 0;
    cin >> n >> m;

    vector<int>v(m);

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

    if(n<sum)cout << -1 << endl;
    else cout << n-sum << endl;


    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define PI atan(1) * 4
#define mod 1000000007
using namespace std;
ll psum[200005];
map<ll, ll> hsh;
ll temp[200005];
set<ll> num;
ll bit[200015];
ll freq[200015];
ll t = 1e18;
ll query (ll i) {
	return ((i == 0) ? 0 : bit[i] + query(i - (i & (-i))));
}
void update (ll i, ll v) {
	if (i > 200010) return;
	bit[i] += v;
	update(i + (i & (-i)), v);
	return;
}
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld %lld", &a, &b);
	psum[0] = temp[0] = 0;
	for (i = 1; i <= a; i++) {
		scanf("%lld", &psum[i]);
		psum[i] += psum[i - 1] - b;
		temp[i] = psum[i];
	}
	stable_sort(temp, temp + a + 1);
	hsh[temp[0]] = c = 1;
	for (i = 1; i <= a; i++) {
		if (temp[i] != temp[i - 1]) hsh[temp[i]] = ++c;
		else hsh[temp[i]] = c;
	}
	hsh[t] = ++c;
	SET(bit, 0); SET(freq, 0);
	num.insert(0); update(hsh[0], 1); freq[hsh[0]] = 1;
	num.insert(t); update(c, 1); freq[c] = 1;
	d = 0; 
	for (i = 1; i <= a; i++) {
		auto r = num.upper_bound(psum[i]);
		e = hsh[*r];
		d += max(query(e) - freq[e], 0LL);
		f = hsh[psum[i]];
		update(f, 1); freq[f]++;
		num.insert(psum[i]);
	}
	printf("%lld\n", d);
	return 0;
}

Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main(){
    ld n, m, d;
    cin >> n >> m >> d;

    ld ans;
    if(d == 0) ans = (m-1) / n;
    else ans = 2 * (m-1) * (n-d) / n / n;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    s += "0";
    t += "0";
    // for (int i = 0; i < s.size(); i++)
    // {
    //     if (s[i] == 'x') continue;
    //     t += s[i];
    // }
    
    // bool ans = true;
    // for (int i = 0; i < t.size()/2; i++)
    // {
    //     if (t[i] != t[t.size()-1-i]) ans = false;
    // }

    int n = s.size()-1;
    int itr_l = -1;
    int itr_r = -1;
    int ans = 0;
    while(1){
        int xl = 0;
        int xr = 0;
        itr_l++;
        itr_r++;
        while(s[itr_l] == 'x' && itr_l < n){
            itr_l++;
            xl++;
        }
        while(t[itr_r] == 'x' && itr_r < n){
            itr_r++;
            xr++;
        }
        if (s[itr_l] != t[itr_r]){
            ans = -1;
            break;
        } else {
            ans += abs(xl-xr);
        }
        if (itr_l == n) break;
        if (itr_r == n) break;
    }

    if (ans == -1) cout << ans << endl;
    else cout << ans/2 << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;
const ll SIZE = 2e5 + 7;

ll n;
ll a, b, c;
ll fact[SIZE];

ll modpow(ll base, ll exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) {
            res = res * base % MOD;
        }
        base = base * base % MOD;
        exp >>= 1;
    }
    return res;
}

ll inv(ll n) {
    return modpow(n, MOD - 2);
}

ll powcomb(ll n, ll m) {
    if (n < m) return 0;
    return fact[n] * inv(fact[m]) % MOD * inv(fact[n - m]) % MOD;
}

int main() {
    cin >> n >> a >> b >> c;
    ll pa = a * inv(a + b) % MOD;
    ll pb = b * inv(a + b) % MOD;

    fact[1] = fact[0] = 1;
    for (ll i = 2; i< SIZE; ++i) {
        fact[i] = i * fact[i - 1] % MOD;
    }
    ll res = 0;
    for (ll k = n; k < 2 * n; ++k) {
        res += powcomb(k-1, n-1) * modpow(pa, n) % MOD * modpow(pb, k-n) % MOD * k % MOD;
        res += powcomb(k-1, n-1) * modpow(pb, n) % MOD * modpow(pa, k-n) % MOD * k % MOD;
        res %= MOD;
    }
    res = res * 100LL % MOD * inv(100LL - c) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	 public static long gcd(long a,long b) 
	    { 
	        if (a == 0) 
	            return b; 
	          
	        return gcd(b%a, a); 
	    } 
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+2];
		long gcd[]=new long[n+2];
//		int first=ar[0]
		gcd[n+1]=1;
		for(int i=1;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		ar[0]=1;
		long first=ar[1];
		gcd[1]=first;
		long right[]=new long[n+2];
		for(int i=2;i<=n;i++)
		{
			first=gcd(first,ar[i]);
			gcd[i]=first;
		}
		right[n]=ar[n];
		first=ar[n];
		right[n+1]=0;
		for(int i=n;i>=1;i--)
		{
			first=gcd(first,ar[i]);
			right[i]=first;
		}
//		for(long x:gcd)
//		{
//			System.out.print(x+" ");
//		}
//		System.out.println();
//		for(long y:right)
//		{
//			System.out.print(y+" ");
//		}
	
		long ans=0;
		for(int i=1;i<=n;i++)
			
		{
			long anss=gcd(right[i+1],gcd[i-1]);
//			System.out.println(anss);
			ans=Math.max(anss, ans);
		}
		System.out.println(ans);
		
		//now skip every element 
	}
}


Measured memory_bytes: 58336
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    int abc[3],cnt5,cnt7;
    cnt5=cnt7=0;

    for(int i=0;i<3;i++){
        scanf("%d",&abc[i]);
        if(abc[i]==5){
            cnt5++;
        }else{
            cnt7++;
        }
    }
    if(cnt5==2&&cnt7==1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
import numpy as np
import itertools

def LI():
    return list(map(int, input().split()))

# input
N, M, X = LI()
C, A = [None] * N, [None] * N
for i in range(N):
    C[i], *A[i] = list(map(int, input().split()))

INF = 10 ** 10

H = []
L = [i for i in range(N)]
for i in range(1, N + 1):
    H += ((list(itertools.combinations(L, i))))

ans = INF
for h in H:
    cost = 0
    a = [0] * M
    for v in h:
        cost += C[v]
        for i in range(M):
            a[i] += A[v][i]
    b = True
    for i in range(M):
        if a[i] < X:
            b = False
            break
    if b == True: # if b:と同義
        ans = min(cost, ans)
if ans == INF:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 27616
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> m(n);
    rep(0,i,n) cin>>m[i];
    sort(m.begin(),m.end());

    int res = n-1;
    for(int i = n-1; i>0; i--){
        x -= m[i];
    }
    res += x/m[0];

    cout << res << endl;
}

Measured memory_bytes: 256
'use strict'
let input = require("fs").readFileSync("/dev/stdin", "utf8");
// 必要な変数に定義する
let Nums = input.split('\n');
let nums = Nums[1].split(' ');
let ans = 0;
let isAllEven = nums.every(x => x%2 == 0);

while(isAllEven){
  nums= nums.map( x => x/2);
  isAllEven = nums.every(x => x%2 == 0);
  ans++;
}

console.log(ans);

Measured memory_bytes: 7624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <algorithm>
using namespace std;

int main(){
    char s[100];
    int a,b;
    stack<int> stk;
    while(1){
        cin>>s;
        if(cin.eof()) break;
        switch(s[0]){
            case '+':
                a=stk.top();
                stk.pop();
                b=stk.top();
                stk.pop();
                stk.push(a+b);
                break;
            case '-':
                a=stk.top();
                stk.pop();
                b=stk.top();
                stk.pop();
                stk.push(b-a);
                break;
            case '*':
                a=stk.top();
                stk.pop();
                b=stk.top();
                stk.pop();
                stk.push(a*b);
                break;
            default:
                stk.push(atoi(s));
        }
    }
    cout<<stk.top()<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  int h,w,tile;
  int dp[1405][1405];
  int maxv=0;
  cin>>h>>w;
  reps(i,h){
    reps(j,w){
      cin>>tile;
      if(!tile){
	dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
	maxv=max(maxv,dp[i][j]);
      }
      else{
	dp[i][j]=0;
      }
    }
  }
  
  cout<<maxv*maxv<<'\n';
  return 0;
}



Measured memory_bytes: 10812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b,c;
int ans;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	ans=max(ans,a+b*10+c);
	ans=max(ans,a+c*10+b);
	ans=max(ans,b+a*10+c);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(int argc, char* argv[])
{
  int n;
  std::cin >> n;
  
  std::vector<std::string> str(n);
  for(int i=0;i<n;++i){
  	std::cin >> str[i];
  }
  
  int ret = 0;
  
  int bx =0;
  int xa =0;
  int ba =0;
  
  for(int i=0;i<n;++i){
    if(str[i].front()=='B'&&str[i].back()!='A'){
    	bx += 1;
    }
    if(str[i].front()!='B'&&str[i].back()=='A'){
    	xa += 1;
    }
    if(str[i].front()=='B'&&str[i].back()=='A'){
    	ba += 1;
    }
    for(int j=0;j<str[i].size()-1;++j){
    	if(str[i][j]=='A' && str[i][j+1]=='B' ){
    		ret += 1;
    	}
    }
  }  
  //std::cout<<ret;
  
  if(ba>=2){
  	ret += (ba - 1);
  }
  
  //std::cout<<ret;
  if( ba ){
    if(bx){
      ret += 1;
      bx -=1;
    }
    if(xa){
      ret +=1;
      xa -= 1;
    }
  }
  
  //std::cout<<ret;
  if( xa >= bx ){
  	ret += bx;
  }
  else{
    ret += xa;
  }
  
  std::cout<<ret;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct edge{
    ll a, b, c;
    bool operator<(const edge &another) const{
        return (c < another.c);
    }
};

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

ll ma[4040][4040];
vector<pll> G[4040];

void dfs(ll root, ll par, ll now, ll mx){
    if(ma[root][now] != -1) return;
    ma[root][now] = mx;
    REP(i, G[now].size()){
        ll next = G[now][i].first;
        ll cost = G[now][i].second;
        if(next == par) continue;
        dfs(root, now, next, max(mx, cost));
    }
    return;
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<edge> edges(M);
    REP(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[i].a = a;
        edges[i].b = b;
        edges[i].c = c;
    }
    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    ll total_weight = 0;
    REP(i, M){
        edge e = edges[i];
        if(uf.merge(e.a, e.b)){
            G[e.a].push_back({e.b, e.c});
            G[e.b].push_back({e.a, e.c});
            total_weight += e.c;
        }
    }

    REP(i, 4040)REP(j, 4040){
        ma[i][j] = -1;
    }

    REP(i, N) dfs(i, -1, i, 0);

    ll Q;
    cin >> Q;
    while(Q--){
        ll S, T;
        cin >> S >> T;
        S--, T--;
        cout << total_weight - ma[S][T] << endl;
    }

    return 0;
}

Measured memory_bytes: 138624
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;

int getint(){
	int f=1,x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
#define N 2123
int a[N];
ll n,d;
int ans=0; 
int main(){
	ll x=getint(); x=max(x,-x);
	n=0;
	while(n*(n+1)/2ll<ll(x)) n++;
	printf("%d\n",n);
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)puts("Possible");
	else puts("Impossible");
 	return 0; 
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		Integer[] d = new Integer[n];
		for(int i = 0;i < n;i++){
			d[i] = saori.saori_hayami();
		}
		Arrays.sort(d, Collections.reverseOrder());
		int ans = 1;
		for(int i = 0;i < d.length-1;i++){
			if(d[i] > d[i+1]){
				ans++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX], b[MAXX];
int main()
{
	FAST;
	ll n, t, m, o = 1, z, p, ans = 0;
	cin >> n >> m;
	if((n*2 <= m && n*4 >= m) && m % 2 == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	

}

Measured memory_bytes: 3652
#include <stdio.h>
int A[2000];
int solve(int,int,int);
int main(){
  int i,n,M[2000],q;
  int x;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }
  for(i=0;i<q;i++){
    x=solve(0,M[i],n);
    if(x==0)printf("no\n");
    else printf("yes\n");
  }

  return 0;
}
int solve(int i,int m,int n){
  int a;
  if(m==0)return 1;
  if(i>=n)return 0;
  a=solve(i+1,m,n)||solve(i+1,m-A[i],n);
  return a;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x << endl, 0;
#define all(v) v.begin(),v.end()

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi( lli n, lli m=mod ){ 
    n%=m;
    n+=m;
    n%=m;
    return n;
}

lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const lli MIN=-1*1e18;
const lli INF=1e18+999999999999999999;
const lli N=2e5+5;
const ldb pi=4*atan(1);

int32_t main(){
    fast_io
    lli i = 0,j = 0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout << fixed << setprecision(22);
   
    lli n;
    cin >> n;
    vector<lli> v;
    loop(i,0,n){
        lli a;
        cin >> a;
        v.pb(a);
    }
    lli a[n],b[n];
    map<lli,lli> ma,mb;
    loop(i,0,n){
        a[i]=v[i]+i;
        b[i]=v[i]-i;
        mb[b[i]]++;
    }
    lli ans=0;
    loop(i,0,n){
        lli cur=a[i];
        ans+=mb[-a[i]];
    }

    cout << ans << endl;

}



Measured memory_bytes: 30524
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string S;
	cin>>S;
	map<char,ll> mp;
	ll i,j;
	for(i=0;i<4;i++){
		mp[S[i]-'A']++;
	}
	if(mp.size()==2&&(mp.begin()->sc)==(--mp.end())->sc){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL N, P;
	cin >> N >> P;
	LL twoeven = 1, odd = 0;
	for (LL i = 0; i < N; ++i)
	{
		LL a;
		cin >> a;
		if (a % 2)++odd;
		else twoeven *= 2;
	}
	vector<LL>fact;
	auto comb = [](LL n, LL r)
	{
		LL res = 1;
		for (LL i = 1; i <= n - r; ++i)
		{
			res *= (i + r);
			res /= i;
		}
		return res;
	};
	LL ans = 0;
	for (int i = P; i <= odd; i += 2)
	{
		ans += comb(odd, i);
	}
	ans *= twoeven;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

long color[202020];
vector<long> adj[202020];

bool isbip(long src) {
    for (long i: adj[src]) {
        if (color[i] == color[src]) return false;
        if (!color[i]) {
            if (color[src] == 1) color[i] = 2;
            if (color[src] == 2) color[i] = 1;
            bool b = isbip(i);
            if (!b) return b;
        }
    }
    return true;
}

int main() {
    long n, m, a, b;
    cin >> n >> m;
    color[0] = 1;
    
    REP(i,m) {
        cin >> a >> b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    
    bool fl = isbip(0);
    if (fl) {
        long c = 0;
        REP(i,202020) {
            if (color[i] == 1) c++;
        }
        cout << c * (n - c) - m << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }
}


Measured memory_bytes: 10368
#include <iostream>
#include <map>

// 8:24AM

int main()
{
	std::map<int, int> nmap;
	nmap[1] = 1;
	nmap[3] = 1;
	nmap[5] = 1;
	nmap[7] = 1;
	nmap[8] = 1;
	nmap[10] = 1;
	nmap[12] = 1;
	
	nmap[4] = 2;
	nmap[6] = 2;
	nmap[9] = 2;
	nmap[11] = 2;
	
	nmap[2] = 3;

	int x, y;
	std::cin >> x;
	std::cin >> y;

	std::printf("%s\n", (nmap[x] == nmap[y] ? "Yes" : "No") );
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int n, m; cin >> n >> m;
	vector< vector<int> > a(n, vector<int>(m));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) cin >> a[i][j];
	vector<int> b(m);
	for (int j = 0; j < m; j++) cin >> b[j];
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++)
			sum += a[i][j] * b[j];
		cout << sum << endl;
	}
}

Measured memory_bytes: 1256
n = int(input())
s = input()

# 暗号化した文字列の結果を格納                                                 
result = ""
for c in s:
    # 暗号化する処理                                                           
    if ord('a') <= ord(c) <= ord('z') :
        result = result + chr(abs(((ord(c) +n - ord('a')) % 26)) + ord('a'))
    else :
        result = result + chr(abs(((ord(c) + n - ord('A')) % 26)) + ord('A'))
print(result)

Measured memory_bytes: 3060
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vll a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));
    ll d = (a[n-1]+1)/2;
    ll ans = a[0];
    ll sample = INF;
    if(a[0]==0&&a[1]==100){
        cout<<100<<' '<<0<<endl;
        return 0; 
    }
    rep(i,n){
        ll tmp = abs(d -a[i]);
        if(sample>=tmp){
            sample = tmp;
            ans =a[i];
        }
    }

    cout<<a[n-1]<<' '<<ans<<endl;
}

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

const int mod = 1000000007;

int main()
{
    string s;
    cin >> s;
    int num[4] = {s[0] - '0', s[1] - '0', s[2] - '0', s[3] - '0'};
    string ans = "";
    for (int bits = 0; bits < (1 << 3); bits++)
    {
        ans = "";
        ans += s[0];
        int sum = num[0];
        for (int i = 1; i <= 3; i++)
        {
            //cout << (bits & (1 << (i - 1))) << endl;
            if (bits & (1 << (i - 1)))
            {
                sum -= num[i];
                ans += '-';
                ans += s[i];
            }
            else
            {
                sum += num[i];
                ans += '+';
                ans += s[i];
            }
        }
        //cout << sum << endl;
        if (sum == 7)
        {
            break;
        }
    }
    ans += '=';
    ans += '7';
    cout << ans << endl;
}


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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

signed main(){
	int n;
	cin>>n;
	int x=1,k=2,hoge=2;
	while(1){
		if(n==x) break;
		if(n<x){
			cout<<"No"<<endl;
			return 0;
		}
		k++;
		x+=hoge;
		hoge++;
	}
	vector<int> ans[100000];
	int z=1;
	lp(i,k){
		lps(j,i+1,k){
			ans[i].push_back(z);
			ans[j].push_back(z);
			z++;
		}
	}
	cout<<"Yes"<<endl;
	cout<<k<<endl;
	lp(i,k){
		cout<<ans[i].size();
		lp(j,ans[i].size()) cout<<" "<<ans[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <string.h>
using namespace std;
int main() {
    char s[1000],p[1000],p1[10000];
    cin>>s;
    int n,i,j=0;
    n=strlen(s);
    for(i=0;i<n/2;i++)
    {
        p[i]=s[i];
    }
    p[(n/2)]='\0';
    for(i=(n/2)+1;i<n;i++)
    {
        p1[j]=s[i];
        j++;
    }
    p1[n-1]='\0';
    if(strcmp(p,p1)==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> T(N + 1), X(N + 1), Y(N + 1);
  T[0] = X[0] = Y[0] = 0;
  REP(i, 1, N + 1) cin >> T[i] >> X[i] >> Y[i];

  bool ans = true;
  REP(i, 0, N) {
    ll dt = T[i + 1] - T[i];
    ll dx = abs(X[i + 1] - X[i]);
    ll dy = abs(Y[i + 1] - Y[i]);
    ans = ans && (dx + dy <= dt && (dt - (dx + dy)) % 2 == 0);
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n,ans=0;
	in(n);
	vll a(n);
	rep(i, 0, n) {
		in(a[i]);
		ans += a[i] - 1;
	}
	outn(ans);

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll a,b,x;
    cin >> a >> b >> x;
    if(a == 0){
        cout << b/x + 1 << endl;
    }else{
        cout << (b/x) - ((a - 1)/x) << endl;
    }
    return 0;
}


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

int main()
{
    int w, h, n, res;
    //freopen("test.inp","r",stdin);
    cin >> w >> h >> n;
    res = n/max(w, h);
    if (n % (max(w, h)) != 0) res++;
    cout <<res;
    return 0;
}


Measured memory_bytes: 256