akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a+b+c==17 && (a==5||a==7) && (b==5||b==7)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s;
  cin >> s;

  ll len = s.size();
  s.erase(len - 1);

  while (true) {
    len = s.size();

    if (len % 2 == 1) {
      s.erase(len - 1);
      continue;
    }
    if (s.substr(0, len / 2) == s.substr(len / 2, len - 1)) {
      break;
    } else {
      s.erase(len - 1);
      continue;
    }
  }
  cout << len << "\n";
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		char[] S = sc.next().toCharArray();

		HashMap<Character, Integer> abcMap = new HashMap<Character, Integer>();
		for (char c : Const.alp) {
			abcMap.put(c, 0);
		}
		for (char c : S) {
			int value = abcMap.get(c);
			abcMap.put(c, ++value);
		}
		boolean None = true;
		for (int i = 0; i < Const.alp.length; i++) {
			int value = abcMap.get(Const.alp[i]);
			if (value == 0) {
				System.out.println(Const.alp[i]);
				None = false;
				return;
			}
		}
		if (None)
			System.out.println("None");
	}
}

class Const {
	final static char[] alp = "abcdefghijklmnopqrstuvwxyz".toCharArray();

}


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

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			List<Integer> lines = new ArrayList<>();
			while(sc.hasNext()) {
				lines.add(Integer.valueOf(sc.nextInt() + sc.nextInt()));
			}
			for (int i = 0; i < lines.size(); i++) {
				System.out.println(String.valueOf(lines.get(i)).length());
			}
		}
	}
}

Measured memory_bytes: 26296
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    int m;
    void solve()
    {
    	cin>>n>>m;
    	if(n==m)
    		cout<<"Yes"<<endl;
    	else
    		cout<<"No"<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define sort(x) sort(ALL(x))
#define ALL(v) v.begin(), v.end()
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	int cnt = 0;
	string s;
	cin >> s;
	rep(i,0,s.size()){
		if(s[i] == 'o')cnt++;
	}
	if(8 <=  15-(ll)s.size()+cnt) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++) //(i, 0, n)でi=0~n-1までn回
#define REPn(i, a, n) for(int i=a; i<=n; i++) //(i, 1, n)でi=1~nまでn回
#define sortv(v) sort(v.begin(), v.end());
#define sortg(v) sort(v.begin(), v.end(), greater<>());
#define rev(v) reverse(v.begin(), v.end()); //逆順に並べ替え

