akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using state = string::const_iterator;

string expr(state &cur, string t = ""){
    int v = 0;
    while(true){
        if(isalpha(*cur)){
            t += (char)((*cur-'A'+v+260)%26+'A');
            cur++;
            v = 0;
        } else if(*cur == '?') {
            t += 'A';
            cur++;
            v = 0;
        } else if(*cur == '+') {
            v++;
            cur++;
        } else if(*cur == '-') {
            v--;
            cur++;
        } else if(*cur == '[') {
            cur++;
            string u = expr(cur);
            reverse(u.begin(),u.end());
            t += u;
            cur++;
        }else break;
    }
    return t;
}

int main() {
    string s;
    while(cin >> s, s != "."){
        state cur = s.begin();
        string t = expr(cur), ans;
        int v = 0;
        for (auto &&i : t) {
            if(isalpha(i)) ans += (char)((i-'A'+v+26)%26+'A'), v = 0;
            else if(i == '?') ans += 'A', v = 0;
            else if(i == '+') v++;
            else v--;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;

ll solve(vector<int> x,vector<int> y)
{
    int mn=INT_MAX,mx=INT_MIN;
    int mn2=INT_MAX,mx2=INT_MIN;
    int max_i=0,min_i=0;
    for(int i=0;i<n;i++)
    {
    mn = min(mn,(x[i]+y[i]));
    mx = max(mx,(x[i]+y[i]));
    mn2 = min(mn2,(x[i]-y[i]));
    mx2 = max(mx2,(x[i]-y[i]));      
    }
    //cout<<mn<<" "<<mx<<" "<<mn2<<" "<<mx2<<" ";
    return max(abs(mx2-mn2),abs(mx-mn));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    vector<int> x(n,0),y(n,0);
    for(int i=0;i<n;i++)
    cin>>x[i]>>y[i];
    cout<<solve(x,y);
    return 0;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	string s;
	cin >> s;
	int t1 = 0;
	rep(i,(int)s.size()) {
		if (i % 2 == 0 && s[i] == '0') t1++;
		if (i % 2 == 1 && s[i] == '1') t1++;
	}
	int t2 = 0;
	rep(i,(int)s.size()) {
		if (i % 2 == 1 && s[i] == '0') t2++;
		if (i % 2 == 0 && s[i] == '1') t2++;
	}
	cout << min(t1, t2) << endl;
}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int a=0,b=0;
        int[] num = new int[w];
        for(int i=0;i<w;i++){
            num[i] = i+1;
        }
        for(int i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            a = Integer.parseInt(ab[0]);
            b = Integer.parseInt(ab[1]);
            int t = num[a-1];
            num[a-1] = num[b-1];
            num[b-1] = t;
        }
        for(int i=0;i<w;i++){
            System.out.println(num[i]);
        }
        sc.close();
    }
}


Measured memory_bytes: 25868
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
       ll x,y;
       cin>>x>>y;
       int i=0;
       int flag=1;
       while(true)
       {
           if((((x-i)*2+i*4==y)||(i*2+(x-i)*4==y)))
               {
                   flag=0;
                   break;
               }
               else
                i++;
                if(i>x)
                    break;
       }
       if(flag==1)
        cout<<"No"<<endl;
       else
        cout<<"Yes"<<endl;
 return 0;
}

Measured memory_bytes: 3580
x,y = list(map(int,input().split()))
if 0<x and x<y:
    print(y-x)
elif x<0 and 0<y:
    if abs(x)>=abs(y):
        print(-x-y+1)
    else:
        print(x+y+1)
    
elif y <0 and 0<x:
    if abs(x)>=abs(y):
        print(x+y+1)
    else:
        print(-x-y+1)
elif 0 < y and y<x:
    print(x-y+2)
elif x<y and y<0:
    print(y-x)
elif y < x and x < 0:
    print(x-y+2)
elif x==0:
    if y > 0:
        print(y)
    else:
        print(-y+1)
        
