akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
	"""Union-Find, 
	http://www.slideshare.net/chokudai/union-find-49066733"""

	def __init__(self, N):
		self.par = [i for i in range(N)]

	def root(self, x):
		if(self.par[x]==x):
			return x
		else:
			self.par[x] = self.root(self.par[x])
			return self.par[x]

	def same(self, x, y):
		return self.root(x)==self.root(y)

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		# if x==y:
		# 	return
		self.par[x] = y
		return

N, K, L = map(lambda x:int(x), input().split())
P = [0]*K
Q = [0]*K
R = [0]*L
S = [0]*L
for i in range(K):
	P[i], Q[i] = map(lambda x:int(x), input().split())
for i in range(L):
	R[i], S[i] = map(lambda x:int(x), input().split())

uf_k = UnionFind(N)
uf_l = UnionFind(N)

for i in range(K):
	uf_k.unite(P[i]-1, Q[i]-1)
for i in range(L):
	uf_l.unite(R[i]-1, S[i]-1)

k_groups = [uf_k.root(i) for i in range(N)]
l_groups = [uf_l.root(i) for i in range(N)]

kl_groups = [(k_groups[i], l_groups[i]) for i in range(N)]
kl_groups_origin = kl_groups
kl_groups = sorted(kl_groups)

results_dict = {}

idx = 0
count = 1
pair = kl_groups[0]
for i in range(1, N):
	if kl_groups[i]==pair:
		count = count+1
	else:
		results_dict[pair] = count
		pair = kl_groups[i]
		count = 1
results_dict[pair] = count