int main() {
  int n, cnt=0, tmpAB=0, tmpB=0, tmpA=0;
  cin >> n;
  string AB[n];
  REP(i, 0, n) cin >> AB[i];
  REP(j, 0, n){
    REP(k, 0, AB[j].size()-1){
      if(AB[j].substr(k, 1)=="A" && AB[j].substr(k+1, 1)=="B") cnt++;
    }
  }
  REP(l, 0, n){
    if(AB[l].substr(0, 1)=="B" && AB[l].substr(AB[l].size()-1, 1)=="A") tmpAB++;
    if(AB[l].substr(0, 1)=="B" && AB[l].substr(AB[l].size()-1, 1)!="A") tmpB++;
    if(AB[l].substr(0, 1)!="B" && AB[l].substr(AB[l].size()-1, 1)=="A") tmpA++;
  }
  int outAB;
  if(n==1)cout << cnt;
  else{
    if(tmpA!=0 || tmpB!=0)outAB=min(tmpAB+tmpA, tmpAB+tmpB);
    else{
      if(tmpAB!=0)outAB=tmpAB-1;
      if(tmpAB==0)outAB=0;
    }
    cout << cnt+outAB << endl;
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char,ll> m;
    ll ans=0;
    for(int i=0;i<n;i++){
        m[s.at(i)]++;
    }
ans = m['R'] * m['G'] * m['B'];
  ll err=0;
    for(int i=0;i<n;i++){
        for(int k=i+1;k<n;k++){
            if((k+i)%2==0){
                if(s.at(i) != s.at(k) && s.at(k) !=s.at((k+i)/2) && s.at((k+i)/2) != s.at(i)){
                    err++;                
                }
            }
        }
    }
    cout << ans - err << endl;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
	int i, N;
	long long A[100000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long sum = 0, tmp;
	for (i = 1; i <= N; i++) sum += A[i];
	for (i = 1, tmp = sum; i <= N / 2; i++) tmp -= A[i*2] * 2;
	printf("%lld ", tmp);
	for (i = 2; i <= N; i++) {
		tmp = A[i-1] * 2 - tmp;
		printf("%lld ", tmp);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int gcd(int a, int b){
   if(a > b){int tmp = a; a = b; b = tmp;} // make sure a <= b 
   int r = b % a;
   return r == 0 ? a : gcd(r, a); // gcd(a, b) = gcd(b % a, a)
}

int main(void) {
   int n;
   scanf("%d\n", &n);
   int ans;
   scanf("%d", &ans);
   for (int i = 0; i < n - 1; i++) {
      int x;
      scanf("%d", &x);
      ans = gcd(ans, x);
   }
   printf("%d\n", ans);
   return 0;
}


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

vector<vector<long long>> multi(vector<vector<long long>> m1,vector<vector<long long>>m2) //正方行列に対する積
{
	int n=m1.size();
	vector<vector<long long>> ans(n,vector<long long> (n,0));
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			for (int k=0;k<n;k++)
			{
				ans[i][j]=(ans[i][j]+m1[i][k]*m2[k][j]%mod)%mod;
			}
	
return ans;
}
vector<vector<long long>> power(vector<vector<long long>> m1,long long r)
{
	if (r==1) return m1;
	else
	{
		vector<vector<long long>> ans;
		ans=power(m1,r/2);
		if (r%2==0) return multi(ans,ans);
		else return multi(multi(ans,ans),m1);
	}	
}

int main()
{
	ll N,K; cin >> N>>K;
	vector<vector<ll>> a(N,vector<ll> (N));
	for (int i=0;i<N;i++)
		for (int j=0;j<N;j++)
			cin >> a[i][j];
	a=power(a,K);
	ll ans=0;
	for (int i=0;i<N;i++)
		for (int j=0;j<N;j++) ans=(ans+a[i][j])%mod;
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {    
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
      s.useDelimiter("\n");
      int n = s.nextInt();
      String str = s.next().toString();


      int sLen = str.length() / 2;
      String ans = "";
      String s1 = str.substring(0, sLen).toString();
      String s2 = str.substring(sLen).toString();

      if (s1.equals(s2)) {
        ans = "Yes";
      } else {
        ans = "No";
      }

      if (n % 2 == 1) {
        ans = "No";
      }

      System.out.println(ans);

	
  }
}


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int q;
  cin >> q;;
  deque<int> a;

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int d; cin >> d;
      int x; cin >> x;
      if (d) a.push_back(x);
      else a.push_front(x);
    } else if (command == 1) {
      int p; cin >> p;
      ans.push_back(a[p]);
    } else {
      int d; cin >> d;
      if (d) a.pop_back();
      else a.pop_front();
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 4576
li=list(input())
A=int(li[0])
B=int(li[1])
C=int(li[2])
D=int(li[3])
if A+B+C+D==7:
  print(li[0]+'+'+li[1]+'+'+li[2]+'+'+li[3]+'=7')
  
elif A+B+C-D==7:
  print(li[0]+'+'+li[1]+'+'+li[2]+'-'+li[3]+'=7')
  
elif A+B-C+D==7:
  print(li[0]+'+'+li[1]+'-'+li[2]+'+'+li[3]+'=7')

elif A+B-C-D==7:
  print(li[0]+'+'+li[1]+'-'+li[2]+'-'+li[3]+'=7')

elif A-B+C+D==7:
  print(li[0]+'-'+li[1]+'+'+li[2]+'+'+li[3]+'=7')
  
elif A-B+C-D==7:
  print(li[0]+'-'+li[1]+'+'+li[2]+'-'+li[3]+'=7')
  
elif A-B-C+D==7:
  print(li[0]+'-'+li[1]+'-'+li[2]+'+'+li[3]+'=7')

elif A-B-C-D==7:
  print(li[0]+'-'+li[1]+'-'+li[2]+'-'+li[3]+'=7')


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

using namespace std;

struct Union_Find {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
    
    Union_Find(int size) : data(size, -1) {}
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }
    int Find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = Find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }
    bool same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -data[Find(x)];
    }
};

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, L;
	cin >> N >> K >> L;
	Union_Find uf1(N), uf2(N);
	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;
		uf1.Union(p, q);
	}
	for (int i = 0; i < L; i++) {
		int r, s;
		cin >> r >> s;
		r--;
		s--;
		uf2.Union(r, s);
	}
	
	vector<P> p(N);
	map<P, int> mp;
	for (int i = 0; i < N; i++) {
		p[i].first = uf1.Find(i);
		p[i].second = uf2.Find(i);
		mp[p[i]]++;
	}

	for (int i = 0; i < N; i++) {
		cout << mp[p[i]];
		if (i != N - 1) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
 
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int X = sc.nextInt();
      
      if(A <= X && A + B >= X) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
      sc.close();
    }
}

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

