akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N)
	fmt.Scan(&K)
	count := 0
	if K%2 != 0 {
		for a := K; a < N+1; a += K {
			count++
		}
		fmt.Println(count * count * count)
	} else {
		var ord int
		var irr int
		for a := 1; a < N+1; a++ {
			if a%K == 0 {
				ord++
			} else if a%(K/2) == 0 {
				irr++
			}
		}
		fmt.Println(irr*irr*irr + ord*ord*ord)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int ans;
int main(){
    //freopen("input.txt","r",stdin);
    cin >> a >> a >> b >> c;
    for(int i = 0;i < a.size();i++){
    	set<char>st;
    	st.insert(a[i]);
    	st.insert(b[i]);
    	st.insert(c[i]);
    	if(st.size() == 2)ans++;
    	else if(st.size() == 3)ans+=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;

    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        ans += i;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	printf("1x1=1\n1x2=2\n1x3=3\n1x4=4\n1x5=5\n1x6=6\n1x7=7\n1x8=8\n1x9=9\n");
	printf("2x1=2\n2x2=4\n2x3=6\n2x4=8\n2x5=10\n2x6=12\n2x7=14\n2x8=16\n2x9=18\n");
	printf("3x1=3\n3x2=6\n3x3=9\n3x4=12\n3x5=15\n3x6=18\n3x7=21\n3x8=24\n3x9=27\n");
	printf("4x1=4\n4x2=8\n4x3=12\n4x4=16\n4x5=20\n4x6=24\n4x7=28\n4x8=32\n4x9=36\n");
	printf("5x1=5\n5x2=10\n5x3=15\n5x4=20\n5x5=25\n5x6=30\n5x7=35\n5x8=40\n5x9=45\n");
	printf("6x1=6\n6x2=12\n6x3=18\n6x4=24\n6x5=30\n6x6=36\n6x7=42\n6x8=48\n6x9=54\n");
	printf("7x1=7\n7x2=14\n7x3=21\n7x4=28\n7x5=35\n7x6=42\n7x7=49\n7x8=56\n7x9=63\n");
	printf("8x1=8\n8x2=16\n8x3=24\n8x4=32\n8x5=40\n8x6=48\n8x7=56\n8x8=64\n8x9=72\n");
	printf("9x1=9\n9x2=18\n9x3=27\n9x4=36\n9x5=45\n9x6=54\n9x7=63\n9x8=72\n9x9=81\n");
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool ok = true;
  int n = sz(s);
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      if (s[i] != 'h') ok = false;
    } else {
      if (s[i] != 'i') ok = false;
    }
  }
  if (n & 1) ok = false;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    ll p = 1;
    while(p <= n) {
        p *= 2;
    }
    
    out(p/2);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=600+5,inf=1e18+1;
ll mod=1e9+7;

ll n;
str z[2]={"YES","NO"};

int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    ll res=0;
    For(i,0,n)
    {
        ll x;
        cin >> x;
        res^=x&1;
    }
    RET(z[res]);
}    

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

