akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;  }
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;  }
#define NMAX 100005



int main()
{
    int X,N;
    int a,b;
    cin>>X>>N;
    a = X;
    b = X;
    int tab[N] = {0};
    for (int i = 0; i < N; ++i)
    {
        cin>>tab[i];
    }
    while(1){
        bool found = false;
        for(int i=0 ; i<N ; ++i){
            if(tab[i] == a){
                found = true;
                break;
            }
        }
        if (!found)
        {
            cout<<a;
            return 0;
        }
        found = false;
        for(int i=0 ; i<N ; ++i){
            if(tab[i] == b){
                found = true;
                break;
            }
        }
        if (!found)
        {
            cout<<b;
            return 0;
        }
        a--;b++;
    }
   return 0;
}


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

int main() {
  double n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  double sum = 0.0;
  
  for (int i = 0; i < n; i = i + 1) {
    cin >> a.at(i);
    sum = sum + a.at(i);
  }
  
  int count = 0;
  for (int i = 0; i < n; i = i + 1) {
    if (a.at(i) >= sum/(4*m))
      count = count + 1;
  }
  
  if (count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl; 
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {

	public static void main(String args[]){

		int w,n,a,b,temp;
		Scanner in = new Scanner(System.in);
		
		w = Integer.parseInt(in.next());
		n = Integer.parseInt(in.next());
		
		int lot[] = new int[w];
		
		for(int i=0;i<w;i++){
			lot[i] = i+1;
		}
		
		String[] array;
		
		for(int i=0;i<n;i++){
			array = in.next().split(",");
			a = Integer.parseInt(array[0]) -1;
			b = Integer.parseInt(array[1]) -1;
			
			temp = lot[a];
			lot[a] = lot[b];
			lot[b] = temp;
		}
		
		for(int i=0;i<w;i++){
			System.out.println(lot[i]);
		}
		in.close();
	}
}

Measured memory_bytes: 26036
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def main():
    S = input()
    tomorrow = {
        'Sunny': 'Cloudy',
        'Cloudy': 'Rainy',
        'Rainy': 'Sunny'
    }
    print(tomorrow[S])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
jisho = ["z","y","x","w","v","u","t","s","r","q","p","o","n","m","l","k","j","i","h","g","f","e","d","c","b","a"]

s = list(input())
n = len(s)
k =int(input())
res = ""

for elem in s:
    if elem == "a":
        res += "a"
    elif jisho.index(elem)+1 <= k:
        res += "a"
        k -= jisho.index(elem)+1
    else:
        res += elem

res = res[0:n-1] + jisho[jisho.index(res[n-1])-k%26]
print(res)


Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>> vec(H,vector<char>(W));
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    vector<vector<int>> sum(H + 1,vector<int>(W + 1));
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if(vec.at(i).at(j) == '1') {
                sum.at(i + 1).at(j + 1) = sum.at(i).at(j + 1) + sum.at(i + 1).at(j) - sum.at(i).at(j) + 1;
            }
            else {
                sum.at(i + 1).at(j + 1) = sum.at(i).at(j + 1) + sum.at(i + 1).at(j) - sum.at(i).at(j);
            }
        }
    }
    int ret = Inf;
    for(int bit = 0;bit < (1 << (H - 1));bit++) {
        vector<int> crunky;
        crunky.push_back(0);
        for(int i = 0;i < H - 1;i++) {
            if(bit & (1 << i)) {
                crunky.push_back(i + 1);
            }
        }
        crunky.push_back(H);
        int cnt = crunky.size();
        vector<bool> cnt2(W + 1);
        int left = 0;
        for(int i = 1;i <= W;i++) {
            bool cnt4 = true;
            for(int j = 0;j < crunky.size() - 1;j++) {
                if(sum.at(crunky.at(j + 1)).at(i) - sum.at(crunky.at(j)).at(i) - sum.at(crunky.at(j + 1)).at(left) + sum.at(crunky.at(j)).at(left) > K) {
                    cnt4 = false;
                }
            }
            if(cnt4 == false) {
                if(left == i - 1) {
                    cnt = Inf;
                }
                cnt2.at(i - 1) = true;
                left = i - 1;
            }
        }
        int cnt3 = 0;
        for(int i = 1;i < W;i++) {
            if(cnt2.at(i) == true) {
                cnt3++;
            }
        }
        ret = min(ret,cnt + cnt3 - 2);
    }
    cout << ret << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<uint32_t> a(N); cin >> a;
    vector<bool> check(N);

    int ans = 0;

    REV(i,31,0){
      int cnt = 0;

      REP(j,N){
	if(a[j] & (1u<<i)) ++cnt;
      }

      if(cnt%2==1){
	REP(j,N){
	  if(!check[j] and (a[j] & (1u<<i)) and ((a[j] ^ ((a[j]>>i)<<i)) == 0)){
	    --a[j];
	    check[j] = true;
	    ++ans;
	    break;
	  }
	}
      }
    }

    uint32_t x = 0;
    for(auto y : a) x ^= y;

    if(x)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int sl=0;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=min(a,b);k>0;i--)
	{
		if((a%i==0)&&(b%i==0))
		{
			ans=i;
			k--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    int n=s.length(),m=t.length(),ans=1000000;
    for(int i=0;i<n;i++)
    {
    	if((n-i)>=m)
    	{
    		int c=0;
    		for(int j=i;j<m+i;j++)
    		{
    			if(s[j]!=t[j-i])
    			{
    				c++;
    			}
    		}
    		ans=min(ans,c);
    	}
    	else
    	{
    		break;
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A, B, T;
  cin >> A >> B >> T;
  cout << (T/A)*B << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
    
    int N, A, C;
    cin >> N;
    
    int ans = 0;
    
    for (C = 1; C < N; C++){
        for (A = 1; pow(A,2) + C <= N; A++) {
            if ((N - C) % A == 0) {
                if ((N - C) == pow(A,2)) ans++;
                else ans = ans + 2;
            }
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    static bool a[1000000001] = {false};
    REP(i,n){
        ll input;
        cin >> input;
        a[input] = true;
    }
    ll q;
    cin >> q;
    ll ans = 0;
    REP(i,q){
        ll input;
        cin >>  input;
        if(a[input])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6264
package main

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

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	a := make([]int, n)
	var sum int
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		sum += a[i]
	}

	var test func(x int) bool
	test = func(x int) bool {
		r := make([]int, n)
		for i := 0; i < n; i++ {
			r[i] = a[i] % x
		}
		sort.Ints(r)

		mSum := make([]int64, n+1)
		pSum := make([]int64, n+1)
		for i := 0; i < n; i++ {
			mSum[i+1] = mSum[i] + int64(r[i])
			pSum[i+1] = pSum[i] + int64(x-r[i])
		}

		for i := 0; i <= n; i++ {
			m := mSum[i]
			p := pSum[n] - pSum[i]

			if p > m {
				m = p
			}
			if m <= int64(k) {
				return true
			}
		}
		return false
	}

	ret := 1
	for i := 1; i*i <= sum; i++ {
		if sum%i != 0 {
			continue
		}

		if test(i) && i > ret {
			ret = i
		}
		if test(sum/i) && sum/i > ret {
			ret = sum / i
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <stdio.h>
//#define ULLONG_MAX implementation-defined
using namespace std;

int main(void)
{
	int i = 1;
	char s[100001];
	cin >> s;
	while(s[i - 1] != '\0') {
		if(i % 2)
			cout << s[i - 1];
		++i;		
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
 
ll mod = 1000000007;
ll modsize = 1010;

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(modsize + 5);
vector<ll> inv(modsize + 5);
vector<ll> facinv(modsize + 5);

void modcalc() {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0) return 0;
	if (n == 0 && k == 0) return 1;
	return modcomb(n + k - 1, k);
}

int dp[21][1010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc();

	int n, k;
	cin >> n >> k;
	vector<int> a(k);
	rep(i, k) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j <= n; j++) {
			int s = max(0LL, j - a[i - 1]);
			for (int x = s; x <= j; x++) {
				dp[i][j] += dp[i - 1][x] * modcomb(n - x, j - x) % mod*modcomb(n + x - j, a[i - 1] - j + x) % mod;
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[k][n] << endl;
}

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

int main(){
    int N;
    cin >> N;
    string S[N];

    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    int jud[4] = {0, 0, 0, 0};

    for(int i = 0; i < N; i++){
        if(S[i] == "P"){
            jud[0] = 1;
        }else if(S[i] == "W"){
            jud[1] = 1;
        }else if(S[i] == "G"){
            jud[2] = 1;
        }else{
            jud[3] = 1;
        }
    }

    for(int i = 0; i < 4; i++){
        if(jud[i] == 0){
            cout << "Three" <<endl;
        }else if(i == 3){
            cout << "Four" <<endl;
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, t;
	scanf("%d%d", &n, &t);
	int maxi = (-1) ^ (1 << 31);
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (b <= t) maxi = min(maxi, a);
	}
	if (maxi == ((-1) ^ (1 << 31))) printf("TLE\n");
	else printf("%d\n", maxi);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

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

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

void init()
{
}

void solve()
{
	int a;
	cin >> a;
	cout << (a + a * a + a * a * a) << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3184
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(int i=0;i<=n-1;i++){
        cin>>w[i]>>v[i];
    }
    ll dp[n][W+1];
    for(int i=0;i<=W;i++){
        dp[0][i]=-10000000000;
    }
    dp[0][0]=0;
    dp[0][w[0]]=v[0];
    for(int j=1;j<=n-1;j++){
        for(int i=0;i<=W;i++){
            if(i-w[j]>=0){
                dp[j][i]=max(dp[j-1][i-w[j]]+v[j],dp[j-1][i]);
            }else{
                dp[j][i]=dp[j-1][i];
            }
        }
    }
    ll m=-1;
    for(int i=0;i<=W;i++){
        m=max(m,dp[n-1][i]);
    }
    cout<<m<<endl;
    return 0;
}



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

using namespace std;

const int H = 1331;

char s[605][605];
unsigned long long h[605][605], v[605][605], p[605];

int main(){
	int n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	scanf("%s", s[i]);
	
	p[0] = 1LL;
	for(int i = 1; i <= 2 * n; i++)
	p[i] = p[i - 1] * H;
	
	for(int i = 0; i < 2 * n; i++){
		for(int j = 0; j < 2 * n; j++){
			s[i][j] = s[i % n][j % n];
			h[i][j] = s[i][j];
			if(j - 1 >= 0)
			h[i][j] += h[i][j - 1] * H;
		}
	}
	
	for(int i = 0; i < 2 * n; i++){
		for(int j = 0; j < 2 * n; j++){
			v[j][i] = s[j][i];
			if(j - 1 >= 0)
			v[j][i] += v[j - 1][i] * H;
		}
	}
	
	int res = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			bool flag = 1;
			for(int k = 0; k < n; k++){
				unsigned long long v1 = h[i + k][j + n - 1];
				if(j - 1 >= 0) v1 -= h[i + k][j - 1] * p[n];
				
				unsigned long long v2 = v[i + n - 1][j + k];
				if(i - 1 >= 0) v2 -= v[i - 1][j + k] * p[n];
				
				if(v1 != v2) flag = 0;
			}
			
			res += flag;
		}
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (i == 0) {
      continue;
    }
    else {
      for (int j = 0; j < i; j++) {
        sum += vec.at(i) * vec.at(j);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k,i,j,l,h,s=0;
  vector<int> d;
  cin>>n>>k;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    s+=a.at(i);
  }
  for(i=1;i*i<=s;i++){
    if(s%i==0){
      d.push_back(i);
      if(i*i<s) d.push_back(s/i);
    }
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  for(i=0;i<d.size();i++){
    int pl=0,mn=0;
    multiset<int> pls,mns;
    for(j=0;j<n;j++){
      if(a.at(j)%d.at(i)<d.at(i)/2){
        mn+=a.at(j)%d.at(i);
        mns.insert(a.at(j)%d.at(i));
      }
      else{
        pl+=d.at(i)-a.at(j)%d.at(i);
        pls.insert(a.at(j)%d.at(i));
      }
    }
    if(pl>mn){
      auto it=pls.begin();
      h=(pl-mn)/d.at(i);
      for(j=0;j<h;j++){
        l=*next(it,j);
        mn+=l;
        pl-=d.at(i)-l;
      }
    }
    else if(pl<mn){
      auto it=mns.end();
      h=(mn-pl)/d.at(i);
      for(j=0;j<h;j++){
        l=*prev(it,j+1);
        mn-=l;
        pl+=d.at(i)-l;
      }
    }
    if(pl<=k){
      cout<<d.at(i)<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 500001
#define prob "C"
#define pb push_back
#define ll long long
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
#define fast ios_base::sync_with_stdio(1); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
int n,a[N],b[N],c[N];
int f[N][3];
int main()
{
    fast
//    io
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
    for(int i=1;i<=n;i++)
    {
        f[i][0]=max(f[i-1][1],f[i-1][2])+a[i];
        f[i][1]=max(f[i-1][0],f[i-1][2])+b[i];
        f[i][2]=max(f[i-1][0],f[i-1][1])+c[i];
    }
    cout<<max(f[n][0],max(f[n][1],f[n][2]));
}



Measured memory_bytes: 7552
from itertools import product
from math import ceil
n,k=map(int,input().split())
A=[]
for i in range(1,n+1):
  a,b=map(int,input().split())
  A+=[(a,i*100,a*i*100+b)]

ans=1e9
for p in product([0,1],repeat=n):
  s=0
  c=0
  m=0
  for i,j in enumerate(p):
    if j==1:
      c+=A[i][0]
      s+=A[i][2]
    else:
      m=max(m,i)
  if s>=k:
    ans=min(ans,c)
  else:
    if (k-s)/A[m][1]<A[m][0]:
      ans=min(ans,c+ceil((k-s)/A[m][1]))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

vector<int> c;
int cnt[200010];
ll dp[200010];
ll sum[200010];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, i, j, k;
    cin >> n;
    c.pb(-1);
    rep(i, n) {
        int x;
        cin >> x;
        if (x != c.back()) {
            c.pb(x);
        }
    }
    n = c.size();
    dp[0] = 1;
    xrep(i, 1, n) {
        dp[i] = (dp[i - 1] + sum[c[i]]) % mod;
        sum[c[i]] += dp[i - 1];
        sum[c[i]] %= mod;
    }
    cout << dp[n - 1] << endl;
}



Measured memory_bytes: 4340
#include<stdio.h>
#include<math.h>
int main(){
	
	double x1,x2,y1,y2;
	double kyori;
	
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	
	kyori=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	
	printf("%.8f\n",kyori);
	return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char s[250000],t;
    long long n,l=0,i;
    scanf("%s",&s);
    scanf("\n");
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        scanf("%1c",&t);
        if(t!=s[i])
        {
            l++;
        }
    }
    printf("%lld\n",l);
    return 0;        
}

Measured memory_bytes: 1900
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int n;string s;

ll solve(int k){
    ll d=0,m=0,dm=0,ret=0;
    rep(i,k){
        if(s[i]=='D')d++;
        if(s[i]=='M'){
            dm+=d;
            m++;
        }
        if(s[i]=='C')ret+=dm;
    }
    for(int i=k;i<n;i++){
        if(s[i-k]=='D'){
            dm-=m;d--;
        }
        if(s[i-k]=='M')m--;
        
        if(s[i]=='D') d++;
        if(s[i]=='M'){
            dm+=d;
            m++;
        }
        if(s[i]=='C')ret+=dm;
    }
    return ret;
}

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

    cin>>n;
    cin>>s;

    vector<ll> ans;
    int q;cin>>q;
    while(q--){
        int k;cin>>k;
        ans.push_back(solve(k));
    }
    for(auto x:ans){
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 1948
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int N = 200;
int cnt[N];

bool construct(int len) {
  if (len % 2 == 1) {
    for (int i = len; i > len / 2; --i) {
      if (cnt[i] < 2) return false;
      cnt[i] -= 2;
    }
  } else {
    for (int i = len; i > len / 2; --i) {
      if (cnt[i] < 2) return false;
      cnt[i] -= 2;
    }
    if (cnt[len / 2] < 1) return false;
    cnt[len / 2]--;
  }
  int min_len = (len + 1) / 2 + 1;
  for (int i = 1; i < min_len; ++i) {
    if (cnt[i]) return false;
  }
  return true;
}

int main() {
  int n;
  int len = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
    len = max(len, x);
  }
  puts(construct(len) ? "Possible" : "Impossible");
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  long long k; cin >> k;
  if(s.size() == 1) {
    cout << k/2 <<endl; return 0;
  }
  string s2 = s + "0";
  long long res = 0;
  vector<long long> comps;
  long long x = 1;
  for(int i = 1; i < s2.size(); i++) {
    if(s2[i] == s2[i-1]) x++;
    else {
      comps.push_back(x);
      x = 1;
    }
  }
//  for(int i = 0; i < comps.size(); i++) cout << comps[i] << endl;
  if(comps.size() == 1) {
    cout << (k*comps[0])/2 << endl; return 0;
  }
  for(int i = 0; i < comps.size(); i++) res += comps[i]/2;
  if(s[0] == s[s.size()-1]) {res -= comps[0]/2; res -= comps[comps.size()-1]/2;}
  res *= k;
  if(s[0] == s[s.size()-1]){
    res += (k-1)*((comps[0]+comps[comps.size()-1])/2);
    res += comps[0]/2; res += comps[comps.size()-1]/2;
  }
  cout << res << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,A,B,C,M,L[200000]={},t[2000],res=0;
string S,T;
long double va,vb;



int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N; i++){
        cin>>L[i];
        res+=L[i];
    }
    sort(L,L+N,greater<long long int>());
    res-=L[0];
    IFYes(L[0]<res);
}    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int n;
double a[3000],dp[3000][3000];
double f(int i,int j){
    if (i>n){
        if (j>n-j)
            return 1;
        else
            return 0;
    }
    if (dp[i][j]!=(double)-1)
        return dp[i][j];
     return dp[i][j]=f(i+1,j+1)*a[i]+f(i+1,j)*(1-a[i]);

}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for (int i=0;i<3000;i++)
    for (int j=0;j<3000;j++)
    dp[i][j]=-1;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    printf("%.9lf\n",f(1,0));
    return 0;
}


Measured memory_bytes: 70784
N = int(input())

def divisors(n):
    ret1 = []
    ret2 = []
    i = 1
    while i**2 <= N:
        if n%i == 0:
            ret1 += [i]
            ret2 += [n//i]
        i += 1
    return ret1 + ret2

ans1 = set(divisors(N-1))
ans2_cand = set(divisors(N))
ans2 = 0
for k in ans2_cand:
    if k == 1: continue
    n = N
    while n%k == 0:
        n = n//k
    if n%k == 1:
        ans2 += 1


print(len(ans1) + ans2 -1)

Measured memory_bytes: 9692
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;


int main(int argc, char *argv[]) {
    long long int n;
    cin >> n;
    long long int res = n - 1;
    for (long long int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res = min(res, i - 1 + n / i - 1);    
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,m,r,r0=0;
  int t[101],p[101],x[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&t[i]);
    r0+=t[i];
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d%d",&p[i],&x[i]);
    r=r0;
    for(int j=0;j<n;j++)if(p[i]==j+1)r-=t[j]-x[i];
    printf("%d\n",r);
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool A = false,B = false,C = false;
  for (int i = 0; i < 3 ;i++){
    if(s.at(i) == 'a')
      A = true;
    if(s.at(i) == 'b')
      B = true;
    if(s.at(i) == 'c')
      C = true;
  }
  if(A && B && C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
g = []
for _ in range(n):
  a, b = map(int, input().split())
  g.append([a,b])
g = np.array(g)
g = g[np.argsort(g[:, 1])]
a = 0
for i,j in g:
  a+=i
  if a>j:
    print('No')
    exit(0)
print('Yes')

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

int main() {
  string w;
  cin >> w;
  vector<int> V(26, 0);
  for (int i=0; i<w.size(); i++) {
    V[w[i]-'a']++;
  }
  
  string ans="Yes";
  for (int i=0; i<V.size(); i++) {
    if (V[i]%2==1) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long sum=0;
  int n=s.size();
  for(int temp=0;temp<(1<<n-1);temp++){
    long long t=s[0]-'0';
    for(int i=0;i<n-1;i++){
      if(temp&(1<<i)){
        sum+=t;
        t=s[i+1]-'0';
      }else{
        t*=10;
        t+=s[i+1]-'0';
      }
    }
    sum+=t;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    print("Yes" if any(a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1]
                       and a[i+2][0] == a[i+2][1] for i in range(0, n-2)) else "No")


def main():
    t = 1
    while t > 0:
        solve()
        t -= 1


main()

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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int k, l;
    cin >> k;
    l = k / 2;
    if (k % 2 == 1) cout << l * (l + 1) << endl;
    else cout << l * l << endl;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = a[0] - 1;
    int val = 2;
    for(int i = 1; i < n; i++) {
        if(a[i] == val) {
            val++;
            continue;
        }
        ans += a[i] / val - (a[i] % val == 0);
    }
    cout << ans << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    vector<ll> f(N+1);
    f[0] = 0;
    f[1] = 1;
    // 2の倍数と3の倍数だけは最初に記録しておく
    for(int i=2; i<=N; i++){
        f[i] = 1;
        if(i % 2 == 0) ++f[i];
        if(i % 3 == 0) ++f[i];
    }
    // それぞれの約数の個数を配列に記録していく
    for(int i=4; i<=N; i++){
        ++f[i];
        int j = 2;
        while(true){
            if(i * j <= N){
                ++f[i*j];
                ++j;
            }else{
                break;
            }
        }
    }
    ll sum = 0;
    for(ll i=1; i<=N; i++) sum += i*f[i];
    cout << sum << endl;
}

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

int main(){
  	unsigned int a, b, c, d, e, f, g, h, i, fN;
  	unsigned long long int N;
  
  	cin >> N;
  
  	i = N / 100000000;
  	h = N / 10000000;
  	g = (N-10000000*h)/1000000;
  	f = (N-10000000*h-1000000*g)/100000;
  	e = (N-10000000*h-1000000*g-100000*f)/10000;
  	d = (N-10000000*h-1000000*g-100000*f-10000*e)/1000;
  	c = (N-10000000*h-1000000*g-100000*f-10000*e-1000*d)/100;
  	b = (N-10000000*h-1000000*g-100000*f-10000*e-1000*d-100*c)/10;
  	a = (N-10000000*h-1000000*g-100000*f-10000*e-1000*d-100*c-10*b);
  
  	fN = a+b+c+d+e+f+g+h+i;
  	
  	if(N % fN == 0)	cout << "Yes" << endl;
  	else	cout << "No" << endl;
  	
  	return 0;
}

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

int main() {

  int n, k;
  cin >> n >> k;
  int p[n];
  for ( int i=0; i<n; i++ ) {
    cin >> p[i];
  }
  
  double sum = 0;
  double sumBest = 0;
  for ( int i=0; i<n; i++ ) {
    if ( i<k ) {
      sum += ( 1.0 + p[i] );
      sumBest = sum;
    } else {
      sum -= p[i-k];
      sum += p[i];
      if ( sum > sumBest ) {
        sumBest = sum;
      }
    }
    
  }

  cout << fixed << setprecision(12) << sumBest/2.0 << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){int64_t h,w;
cin>>h>>w;
if(h==1||w==1){
  cout<<1<<endl;
}
else if((h*w)%2==0){
  cout<<(h*w)/2<<endl;
}
else{
cout<<(h*w+1)/2<<endl;
}


}


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

using namespace std;

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


int main()
{
  string s;
  cin >> s;

  while(true) {
    s.erase(s.begin() + int(s.size()) - 1);
    string tmps1 = s.substr(0,int(s.size()) / 2);
    string tmps2 = s.substr(ceil(double(s.size())) / 2, int(s.size()));
    if (tmps1 == tmps2) {
      cout << s.size() << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int h[n+1]; for(int i = 1; i < n+1; ++i) cin >> h[i];
    int dp[n+1]; memset(dp,0,sizeof(dp));
    for(int i = 2; i < n+1; ++i){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i >= 3) dp[i] = min(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4392
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,a,b=pM(split(readline()))
  s=abs(a-b)
  if s%2==0
    println(s÷2)
  else
    println(min(a-1,n-b)+(s-1)÷2+1)
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 169708
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>


using namespace std;

int main(int argc, const char * argv[]) {
    float A,B;
    cin >> A >> B;
    float answer;
    answer = max(A+B,A-B);
    answer = max(answer,A*B);
    cout << answer;
}

Measured memory_bytes: 256
from math import sqrt
from itertools import combinations

def dist(X, Y):
    d = 0
    for x, y in zip(X, Y):
        d += pow(x-y, 2)
    d = sqrt(d)
    if d == int(d):
        return 1
    return 0

N, D = map(int, input().split())
Z = []
for n in range(N):
    z = list(map(int, input().split()))
    Z.append(z)

C = [i for i in range(N)]
ans = 0
for c in combinations(C, 2):
    ans += dist(Z[c[0]], Z[c[1]])

print(ans)


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------


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

	while(true) {
		int n,p;cin>>n>>p;
		if(n==0) break;
		int have[n]={};
		int idx=0,stone=p;
		while(true) {
			if(stone>0) {
				have[idx%n]++,stone--;
				if(have[idx%n]==p) {
					cout<<idx%n<<endl;
					break;
				}
			}
			else {
				stone+=have[idx%n],have[idx%n]=0;
			}
			idx++;
		}
	}

	return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    vector<int> S(s.size()+1, 0), T(s.size()+1, 0);

    int ans = 0;
    for(int i=1; i<=s.size(); i++){
        if(s[i-1] == 'S'){
            S[i] = S[i-1]+1;
            T[i] = T[i-1];
        }
        else{
            S[i] = S[i-1];
            T[i] = T[i-1]+1;
        }

        if(T[i]>S[i]){
            ans += 2;
            T[i]--;
        }
    }

    cout << ans << endl;
}

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

struct edge{int from, to;};
int N, M;
vector<edge> es;
bool d[50][50];
bool dist[50];

bool bfs(int s){
	queue<int> q;
	q.push(s);
	for(int i = 0; i < N; i++) dist[i] = false;
	dist[s] = true;
	int u;
	while(!q.empty()){
		u = q.front(); q.pop();
		for(int v = 0; v < N; v++){
			if(d[u][v] == false) continue;
			if(dist[v] != false) continue;
			dist[v] = true;
			q.push(v);
		}
	}
	for(int i = 0; i < N; i++){
		if(dist[i] == false) return false;
	}
	return true;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		es.push_back((edge){a, b});
	}

	int ans = 0;
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k < N; k++){
				d[j][k] = false;
			}
		}
		for(int j = 0; j < M; j++){
			if(i == j) continue;
			d[es[j].from][es[j].to] = true;
			d[es[j].to][es[j].from] = true;
		}
		if(bfs(0) == false) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){

    int k,last;
    cin >> k;
    vector<ll> a ;
    rep(i,9) a.push_back(i+1);
    
    int p=0;
    while(p<k){
        last = a[p] % 10 ;
        if( last - 1 >= 0 )a.push_back(a[p]* 10 + last -1);
        a.push_back(a[p]*10 + last);
        if( last + 1 < 10 )a.push_back(a[p]* 10 + last +1);
        p++;
    }
    
    cout << a[p-1] << endl;
	return 0;
}



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

int N;
int d = 0;                    //総距離
vector<int> p;


int main(){
  cin >> N;

  p.push_back(0);    //初期
  int v;
  for(int i = 0; i < N; i++){ cin >> v; p.push_back(v); }
  p.push_back(0);   //終端
  for(int i = 0; i <= N; i++){ d += abs(p[i+1] - p[i]); }   //現在N+2個の位置情報がある

  /*パターンは3*2*1 = 6通り*/
  for(int i = 1; i <= N; i++){
    if(p[i-1] <= p[i] && p[i] <= p[i+1] || p[i-1] >= p[i] && p[i] >= p[i+1] )
      cout << d << endl;                                            //p[i],つまり通過ポイントが途中にあり短縮なし
    else if(p[i] <= p[i-1] && p[i-1] <= p[i+1] || p[i+1] <= p[i-1] && p[i-1] <= p[i])
      cout << d-2*abs(p[i]-p[i-1]) << endl;      //p[i]--p[i-1]間が往復分消える
    else if(p[i] <= p[i+1] && p[i+1] <= p[i-1] || p[i-1] <= p[i+1] && p[i+1] <= p[i])
      cout << d-2*abs(p[i+1]-p[i]) << endl;     //p[i+1]--p[i]間が往復分消える
  }

  return 0;
}

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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector< long long > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sp(x) setprecision(x)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define deb(x) cout<<#x <<x <<endl
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
        string s;
  cin>>s;
  if(s[1]=='B')
    cout<<"ARC"<<endl;
  else
    cout<<"ABC"<<endl;
        

}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.lang.Math;
class Main {
    public static void main(String args[]) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int m = scan.nextInt();
      int sum = 0;
      for(int i = 0; i < m; i++){
          sum += scan.nextInt();
          
      }
      if(n-sum < 0){
          System.out.println(-1);
      }else{
          System.out.println(n-sum);
      }
    }
}


Measured memory_bytes: 46392
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

typedef long double ld;
const ld MAX=1e4;
const ll E=1e9;
const ll INF=1e18;

bool check(ll A,ll B){
  if(A>(2*INF/B)) return true;
  if(A*B>=INF) return true;
  return false;
}

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

  int N;
  //cin>>N;
  scanf("%d\n",&N);
  vector<ld> A(N);
  vector<ll> B(N),C(N);
  rep(i,N){
    string S;
    getline(cin,S);
    bool flag=false;
    int num=0;
    S+=".0000000000";
    for(auto c:S){
      if(num==9) break;
      if(c=='.') flag=true;
      else if(flag){
        num++;
        C[i]=C[i]*10+(c-'0');
      }else{
        B[i]=B[i]*10+(c-'0');
      }
    }
  }

  vector<ll> D(N);
  rep(i,N) D[i]=B[i]*E+C[i];
  map<pair<int,int>,ll> mp;
  rep(i,N){
      int tn=0;
      while(D[i]%2==0){
          D[i]/=2;
          tn++;
      }
      int fn=0;
      while(D[i]%5==0){
          D[i]/=5;
          fn++;
      }
      mp[mkp(tn,fn)]++;
  }

  ll ans=0;
  for(auto lef:mp){
      for(auto rig:mp){
          auto l=lef.first;
          auto r=rig.first;
          if(l.first+r.first>=18&&l.second+r.second>=18){
              ans+=lef.second*rig.second;
              if(lef==rig) ans-=lef.second;
          }
      }
  }
  cout<<ans/2<<endl;


  //rep(i,N) cout<<B[i]<<" "<<C[i]<<endl;

  return 0;
}


Measured memory_bytes: 11180