static SUIT: &'static [&'static str] = &["S", "H", "C", "D"];

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines();
  let n = lines.next().unwrap().unwrap().parse::<u64>().unwrap();

  let mut cards = [[false; 13]; 4];

  for _ in 0..n {
    let line = lines.next().unwrap().unwrap();
    let mut args = line.split_whitespace();
    let s = args.next().unwrap();
    let r = args.next().unwrap().parse::<usize>().unwrap();

    let s = SUIT.iter().position(|suit| &s == suit).unwrap();
    cards[s][r - 1] = true;
  }

  let stdout = stdout();
  let mut stdout = BufWriter::new(stdout.lock());

  for (suit, c) in cards.into_iter().enumerate() {
    for (rank, has) in c.into_iter().enumerate() {
      if !has {
        writeln!(stdout, "{} {}", SUIT[suit], rank + 1).unwrap();
      }
    }
  }
}



Measured memory_bytes: 5028
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC120B
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            var g = Gcd(s[0],s[1]);

            var anslst = new List<int>();
            for(int i = 1; i <= g; i++)
            {
                if (g % i == 0)
                {
                    anslst.Add(i);
                }
            }

            anslst.Sort((x,y)=>y.CompareTo(x));
            Console.WriteLine(anslst[s[2] - 1]);
        }


        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
    }
}




Measured memory_bytes: 13268
use std::collections::VecDeque;

fn main() {
    let mut first_line = String::new();
    std::io::stdin().read_line(&mut first_line).unwrap();
    let _n: usize = first_line.trim().parse().unwrap();
    let mut second_line = String::new();
    std::io::stdin().read_line(&mut second_line).unwrap();
    let s = second_line.trim();

    let mut queue = VecDeque::<char>::new();
    for slime in s.chars() {
        match queue.pop_back() {
            None => queue.push_back(slime),
            Some(back) => {
                queue.push_back(back);
                if slime != back {
                    queue.push_back(slime);
                }
            }
        }
    }
    print!("{}", queue.len())
}


Measured memory_bytes: 4352
N = int(input())
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A.sort()
A2 = [True for i in range(A[-1] + 1)]
for i in range(len(A)):
    k = A[i] * 2
    if A2[A[i]]:
        if i != 0 and A[i-1] == A[i]:
            A2[A[i]] = False
        while(k < len(A2)):
            A2[k] = False
            k += A[i]
for i in A:
    if A2[i]:
        ans += 1
print(ans)

Measured memory_bytes: 162684
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        string a,b;
        cin >> a >> b;
        int n,m;
        cin >> n >> m;
        string c;
        cin >> c;
        if(a==c)n--;
        else if(b==c)m--;
        cout << n << ' ' << m << '\n';
        
        

}