int main() {
    ll N, M; cin >> N >> M;
    ll ans = 1;
    for (ll i = 1; i * i <= M; i++) {
        if (M % i != 0) continue;

        if (N * i <= M) ans = max(ans, i);
        if (N * (M / i) <= M) ans = max(ans, M / i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll modfact[100001];

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

ll nCr(ll n, ll r){
	return ((modfact[n]*modinv(modfact[n-r]))%MOD*modinv(modfact[r]))%MOD;
}

int main(){
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	ll modmax = 0, modmin = 0;

	modfact[0] = 1;
	for (int i = 1; i <= 100000; i++){
		modfact[i] = i*modfact[i-1];
		modfact[i] %= MOD;
	}

	for (int i = k-1; i < n; i++){
		modmax += (nCr(i, k-1)*a[i])%MOD;
	}

	reverse(a.begin(), a.end());
	for (int i = k-1; i < n; i++){
		modmin += (nCr(i, k-1)*a[i])%MOD;
	}

	ll ans = (modmax - modmin)%MOD;
	if (ans < 0) cout << ans + MOD << endl;
	else cout << ans << endl;

	return 0;
}

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

int main() {
    /*変数定義，入力*/
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    static const double pi = 3.141592653589793;

    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    double th_h = H / 12.0 * 2.0 * pi + M / 60.0 * pi/6.0;
    double th_m = M / 60.0 * 2 * pi;

    //cout << th_h << "," << th_m << endl;

    double th = th_h - th_m;
    double c = sqrt(double(A*A + B*B - 2*A*B*cos(th))); 
    //cout << th << endl;
    cout << std::fixed << std::setprecision(15) << c << endl;
   /*終了*/
    return 0;
}

Measured memory_bytes: 4160
def pow_mod(a, b, p):
    res = 1
    mul = a
    for i in range(len(bin(b)) - 2):
        if (1 << i) & b:
            res = (res * mul) % p
        mul = (mul ** 2) % p
    return res


def perm_mod(n, r, p):
    res = 1
    for i in range(r):
        res = (res * (n - i)) % p
    return res


def comb_mod(n, r, p):
    r = min(r, n - r)
    return (perm_mod(n, r, p) * pow_mod(perm_mod(r, r, p), p - 2, p)) % p


def main():
    p = 10 ** 9 + 7
    n, a, b = map(int, input().split())
    print((pow_mod(2, n, p) - 1 - comb_mod(n, a, p) - comb_mod(n, b, p)) % p)


main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int n, i, x;
    
    scanf("%d", &n);
    
    for(i=3; i<=n; i++){
        x=i;
        if(x%3==0){
            printf(" %d", i);
        }else{
            do{
                if(x%10==3){
                    printf(" %d", i);
                    break;
                }
                x/=10; 
            }while(x!=0);
        }
    }
    
    putchar('\n');
    
    return 0;
}


Measured memory_bytes: 2100
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    int ro = n - k;
    int ans = INT32_MAX;
    for (int i = 0; i <= ro; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n>>m;
    for(i=0; i<m+2; i++)
    {
        cout<<"#";
    }
    cout<<endl;
    for(i=0; i<n; i++)
    {
        cin>>a;
        cout<<"#"<<a<<"#"<<endl;;
    }
    for(i=0; i<m+2; i++)
    {
        cout<<"#";
    }
    cout<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(K: int):
    lastMod = 0
    for i in range(K):
        lastMod = (lastMod*10+7)%K
        if lastMod == 0:
            print(i+1)
            return
    print(-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62652
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var X = cin.ReadInt;
            var ans = 0;
            var a = 0;
            var b = 0;
            var c = 0;
            while(a * 500 <= X && a <= A)
            {
              while(b * 100 <= X - a * 500 && b <= B)
              {
                while(c * 50 <= X - a * 500 - b * 100 && c <= C)
                {
                  if(a * 500 + b * 100 + c * 50 == X)
                  {
                    ans += 1;
                  }
                  c += 1;
                }
                c = 0;
                b += 1;
              }
              b = 0;
              a += 1;
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}



Measured memory_bytes: 13268
import java.util.Scanner;

/**
 *
 * @author HP
 */
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n  = s.nextInt();
        int m  = s.nextInt();
        int limit = s.nextInt();
        
        int a[] = new int[n];
        long sumA[] = new long[n+1];
        int b[] = new int[m];
        long sumB[] = new long[m+1];
        
        for(int i = 1; i <= n; ++i) {
            a[i-1] =  s.nextInt();
            sumA[i] = sumA[i-1] + a[i-1];
//            System.out.println(sumA[i]);
        }
        
        for(int i = 1; i <= m; ++i) {
            b[i-1] =  s.nextInt();
            sumB[i] = sumB[i-1] + b[i-1];
//            System.out.println(sumB[i]);
        }

        int j = m;
        int ans = 0;
        for(int i = 0; i <= n; i++) {
            if(sumA[i] > limit)
                break;
            while(limit - sumA[i] < sumB[j])
                j--;
            ans = Math.max(ans,i+j);
        }
        System.out.println(ans);
    }
}


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

int main(){
	int S=0,h=0,m=0,s=0;
	cin >> S;

	h = S/3600;
	m = S%3600/60;
	s = S%3600%60;


	cout << h << ":" << m << ":" << s <<"\n";

	return 0;
}

Measured memory_bytes: 1164
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;
int		ans;

int		main(void)
{
	int		N, D;
	cin >> N >> D;
	ans = N / (D * 2 + 1);
	if (N % (D * 2 + 1))
		ans++;
	cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    int c=1;
    int b=0;
    for(int i = 0; i < s.size()-1; ++i){
        if(s[i] == s[i+1]){
            c++;
        }else{
            b=max(c,b);
            c=1;
        }
    }
    b=max(c,b);
    if(b >= 3){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(3);
    vint b(3);
    vvint city(4);
    bool ans = false;
    REP(i,3){
        cin >> a[i] >> b[i];
        city[a[i]-1].pb(b[i]-1);
        city[b[i]-1].pb(a[i]-1);
    }
    REP(c1,4){
       for(int c2: city[c1]){
           for(int c3: city[c2]){
               if(c3!=c1&&c3!=c2){
                   for(int c4:city[c3]){
                       if(c4!=c1&&c4!=c2&&c4!=c3){
                           ans = true;
                       }
                   }
               }
           }
       }
    }
    if(ans){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_M = 11111;
const int MAX_R = 1111;
const int MAX_T = 800;
int id[MAX_M][MAX_T];
int N, M;
int r, q;
struct _R{int t, m, n, s;} R[MAX_R];
int ts, te, m;

int main()
{
  while(cin >> N >> M, N){
    rep(i, M) rep(j, 777) id[i][j] = 0;
    cin >> r;
    rep(i, r) cin >> R[i].t >> R[i].n >> R[i].m >> R[i].s;
    rep(i, r) if(!R[i].s) R[i].s = -1;

    rep(i, r) id[R[i].m - 1][R[i].t - 540] += R[i].s;
    rep(i, M) rrep(j, 1, 777) id[i][j] += id[i][j - 1];

    cin >> q;
    rep(i, q){
      cin >> ts >> te >> m;
      int res = 0;
      rrep(j, ts, te) if(id[m - 1][j - 540]) res += 1;
      cout << res << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 31876
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        String result = "No";

        for (int i = 0; i <= x; i++) {
            int j = x - i;
            if (2 * i + 4 * j == y) result = "Yes";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 27072
#include<stdio.h>
int main(void){
	
	unsigned long long int a,b,r,tmp,x;
	
	scanf("%lld %lld", &a, &b);
	
	x=a*b;
	
	if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

	
	printf("%lld\n",x/b);
	return 0;
}

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

signed main(void){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int odd=0,four=0;
    for(int i=0;i<n;i++){
        if (a[i] %2 != 0){
            odd++;
        }else if(a[i]%4==0){
            four++;
        }
    }
    if((odd <= four) || (four+1==odd && four+odd==n)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
using namespace std;

bool check(vector<pair<int, int>>& a1, vector<pair<int, int>>& a2) {
	int Size = a1.size();
	//cout << "check" << endl;
	for (int i = 0; i < Size;i++) {
		//cout << "{" << a1[i].first << ", " << a1[i].second << "}{" << a2[i].first << ", " << a2[i].second << "} " << endl;

		if (a1[i].first != a2[i].first || a1[i].second != a2[i].second)return false;
	}
	return true;
}

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

	while (cin >> n, n) {
		int m; cin >> m;
		vector<pair<int, int>> base(m), baseL[2];
		for (int i = 0; i < m; i++) {
			int x, y; cin >> x >> y;
			base[i] = { x,y };
		}
		pair<int, int> baseP[2];
		baseP[0]= base[0], baseP[1] = base[m - 1];

		baseL[0] = baseL[1] = base;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < m;j++) {
				baseL[i][j].first -= baseP[i].first;
				baseL[i][j].second -= baseP[i].second;
			}
		}
		reverse(baseL[1].begin(), baseL[1].end());

		//sort(baseL[0].begin(), baseL[0].end());
		//sort(baseL[1].begin(), baseL[1].end());

		
		/*for (int i = 0; i < 2; i++) {
			cout << "base" << i << endl;
			for (int j = 0; j < m;j++) {
				cout << baseL[i][j].first << " " << baseL[i][j].second << endl;
			}
			cout << "-----" << endl;
		}*/
		

		for (int i = 1; i <= n;i++) {
			int M; cin >> M;
			vector<pair<int, int>> L(M);
			for (int j = 0; j < M;j++) {
				int x, y; cin >> x >> y;
				L[j] = { x,y};
			}

			int basex = L[0].first, basey = L[0].second;
			for (int j = 0; j < M;j++) {
				L[j].first -= basex; L[j].second -= basey;
			}

			if (M != m) continue;
			for (int j = 0; j < 4;j++) {
				//sort(L.begin(), L.end());

				/*cout << "L = " << i << endl;
				for (int j = 0; j < m;j++) {
					cout << L[j].first << " " << L[j].second << endl;
				}
				cout << "-----" << endl;*/

				if (check(L, baseL[0]) || check(L, baseL[1])) {
					cout << i << endl;
					break;
				}
				for (int k = 0; k < L.size();k++) {
					L[k] = { -L[k].second,L[k].first };
				}
			}
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+1;
long long dp[maxn],a[maxn];
int main()
{
    long long n,i;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    dp[1]=0,dp[2]=abs(a[2]-a[1]);
    for (i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 5156
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"
MAX = 100001

dp = [0 for i in range(MAX)]
color = [0 for i in range(MAX)]
e = [[] for i in range(MAX)]

def paint(v, d, c):
    if not color[v]:
        color[v] = c
    if dp[v] >= d or d == 0:
        return
    dp[v] = d
    for u in e[v]:
        paint(u, d - 1, c)

def main():
    n, m = map(int, input().split())
    for i in range(m):
        a, b = map(int, input().split())
        e[a].append(b)
        e[b].append(a)
    q = int(input())
    vq, dq, cq = [], [], []
    for i in range(q):
        v, d, c = map(int, input().split())
        vq.append(v)
        dq.append(d)
        cq.append(c)
    assert len(vq) == len(dq) == len(cq) == q

    for i in reversed(range(q)):
        paint(vq[i], dq[i], cq[i])
    for i in range(n):
        print(color[i + 1])


main()


Measured memory_bytes: 32180
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n];
        for (int i = 0; i < n; i++) {
        	a[i]=sc.nextLong();
		}
        
        Arrays.sort(a);
        for(int i=1;i<n;i++) {
        	while(a[i]!=a[i-1]) {
        		
        	
        		if(a[i]>a[i-1]) {
        			
        			a[i]=a[i]%a[i-1]==0?a[i-1]:a[i]%a[i-1];
        		}
        		else if(a[i]<a[i-1]) {
        			a[i-1]=a[i-1]%a[i]==0?a[i]:a[i-1]%a[i];
        		}
        			
        		
        	}	
        }
        
        
        System.out.println(a[n-1]);
        
    }
}


Measured memory_bytes: 50404
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 505

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<int, int> par;
typedef pair<int, par> par1;

int N,A[maxn][maxn],nc,nf,cost,C[maxn][maxn],sol,a;
par B[maxn*maxn];
deque<par> Q;
int movf[]={0,0,1,-1};
int movc[]={1,-1,0,0};

int bfs(int f,int c)
{
    Q.push_front(par(f,c));
    A[f][c] = 0;
    int ret = C[f][c];
    while(!Q.empty()){
        f = Q.front().fi;
        c = Q.front().se;
        Q.pop_front();
        for(int i=0;i<4;i++){
            int nf = f+movf[i],nc = c+movc[i];
            if(nf<1 || nf>N || nc<1 || nc>N){
                continue;
            }

            if(C[nf][nc]>C[f][c] + (A[f][c]!=0) ){
                C[nf][nc] = C[f][c] + (A[f][c]!=0);
                if(A[f][c])
                    Q.push_back(par(nf,nc));
                else
                    Q.push_front(par(nf,nc));
            }
        }
    }
    return ret;
}
int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    cin >> N;

    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++){
            A[i][j] = (i-1)*N+j;
            B[(i-1)*N+j]=par(i,j);
            C[i][j] = min( min(i,j)-1,min(N-i,N-j));
        }

    for(int i=1;i<=N*N;i++){
        cin >> a;
        sol+=bfs(B[a].fi,B[a].se);
    }

    cout << sol;

/*
4
6 7 1 4 13 16 10 9 5 11 12 14 15 2 3 8


*/


}


Measured memory_bytes: 8064
while True:
    n1=input()
    if n1=="0":
        break
    n2=input()
    n3=input()
    l1=len(n1)
    l2=len(n2)
    l3=len(n3)
    if n1=="0":
        break
    else:
        a1=n1.count("A",1)
        b1=n1.count("B",1)
        if n2[:1]=="A":
            a1+=1
        if n2[:1]=="B":
            b1+=1
        print(a1,b1)
        
        a2=n2.count("A",1)
        b2=n2.count("B",1)
        if n3[:1]=="A":
            a2+=1
        if n3[:1]=="B":
            b2+=1
        print(a2,b2)
        
        a3=n3.count("A",1)
        b3=n3.count("B",1)
        if a3>b3:
            a3+=1
        if a3<b3:
            b3+=1
        print(a3,b3)
        
        


Measured memory_bytes: 5556
#include <stdio.h>
int v[55]={},g[55][55]={},n,m,a[55]={},b[55]={},ans=0,i=0,j;int d(int x){v[x]=1;for(int w=0;w<n;w++)if(g[x][w]==1&&v[w]==0)d(w);return 0;}int main(){scanf("%d%d",&n,&m);for(;i<m;i++){scanf("%d%d",&a[i],&b[i]);a[i]--;b[i]--;g[a[i]][b[i]]=1;g[b[i]][a[i]]=1;}for(i=0;i<m;i++){g[a[i]][b[i]]=0;g[b[i]][a[i]]=0;for(j=0;j<n;j++)v[j]=0;d(0);for(j=0;j<n;j++)if(v[j]==0){ans++;break;}g[a[i]][b[i]]=1;g[b[i]][a[i]]=1;}printf("%d",ans);return 0;}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

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

//-----Template---------

int main(){
    //cout<< fixed << setprecision(10);
    LL w,h;
    cin>>w>>h;

    vector<LL> p(w);
    vector<LL> q(h);

    for (int i = 0; i < w; ++i) cin>>p[i];
    for (int i = 0; i < h; ++i) cin>>q[i];

    vector<pair<LL,int>> hens;
    for (int i = 0; i < w; ++i)
        hens.emplace_back(p[i],0);  //x

    for (int i = 0; i < h; ++i)
        hens.emplace_back(q[i],1);  //y

    sort(hens.begin(),hens.end());

    LL sum=0;
    LL row=0,column=0; //row..x方向に舗装した数　column..y
    for(int i=0;i<hens.size();i++){
        LL a=hens[i].first;
        int t=hens[i].second;
        if(t==0){
            sum+=(h-column+1)*a;
            row++;
        }else{
            sum+=(w-row+1)*a;
            column++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
int dig(long long n) {
	int res = 0;
	while (n) {
		res += n % 10;
		n /= 10;
	}
	return res;
}
int main() {
	long long n, nine = 0;
	cin >> n;
	int ans = dig(n);
	for (long long x = 1; x <= n; x *= 10) {
		long long tmp = (n / x - 1) * x + nine;
		nine = nine * 10 + 9;
		ans = max(ans, dig(tmp));
	}
	cout << ans << endl;
}



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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int x,y,N;

    cin>>N>>x>>y;

    cout<<min(x,y)<<" "<<max(0,x+y-N)<<endl;

    return 0;
}


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

long long X[100005];

int main() {
    int N, K;
    long long x;
    scanf("%d %d", &N, &K);
    int start = 0;
    for (int i = 0; i < N; i++) {
        scanf("%lld", &x);
        X[i] = x;
        if (x >= 0 && (X[i-1] < 0 || i == 0)) start = i;
    }
    if (x < 0) start = N;
    long long ans = 10000000000000;
    for (int i = 0; i <= K; i++) {
        if (start + K - i -1 >= N || start < i) continue;
        long long sum = 0;
        if (i > 0) sum += -2 * X[start-i];
        if (i != K) sum += X[start+K-i-1];
        ans = min(ans, sum);
        sum = 0;
        if (i > 0) sum += -1 * X[start-i];
        if (i != K) sum += 2 * X[start+K-i-1]; 
        ans = min(ans, sum);
    }
    if (K == 1) {
        ans = abs(X[start]);
        if (start > 0) ans = min(ans, abs(X[start-1]));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#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() {
    ll N; cin >> N;
    for(ll h=1;h<=3500;h++) {
        for(ll n=h;n<=3500;n++) {
            if((4*h*n-N*n-N*h)>0 && (N*h*n)%(4*h*n-N*n-N*h)==0) {
                if((N*h*n)/(4*h*n-N*n-N*h) < 1) continue;
                printf("%lld %lld %lld\n",h,n,(N*h*n)/(4*h*n-N*n-N*h));
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int i,j,n,q,count=0,mid;
		n=scan.nextInt();
		int[] s=new int[n];
		for(i=0;i<n;i++) {
			s[i]=scan.nextInt();
		}
		mid=n/2;
		q=scan.nextInt();
		int[] t=new int[q];
		for(i=0;i<q;i++) {
			t[i]=scan.nextInt();
		}
		for(i=0;i<q;i++) {
			if(t[i]<s[mid]) {
				for(j=0;j<mid;j++) {
					if(t[i]==s[j]) {
						count++;
						break;
					}
				}
			}
			else {
				for(j=mid;j<n;j++) {
					if(t[i]==s[j]) {
						count++;
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 68480
#include "bits/stdc++.h"

using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)

using namespace std;
//#define DEBUG

void run() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h, "");
	rep(i, h) {
		cin >> a[i];
	}
	if(a[h-1][w-1] == '.') {
		cout << "Impossible" << endl;
		return;
	}

	int x = h - 1, y = w - 1;
	for(;;) {
		if(x==0 && y==0 && a[x][y] == '#') {
			cout << "Possible" << endl;
			return;
		}
		if(x > 0 && y > 0 && a[x][y-1] == '.' && a[x-1][y] == '.') {
			cout << "Impossible" << endl;
			return;
		}

		if(x > 0 && a[x-1][y] == '#') {
			rep(i, y) if(a[x][i] == '#') {
				cout << "Impossible" << endl;
				return;
			}
			x--;
			continue;
		}
		if(y > 0 && a[x][y-1] == '#') {
			rep(i, x) if(a[i][y] == '#') {
				cout << "Impossible" << endl;
				return;
			}
			y--;
			continue;
		}
	}
}

int main() {
#ifdef DEBUG
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	rep(i, 4) {
		cout <<"--------------: i=" << i << endl;
		run();
	}
#else
	run();
#endif
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main () {
    char S[100000];
    int c, l, ch[26] = {0};
    scanf("%s", S);
    l = strlen(S);
    for(int i = 0; i < l; ++i){
        for(int j = 0; j < 26; ++j){
            if(S[i] == 97 + j){
                ch[j]++;
                break;
            }
        }
    }
//    for(int i = 0; i < 26; ++i) printf("%c : %d\n", i + 97, ch[i]);
    for(int i = 0; i < 26; ++i){
        if(ch[i] == 0){
            
            printf("%c\n", 97 + i);
            return 0;
        }else if(25 == i){
            puts("None");
            return 0;    
        }
    }
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	[ ss, ps' ] <- transpose . map words <$> replicateM n getLine
	let
		ps = map read ps'
		pairs = zip ss $ map negate ps
	mapM_ print $ map snd $ sort $ zip pairs [ 1 .. ]

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    ll y=x;
    ll a=360;
    ll rotate=0;
    while(x%a!=0)
    {
        x+=y;
        rotate++;
    }
    cout<<rotate+1<<"\n";
}

Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc123/tasks/abc123_c
#include <bits/stdc++.h>
using namespace std;

int main(void){
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long min_num = min({A, B, C, D, E});

  long long groups = (N + min_num - 1) / min_num;
  cout << 5 + groups - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,a[maxn],cnt[maxn]={0},ans;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n){
		cin >> a[i];
		cnt[a[i]]++;
	}
	rep(maxn) ans+=cnt[i]*(cnt[i]-1)/2;
	rep(n) print1(ans-cnt[a[i]]+1);
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie   
    int a[100001] = {0};
    set<pair<int, pair<int, int>>> s ;
    rep(i, 1, 101) {
        rep(j, 1, 101) {
            rep(k, 1 ,101) {
                int n = i*i+j*j+k*k+i*j+i*k+j*k ;
                int aa[3] = {i, j, k} ;
                sort(aa, aa+3) ;
                int temp = s.size() ;
                s.insert({aa[0], {aa[1], aa[2]}}) ;
                if(s.size() > temp) {
                    // if(n == 15000) {
                    //     cout << aa[0] << " " << aa[1] << " " << aa[2] << "\n" ;
                    // }
                    if(i == j && j == k) {
                        a[n] += 1 ;
                    }
                    else if(i != j && j != k && i != k) a[n] += 6 ;
                    else a[n] += 3 ;
                }
            }
        }
    }
    int n ;
    cin >> n ;
    rep(i, 1, n+1) cout << a[i] << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}


Measured memory_bytes: 15168
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::vector<std::pair<i64, std::pair<i64, i64>>> vec;
	for(int i = 0; i < n; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		vec.push_back({a + b, {a, b}});
	}
	sort(begin(vec), end(vec)); reverse(begin(vec), end(vec));
	
	i64 A = 0, B = 0;
	for(int i = 0; i < n; i++) {
		if(i % 2 == 0) {
			A += vec[i].second.first;
		} else {
			B += vec[i].second.second;
		}
	}
	printf("%lld\n", A - B);
	return 0;
}


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

using lint = long long;
const int mod = 1e9 + 7;

int main() {
  int n;
  string u, d;

  cin >> n >> u >> d;

  u.erase(unique(u.begin(), u.end()), u.end());
  d.erase(unique(d.begin(), d.end()), d.end());

  lint ans = (u[0] == d[0] ? 3 : 6);
  bool f = u[0] == d[0];
  for (int i = 1; i < u.size(); ++i) {
    bool t = d[i] == u[i];
    if (f) {
      ans *= 2;
    } else {
      if (!t) ans *= 3;
    }

    ans %= mod;

    f = t;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define ll long long
# define F first
# define S second
# define pb push_back
#define INF 1e9 + 7
 
const int N = 1e4 + 5;
typedef vector<int>vi;
typedef pair<int,int>ii;
typedef pair<int,ii>iii;
int arr[N],n;
int bs(int x){
  int l=0, r=n, m;
  while(r-l > 1){
    m = (l + r) / 2;
    if(arr[m] < x) l = m;
    else r = m;
  }
  return l;
}
int main() {  
  while(cin >> n){
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    ll ans = 0;
    for(int i=n-1 ; i ; i--)
      for(int j=i-1 ; j>=0 ; j--){
        ans += bs(arr[i] + arr[j]) - i;
        // printf("suma = %d ans=%lld bs=%d i=%d\n",arr[i]+arr[j],ans,bs(arr[i]+arr[j]),i);
      }
    cout << ans << endl;
  }    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxi -1e18
int main()
{
ll n,m;
cin>>n>>m;
ll ans =maxi;
vector<ll> a(n), b(n), c(n);
for(int i = 0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
for(int i = 0;i<8;i++)
{
vector<ll>v(n);
for(int j = 0;j<n;j++)
{

ll x = 0;
if(i&1) x+=a[j];else x-=a[j];
if(i&2) x+=b[j];else x-=b[j];
if(i&4) x+=c[j];else x-=c[j];
v[j] =x;

}
sort(v.rbegin(),v.rend());
ll sum = 0;
for(int i = 0;i<m;i++) sum+=v[i];
ans = max(ans,sum);

}
cout<<ans;
return 0;
}

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

int main(){
	vector<int> a,b;
	int n,m;
	cin>>n;
	lp(i,n){
		int hoge;
		cin>>hoge;
		a.push_back(hoge);
	}
	cin>>m;
	lp(i,m){
		int hoge;
		cin>>hoge;
		b.push_back(hoge);
	}
	vector<int> ans;
	set_symmetric_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(ans,ans.end()));
	for_each(ans.begin(),ans.end(),[](int hoge){ cout<<hoge<<endl;});
	return 0;
}


Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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 ll INF = 1LL << 60;
int main(){
    int n;
    cin >> n;
    n++;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    sort(x.begin(),x.end());
    vector<int> d(n-1);
    rep(i,n-1) d[i] = x[i+1]-x[i];
    ll ans = d[0];
    rep(i,n-1) ans = __gcd(ans,(ll)d[i]);
    cout << ans << endl;
    return 0;
}

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

int main() {
int X,Y,max,min,a,b;
cin >> X >> Y;
max=4*X; //最大足本数
min=2*X;
if(Y%2!=0){
    cout << "No" <<endl;
}
else if(Y<min || Y>max){
    cout << "No" <<endl;
}
else {
    cout << "Yes" <<endl;
}
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int X;
    cin >> X;

    for (int ans = X; ans <= int(1e9); ++ans) {
        bool ng = false;
        // cout << ans << endl;

        for (int i = 2; i <= int(sqrt(X)); ++i) {
            if (ans%i == 0) {
                ng = true;
                break;
            }
        }
        if (ng == false) {
            cout << ans << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>

int countword(char *p){
    int z = 0;
    while(1){
        if(*p == '\0')
            break;
        z++;
        p++;
    }
    return z;
}
int main(void){
    char text[102];
    char word[102];
    char code[204];
    int j, q, k, a;
    int x, y;
    int s;
    
    fgets(text, 102, stdin);
    fgets(word, 102, stdin);
    j = 0;
    q = 0;
    k = 0;
    a = 0;
    s = 0;
    
    x = countword(text);
    y = countword(word);
    
    for(j = 0; j < (x * 2) - 2; j++, q++){
        if(q == x - 1)
            q = 0;
        code[j] = text[q];
    }
    
    while(s != x - 1){
        a = 0;
        for(j = 0; j < y - 1; j++){
            if(code[j + s] == word[j]){
                a++;
                if(a == y - 1)
                    break;
            }
            else
                break;
        }
        s++;
        if(a == (y - 1))
            break;
    }
    if(a == (y -1))
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}



Measured memory_bytes: 2100
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

res = 1000000000 + 7

main = do
  [n, m] <- readIntList
  pic <- V.fromList <$> replicateM n (V.fromList <$> getLine)
  temp <- V.fromList <$> replicateM m (V.fromList <$> getLine)
  let cands = [(i, j) | i <- [0..(n - m)], j <- [0..(n - m)]]
      includes = any (judge pic temp m) cands
  putStrLn $ if includes then "Yes" else "No"

judge pic temp m (x, y) = all (\(i, j) -> (pic V.! (x + i)) V.! (y + j) == (temp V.! i) V.! j) [(i, j) | i <- [0..(m - 1)], j <- [0..(m - 1)]]




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

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

using namespace std;
using i64 = long long int;

int main(){
    i64 n, k;
    cin >> n >> k;
    i64 cnt = 0;
    rep(i, n){
        i64 h;
        cin >> h;
        if(h >= k) ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

class Searchable_BIT():
    def __init__(self,N):
        self.N = N
        self.node = [0]*(self.N+1)
        self.cnt = 0

    def add(self,a): # 要素 x を追加
        x = a
        self.cnt += 1
        while x <= self.N:
            self.node[x] += 1
            x += x & -x

    def delete(self,x): # 要素 x を削除
        self.cnt -= 1
        while x <= self.N:
            self.node[x] -= 1
            x += x & -x

    def count(self,x): # x以下の要素数
        tmp = 0
        while x > 0:
            tmp += self.node[x]
            x -= x & -x
        return tmp

    def get_maxval(self):
        return self.get_lower_i(self.cnt)

    def get_lower_i(self,i): # i 番目に小さい要素を取得
        NG = -1
        OK = self.N+1
        while OK-NG > 1:
            mid = (OK+NG)//2
            #print(OK,NG,self.count(mid))
            if self.count(mid) >= i:
                OK = mid
            else:
                NG = mid
        return OK

N = inp()
PP = inpl()
inds = [0]*(N+1)
for i,P in enumerate(PP):
    inds[P] = i+1

BIT = Searchable_BIT(N)
ans = 0
for i in reversed(range(1,N+1)):
    ind = inds[i]
    BIT.add(ind)
    cnt = BIT.count(ind)
    Lind1 = BIT.get_lower_i(cnt-1)
    Lind2 = BIT.get_lower_i(cnt-2)
    Rind1 = BIT.get_lower_i(cnt+1)
    Rind2 = BIT.get_lower_i(cnt+2)
    L1 = ind   - Lind1
    L2 = Lind1 - Lind2
    R1 = Rind1 -   ind
    R2 = Rind2 - Rind1
    #print(i,Lind2,Lind1,ind,Rind1,Rind2)
    if Rind1 != N+1:
        ans += i * L1 * R2
    if Lind1 != 0:
        ans += i * L2 * R1


print(ans)


Measured memory_bytes: 60060