for i in range(N):
	pair = kl_groups_origin[i]
	print(results_dict[pair], end=" ")

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  if(s.size()>=4 && s.substr(0,4)=="YAKI"){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = map(int,input().split())
Y = list(map(int,input().split()))

l = max(Y) + 1
X = [0] * l
for i in range(n):
    X[Y[i]] += 1

# print(X)
U = [[0] * m for i in range(2)]

for i in range(l):
    a = X[i] // 2
    U[0][i % m] += a

A = [0] * m
for i in range(l):
    A[i % m] += X[i]
# print(A)

for i in range(1, m//2 + 1):
    a = min(A[i], A[m-i])
    U[1][i] += a
    U[1][m-i] += a

U[1][0] = A[0]

# print(U)

ans = 0
for i in range(m):
    ans += min((A[i]-U[1][i]) // 2, U[0][i]) * 2 + U[1][i]

print(ans // 2)

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

int main() {
  cout << fixed << setprecision(10);
  double a,b,x;cin>>a>>b>>x;
  double pi=3.14159265359;
  double ans;
  if(x/a<=a*b/2) ans=a*b*b/(2*x);
  else ans=2*b/a-2*x/(a*a*a);
  cout<<atan(ans)*180/pi<<endl;
    
 // double l=2*x/(a*b);
 // cout<<l<<endl;
 // double ans=atan2(b,l);
 // cout<<ans*180<<endl;
 // cout<<ans/pi<<endl;
 // cout<<ans*180/pi<<endl;
 // cout<<(ans/pi)*180<<endl;
 // cout<<ans/pi<<endl;
 // cout<<(ans/pi)*180<<endl;
}


Measured memory_bytes: 4016
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        System.out.println(list.get(n / 2) - list.get((n / 2) - 1));
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char b;
    cin >> b;
    if(b=='A') cout << "T" << "\n";
    else if(b=='T') cout << "A" << "\n";
    else if(b=='G') cout << "C" << "\n";
    else cout << "G" << "\n";
    return 0;
}

Measured memory_bytes: 3648
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    ll n;
    ll sum=0;
    ll f[maxn];
    
    cin >> n;
    rep(i,n){
        ll a,b;cin >> a>>b;
        sum-=b;
        f[i]=a+b;
    }
    
    sort(f,f+n);
    reverse(f,f+n);
    
    rep(i,n){
        sum+=f[i];
        i++;
    }
    
    cout << sum<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, s, c, ans=-1;
  bool h=true;
  vector<int> a(3, 0);
  vector<pair<int, int>> p(5);
  cin>>N>>M;
  for (int i=0;i<M;i++){
    cin>>s>>c;
    p.at(i)=make_pair(s,c);
  }
  
  sort(p.begin(), p.end());
  
  for(int i=0;i<4;i++){
    if(p.at(i).first==p.at(i+1).first&&p.at(i).second!=p.at(i+1).second){
      h=false;
    }
  }
  for(int i=0;i<5;i++){
    if(N!=1 && p.at(i).first==1 && p.at(i).second==0){
      h=false;
    }
  }
/*  
  for (int i=0;i<5;i++){
    printf("%d,%d\n",p.at(i).first,p.at(i).second);
  }
*/  
  if(h){
    int k=0;
    for(int i=0;i<5;i++){
      if(p.at(i).first>k){
        k=p.at(i).first;
        a.at(k-1)=p.at(i).second;
      }
//      cout<<k<<","<<p.at(i).first<<","<<p.at(i).second<<endl;
    }
//    printf("%d,%d,%d\n",a.at(0),a.at(1),a.at(2));
    ans=a.at(0)*100+a.at(1)*10+a.at(2);
    for(int i=0;i<3-N;i++){
      ans/=10;
    }
  }
  if(h && N==3 && a.at(0)==0){
    ans+=100;
  }
  if(h && N==2 && a.at(0)==0){
    ans+=10;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
a = "a"+input()+"q"
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 1
t = N
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
    c+=1
  if j == "L" and i == a[s]:
    s+=1
  if j == "R" and i == a[s-1] and s!= 1:
    s-=1
  if j == "L" and i == a[t+1] and t!= N:
    t+=1
    c-=1
  if s+c-1==N and N!=0:break
if N>1:print(N-s-c-1+2)
else: 
  if s+c+1>1:print(1)
  else:print(0)


Measured memory_bytes: 25264
import java.util.*;
public class Main { 

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr = new int[m][2];
        for(int i = 0; i < m; i++) {
           arr[i][0] = sc.nextInt();
           arr[i][1] = sc.nextInt();
        }
        int start = arr[0][0];
        int end = arr[0][1];
        for(int i = 1; i < m; i++) {
            start = Math.max(start, arr[i][0]);
            end = Math.min(end, arr[i][1]);
        }
        if(end - start >= 0)
            System.out.println(end - start + 1);
        else
            System.out.println(0);
    }

}

Measured memory_bytes: 86568
#include<stdio.h>
int main(){
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  scanf("%d",&d);
  for(e=0;e<d;e++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c||a*a+c*c==b*b){
      printf("YES\n");
    }
    else if(b*b+c*c==a*a){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<19;
	ll dp[1<<20];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	ll query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 1145141;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		ll vl=query(a,b,k*2+1,l,mid);
		ll vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

string s;
int pos=0;
int fie[200005];
int sum[200005];
vector<int> vec[400005];
segtree seg;

int main(void){
	cin >> s;
	int n=s.size();
	int CN=200000;
	ll ans=0;
	seg.update(0,0);
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			fie[pos]=1;
			//seg.update(CN+sum[pos],1);
			vec[CN+sum[pos]].push_back(pos);
			sum[pos+1]=sum[pos]+1;
			seg.update(pos+1,sum[pos+1]);
			//mini[pos+1]=mini[pos];
			//mini[pos+1]=max(mini[pos+1],mini[pos]);
			pos++;
		}
		if(s[i]==')'){
			fie[pos]=-1;
			sum[pos+1]=sum[pos]-1;
			seg.update(pos+1,sum[pos+1]);
			pos++;
			//printf("%d %lld\n",pos,sum[pos]);
			int l=-1,r=pos;
			while(l+1<r){
				int mid=(l+r)/2;
				if(seg.query(mid,r)>=sum[pos]){
					r=mid;
				}else{
					l=mid;
				}
			}
			//printf("r %d\n",r);
			int v=lower_bound(vec[CN+sum[pos]].begin(),vec[CN+sum[pos]].end(),r)-vec[CN+sum[pos]].begin();
			//if(v!=vec[CN+sum[pos]].size())printf("%d %d\n",v,r,vec[CN+sum[pos]][v]);
			ans+=vec[CN+sum[pos]].size()-v;
			//ans+=seg.query(CN+sum[pos],CN+sum[pos]+1);
		}
		if(s[i]=='-'){
			pos--;
			if(fie[pos]==-1){
				pos++;
				int l=-1,r=pos;
				while(l+1<r){
					int mid=(l+r)/2;
					if(seg.query(mid,r)>=sum[pos]){
						r=mid;
					}else{
						l=mid;
					}
				}
				//printf("r %d\n",r);
				int v=lower_bound(vec[CN+sum[pos]].begin(),vec[CN+sum[pos]].end(),r)-vec[CN+sum[pos]].begin();
				//if(v!=vec[CN+sum[pos]].size())printf("%d %d\n",v,r,vec[CN+sum[pos]][v]);
				ans-=vec[CN+sum[pos]].size()-v;
				//ans-=seg.query(CN+sum[pos+1],CN+sum[pos+1]+1);
				pos--;
			}else{
				//seg.update(CN+sum[pos],-1);
				vec[CN+sum[pos]].pop_back();
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}



Measured memory_bytes: 28584
#include<stdio.h>
int main(){
    
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a<b){
        printf("a < b");
    }
    else if(a>b){
        printf("a > b");
    }
    else if(a==b){
        printf("a == b");
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2688
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const int T = 80 * 81;
	const int X = 60;
	const int Y = T / X + 1;
	public void Solve(){
		
		long[][][] M = new long[H][][];
		for(int i=0;i<H;i++){
			M[i] = new long[W][];
			for(int j=0;j<W;j++){
				M[i][j] = new long[Y];
			}
		}
		
		int[][] C = new int[H][];
		for(int i=0;i<H;i++){
			C[i] = new int[W];
			for(int j=0;j<W;j++){
				C[i][j] = Math.Abs(A[i][j] - B[i][j]);
			}
		}
		
		M[0][0][C[0][0] / X] |= 1L << (C[0][0] % X);
		
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				for(int k=0;k<T;k++){
					if((M[i][j][k / X] >> (k % X)) % 2 == 0) continue;
					if(i + 1 < H){
						int a = Math.Abs(k + C[i+1][j]);
						int b = Math.Abs(k - C[i+1][j]);
						if(a < T) M[i+1][j][a / X] |= 1L << (a % X);
						if(b < T) M[i+1][j][b / X] |= 1L << (b % X);
					}
					if(j + 1 < W){
						int a = Math.Abs(k + C[i][j+1]);
						int b = Math.Abs(k - C[i][j+1]);
						if(a < T) M[i][j+1][a / X] |= 1L << (a % X);
						if(b < T) M[i][j+1][b / X] |= 1L << (b % X);
					}
				}
			}
		}
		for(int i=0;i<T;i++){
			if((M[H-1][W-1][i / X] >> (i % X)) % 2 == 1){
				Console.WriteLine(i);
				return;
			}
		}
	}
	int H,W;
	int[][] A;
	int[][] B;
	public Sol(){
		var d = ria();
		H = d[0];
		W = d[1];
		A = new int[H][];
		for(int i=0;i<H;i++){
			A[i] = ria();
		}
		B = new int[H][];
		for(int i=0;i<H;i++){
			B[i] = ria();
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 21200
#include <cstdio>

int main()
{
  int N;
  int A[200];
  int sum = 0;
  int count = 0;

  scanf("%d", &N);

  for (int i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
  }

  while (1)
  {
    for (int i = 0; i < N; i++)
    {
      if (A[i] % 2 == 0)
      {
        A[i] = A[i] / 2;
      }
      else
      {
        printf("%d", count);
        return 0;
      }
    }
    count++;
  }

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

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(4));
    for(auto &i:a){cin>>i[1]>>i[2]>>i[3]; i[0]=i[1]+i[2];}
    sort(a.begin(),a.end());
    ll mx=10001;
    vector<ll> dp(mx,0);
    ll ans=0;
    for(auto &i:a){
        for(ll t=i[2];t>=0;t--){
            ans=max(ans,dp[t]+i[3]);
            if(t+i[1]<mx){dp[t+i[1]]=max(dp[t+i[1]],dp[t]+i[3]);}
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 384
N=gets.to_i
as=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)

rest = as[-1]

i = N-1
ret = 0
while 0 <= i
    n = bs[i] - rest
    if n <= 0
        ret += bs[i]
        rest = as[i]
    else
        if as[i]+rest < bs[i]
            ret += as[i]+rest
            rest = 0
        else
            ret += bs[i]
            rest = as[i]+rest - bs[i]
        end
    end
    i -= 1
end

puts ret


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

int main()
{
	
	int N, A, B, cntA = 0, cntB = 0;
	string str;
	
	cin >> N >> A >> B;
	cin >> str;
	
	for(int i=0; i<N ; i++) {
		if(str[i] == 'a' && (cntA + cntB) < (A + B)){
			cntA++;
			cout << "Yes" << endl;
		}
		else if(str[i] == 'b' && (cntA + cntB) < (A + B) && cntB < B){
			cntB++;
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 896
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let mut v: Vec<(i32, i32, i32)> = (0..n).map(|_| (read(), read(), read())).collect();
    v.insert(0, (0, 0, 0));
    let yes = v[..].windows(2).all(|w| {
        let (t, x, y) = w[0];
        let (nt, nx, ny) = w[1];
        let time = nt - t;
        let dist = (nx - x).abs() + (ny - y).abs();
        dist <= time && time % 2 == dist % 2
    });
    println!("{}", if yes {"Yes"} else {"No"});
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    int i = 0;

    scanf("%d %d %d %d", &a, &b, &c, &d);
    while (i ==0)
    {
        c = c - b;
        if (c <= 0)
        {
            printf("Yes\n");
            break;
        }
        a = a - d;
        if (a <= 0)
        {
            printf("No\n");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L s, P p) { return ccw(s.s, s.t, p); }

// BEGIN CUT HERE
P proj(P p, L l) {
  P e = l.vec() / l.abs();
  return l.s + dot(p - l.s, e) * e;
}
P refl(P p, L l) { return (R)2 * proj(p, l) - p; }
R distPP(P p, P q) { return abs(q - p); }
R distPL(P p, L l) { return distPP(p, proj(p, l)); }
R distPS(P p, L s) {
  P q = proj(p, s);
  if (!ccw(s, q)) return distPP(p, q);
  return min(distPP(p, s.s), distPP(p, s.t));
}
R distLL(L l, L m) {
  if (sgn(crs(l.vec(), m.vec()))) return 0;
  return distPL(l.s, m);
}
R distLS(L l, L s) {
  if (ccw(l, s.s) * ccw(l, s.t) != 1) return 0;
  return min(distPL(s.s, l), distPL(s.t, l));
}
R distSS(L s, L t) {
  if (ccw(s, t.s) * ccw(s, t.t) <= 0 and ccw(t, s.s) * ccw(t, s.t) <= 0) return 0;
  return min({distPS(s.s, t), distPS(s.t, t), distPS(t.s, s), distPS(t.t, s)});
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    L s, t; cin >> s.s >> s.t >> t.s >> t.t;
    cout << !sgn(distSS(s, t)) << '\n';
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3573104#1


Measured memory_bytes: 3380
tailrec fun gcd(a:Int,b:Int):Int=if(b==0) a else gcd(b,a%b)

fun main() {
	val n=readLine()!!.toInt()
	println((1..n).asSequence()
			.flatMap {a-> (1..n).asSequence().map {b-> gcd(a,b)}}
			.flatMap {a-> (1..n).asSequence().map {b-> gcd(a,b)}}
			.sum())
}


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

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //入力終了

  // a[i]^a[i+1]^a[i+2] = 0と
  // a[i+1]^a[i+2]^a[i+3] = 0より  
  // a[i]^a[i+3] = 0が成り立ち
  // a[i] = a[i+3]

  // a[i] = xとするとa[]は
  // x, y, z, x, y, z, x, y, z, ....
  // と並び変えられる

  sort(a, a+N);

  // 0 0 0 0 0 , ....のとき
  if(a[0] == a[N-1] && a[0] == 0){
    cout << "Yes" << endl;
    return 0;
  }
  
  // Nが3の倍数でないとダメ
  if(N%3 != 0){
    cout << "No" << endl;
    return 0;
  }

  // y = zのとき
  // x y y x y y x y y , ....
  // x^y^y = 0 より，x=0
  // 0 y y 0 y y 0 y y , ....のとき
  // 最初のN/3項が0で，残りがすべてy
  if(a[N/3-1] == 0 && a[N/3] == a[N-1]){
    cout << "Yes" << endl;
    return 0;
  }

  // y != zのとき
  // x y z x y z , ....
  if(a[0] == a[N/3-1] && a[N/3] == a[N*2/3-1] && a[N*2/3] == a[N-1]){
    if((a[0]^a[N/3]^a[N*2/3]) == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
  }

  
  cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
long long int waru=1000000007;

int main(){
  long long int n;
  cin >> n;
  long long int a[n],b[n];
  for(int i=0;i<n;i++)b[i]=0;
  for(int i=0;i<n;i++){
    cin >>a[i];
    b[a[i]]++;
  }
  long long int ans=1;
  sort(a,a+n);
  if (n%2==0){
    bool x=true;
    for(int i=0;i<n;i++)if((i%2==1 && b[i]!=2) || (i%2!=1 && b[i]!=0))x=false;
    if(!x)cout << 0 <<endl;
    else {
      for(int i=0;i<n/2;i++)ans=ans*2%waru;
      cout << ans <<endl;
    }
  }
  else{
    bool x=true;
    for(int i=1;i<n;i++)if((i%2==0 && b[i]!=2) || (i%2!=0 && b[i]!=0))x=false;
    if(b[0]!=1 || !x)cout << 0 <<endl;
    else {
      for(int i=0;i<(n-1)/2;i++)ans=ans*2%waru;
      cout << ans <<endl;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  
  if ((N % 1000) % 111 == 0 || (N - N % 10) % 111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int dp[200000], ar[200000];
    for(int i = 0; i < n; i++) {
        cin >> ar[i];
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i = 0; i < n - 1; i++) {
        dp[i + 1] = min(dp[i + 1], abs(ar[i] - ar[i + 1]) + dp[i]);
        dp[i + 2] = min(dp[i + 2], abs(ar[i] - ar[i + 2]) + dp[i]);
    }
    cout << dp[n - 1] << endl;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
ll mplus(string s){
   ll ans=0,k=0;
   for(int i=0;i<=s.size();i++){
      if(s[i]=='+'||i==s.size()){
         ans+=k;
         k=0;
      }
      else{
         k=10*k+(s[i]-48);
      }
   }

   return ans;
}

int main(){
   string s;cin>>s;
   int n=s.size();
   vector<string> v;
   for(int bits=0;bits<(1<<n-1);bits++){
      string k=s;
      int b=1;
      rep(i,n){
        if(bits & (1<<i)){
           k.insert(k.begin()+i+b,'+');
           b++;
        }
      }
      v.push_back(k);
   }
   ll ans=0;
   for(auto e:v){
      ans+=mplus(e);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
#define endl '\n'
//char a[2000][2000];
using namespace std;
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);            
    //std::setprecision(20);    
    int tests=1;
      //freopen("input.txt", "r", stdin);   
    //cin>>tests;
  while(tests--)
    { 
      string s;
      cin>>s;
      if(s[0] == s[1] || s[1]==s[2]|| s[2]==s[3]){
        cout<<"Bad";
        exit(0);
      }
      else{
        cout<<"Good";
      }
    }
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  int n;
  cin >> n;
  vi v(n);
  REP(i, n) cin >> v[i];

  map<int, int> a1;
  map<int, int> a2;

  for (int i = 0; i < n; i += 2) {
    a1[v[i]]++;
  }
  for (int i = 1; i < n; i += 2) {
    a2[v[i]]++;
  }

  vector<pii> b1, b2;

  for (auto p : a1) {
    b1.push_back(make_pair(p.second, p.first));
    // cout << " 1 " << p.first << " : " << p.second << endl;
  }
  for (auto p : a2) {
    b2.push_back(make_pair(p.second, p.first));
    // cout << " 2 " << p.first << " : " << p.second << endl;
  }

  sort(b1.begin(), b1.end());
  sort(b2.begin(), b2.end());

  auto x1 = b1[b1.size() - 1];
  pii x2;
  if (b1.size() > 1)
    x2 = b1[b1.size() - 2];
  else
    x2 = make_pair(0, 0);

  auto y1 = b2[b2.size() - 1];
  pii y2;
  if (b2.size() > 1)
    y2 = b2[b2.size() - 2];
  else
    y2 = make_pair(0, 0);

  if (x1.second != y1.second)
    cout << n - x1.first - y1.first << endl;
  else {
    if (x1.first > y1.first) {
      cout << n - x1.first - y2.first << endl;
    } else if (y1.first > x1.first) {
      cout << n - x2.first - y1.first << endl;
    } else {
      cout << n - x1.first - max(x2.first, y2.first) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6520
import java.util.*;

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

        String s = sc.next();
        int ans = 0;
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A' || s.charAt(i) == 'C' || s.charAt(i) == 'G' || s.charAt(i) == 'T') {
                count++;
                ans = Math.max(ans, count);
            } else {
                count = 0;
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    int x, y;
};

int main() {
    int n;
    cin >> n;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int a = p[i].x - p[j].x;
            int b = p[i].y - p[j].y;
            if (a < 0) a *= -1, b *= -1;
            if (a == 0 && b < 0) b *= -1;
            int t = 0;
            for (int i1 = 0; i1 < n; i1++) {
                for (int j1 = 0; j1 < i1; j1++) {
                    int a1 = p[i1].x - p[j1].x;
                    int b1 = p[i1].y - p[j1].y;
                    if (a1 < 0) a1 *= -1, b1 *= -1;
                    if (a1 == 0 && b1 < 0) b1 *= -1;
                    if (a == a1 && b == b1) t++;
                }
            }
            r = max(r, t);
        }
    }

    cout << n - r << endl;

    //2駒関係はN*(N-1)/2通り 全列挙してどれかを選ぶ 全部試す
    //そりゃそうだ いや正しい 

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int q=998244353;
inline int Plus(int x,int y) {return x+y>=q?(x+y-q):(x+y);}
inline int Sub(int x,int y) {return x<y?(x-y+q):(x-y);}
inline int Multi(int x,int y) {return 1ll*x*y%q;}
inline int& Pe(int &x,int y) {return x=Plus(x,y);}
inline int& Se(int &x,int y) {return x=Sub(x,y);}
inline int& Me(int &x,int y) {return x=1ll*x*y%q;}
inline int mi(int x,int y) {
	int ret(1);
	for (;y;y>>=1,Me(x,x)) if (y&1) Me(ret,x);
	return ret;
}
inline int inv(int x) {return mi(x,q-2);}
const int maxw=1e6+10;
const int maxn=2e5+10;
const int inv2=499122177;
namespace mat {
	int p[maxw],ps=0,mu[maxw],inv[maxw];
	bool np[maxw];
	void init() {
		mu[1]=1;
		for (int i=2;i<maxw;++i) {
			if (!np[i]) p[++ps]=i,mu[i]=q-1;
			for (int j=1,k;j<=ps && (k=i*p[j])<maxw;++j) {
				np[k]=true;
				if (i%p[j]==0) break;
				mu[k]=Sub(0,mu[i]);
			}
		}
		for (int i=1;i<maxw;++i) inv[i]=::inv(i);
	}
	int __initer__=(init(),0);
}
int n,c[maxw],a[maxn],sum=0,ans=0;
int F[maxw],G[maxw];
int main() {
	n=read();
	for (int i=1;i<=n;++i) {
		a[i]=read();
		++c[a[i]];
		Pe(sum,a[i]);
	}
	for (int d=1;d<maxw;++d) {
		for (int i=d,j=1;i<maxw;i+=d,++j) {
			Pe(G[i],Multi(mat::inv[d],mat::mu[j]));
			Pe(F[d],Multi(i,c[i]));
		}
		Me(F[d],F[d]);
	}
	for (int i=1;i<maxw;++i) Pe(ans,Multi(F[i],G[i]));
	ans=Multi(Sub(ans,sum),inv2);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 22784
x, y = map(int, input().split())
ans = 10**9 + 10
if x == y:
    ans = 0
else:
    #1
    ans1 = y-x
    ans2 = (-y)-(-x) + 2
    ans3 = y-(-x) + 1
    ans4 = (-y)-x + 1
    if ans1 > 0:
        ans = min(ans, ans1)
    if ans2 > 0:
        ans = min(ans, ans2)
    if ans3 > 0:
        ans = min(ans, ans3)
    if ans4 > 0:
        ans = min(ans, ans4)

print(ans)


Measured memory_bytes: 9136
import sys
from collections import deque


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
q = inint()

S = deque()
f = [0,1]

for i in range(len(s)):
    S.append(s[i])

for i in range(q):
    Q = instrl()
    if Q[0] == "1":
        f = f[::-1]
    else:
        if f[0] == 0:
            if Q[1] == "1":
                S.appendleft(Q[2])
            else:
                S.append(Q[2])
        else:
            if Q[1] == "1":
                S.append(Q[2])
            else:
                S.appendleft(Q[2])

if f[0] == 1:
    S.reverse()

print("".join(S))

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main(){
int k,a,b;
  bool f=0;
  int re=0;
cin >>k >>a >>b;
 for(int i=1; i<=b; i++){
    re=k*i;
   if(a<=re and re<=b){
        f=1;
    }
 }

     if(f==1)cout <<"OK" <<endl;
  else cout <<"NG" <<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 200005
const llong mod = 1000000000 + 7;

int N, K;
int memo[MAX];

int main()
{
  llong sum = 0;
  scanf("%d%d", &N, &K);

  llong low = 0, high = 0;
  for (int i = 0; i < N + 1; i++)
  {
    low += i;
    high += N - i;
    if (i + 1 >= K)
    {
      sum += high - low + 1;
      sum %= mod;
    }
  }

  printf("%d", sum);

  return 0;
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	int deleted = 0;
	int counter = 1;
	for(int i = 0; i < N; i++){
		int number; 
		cin >> number;
		if(number != counter){
			deleted++;
			continue;
		}
		counter++;
	}
	
	if(deleted == N)
		cout << "-1";
	else
		cout << deleted;
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll mod=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(a) LIN(b) LIN(c)
    ll ans;
    ans = fmax( a * 10 + b + c, a + b * 10 + c );
    ans = fmax( ans, a + b + c * 10 );
    puta( ans );
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;

int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if(a > b){
		puts("0");
		return 0;
	}
	if(n == 1){
		if(a == b)puts("1");
		else puts("0");
		return 0;
	}
	if(n == 2){
		puts("1");
		return 0;
	}
	n -= 2;
	printf("%lld\n", 1LL * b * n - 1LL * a * n + 1);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n;
vector<ll> edge[MAXN];
ll dp[MAXN][2];

ll DFS(ll nd,bool b,ll par) {
    if (dp[nd][b] != -1) {
        return dp[nd][b];
    }

    dp[nd][b] = 1;
    if (b) {
        for (auto v:edge[nd]) {
            if (v != par) {
                dp[nd][b] = (dp[nd][b] * DFS(v,0,nd)) % MOD;
            }
        }
    } else {
        for (auto v:edge[nd]) {
            if (v != par) {
                dp[nd][b] = (DFS(v,1,nd) + DFS(v,0,nd)) * dp[nd][b] % MOD;
            }
        }
    }
    return dp[nd][b];
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n-1) {
        ll u,v;
        cin >> u >> v;
        edge[u].eb(v);
        edge[v].eb(u);
    }

    MEM(dp,-1);
    cout << (DFS(1,0,1) + DFS(1,1,1))  % MOD << endl;
    return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

map<string,int> m;
int32_t main(){
	int n;
	string s;
	cin>>n;
	while(n--){
		cin>>s;
		sort(all(s));
		m[s]++;
	}
	int ans = 0;
	for(auto x: m){
		//cout<<x.first<<" "<<x.second<<"\n";
		int t = x.second;
		ans += (t*(t-1))/2;
	}
	cout<<ans;
}


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

int main(){
  string s;
  int flag_a=0;
  int flag_b=0;
  int flag_c=0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='a'){
      flag_a++;
    }else if(s.at(i)=='b'){
      flag_b++;
    }else{
      flag_c++;
    }
  }
  int MAX= max(flag_a,max(flag_b,flag_c));
  if(flag_a>=MAX-1 && flag_b>=MAX-1 && flag_c>=MAX-1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n-1):
            for j in range (i+1,n):
                for k in range (j+1,n+1):
                    if i+j+k==x:
                        count=count+1
        print(count)


Measured memory_bytes: 5592
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  S = readline()
  T = readline()
  sum=0
  if occursin(T,S)
    println(0)
  elseif T==""
    println(0)
  else
    tmax=0
    for i in 1:length(S)-length(T)+1
      tmp=0
      la = length(T)
      if i > length(S)-length(T)+1
        la = length(S)-i
      end
      for j in 1:la
        if S[i+j-1] == T[j]
          tmp += 1
        end
      end
      if tmax < tmp
        tmax = tmp
      end
    end
    println(length(T)-tmax)
  end
end
main()


Measured memory_bytes: 157964
#include  <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int x[n],i=0;
int z=0;
for (;i<n;i++){
cin>>x[i];
if(z==0&&i>0){
int j=i-1;
if(x[j]==x[i]||x[j-1]==x[i])
z++;
}
}
if(z==0){
sort(x,x+n);
int j=n-1;
int m=n/2+1;
int k=n/2-1;
for (int i=0;i<n/4+2;i++){
if(x[i+1]==x[i]||x[j]==x[j-1]||x[m]==x[m-1]||x[k]==x[k+1]){
z++;
break;
}
else{
j--;
m++;
k--;
}
}
}
if(z==0)
cout<<"YES";
else
cout<<"NO";
return 0;
}


Measured memory_bytes: 4396
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n - 2):
    a, b, c = p[i], p[i + 1], p[i + 2]
    if (b > a and b <= c) or (b <= a and b > c):
        ans += 1
print(ans)

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <fstream>
using namespace std;
signed main(void)
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int cnt = 0;
	cnt += (a[1] - a[0]) / 2;
	a[0] += (a[1] - a[0]) / 2 * 2;
	if (a[1] - a[0] == 1) { cnt += 1; a[0] += 1; a[2] += 1; }
	cout << cnt + a[2] - a[1];
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

    static PrintStream out = System.out;


    static void solve(Scanner in){


        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();

        int num = B / A;
        if(num >= C) out.println(C);
        else out.println(num);

    }

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

Measured memory_bytes: 25300
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
  
	lli ma = 0, mi = 0,v=1000000000,sum=0;
	int n,m=1;
    int i,j,k;
    cin>>n;
	vector<int> x(n);
	for(i = 0; i < n; ++i) {
		cin >> x.at(i);
      if(i!=0&&x.at(0)!=x.at(i))
        m=0;
	}
  if(m==1){
    cout<<0<<endl;
    return 0;
  }
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
	st(x);
	ma = x.at(n-1);
	mi = x.at(0);
	for(i = 0;i<ma-mi+1; ++i) {
      sum=0;
		for(j = 0; j <n; ++j) {
          sum+=pow((x.at(j)-i),2);
		}
        if(sum<v)
            v=sum;
	}
  cout<<v<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    rrep(i,n,1000){
        string s=to_string(i);
        if(s[0]==s[1]&&s[1]==s[2]){
            std::cout << i << std::endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  vector<ll>cnt(3);
  map<char,ll>mp={{'R',0},{'G',1},{'B',2}};
  rep(i,0,n)cnt[mp[s[i]]]++;
  res=cnt[0]*cnt[1]*cnt[2];
  rep(i,0,n)rep(j,i+1,n){
    if((j-i)%2!=0)continue;
    ll m=(i+j)/2;
    if(s[i]!=s[j]&&s[i]!=s[m]&&s[m]!=s[j])res--;
  }
  cout<<res<<endl;
  return 0;
}

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

int n, s;

int countAns(int sum, int pos, int last){
	int ans = 0;
	if (pos > n) {
		return 0;
	}else if(pos==n && sum==s){
		return 1;
	}else if(sum > s){
		return 0;
	}

	for (int i = last+1; i < 10; i++) {
		ans += countAns(sum+i, pos+1, i);
	}
	return ans;
}

int main(){
	while(cin >> n >> s){
		if(n==0 && s==0){
			break;
		}
		cout << countAns(0,0,-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n;i++)
 
int main()
{
    string N;
    cin >> N;
    if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	N := nextInt()
	sw := 1
	for i := 0; i < N; i++ {
		A := nextInt()
		if A%2 != 0 {
			sw *= -1
		}
	}
	if sw > 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 2176