Measured memory_bytes: 256
d={'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, \
   'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, \
   't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26, \
   'A': 27, 'B': 27, 'C': 27, 'D': 27, 'E': 27, 'F': 27, 'G': 27, 'H': 27, 'I': 27, 'J': 27, \
   'K': 27, 'L': 27, 'M': 127, 'N': 27, 'O': 27, 'P': 27, 'Q': 277, 'R': 27, 'S': 27, \
   'T': 27, 'U': 27, 'V': 227, 'W': 27, 'X': 27, 'Y': 27, 'Z': 227,}
a=input()
if 1<=d[a]<=26:
    print("a")
else:
    print("A")


Measured memory_bytes: 61500
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for(int i=0; i<=k; i++) for(int j=i; j<=k; j++) for(int l=j; l<=k; l++){
        //cout << i << ' ' << j << ' ' << l;
        if(i+j+l == s){
            //cout << " ok";
            if(i == j && j == l) ans++;
            if(l == i && i != j) ans += 3;
            if(i == j && j != l) ans += 3;
            if(j == l && l != i) ans += 3;
            if(i != j && j != l && l != i) ans += 6;
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n,i,j,a[4010],dp[4010][3];
    string s;
    cin >> n >> s;
    for (i,0,n)
    {
        a[i]=0;
        if (s[i]=='G')
            a[i]=1;
        if (s[i]=='B')
            a[i]=2;
    }
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    dp[0][a[0]]=1;
    for (i,1,n)
    {
        for (j,0,3)
            dp[i][j]=dp[i-1][j];
        dp[i][a[i]]++;
    }
    ll k = 0;
    for (i,0,n-3)
        for (j,i+1,n-1)
            if (a[i]!=a[j])
        {
            int q = 3-a[i]-a[j];
            k+=(dp[n-1][q]-dp[j][q]);
            if (j+j-i<n && a[j+j-i]==q)
                k--;
        }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 3656
n = gets.to_i
n.times do
  s = gets.chomp
  data = s.split(//)#.map(&:to_i)
  
  max = data.sort{|a,b| b<=>a}.join.to_i
  data.delete("0")
  min = data.sort.join("").to_i
  p max - min
end

Measured memory_bytes: 6096
import java.util.Scanner;
public class Main{

	public static void main (String [] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve() {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String s = scanner.next();

		String [] list = new String [N];
		list=s.split("");

		int countR = 0;
		int countB = 0;

		for (int index=0; index<N; index++) {
		if (list[index].equals("R")) {
			countR++;
		} else {
			countB++;
		}
		}
		if (countR>countB) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21588
import sys
import heapq

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def all_group_memberss(self):
        return [self.size(r) for r in self.roots()]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = [int(x) for x in input().split()]
    AB = [[int(x) for x in input().split()] for _ in range(M)]

    uf = UnionFind(N)

    for a, b in AB:
        uf.union(a - 1, b - 1)

    hq = []
    for k in uf.all_group_memberss():
        heapq.heappush(hq, k)

    ans = 0
    prev = 0
    while hq:
        c = heapq.heappop(hq)
        if prev != c:
            ans += (c - prev)
            prev = c

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 115208
/* In the name of ALLAH */
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>

// MAXIMUM and MINIMUM elements
#define mx_ari(a)   *max_element(a , a+sizeof(a)/4)
#define mn_ari(a)   *min_element(a , a+sizeof(a)/4)
#define mx_arl(a)   *max_element(a , a+sizeof(a)/8)
#define mn_arl(a)   *min_element(a , a+sizeof(a)/8)
#define mx_vec(v)   *max_element(v.begin() , v.end())
#define mn_vec(v)   *min_element(v.begin() , v.end())
// COUNT the occurence of an element
#define cnt_ari(a,b)   count(a , a+sizeof(a)/4 , b)
#define cnt_arl(a,b)   count(a , a+sizeof(a)/8 , b)
#define cnt_vec(v,b)   count(v.begin() , v.end() , b)
// INPUTs
#define sci(a)        scanf("%d",&a)
#define scii(a,b)     scanf("%d %d",&a,&b)
#define sciii(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scl(a)        scanf("%lld",&a)
#define scll(a,b)     scanf("%lld %lld",&a,&b)
#define sclll(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define scf(a)        scanf("%f",&a)
#define scff(a,b)     scanf("%f %f",&a,&b)
#define scfff(a,b,c)  scanf("%f %f %f",&a,&b,&c)
#define scd(a)        scanf("%ld",&a)
#define scdd(a,b)     scanf("%lf %lf",&a,&b)
#define scddd(a,b,c)  scanf("%lf %lf %lf",&a,&b,&c)
// OUTPUTs
#define pri(a)        printf("%d ",a)
#define prii(a,b)     printf("%d %d ",a,b)
#define priii(a,b,c)  printf("%d %d %d ",a,b,c)
#define prl(a)        printf("%lld ",a)
#define prll(a,b)     printf("%lld %lld ",a,b)
#define prlll(a,b,c)  printf("%lld %lld %lld ",a,b,c)
#define prd(a)        printf("%.4lf ",a)
#define prdd(a,b)     printf("%.4lf %.4lf ",a,b)
#define prddd(a,b,c)  printf("%.4lf %.4lf %.4lf ",a,b,c)
#define prf(a)        printf("%.4f ",a)
#define prff(a,b)     printf("%.4f %.4f ",a,b)
#define prfff(a,b,c)  printf("%.4f %.4f %.4f ",a,b,c)
// LOOPs
#define foi(i,n)      for(int i=0;i<n;i++)
#define fol(i,n)      for(long long int i=0;i<n;i++)
#define fod(i,n)      for(double i=0;i<n;i++)
#define fof(i,n)      for(float i=0;i<n;i++)
// NEWLINEs
#define nwl           << "\n"
#define nl            printf("\n");
// PAIRs and PUSHbacks
#define mp            make_pair
#define pb            emplace_back
// IMPORTANTs
#define ll          long long
#define ull         unsigned long long int
#define mod         1000000007
#define lcm(a,b)     (a*b) / __gcd(a,b)

using namespace std;


int cost[100010];
int chi(int i , int n ,int k, int a[]){
   if(i < 0){
      return cost[0];
   }

   int cnt = 0;
   int mn = INT_MAX;
   for(int j=i+1; ;j++){
      int mini = abs(a[i] - a[j]) + cost[j];
      mn = min(mn , mini);
      cnt++;
      if(cnt == k){break;}
   }
   cost[i] = mn;
   return chi(i-1 , n , k , a);
}

int main()
{
   int n,k;
   cin >> n >> k;
   int a[n];
   foi(i,n){
      cin >> a[i];
   }

   cost[n-1] = 0;
   int cnt = 0;
   for(int i=n-2;i>=0;i--){
      cost[i] = abs(a[n-1] - a[i]);
      cnt++;
      if(cnt == k){break;}
   }

   cout << chi(n-k-2 , n , k , a);

   return 0;
}

Measured memory_bytes: 4360
//Volume5-0502
import java.util.*;

class Main {
	
	private static int[][][] t = {{{1,2,3},{2,3,4}},
		                          {{2,2,0},{5,4,2}},
		                          {{0,0,3},{1,3,5}}};
	
	private static int[] dice;
	private static int   sum;
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n;
		String s;
		while((n=sc.nextInt())!=0){
			init();
			while(n-- > 0){
				s=sc.next();
				if     (s.equals("North")){change(0,0);}
				else if(s.equals("South")){change(0,1);}
				else if(s.equals("East")) {change(1,0);}
				else if(s.equals("West")) {change(1,1);}
				else if(s.equals("Right")){change(2,0);}
				else if(s.equals("Left")) {change(2,1);}
				sum+=dice[2];
			}
			System.out.println(sum);
		}
	}

	private static void init(){
		sum  = 1;
		dice = new int[6];
		int[] init = {4,5,1,2,6,3}; 
		for(int i=0;i<6;i++){
			dice[i] = init[i];
		}
	}

	private static void change(int a,int b){
		int init,limit,incr;
		if   (b==0){init=0; limit= 3; incr= 1;}
		else       {init=2; limit=-1; incr=-1;}
		for(int i=init;i!=limit;i+=incr){
			swap(t[a][0][i],t[a][1][i]);
		}
	}
	
	private static void swap(int i,int j){
		dice[j]  = dice[i] - dice[j];
		dice[i] -= dice[j];
		dice[j] += dice[i];
	}
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  cout << (n-1)*(m-1) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
/**
*    created: 02.08.2020 18:41:49
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// Template for ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;
mint fac[MAX], finv[MAX], inv[MAX];

// Combination Table
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep2(i,2,MAX){
        fac[i] = fac[i-1] * (mint)i;
        inv[i] = (mint)MOD - inv[MOD%i] * (mint)(MOD/i);
        finv[i] = finv[i-1] * inv[i];
    }
}

// nCk
mint COM(int n,int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    COMinit();
    rep2(i,1,k+1) {
        mint ans = 1;
        ans *= COM(k-1,i-1);
        int a = n-k;
        if (a < i-1) ans = 0;
        else ans *= COM(n-k+1,i);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 27036
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, a, b;

    cin >> n >> a >> b;

    cout << min(n * a, b) << endl;
}

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

// -- prop methods ----------
template<class T> inline T sq(T x){return x*x;}
template<class T> inline int sgn(T x){return x?(x>0?1:-1):0;}
// -- geometry -------------
double rad2deg(double radian){return radian/3.141592653589*180;}
double deg2rad(double degree){return degree/180*3.141592653589;}
double normalizeAngle(double a/*degree*/){ // return val is in [0...180] deg.
  while (a<0||a>360){ a += a<0? 360: -360; }  
  return a>180? 360-a: a;
}

int main(void){
  int a,b,h,m;
  double th, ph, angle;
  double ans;
  
  cin >> a >> b >> h >> m;
  th = 360.0*h/12 + 30.0*m/60;
  ph = 360.0*m/60;
  angle = deg2rad(normalizeAngle(th-ph));
  ans = sqrt(sq(a)+sq(b)-2*a*b*cos(angle));
  cout << setprecision(12);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  int sumL = 0;
  int sumR = 0;
  vector<int> w(n);
  rep(i, n) {
    cin >> w[i];
    sumR += w[i];
  }
  int ans = sumR;
  rep(i, n) {
    sumL += w[i];
    sumR -= w[i];
    ans = min(ans, abs(sumR - sumL));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    unsigned long n,a[10000000],ans =0 ;
    cin>>n;
    for(unsigned long i=0;i<n;i++)
    {
        cin>>a[i];
        ans = ans^a[i];
    }
    int r[10000000];
    for(unsigned long i=0;i<n;i++)
    {
        r[i] = ans ^a[i];
    }
    for(unsigned long i=0;i<n;i++)
    {
        cout<<r[i]<<" ";
    }
}


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

int main() {
	vector<int> A(3);
	int ans;
	cin >> A[0] >> A[1] >> A[2];
	sort(A.begin(),A.end());
	ans = A[2] * 10 + A[1] + A[0];
	cout << ans << endl;
	return 0;
}

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

public class Main{
	
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while((line = br.readLine()) != null){
			int n = Integer.parseInt(line);
			int num = 0;
			int[] array = new int[n+1];
			Arrays.fill(array, 1);
			for(int i=2; i<(int)(n/2+1); i++){
				if(array[i] != 1)continue;
				for(int j=2; i*j<=n; j++){
					array[i*j] = 0;
				}
			}
			for(int i=2; i<=n; i++){
				if(array[i] == 1)num++;
			}
			System.out.print(Integer.toString(num)+"\n");
		}
	}
}

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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T>
bool chmax(T& a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>vec(n,vector<int>(3));
    vector<vector<int>>dp(n,vector<int>(3));
    for(int i=0;i<n;i++){
        cin>>vec.at(i).at(0)>>vec.at(i).at(1)>>vec.at(i).at(2);
        dp.at(i).at(0)=inf*(-1);
        dp.at(i).at(1)=inf*(-1);
        dp.at(i).at(2)=inf*(-1);
    }
    for(int i=0;i<3;i++)dp.at(0).at(i) = vec.at(0).at(i);

    for(int i=1;i<n;i++){
        chmax(dp.at(i).at(0),dp.at(i-1).at(1)+vec.at(i).at(0));//b to a
        chmax(dp.at(i).at(0),dp.at(i-1).at(2)+vec.at(i).at(0));//c to a
        chmax(dp.at(i).at(1),dp.at(i-1).at(0)+vec.at(i).at(1));//a to b
        chmax(dp.at(i).at(1),dp.at(i-1).at(2)+vec.at(i).at(1));//c to b
        chmax(dp.at(i).at(2),dp.at(i-1).at(0)+vec.at(i).at(2));//a to c
        chmax(dp.at(i).at(2),dp.at(i-1).at(1)+vec.at(i).at(2));//b to c
    }

    cout<<max(dp.at(n-1).at(0),max(dp.at(n-1).at(1),dp.at(n-1).at(2)))<<endl;
}

Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];
            var A = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(s => s);
            var border = A.Sum() / 4.0 / M;

            Console.WriteLine(A.Take(M).All(s => s >= border) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static int[] a;
        //static string S;


        public static void Input()
        {
            var cin = new Scanner();
            N = int.Parse(Console.ReadLine());
            a = cin.SplitReader();
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = INF;
            for(var i = -100; i <= 100; i++)
            {
                long cost = 0;
                for(var j = 0; j < N; j++)
                {
                    cost += Abs(a[j] - i) * Abs(a[j] - i);
                }

                ans = Min(ans, cost);
            }

            Console.WriteLine(ans);
            //Console.Out.Flush();
        }

        
    }

    

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public int[] MultiLineReader(int N)
        {
            int[] ret = new int[N];
            for(var i = 0; i < N; i++)
            {
                ret[i] = int.Parse(Console.ReadLine());
            }

            return ret;
        }
        public long[] MultiLineReaderL(int N)
        {
            long[] ret = new long[N];
            for (var i = 0; i < N; i++)
            {
                ret[i] = long.Parse(Console.ReadLine());
            }

            return ret;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    multiset<int> s;
    while(n--) {
        int a;
        cin >> a;
        auto it = s.lower_bound(a);
        if(it == s.begin()) {
            s.insert(a);
        } else {
            --it;
            s.erase(it);
            s.insert(a);
        }
    }
    cout << s.size() << '\n';
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>

using namespace std;
int main()
{
	int n, a[200000], aa[200000], max, amax;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		aa[i] = a[i];
	}
	sort(aa, aa + n);
	max = aa[n - 1];
	amax = aa[n - 2];
	for (int i = 0; i < n; i++) {
		if (a[i] == max) {
			cout << amax << endl;
		}
		else {
			cout << max << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  string S;
  cin >> S;
  int i = 0;
  int cnt = 0;
  while (i < S.length()) {
    if (i < S.length() - 1 && S[i] == S[i+1]) {
      if (i+2 < S.length()) {
        cnt++;
        i += 3;
        continue;
      } else {
        cnt++;
      }
    }
    i++;
  }
  cout << S.length() - cnt << endl;
  return 0;
}


Measured memory_bytes: 640
# C
N, K = map(int, input().split())
x_list = list(map(int, input().split()))

zero_cnt = 0
posi_ind = N
nega_ind = -1

# minus
for i in range(N):
    if x_list[i] == 0:
        zero_cnt = 1
        nega_ind = i-1
    elif x_list[i] > 0:
        posi_ind = i
        if zero_cnt == 0:
            nega_ind = i-1
        break
if zero_cnt == 1:
    K -= 1

if x_list[N-1] < 0:
    nega_ind = N-1
    
nega_seq = list(reversed(x_list[:(nega_ind+1)]))
posi_seq = x_list[posi_ind:]

res = 10**13
if K == 0:
    res = 0
else:
    for i in range(1, min(len(posi_seq)+1, K)):
        if K-i-1 >= len(nega_seq) or K-i-1 < 0:
            continue
        p = posi_seq[i-1]
        n = -nega_seq[K-i-1]
        r = min(2*p+n, 2*n+p)
        res = min(res, r)
    if len(posi_seq) >= K:
        r = posi_seq[K-1]
        res = min(res, r)
    if len(nega_seq) >= K:
        r = -nega_seq[K-1]
        res = min(res, r)
print(res)

Measured memory_bytes: 14252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] t = new int[N + 1];
        int[] x = new int[N + 1];
        int[] y = new int[N + 1];
        for (int i = 1; i < N + 1; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int dis = Math.abs(x[i] - x[i+1]) + Math.abs(y[i] - y[i+1]);
            int span = t[i+1] - t[i];

            if (dis > span || (span - dis) % 2 == 1) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 90984
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef vector<ull> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
int get_bits(char c){
  if('A'<=c&&c<='Z'){
    return c-'A';
  }else if('a'<=c&&c<='z'){
    return 26+(c-'a');
  }else if(isdigit(c)){
    return 52+(c-'0');
  }else if(c=='+'){
    return 62;
  }else{
    return 63;
  }
}
vvi decode(vs &f,int h,int w){
  vvi df(h,vi(w));
  REP(i,h){
    REP(j,f[i].size()){
      int b=get_bits(f[i][j]);
      REP(k,6){
        if(((b>>(6-k-1))&1)&&j*6+k<w){
          df[i][j*6+k]=1;
        }
      }
    }
  }
  return df;
}
vvl get_hash(const vvi &f,int h,int w,int p){
  vvl hash(h-p+1,vl(w-p+1));
  const ull B1=9973;
  const ull B2=100000007;
  vvl tmp(h,vl(w));
  ull t1=1;
  REP(i,p){
    t1*=B1;
  }
  REP(i,h){
    ull e=0;
    REP(j,p){
      e=e*B1+f[i][j];
    }
    REP(j,w-p+1){
      tmp[i][j]=e;
      if(j+p<w){
        e=e*B1-t1*f[i][j]+f[i][j+p];
      }
    }
  }

  ull t2=1;
  REP(i,p){
    t2*=B2;
  }
  REP(j,w-p+1){
    ull e=0;
    REP(i,p){
      e=e*B2+tmp[i][j];
    }
    REP(i,h-p+1){
      hash[i][j]=e;
      if(i+p<h){
        e=e*B2-t2*tmp[i][j]+tmp[i+p][j];
      }
    }
  }

  return hash;
}
vvi rotate(vvi &p){
  int n=p.size();
  vvi ret(n,vi(n));
  REP(i,n){
    REP(j,n){
      ret[i][j]=p[n-j-1][i];
    }
  }
  return ret;
}
vvi reverse_x(vvi &p){
  int n=p.size();
  vvi ret(n,vi(n));
  REP(i,n){
    REP(j,n){
      ret[i][j]=p[i][n-j-1];
    }
  }
  return ret;
}
vvi reverse_y(vvi &p){
  int n=p.size();
  vvi ret(n,vi(n));
  REP(i,n){
    REP(j,n){
      ret[i][j]=p[n-i-1][j];
    }
  }
  return ret;
}
int main(){
  int w,h,np;
  while(cin>>w>>h>>np,w|h|np){
    vs f(h);
    REP(i,h){
      cin>>f[i];
    }
    vs p(np);
    REP(i,np){
      cin>>p[i];
    }
    vvi df=decode(f,h,w);
    vvi dp=decode(p,np,np);

    /*
    REP(i,h){
      REP(j,w){
        cerr<<df[i][j];
      }
      cerr<<endl;
    }
    REP(i,np){
      REP(j,np){
        cerr<<dp[i][j];
      }
      cerr<<endl;
    }
    */

    vvl hf=get_hash(df,h,w,np);
    set<ull> hps;
    REP(i,4){
      vvl h=get_hash(dp,np,np,np);
      hps.insert(h[0][0]);
      vvl h2=get_hash(reverse_x(dp),np,np,np);
      hps.insert(h2[0][0]);
      dp=rotate(dp);
    }

    int ans=0;
    REP(i,h-np+1){
      REP(j,w-np+1){
        for(set<ull>::iterator it=hps.begin();it!=hps.end();it++){
          if(hf[i][j]==*it){
            ans++;
          }
        }
      }
    }
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 19604
n=int(input())
T=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
    a,b=map(int,input().split())
    p[i]+=a
    x[i]+=b
tt =sum(T)
for j in range(len(p)):
    ans = tt - T[p[j]-1] + x[j]
    print(ans)

Measured memory_bytes: 62744
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def pm(n):
    if n % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([pm(i//4) * x + pm(i//2) * y + pm(i) * z for x, y, z in A], reverse=True)
    B.append(sum(temp[:m]))
    
print(max(B))

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

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); }
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
// 1000000000000001
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

    ll n;cin>>n;
    vl a(n);
    ll x=0;
    forn(i,n){
        cin>>a[i];
        if(i>0)x^=a[i];
    }
    ll res=x^a[0];
    cout<<x<<" ";
    for(ll i=1LL;i<n;i++)cout<<(res^a[i])<<" ";
}



Measured memory_bytes: 4700
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,pair<int,int> > P;


int main(){
    int ans;
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    if(2*x==W && 2*y==H) ans=1;
    else ans=0;
    double sum=(double)W*H/2;
    printf("%.9lf\n",sum);
    cout<<ans<<endl;
}


Measured memory_bytes: 256