else: #y==0
    if x > 0:
        print(x+1)
    else:
        print(-x)

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n, m, a;
VVI tbl;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while (1) {
		tbl.clear();
		cin >> n >> m >> a;
		if (n == 0 && m == 0 && a == 0) break;
		tbl.resize(n + 1, VI(1001));
		rep (i, m) {
			int h, p, q;
			cin >> h >> p >> q;
			tbl[p][1000 - h] = q;
			tbl[q][1000 - h] = p;
		}
		int pos = a;
		rep (i, 1001) {
			if (tbl[pos][i] != 0) {
				pos = tbl[pos][i];
			}
		}
		cout << pos << endl;
	}
	return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define fi first
#define sz size 
#define len length 
#define se second 
const ll mod=998244353;
//const ll mod = 1000000000+7;
#include <bits/stdc++.h>
using namespace std;
int arr[100000+4][26];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	string t;
	cin>>s>>t;
	ll n=s.len();
	ll u=t.len();
	
	memset( arr,-1,sizeof ( arr));
	int brr[26];
	memset( brr,0 , sizeof ( brr));
	for ( int i=0;i<n;i++)
		brr[s.at(i)-'a']++;
	int crr[26];
	memset( crr,0,sizeof ( crr));
	for ( int i=0;i<u;i++)
		crr[t.at(i)-'a']++;
	for ( int i=0;i<26;i++)
		if ( crr[i]!=0&&brr[i]==0)
		{
			cout<<-1<<'\n';
			return 0;
		}
	for ( int i=n-1;i>=0;i--){
		for ( int j=0;j<26;j++)
			arr[i][j]=arr[(i+1)%n][j];
		arr[i][s.at(i)-'a']=i;
	}
	for ( int i=n-1;i>=0;i--){
		for ( int j=0;j<26;j++)
			arr[i][j]=arr[(i+1)%n][j];
		arr[i][s.at(i)-'a']=i;
	}
	ll pos=0;
	ll count=0;
	for ( int i=0;i<u;i++)
	{
		int val=t.at(i)-'a';
		int next_pos=arr[pos][val];
		if ( next_pos<pos||next_pos==n-1)
			count++;
		pos=(next_pos+1)%n;
	}
	cout<<count*n+pos<<'\n';
	
}
    

Measured memory_bytes: 10704
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long n;
	cin >> n;
	if (n == 2)
		cout << 1;
	else if (n == 1)
		cout << 0;
	else
	{
		long long res = 0;
		if (n % 2 == 1)
		{
			res += n % 2;
			res += (2 + n - 1) * (n - 2) / 2;

		}
		else
		{
			res += 1 % 2;
			res += (2 + n - 1) * (n - 2) / 2;
		}
		cout << res;
	}
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))

DP=[False]*(K+1)
for i in range(1,K+1):
    for j in range(0,N):
        if A[j]<=i:
            DP[i]=DP[i] or not DP[i-A[j]]
        else:
            break

if DP[K]:
    print('First')
else:
    print('Second')



Measured memory_bytes: 44268
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S,T;
	int N;
	scan(N>>S>>T);
	rep(i,N){
		printf("%c%c",S[i],T[i]);
	}
	kaigyo;
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x; cin >> x;
    rep1(i,x+1){
        if(100*i <= x && x <= 105*i){
            out(1);
            return 0;
        }
    }
    out(0);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,n,i,s=0;
    scanf("%d %d",&h,&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    if(s>=h){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

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

int main()
{
    long long i,j,n,ans=0;
    scanf("%lld",&n);
    long long a[(3*n)];
    for(i=0;i<3*n;i++)
    {
        scanf("%lld",&a[i]);
    }

    sort(a,a+(3*n));
    for(i=0,j=(n*3)-2;i<n;i++,j-=2)
    {
        ans+=a[j];
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 6076
s = input()
t = input()

ans = len(t)

for i in range(len(s) - len(t) + 1):
  cnt = len(t)
  for j in range(len(t)):
    if t[j] == s[j + i]:
      cnt -= 1
    
  ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 9072
# encoding: utf-8
dishs = []
5.times do
  x = gets.chomp.to_i
  dishs << x
end
# p dishs
m = 0
for i in 1..4 do
  if (dishs[i] % 10 > 0) && ((dishs[i] % 10) < (dishs[m] % 10)) then
    m = i
  end
end
dishs[4], dishs[m] = dishs[m], dishs[4]
# p dishs
sum = 0
for i in 0..3 do
  if dishs[i] % 10 == 0 then
    sum = sum + dishs[i]
  else
    sum = sum + (dishs[i] / 10 + 1 ) * 10
  end
end
sum = sum + dishs[4]
puts sum

Measured memory_bytes: 3836
#include<stdio.h>

int depth(int);
void P(int);

struct node{
  int p,l,r;
};

struct node tree[100005];
int n,D[100005];

main(void){

  int i,j,d,e,c,l,r;
   
  scanf("%d",&n);
   
  for (i=0;i<n;i++){
    tree[i].p=tree[i].l=tree[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&e,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      tree[c].p=e;
       
      if(j==0){
	tree[e].l=c;
      }
      
      else if(j>=1){
	tree[r].r=c;
      }
      r=c;
      
    }
   }
   
  for(i=0;i<n;i++){
    D[i]=depth(i);
  }
 
  for(i=0;i<n;i++){
    P(i);
  }
  return 0;
}

int depth(int x){

  int d=0;
 
  while(tree[x].p>=0){
    x=tree[x].p;
    d=d+1;
  }
  return d;
}
void P(int y){
  if(tree[y].p==-1){
    printf("node %d: parent = %d, depth = %d, root, ",y,tree[y].p,D[y]);
  }
   
  else if(tree[y].l==-1){
    printf("node %d: parent = %d, depth = %d, leaf, ",y,tree[y].p,D[y]);
  }
   
  else printf("node %d: parent = %d, depth = %d, internal node, ",y,tree[y].p,D[y]);
   
  printf("[");
  int t;
  t = y;
  if(tree[t].l!=-1){
    printf("%d",tree[t].l);
    if(tree[tree[t].l].r==-1){
      printf("]\n");
    }
    else printf(",");
    t =tree[t].l;
    while(tree[t].r!=-1){
      printf(" %d",tree[t].r);
      if(tree[tree[t].r].r==-1){
	printf("]\n");
      }
      else printf(",");
      t=tree[t].r;
    }
  }
  else printf("]\n");
}

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

int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(n,0));
    rep(i,n) rep(j,n) cin >> a[i][j];

    ll ans = 0;

    rep(i,n-1) {
        rep2(j,i,n) {
            bool shortest = true;
            rep(k,n) {
                if(k == i || k == j) continue;
                if(a[i][k] + a[k][j] < a[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                if(a[i][k] + a[k][j] == a[i][j])
                    shortest = false;
            }

            if(shortest) ans += a[i][j];
        }
    }

    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

ll func(ll x)
{
    return x * x;
}

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

    ll d;
    
    while(cin >> d)
    {
        ll sum = 0;
    
        FOR(i, 1, 600 / d)
        {
            sum += d * func(d * i);
        }

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

ll choose(ll a) {
    return a * (a - 1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<ll> A(n), B(n + 1, 0);
    rep(i, n) {
        cin >> A[i];   
        B[A[i]]++;
    }
    ll ans = 0;
    rep(i, n + 1) {
        ans += B[i] * (B[i] - 1) / 2;
    }
    rep(i, n) {
        cout << ans - (B[A[i]]- 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int qzh[1000][1000];
int n,m,q;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>q;
	int l,r;
	for(int i=1;i<=m;i++)
	{
		cin>>l>>r;
		qzh[l][r]++;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			qzh[i][j]+=qzh[i][j-1];
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			qzh[i][j]+=qzh[i-1][j];
		}
	for(int i=1;i<=q;i++){
		cin>>l>>r;
		cout<<qzh[r][r]+qzh[l-1][l-1]-qzh[r][l-1]-qzh[l-1][r]<<endl;
	}
	return 0;
}


Measured memory_bytes: 2816
k, n = map(int, input().split())
a = list(map(int, input().split()))

#find distance
d_ls = []
for i in range(1, n):
  d = abs(a[i] - a[i-1])
  d_ls.append(d)

# final distance
d = k - sum(d_ls)
d_ls.append(d)

#delete maximum distance
d_ls.remove(max(d_ls))

print(sum(d_ls))

Measured memory_bytes: 26436
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    vector<ll>count(n+1);
    rep(i, n)   count[a[i]]++;
    vector<ll>ans(n+1);
    for(int i = 1; i <= n; i++){
        ll tmp = count[i];
        ans[0] += tmp*(tmp-1)/2;
    }
    for(int i = 1; i <= n; i++){
        ll tmp = count[i];
        if(!tmp)   continue;
        ans[i] = ans[0] - (tmp*(tmp-1) - (tmp-1)*(tmp-2))/2;
    }
    rep(i, n){
        cout << ans[a[i]] << endl;
    }
}


Measured memory_bytes: 7296
n = int(input())
a = list(map(int,input().split()))

heighest = 0
humi =[]

for i in range(n):
  if a[i] > heighest:
    heighest = a[i]
  elif a[i]<heighest:
    sa = heighest-a[i]
    humi.append(sa)
print(sum(humi))

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


int main(){
    ll n,t;cin>>n>>t;
    ll a[100010];
    rep(i,0,n)cin>>a[i];
    ll MX[100010],MN[100010];
    MN[0]=a[0];
    MX[n-1]=a[n-1];
    ll MMX=0,cn=0;
    rep(i,1,n-1){
        MN[i]=min(MN[i-1],a[i]);
    }
    for(int i=n-2;i>=1;i--){
        MX[i]=max(MX[i+1],a[i]);
    }
    rep(i,0,n-1){
        MMX=max(MX[i+1]-MN[i],MMX);
    }
    rep(i,0,n){
        if(MX[i+1]-a[i]==MMX)cn++;
    }

    cout<<cn<<endl;
}

    









Measured memory_bytes: 2560
package main

import (
	"bufio"
	"os"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

//func nextInt() int {
//	sc.Scan()
//	i, e := strconv.Atoi(sc.Text())
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	s := nextString()
	t := nextString()
	count := 0

	for i := range s {
		if s[i] != t[i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 2596
n,x = map(int,input().split())
# gcdは結合法則が成り立つ
X = tuple(map(int,input().split()))
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a % b)
diff_gcd = abs(x - X[0])
for i in range(n - 1):
  diff_gcd = gcd(diff_gcd,abs(X[i + 1] - X[i]))
print(diff_gcd)

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

using namespace std;


const int BITS = 64;
long long N, K;
vector<bool> k(BITS);
vector<int> cnt(BITS);
vector<long long> pw(BITS);

vector<bool> get_bits(long long x)
{
    vector<bool> v(BITS);
    for (int i = 0; i < BITS && x; ++i) {
        if (x & 1) v[i] = 1;
        x /= 2;
    }
    reverse(v.begin(), v.end());
    return v;
}

void solve()
{
    int put;
    bool match = true;
    long long ans = 0;
    for (int i = 0; i < BITS; ++i) {
        if ((N-cnt[i]) <= cnt[i]) {
            put = 0;
            if (k[i]) match = false;
        } else {
            if (!match || k[i])
                put = 1;
            else
                put = 0;
        }
        ans += pw[i] * (put ? (N-cnt[i]) : cnt[i]);
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    pw[BITS-1] = 1;
    for (int i = BITS-2; i; --i) {
        pw[i] = 2ll * pw[i+1];
    }

    cin >> N >> K;
    k = get_bits(K);

    long long a;
    for(int i = 0 ; i < N ; i++){
        cin >> a;
        vector<bool> bits = get_bits(a);
        for (int i = 0; i < BITS; ++i) {
            cnt[i] += bits[i];
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
  let stdin = stdin();
  let stdout = stdout();
  let mut stdout = BufWriter::new(stdout.lock());

  for line in stdin.lock().lines() {
    let line = line.unwrap();
    let mut args = line.split_whitespace().map(|str| str.parse::<usize>().unwrap());
    let h = args.next().unwrap();
    let w = args.next().unwrap();

    if h == 0 { break }

    let str1 = "#".repeat(w);

    let mut str2 = String::with_capacity(w);
    str2.push('#');
    for _ in 1..(w - 1) { str2.push('.') }
    str2.push('#');

    writeln!(&mut stdout, "{}", str1).unwrap();
    for _ in 1..(h - 1) {
      writeln!(&mut stdout, "{}", str2).unwrap();
    }
    writeln!(&mut stdout, "{}", str1).unwrap();

    writeln!(&mut stdout).unwrap();
  }
}



Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,M;
    cin>>N>>M;
    ll sum=0;
    rep(i,0,M){
        ll in;
        cin>>in;
        sum+=in;
    }
    if(sum>N){
        cout<<-1<<endl;
    }
    else{
        cout<<N-sum<<endl;
    }
    return 0;
}




Measured memory_bytes: 3636
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int n, m;
	cin >> n >> m;
	
	set<int> point;
	vector<pair<int, int>> ship(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		ship[i] = make_pair(a, b);
		if (a == 1) point.insert(b);
	}
	
	rep(i, m) {
		if (ship[i].second == n) {
			if (point.count(ship[i].first)) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
ll a[200005];
ll n,k;
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int L = 0,R = n-1;
	if(k&1){
		if(a[n-1] < 0){
			ll ans = 1;
			for(int i=n-1;i>=n-k;i--){
				ans *= a[i];
				ans %= mod;
			}
			if(ans < 0) cout<<ans+mod<<endl;else cout<<ans<<endl;
			exit(0);
		}
		
		R--,k--;
	}
	while(k){
		ll lv = a[L] * a[L+1];
		ll rv = a[R] * a[R-1];
		
		if(lv < rv){
			R -= 2;
		}	else L += 2;
		k -= 2;
	}
	ll ans = 1;
	for(int i=0;i<L;i++){
		ans *= a[i];
		ans %= mod;
	}
	for(int i=R+1;i<n;i++){
		ans *= a[i];
		ans %= mod;
	}
	if(ans < 0) cout<<ans+mod<<endl;
	else cout<<ans<<endl;
	return 0;
}








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

int main() {

  int A,B,C;
  int S=1;
  C=0;
  cin>>A>>B;
  for(int i=0;i<30;i++){
    if(S>=B)break;
    else S+=A-1;
    C++;
  }
  cout<<C<<endl;
}

  

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let a: u8 = iter.next().unwrap().parse().unwrap();
    let b: u8 = iter.next().unwrap().parse().unwrap();

    let mut ans = String::new();
    if a > b {
        let b_str = &b.to_string();
        for _ in 0..a {
            ans.push_str(b_str);
        }
    } else {
        let a_str = &a.to_string();
        for _ in 0..b {
            ans.push_str(a_str);
        }
    }
    return ans;
}

#[test]
fn test() {
    assert_eq!(solve(r"4 3"), "3333");
    assert_eq!(solve(r"7 7"), "7777777");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0; 
    rep1(i, n-1) if (s[i]!=s[i+1]) ans++;
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3744
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> W = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            W.add(scanner.nextInt());
        }
        scanner.close();

        int min = Integer.MAX_VALUE;

        // max
        int max = 0;
        for (int n : W) {
            max += n;
        }

        int s1 = 0;
        int s2 = max;

        for (int i = 0; i < N; i++) {
            s1 += W.get(i);
            s2 -= W.get(i);
            int calc = s2 - s1;
            calc = (calc >= 0) ? calc : -calc;
            if (min > calc) {
                min = calc;
            } else {
                break;
            }
        }

        System.out.println(min);

//        System.out.println(System.currentTimeMillis() - startTime);
    }

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<vector<vector<int>>> F(N);
    REP(i, N) {
        F[i].resize(5, vector<int>(2));
        REP(j, 5) REP(k, 2) cin >> F[i][j][k];
    }
    vector<vector<int>> P(N);
    REP(i, N) {
        P[i].resize(11);
        REP(j, 11) cin >> P[i][j];
    }
    int res = INT_MIN;
    for (int bit = 1; bit < (1 << 10); ++bit) {
        vector<int> c(N);
        REP(i, 5) {
            REP(j, 2) {
                if (bit >> (2 * i + j) & 1) { REP(k, N) c[k] += F[k][i][j]; }
            }
        }

        int sum = 0;
        REP(i, N) sum += P[i][c[i]];
        res = max(res, sum);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  var i,j,result;
  var a = line.split(' ');
  var b = parseInt(a[0],10);
  var c = parseInt(a[1],10);
  if(!b && !c)
    process.exit();
  for(i=0;i<b;i++){
    result="";
    for(j=0;j<c;j++)
      result += "#";
    console.log(result);
  }
  console.log("");
});
process.stdin.on('end', function () {
});

Measured memory_bytes: 18508
#include <cstdio>
#include <vector>
#include <stack>
#include <utility>

bool visit[100000];
int x[100000];
using pair = std::pair<int, long long>;

struct edge
{
  int to;
  long long cost;
};

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<edge> edges[200000];
  for (int i = 0; i < m; ++i)
  {
    int l, r; long long d;
    scanf("%d%d%lld", &l, &r, &d);
    --l, --r;
    edges[l].emplace_back(edge{r, d});
    edges[r].emplace_back(edge{l, -d});
  }
  std::stack<pair> stack;
  for (int i = 0; i < n; ++i)
  {
    if (visit[i]) continue;
    visit[i] = true;
    stack.emplace(std::make_pair(i, 0));
    while (stack.size() > 0)
    {
      auto p = stack.top();
      stack.pop();
      for (auto e : edges[p.first])
      {
        if (visit[e.to])
        {
          if (x[e.to] != p.second + e.cost)
          {
            puts("No");
            return 0;
          }
        }
        else
        {
          visit[e.to] = true;
          x[e.to] = p.second + e.cost;
          stack.emplace(std::make_pair(e.to, p.second + e.cost));
        }
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 16496
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.length() > b.length()) {
            System.out.println("GREATER");
            return;
        } else if (b.length() > a.length()) {
            System.out.println("LESS");
            return;
        }
        for(int i=0;i<b.length();i++){
            if(a.charAt(i)>b.charAt(i)){
                System.out.println("GREATER");
                return;
            }
            else if(b.charAt(i)>a.charAt(i)){
                System.out.println("LESS");
                return;
            }
        }
        System.out.println("EQUAL");
    }
}


Measured memory_bytes: 35596
package main

import "fmt"

func main() {
	var S, T, U string
	var A, B int

	fmt.Scanf("%s %s", &S, &T)
	fmt.Scanf("%d %d", &A, &B)
	fmt.Scanf("%s", &U)

	if U == S {
		A--
	} else {
		B--
	}

	fmt.Println(A, B)
}


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

int main() {
  int N, count = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N - 2; i++) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0),cin.tie(0);
#define endl '\n'
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ll long long
#define F first
#define S second
#define pb push_back
const int N = 1e6 + 5;
typedef pair<int,int>ii;
int main(){
  fast;
  int n,a,b;
  while(cin >> n){
    ll v[n];
    for(int i=0;i<n;i++)
      cin >> v[i];
    ll ans = 0;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
        ans += v[i]*v[j];
    cout << ans << endl;
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  vector<int> v(200);
  FOR(i,0,200) v[i] = i * (i + 1) * (i + 2) / 6;

  int dp[1000006];
  FOR(i,0,1000006) dp[i] = 1e9;
  dp[0] = 0;
  FOR(i,0,1000006) {
    FOR(j,0,v.size()) {
      if(i - v[j] >= 0) dp[i] = min(dp[i], dp[i - v[j]] + 1);
    }
  }

  int dp_even[1000006];
  FOR(i,0,1000006) dp_even[i] = 1e9;
  dp_even[0] = 0;
  FOR(i,0,1000006) {
    FOR(j,0,v.size()) {
      if(v[j]%2 == 0) continue;
      if(i - v[j] >= 0) dp_even[i] = min(dp_even[i], dp_even[i - v[j]] + 1);
    }
  }
  while(cin>>n,n) {
    cout << dp[n] << " " << dp_even[n] << endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  map<ll,int> m;
  vector<ll> cand;
  for(int i=0;i<N;i++){
    ll A;
    cin>>A;
    if(m.count(A)==0){
      m[A]=1;
    }else{
      m[A]++;
    }
    if(m[A]==2){
      m.erase(A);
      cand.push_back(A);
    }
  }
  sort(cand.begin(),cand.end());
  reverse(cand.begin(),cand.end());
  if(cand.size()<2){
    cout<<0<<endl;
  }else{
    cout<<cand.at(0)*cand.at(1)<<endl;
  }

}


Measured memory_bytes: 6528
n = int(input())
rests = {}

for i in range(n):
  s,p = input().split()
  p = int(p)
  if s in rests:
    rests[s].append((i+1,p))
  else:
    rests[s] = [(i+1,p)]

for s in sorted(list(rests)):
  rest = rests[s]
  rest.sort(key = lambda x:x[1], reverse = True)
  for i,p in rest:
    print(i)
    

Measured memory_bytes: 3060
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int r, d;
  vector<int> x(11);
  cin >> r >> d >> x[0];
  for (int i = 1; i <= 10; i++) {
    x[i] = r * x[i - 1] - d;
    cout << x[i] << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
ll a,b,c,k;
int main(){
	a=read(),b=read(),c=read(),k=read();
	writeln(!(k&1)?(a-b):(b-a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  int n;
  cin >> N;
  string S;
  cin >> S;
  ll r = 0,g = 0,b = 0;
  for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }

    ll xor_all = 0;
    rep(i, n) { xor_all ^= a[i]; }

    rep(i, n) { cout << (xor_all ^ a[i]) << " "; }
    cout << endl;

    return 0;
}



Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    int ans = 0;
    string str;
    for(int i=1;i<=N;i++){
        str = to_string(i);
        if(str.size() % 2 == 1)
            ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
# include<bits/stdc++.h>
# include<ext/pb_ds/assoc_container.hpp>
# include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

# define int long long

typedef long long ll;
typedef pair<int, int> pii;

# define S second
# define F first
# define kill(x) return(cout << x << '\n', 0LL)
# define debug(x) cerr<< #x << " = " << (x) << endl
# define ddebug(x, y) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << endl
# define tdebug(x, y, z) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
# define bin(x) cerr<< #x << " : " << bitset<4>(x) << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define uop(x, y) pii(min(x, y), max(x, y))
# define MP(x, y) make_pair(x, y)

const int MAXN = 300 + 10;
int dp[MAXN][MAXN][MAXN];

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

	string s;
	int k;
	cin >> s >> k;

	for (int t = 1; t <= sz(s); t ++)
	{
		for (int i = 0; i + t - 1 < sz(s); i ++)
		{
			int j = i + t - 1;
			for (int l = 0; l <= k; l ++)
			{
				if (t == 1)
				{
					dp[i][j][l] = 1;
					continue;
				}

				dp[i][j][l] = max(dp[i + 1][j][l], dp[i][j - 1][l]);
				if (l || s[i] == s[j])
					smax(dp[i][j][l], dp[i + 1][j - 1][l - (s[i] != s[j])] + 2);
			}
		}
	}
	cout << dp[0][sz(s) - 1][k] << '\n';

	return 0;
}


Measured memory_bytes: 113928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,xmax=-1*INF,xmin=INF,ymax=-1*INF,ymin=INF; cin>>N;
  rep(i,N){
    int64_t a,b; cin>>a>>b;
    auto x=(a+b),y=(a-b);
    xmin=min(xmin,x);
    xmax=max(xmax,x);
    ymin=min(ymin,y);
    ymax=max(ymax,y);    
  }
  cout<<max(xmax-xmin,ymax-ymin);
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
    int totalsecond, hour, min, sec;
    scanf("%d", &totalsecond);
    hour = totalsecond / 3600;
    min = totalsecond % 3600 / 60;
    sec = totalsecond % 3600 % 60;
    printf("%d:%d:%d\n", hour, min, sec);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

// #..#.. 4000*4000 のとき、O 1.6* 10^7 右 1.6*8 * 10^7 * 10^3 ≒ 1.28 10^11 たりない
// .....# 1回のマスを愚直に見ると8000
// ....#.
// #.#...

struct grid_vert {
    bool is_path;
    int height_size;
    int height_rv_size;
    int width_size;
    int width_rv_size;
};


int main () {

    int h, w;
    char c;

    cin >> h >> w;

    grid_vert grid[h][w];

    rep(i,h) {
        rep(j,w) {
            cin >> c;
            grid[i][j].is_path = (c == '.');
        }
    }

    // 横チェック
    rep(i,h) {
        rep(j,w) {
            grid[i][j].width_size = 0;
            if (grid[i][j].is_path) {
                if (j == 0) {
                    grid[i][j].width_size = 1;
                } else {
                    grid[i][j].width_size = grid[i][j-1].width_size + 1;
                }
            }
        }
    }

    reprv(i,h) {
        reprv(j,w) {
            grid[i][j].width_rv_size = 0;
            if (grid[i][j].is_path) {
                if (j == w - 1) {
                    grid[i][j].width_rv_size = 1;
                } else {
                    grid[i][j].width_rv_size = grid[i][j+1].width_rv_size + 1;
                }
            }
        }
    }

    // 縦チェック
    rep(j,w) {
        rep(i,h) {
            grid[i][j].height_size = 0;
            if (grid[i][j].is_path) {
                if (i == 0) {
                    grid[i][j].height_size = 1;
                } else {
                    grid[i][j].height_size = grid[i-1][j].height_size + 1;
                }
            }
        }
    }

    reprv(j,w) {
        reprv(i,h) {
            grid[i][j].height_rv_size = 0;
            if (grid[i][j].is_path) {
                if (i == h - 1) {
                    grid[i][j].height_rv_size = 1;
                } else {
                    grid[i][j].height_rv_size = grid[i+1][j].height_rv_size + 1;
                }
            }
        }
    }


    // サイズチェック
    int max = 0;
    rep(i,h) {
        rep (j,w) {
            int tmp = 0;
            tmp = grid[i][j].height_size + grid[i][j].width_size + grid[i][j].width_rv_size + grid[i][j].height_rv_size - 3;
            if (tmp > max) max = tmp;
        }
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 78336
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		while(scan.hasNext()){
			boolean sw = true;
			for(int i = a;i <= b;i++){
				if(i % 4 == 0){
					if(i % 400 == 0){
						System.out.println(i);
						sw = false;
					}else if(i % 100 != 0){
						System.out.println(i);
						sw = false;
					}
				}
			}
			if(sw){
				System.out.println("NA");
			}
			a = scan.nextInt();
			b = scan.nextInt();
			if(a == 0 && b == 0){
				break;
			}else{
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 20728
import sys
input = sys.stdin.readline

class DSU:
    __slots__ = ["_n", "parent_or_size"]
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if self.parent_or_size[x] > self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        while self.parent_or_size[a] >= 0:
            a = self.parent_or_size[a]
        return a

def main():
    n, q = map(int, input().split())
    dsu = DSU(n)
    for _ in range(q):
        t, u, v = map(int, input().split())
        if t == 0:
            dsu.merge(u, v)
        else:
            print(1 if dsu.same(u, v) else 0)

main()

Measured memory_bytes: 74800
#include <iostream>
#include <string>

int main(int argc, char const *argv[]) {
    std::string r;
    std::string g;
    std::string b;

    std::cin >> r>>g>>b;
    std::string s= g+b;
    int num=std::stoi(s);
    if (num%4==0) {
        std::cout << "YES" << '\n';
    }
    else{
        std::cout << "NO" << '\n';
    }


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
ll solve(vector <int> a){
    ll p0=0,p1=0;
    for (auto u : a){
        if (u%2==1) p1++;
        else p0++;
    }
    if (p0%2==1) return 1;
    if (p1!=1) return 0;
    for (int i=0;i<a.size();i++){
            if (a[i]%2==1)
                a[i]--;
            if (a[i]==0) return 0;
    }
    ll w=0;
    for (auto u : a) w=__gcd(w,u);
    for (int i=0;i<a.size();i++) a[i]/=w;
    return 1-solve(a);
}
int32_t main(){
    ll n;
    cin >> n;
    vector <int> a;
    for (int i=0;i<n;i++){
        ll x;
        cin >> x;
        a.pb(x);
    }
    ll ans=solve(a);
    if (ans) kill("First");
    kill("Second");
}


Measured memory_bytes: 22948