akhauriyash/Code-Regression huggingface dataset:
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
} 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
ll ncr(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		if(s[2]==s[3] && s[4]==s[5])
		{
			cout<<"Yes";
		}
		else
		cout<<"No";
	}
	return 0;
}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> a(n), f(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	f[0] = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] <= a[i - 1])
			f[i] = f[i - 1] + 1;
		else
			f[i] = 0;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, f[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int N; cin >> N;
    vector<string> s(N); for(int i = 0; i < N; i++) cin >> s[i];
    // vector<string> s_sort(N);
    map<string, ll> mp;
    
    for(int i = 0; i < N; i++){
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }
    
    ll ans = 0;
    for(auto itr : mp){
        if(itr.second > 1) ans += (itr.second * (itr.second-1)) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18176
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    int a; cin>>a;
    if(a%2){cout<<0; return 0;}
    vec<int> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    sort(m.begin(), m.end());
    cout<<m[a/2]-m[a/2-1];
}

Measured memory_bytes: 640
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()
    s = list(input())
    a = 0
    for i,q in itertools.groupby(s):
        # print(i,k)
        a += 1
    a -= 1
    print(n-1-max(a-2*k,0))




if __name__=="__main__":
    main()


Measured memory_bytes: 78112
import itertools
N = int(input())
p = 3
digits = [3, 5, 7]
A = []
flag = False
while True:
    for tup in itertools.product(digits, repeat=p):
        a = int("".join(list(map(str, tup))))
        if a > N:
            flag = True
            break
        A.append(a)
    if flag:
        break
    p += 1
count = 0
for a in A:
    if "3" in str(a) and "5" in str(a) and "7" in str(a):
        count += 1
print(count)


Measured memory_bytes: 4364
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using ll=long long;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    
    int center=n/2;
    sort(d.begin(),d.end());
    
    if(d[center]==d[center-1]) cout<<0<<endl;
    else{
        cout<<d[center]-d[center-1]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3748
a,b,c,x,y = list(map(int,input().split()))
ret = 0
if a+b > c*2:
    targetPizza = 0
    if x>y:
        x -= y
        ret += y*c*2
        y = 0
        if c*2 < a:
            ret += c*2*x
            x = 0

    else:
        y -= x
        ret += x*c*2
        x = 0
        if c*2 < b:
            ret += c*2*y
            y = 0
ret += a*x
ret += b*y
print(ret)


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,k;

int main(){
    cin >> n >> k;
    if(n%k == 0)    cout << "0\n";
    else
    {
        cout << "1\n";
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

int N;
int T;

signed main()
{
    cin >> N;

    int ans = 1;
    REP(i,N) {
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int distance2(vector<int> a, vector<int> b) {
  int sum = 0;
  for (int i = 0; i < static_cast<int>(a.size()); ++i)
    sum += pow(a[i] - b[i], 2);
  return sum;
}

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

  vector<vector<int>> vec(n, vector<int>(d));
  for (auto &v : vec)
    for (auto &a : v)
      cin >> a;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d2 = distance2(vec[i], vec[j]);
      if (pow(int(sqrt(d2)), 2) == d2)
        ++cnt;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
def q3():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = [0] * N
    for i, a in enumerate(A):
        ans[a-1] = i + 1
    print(' '.join([str(i) for i in ans]))


if __name__ == '__main__':
    q3()


Measured memory_bytes: 17804
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;
const double PI=3.14159265358979323846;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int flag=1;
  rep(i,(n-1)/2){
    if(s[i]!=s[n-1-i]) flag=0;
  }
  rep(i,(n-1)/2){
    if(s[i]!=s[(n-3)/2-i]) flag=0;
    if(s[(n+1)/2+i]!=s[n-1-i]) flag=0;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      _s: [usize; n]
   }
   let mut s = _s;
   s.sort();
   let mut ans = 0;
   for &c in s.iter() {
      ans += c;
   }

   if ans % 10 == 0 {
      for &c in s.iter() {
         if c % 10 != 0 {
            ans -= c;
            break;
         }
      }
   }
   if ans % 10 == 0 {
      ans = 0;
   }
   println!("{}", ans);
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

int main(){
  int N;
  map<int, int> mp;
  cin >> N;
  vector<int> A(N);
  // REP(i, N){
  //   cin >> A[i];
  //   auto itr = mp.find(A[i]);
  //   if(itr == mp.end()){
  //     mp[A[i]]=1;
  //   }
  //   else{
  //     itr->second++;
  //   }
  // }
  // pair<int, int> ans = make_pair(0,0);
  // for(auto it = mp.begin(); it != mp.end(); it++){
  //   if(it->second >= 4){
  //     ans.first = max(ans.first, it->first);
  //     ans.second = max(ans.second, it->first);
  //   }
  //   else if(it->second >= 2){
  //     ans.first = max(ans.first, it->first);
  //   }
  //   if(ans.first > ans.second){
  //     int box;
  //     box = ans.first;
  //     ans.first = ans.second;
  //     ans.second = box;
  //   }
  // }
  // cout << ans.first * ans.second << endl;
  // cout << "first:" << ans.first << " second:" << ans.second << endl;
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<int>ans;
  int cnt = 0, box = -1;
  for(int i = A.size()-1; i >= 0; --i){
    if(A[i] != box){
      for(int j =1; j*2 <= cnt; j++){
        ans.push_back(box);
      }
      box = A[i];
      cnt = 1;
    }
    else{
      cnt++;
    }
  }
  for(int j =1; j*2 <= cnt; j++){
        ans.push_back(box);
  }
  if(ans.size() >= 2){
    cout << (ll)ans[0] * (ll)ans[1] << endl;
  }
  else{
    cout << 0 << endl;
  }
  // cout << ans[0] << " " <<ans[1] << endl;
  // REP(i, N){
  //   cout << A[i] << " ";
  // }
  return 0;
  
}

Measured memory_bytes: 1024
#include<cstdio>
char a[100][101];
bool wflag[100],hflag[100];
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",a[i]);
    for(int i=0;i<h;i++){
        hflag[i]=true;
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                hflag[i]=false;
                break;
            }
        }
    }
    for(int i=0;i<w;i++){
        wflag[i]=true;
        for(int j=0;j<h;j++){
            if(a[j][i]=='#'){
                wflag[i]=false;
                break;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(!hflag[i]){
            for(int j=0;j<w;j++){
                if(!wflag[j]){
                    printf("%c",a[i][j]);
                }
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
package main

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

const mod = 1000000007

var cs [][]int

func initCmb(x int) {
	cs = make([][]int, x+1)
	for i := range cs {
		cs[i] = make([]int, i+1)
		cs[i][0], cs[i][len(cs[i])-1] = 1, 1
		for j := 1; j < len(cs[i])-1; j++ {
			cs[i][j] = (cs[i-1][j-1] + cs[i-1][j]) % mod
		}
	}
}

func cmb(x, y int) int {
	if y > x {
		return 0
	}
	return cs[x][y]
}

var wr = bufio.NewWriter(os.Stdout)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

	initCmb(max(n-k+1, k-1))
	for i := 1; i <= k; i++ {
		wr.WriteString(strconv.Itoa(cmb(n-k+1, i)*cmb(k-1, i-1)%mod) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 6/3/2020

 9:00-

 */

const int MAX_N=1e6+1;
LL A[3][MAX_N];
int N[3],K;

void solve() {
  REP(i,3)REP(j,N[i]) sort(A[i],A[i]+N[i]),reverse(A[i],A[i]+N[i]);
  vector<LL> xs;
  REP(i,N[0])REP(j,N[1]) xs.push_back(A[0][i]+A[1][j]);
  sort(xs.rbegin(),xs.rend());
  vector<LL> res;
  REP(i,min(SZ(xs),K))REP(j,N[2]) res.push_back(xs[i]+A[2][j]);
  sort(res.rbegin(),res.rend());
  REP(i,K) cout<<res[i]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  REP(i,3)cin>>N[i];
  cin>>K;
  REP(i,3)REP(j,N[i]) cin>>A[i][j];
  solve();

  return 0;
}


Measured memory_bytes: 47460
# coding: utf-8
# Your code here!

N = int(input())
x = [list(map(str, input().split())) for _ in range(N)]
tmp = []
for i in range(N):
    if x[i][1] == 'JPY':
        tmp.append(float(x[i][0]))
    else:
        tmp.append(float(x[i][0]) * 380000)
print(sum(tmp))

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

void doRoutine() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("C:\\Users\\M\\alg\\practice\\clion_main\\input.txt", "r", stdin);
    freopen("C:\\Users\\M\\alg\\practice\\clion_main\\output.txt", "w", stdout);
#endif
}


#define DBG(VAR) cerr << #VAR << ": " << VAR << endl

#define all(x) x.begin(), x.end()
#define vb vector<bool>
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define vc vector
#define $ make_pair

#ifndef LOCAL
#define cerr if(0) cerr
#define DBG(...) (true)
#endif

#define D double
#define int long long

// ----------------------------- CODE NOW ------------------------

signed main() {
    doRoutine();

    int n;
    cin >> n;
    bool odd = false;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2) {
            odd = true;
        }
    }

    if (odd) {
        cout << "first" << endl;
    }
    else {
        cout << "second" << endl;
    }

    return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)

#define INF 20000

using ll = long long;
using namespace std;

int main() {
    int sx, sy, gx, gy, ans = 0;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    int H, W;
    cin >> H >> W;
    int a[30][30];  //スタート位置からの距離
    char c[30][30]; //迷路の形状

    rep(i, H)
        rep(j, W)
            a[i][j] = INF;  //未探索のエリアはINFに

    rep(i, H)
        rep(j, W)
            cin >> c[i][j];

    rep(i,H) {
        rep(j,W) {
            if(c[i][j] != '.') continue;
            sx = i; sy = j;
            rep(k,H){
                rep(l,W){
                    if(c[k][l] != '.') continue;
                    gx = k; gy = l;
                    rep(i_i, H)
                        rep(j_i, W)
                            a[i_i][j_i] = INF;  //未探索のエリアはINFに

                    queue<int> qy,qx;   //探索予定の座標(ペアにするとxy逆でよくミスする)
                    a[sx][sy] = 0;  //スタート位置の移動距離距離を0に設定
                    qx.push(sx); qy.push(sy);
                    while(!qx.empty()) {
                        //現在地の取得
                        int x = qx.front(); qx.pop();
                        int y = qy.front(); qy.pop();

                        if(x == gx && y == gy) break;

                        rep(i, 4){
                            //チェックする座標の取得
                            int cx = x + dx[i];
                            int cy = y + dy[i];

                            //チェックする座標が範囲内
                            if(cx >= 0 && cx < H && cy >= 0 && cy < W){
                                //チェックする座標が通れる かつ　未探索
                                if(c[cx][cy] == '.' && a[cx][cy] == INF) {
                                    a[cx][cy] = a[x][y] + 1;
                                    qx.push(cx);
                                    qy.push(cy);
                                }
                            }
                        }
                    }
                    
                    ans = max(ans,a[gx][gy]);
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
// Aizu 1126: The Secret Number
// 2017.9.15 bal4u@uu

#include <stdio.h>
#include <ctype.h>
#include <string.h>

char d[72][72], s[72][72][72];
int a[72][72];
char ans[72]; int len;

int main()
{
	int w, h, r, c;

	while (scanf("%d%d", &w, &h) && w) {;
		memset(a, 0, sizeof(a));
		for (r = 0; r < h; r++) scanf("%s", d[r]);
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
			if (!isdigit(d[r][c])) continue;
			a[r][c] = 0;
			if (c > 0 && isdigit(d[r][c-1]))
				a[r][c] = a[r][c-1], memcpy(s[r][c], s[r][c-1], a[r][c]);
			if (r > 0 && isdigit(d[r-1][c])) {
				if (a[r-1][c] > a[r][c] || (a[r-1][c] == a[r][c] && memcmp(s[r-1][c], s[r][c], a[r][c]) > 0))
					a[r][c] = a[r-1][c], memcpy(s[r][c], s[r-1][c], a[r][c]);
			}
			if (a[r][c] == 0 && d[r][c] == '0') continue;
			s[r][c][a[r][c]] = d[r][c], a[r][c]++;
		}
		for (len = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) {
			if (a[r][c] > len || (a[r][c] == len && memcmp(s[r][c], ans, len) > 0)) len = a[r][c], memcpy(ans, s[r][c], len);
		}
		ans[len] = 0;
		puts(ans);
    }
	return 0;
}

Measured memory_bytes: 2020
#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 x,k,d;
	cin >> x >> k >> d;
	map<ll,ll> xold;
	ll krest = k;
	bool rept = false;
	if (x < 0) {
		x = -x;
	}
	ll kadv = x / d;
	if (kadv > k) {
		x -= k*d;
		k = 0;
		cout << abs(x) << endl;
	} else {
		x -= kadv*d;
		k -= kadv;
	
		if (k % 2 == 0) 
			cout << abs(x) << endl;
		else {
			x -= d;
			cout << abs(x) << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, T;
	cin >> S >> T;
	T.pop_back();
	if (S == T) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, c=0;
  cin >> n;
  forll(i, 1, n)
	c += i;
  cout << c << endl;
}

Measured memory_bytes: 256
n = int(input())
d_array = [int(x) for x in input().split()]
d_dict = {}
for d in d_array:
    d_dict.setdefault(d, 0)
    d_dict[d] += 1
m = int(input())
t_array = sorted([int(x) for x in input().split()])

try:
    for t in t_array:
        if d_dict[t] > 0:
            d_dict[t] -= 1
        else:
            print("NO")
            break
    else:
        print("YES")
except KeyError:
    print("NO")
    exit()


Measured memory_bytes: 46176
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;

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

    int N, M, C;
    cin >> N >> M >> C;
    int A[N][M];
    vector<int> B(M);
    REP(i, M) { cin >> B[i]; }
    REP(i, N) { REP(j, M) cin >> A[i][j]; }

    int ans = 0;
    REP(i, N) {
        int sum = 0;
        REP(j, M) { sum += A[i][j] * B[j]; }
        sum += C;
        if (sum > 0)
            ans++;
    }

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

Measured memory_bytes: 256
#1???????????????
num_data = int(input())


for i in range(num_data):
    input_line = input().split(" ")
    
    a = int(input_line[0])
    b = int(input_line[1])
    c = int(input_line[2])
    
    #?????????????????????????????????????????§
    if (pow(a,2) + pow(b,2) == pow(c,2) ) or (pow(a,2) + pow(c,2) == pow(b,2) ) or (pow(b,2) + pow(c,2) == pow(a,2)):  
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7628
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <iostream>
#include <cmath>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <fstream>
#include <numeric>
#include <iterator>
#include <cstdio>
#include <cstring>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fread(p) freopen(p,"r",stdin);
#define fwrite(p) freopen(p,"w",stdout);
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define nl "\n"
#define mem(s,k) memset(s, k, sizeof(s))
#define sf scanf
#define pf printf
#define PI 2*acos(0.0)
#define ALL(p) (p.begin(),p.end())
#define mod(a,b) ((((a)%(b))+(b))%(b))
#define time_start clock_t start = clock();
#define time_end clock_t finish = clock(); cout << (double)(finish-start)/CLOCKS_PER_SEC << endl;
const double EPS = 1e-9;

////--- Graph Moves---////
//const ll xx[] = {0,0,1,-1};
//const ll yy[] = {1,-1,0,0};
//const ll xx_king[] = {0,0,1,-1,1,1,-1,-1};
//const ll yy_king[] = {1,-1,0,0,1,-1,1,-1};
//const ll xx_knight[]= {-2,-1,1,2,2,1,-1,-2};
//const ll yy_knight[]= {1,2,2,1,-1,-2,-2,-1};
////------------------////

ll POW(ll b,ll p) {ll Ans=1; while(p){if(p&1)Ans=(Ans*b);b=(b*b);p>>=1;}return Ans;}
ll BigMod(ll b,ll p,ll Mod) {ll Ans=1; while(p){if(p&1)Ans=(Ans*b)%Mod;b=(b*b)%Mod;p>>=1;}return Ans%Mod;}
ll ModInverse(ll b,ll Mod) {return BigMod(b,Mod-2,Mod);}

string tostr(ll n) {stringstream rr;rr<<n;return rr.str();}
//template<typename T> using orderedSet = tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

////----------- Bit Manipulation -----------------//
//int bitOn(int N,int pos){return N=N OR (1<<pos);}
//int bitOff(int N,int pos){return N= N &~(1<<pos);}
//bool bitCheck(int N,int pos){return (bool)(N & (1<<pos));}
////---------------------------------------------//

////------------ Debugging -----------------------//
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ",   ";
    deb(++it, args...);
}

#define ekhane(k) cerr << "Ekhane asche-" << k << "\n";
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
////-----------------------------------------------//

int main()
{
    int r;
    cin >> r;
    cout << 3*r*r << nl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n[5], tmp, i, j;
    
    scanf("%d %d%d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4]);
    for (i = 0; i < 4; i++){
        for (j = i + 1; j < 5; j++){
            if (n[i] < n[j]){
                tmp = n[i];
                n[i] = n[j];
                n[j] = tmp;
            }
        }
    }
    printf("%d %d %d %d %d\n", n[0], n[1], n[2], n[3], n[4]);
    
    return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    System.out.println(n%k==0?0:1);
  }
}

Measured memory_bytes: 21076
n = int(input())
def check(fours,sevens,rem):
    if rem<0:
        return False
    elif rem==0:
        return True
    elif rem > 0:
        bf,bs = False,False
        bf = check(fours+1,sevens,rem-4)
        bs = check(fours,sevens+1,rem-7)
        if bf or bs:
            return True
        else:
            return False
        
if check(0,0,n) == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
//ワーシャルフロイゼ法(隣接行列を受け取り、それぞれの最短を受け取る、size:10^2-)
vector<vector<int>> WarshallFloyd(vector<vector<int>> &pathmatrix){
	int index=pathmatrix.size();
	vector<vector<int >>res=pathmatrix;
	for (int a = 0; a < index; a++){
		for (int b = 0; b < index; b++){
			for (int c = 0; c < index; c++){ 
				chmin(res[b][c], res[b][a] + res[a][c]);
			}
		}
	}
	return (res);
}
int main(){
	int h,w;
	ll ans=0LL;
	cin >>h>>w;
	VVi c(10, Vi(10));
	rep(i, 10) { input(c[i]); }
	VVi res = WarshallFloyd(c);
	VVi a(h, Vi(w));
	map<int, int> dis;
	rep(i, h) { input(a[i]); }
	rep(i, h) {
		rep(j, w) { dis[a[i][j]]++; }
	}
	repi(itr, dis) {
		if (itr->F == -1) continue;
		ans += (ll)(itr->S) * res[itr->F][1]; }
	cout<<ans<<endl;
}

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

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

  long ans = 0;
  for(long i=0; i<N; i++){
    ans += a[i]-1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

struct Parsed {
  string str;
  bool res;
  Parsed(string str, bool res): str(str), res(res) {}
};

string str;
bool table[11];

Parsed formula(string str)
{
  if (str == "") {
    return Parsed("", true);
  }

  char c1 = str[0];
  string rest = str.substr(1);
  if (c1 == 'T') {
    return Parsed(rest, true);
  } else if (c1 == 'F') {
    return Parsed(rest, false);
  } else if (c1 >= 'a' && c1 <= 'k') {
    return Parsed(rest, table[c1 - 'a']);
  } else if (c1 ==  '-') {
    Parsed ps = formula(rest);
    ps.res = !ps.res;
    return ps;
  } else if (c1 == '(') {
    Parsed lhs = formula(rest);
    char op = lhs.str[0];
    if (op == '*') {
      Parsed rhs = formula(lhs.str.substr(1));
      return Parsed(rhs.str.substr(1), lhs.res & rhs.res);
    } else if(op == '+') {
      Parsed rhs = formula(lhs.str.substr(1));
      return Parsed(rhs.str.substr(1), lhs.res | rhs.res);
    } else if (op == '-') {
      Parsed rhs = formula(lhs.str.substr(2));
      bool res;
      if (lhs.res && !rhs.res) {
        res = false;
      } else {
        res = true;
      }
      return Parsed(rhs.str.substr(1), res);
    }
  }
}

bool equ(string str)
{
  Parsed lhs = formula(str);
  Parsed rhs = formula(lhs.str.substr(1));
  return (lhs.res == rhs.res);
}


bool rec(int pos)
{
  if (pos == 10) {
    return equ(str);
  }

  bool ret1, ret2;
  table[pos] = true;
  ret1 = rec(pos + 1);

  table[pos] = false;
  ret2 = rec(pos + 1);

  return (ret1 && ret2);
}

int main()
{
  for (;;) {
    cin >> str;
    if (str == "#") 
      break;

    memset(table, false, sizeof(table));
    if (rec(0)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 2044
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 4006;

void solve(){
    int n; cin>>n;
    string s; cin>>s; s = 'P' + s;

    int ans = 0;
    int r = 0,g = 0,b = 0;
    FOR(i,1,n) if(s[i] == 'R') r++; else if(s[i] == 'G') g++; else b++;
    ans = r*g*b;

    FOR(jump,1,n){
        FOR(i,1,n){
            int j = i + jump; int k = j + jump;
            if(j > n || k > n) continue;
            if(s[i] == s[j] || s[i] == s[k] || s[j] == s[k]) continue;
            ans--;
        }
    }

    cout<<ans<<endl;
}

signed main(){

   FastRead; 

    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}





Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <string>

int main() {
    int N;
    std::cin >> N;
    int ans = 0;
    int _A = 0;
    int B_ = 0;
    int BA = 0;
    for (int i = 0; i < N; ++i) {
        std::string s;
        std::cin >> s;
        int size = s.size();
        for (int index = 0; index < size - 1; ++index) {
            if (s[index] == 'A' && s[index + 1] == 'B') {
                ++ans;
            }
        }
        if (s[size - 1] == 'A' && s[0] == 'B') {
            ++BA;
        } else if (s[size - 1] == 'A') {
            ++_A;
        } else if (s[0] == 'B') {
            ++B_;
        }
    }
    ans += BA + std::min(_A, B_);
    if (BA != 0 && _A == 0 && B_ == 0) {
        ans -= 1;
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	int t=0;
	while(b<=a)b<<=1,t++;
	while(c<=b)c<<=1,t++;
	printf(t<=k?"Yes":"No");
} 

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int remove(int x, int b){
	int s = (x>>(b + 1));
	int r = (x&((1<<(b)) - 1));
	return (s<<b) + r;
}
int add(int x, int b, int v){
	int s = ((x>>b)<<1) + v;
	int r = (x&((1<<b)-1));
	return (s<<b) + r;
}
vector<int> build(int s, int t, int n){
	if(n == 1) return {s, t};
	int x = 0;
	while(((s>>x)&1) == ((t>>x)&1)) x++;
	int s1 = remove(s, x), s2 = (s>>x)&1;
	int t1 = remove(t, x), t2 = (t>>x)&1;
	int ms = s1 ^ 1;
	vector<int> left = build(s1, ms, n - 1);
	vector<int> right = build(ms, t1, n - 1);
	vector<int> ans;
	for(int v : left) ans.push_back(add(v, x, s2));
	for(int v : right) ans.push_back(add(v, x, t2));
	return ans;
}
int main(){
	int n, a, b; cin >> n >> a >> b;
	if(((__builtin_popcount(a) + __builtin_popcount(b))%2) == 0){
		cout << "NO" << endl;
	} else {
		vector<int> ans = build(a, b, n);
		cout << "YES" << endl;
		for(int v : ans) cout << v << " ";
		cout << endl;
	}
	return 0;
}


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);

    ll x;
    cin >> x;

    ll cur = 100;

    for(int n = 1; ; n++) {
        if(cur / 100 >= 1) {
            cur += cur / 100;
        }

        if(cur >= x) {
            cout << n << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
  string S;
  cin >> S;
  if(S == "SSS") cout << 0 << endl;
  else if(S == "SSR") cout << 1 << endl;
  else if(S == "SRS") cout << 1 << endl;
  else if(S == "SRR") cout << 2 << endl;
  else if(S == "RSS") cout << 1 << endl;
  else if(S == "RSR") cout << 1 << endl;
  else if(S == "RRS") cout << 2 << endl;
  else cout << 3 << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
ll N;
bool check(ll mid, vector<ll>& a, vector<ll>& f, ll k) {
  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] * f[i] > mid) {
      sum += a[i] - mid / f[i];
    }
  }
  return sum <= k;
}

ll bsearch(vector<ll>& a, vector<ll>& f, ll k) {
  ll ok = 1e13, ng = -1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid, a, f, k)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}

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

  ll k;
  cin >> N >> k;
  vector<ll> a(N), f(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> f[i];
  }
  sort(all(a));
  sort(all(f));
  reverse(all(f));

  ll ans = bsearch(a, f, k);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long[] a = new long[100];
            a[0] = 2;
            a[1] = 1;
            for (int i = 2; i < 90; i++) {
                a[i] = a[i - 1] + a[i - 2];
            }
            out.println(a[n]);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
N,D = map(int,input().split())
dot = [list(map(int,input().split())) for i in range(N)]
ans = 0
from math import sqrt
for i in range(N-1):
  for k in range(i+1,N):
    total = 0
    for j in range(D):
      total += (dot[i][j]-dot[k][j])**2
    if sqrt(total) % 1 == 0:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

const int MAX_SUM = 50 * 50 + 1;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    cin >> x;
    for (auto& i : x) i -= a;

    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(2 * MAX_SUM, 0));
    dp[0][MAX_SUM] = 1;
    for (int i = 0; i < n; ++i) {
        for (int s = 0; s < 2 * MAX_SUM; ++s) {
            dp[i + 1][s] = dp[i][s];
            if (s - x[i] >= 0 && s - x[i] < 2 * MAX_SUM) {
                dp[i + 1][s] += dp[i][s - x[i]];
            }
        }
    }
    cout << dp[n][MAX_SUM] - 1;
}


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

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

using namespace std;

typedef long long ll;

void compute(ll p, ll q) {
  ll gcd = __gcd(p,q);
  p /= gcd, q /= gcd;
  ll answer = 1LL, value = q;
  for(ll i=2;i*i<=q;++i) {
    if( value % i == 0 ) {
      answer *= i;
      while( value % i == 0 ) value /= i;
    }
  }
  answer *= value;
  cout << answer << endl;
}

int main() {
  ll p,q;
  cin >> p >> q;
  compute(p,q);
  return 0;
}

Measured memory_bytes: 1160
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int, input().split())))
dp = np.array([np.inf] * n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    if i-k > 0:
        dp[i] = min(dp[i-k:i]+abs(h[i]-h[i-k:i]))
    else:
        dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[n-1]))

Measured memory_bytes: 38808
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        int p_count = 0;
        int g_count = 0;
        for (int i = 0; i < d.length; i++) {
            if (d[i] == 'p') {
                p_count += 1;
            } else {
                g_count += 1;
            }
        }
        int diff = g_count - p_count;
        if (diff == 0 || diff == 1) {
            System.out.println(0);
        } else {
            System.out.println(diff / 2);
        }
    }
}


Measured memory_bytes: 27604
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<int> P(N);
	int i;
	int bigNum=0;
	for (i=0;i<N;i++){
		cin>>P[i];
	}
	vector<int> Pos;
	for (i=0;i<N-1;i++){
		if (P[i]>P[i+1]){
			if (bigNum==0){
				Pos.push_back(i);
			}else{
				Pos.push_back(i+1);
			}
			bigNum++;
		}
		if (bigNum>2){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if (bigNum==0){
		cout<<"YES"<<endl;
		return 0;
	}
	int tmp=P[Pos[0]];
	P[Pos[0]]=P[Pos[1]];
	P[Pos[1]]=tmp;
	for (i=0;i<N-1;i++){
		if (P[i]>P[i+1]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

void solve() {
    const int64_t vmax = 10000;

    int64_t n;
    std::cin >> n;

    std::vector<int64_t> A(n + 1), B(n + 1);

    int64_t C[vmax + 1];
    for (int64_t i = 0; i < vmax + 1; i++) {
        C[i] = 0;
    }
    for (int64_t i = 0; i < n; i++) {
        std::cin >> A[i + 1];
        C[A[i + 1]]++;
    }

    for (int64_t i = 1; i < vmax + 1; i++) {
        C[i] += C[i - 1];
    }

    for (int64_t i = n; i > 0; i--) {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

    for (int64_t i = 1; i < n + 1; i++) {
        if (i > 1) std::cout << " ";
        std::cout << B[i];
    }
    std::cout << std::endl;

    return;
}

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}



Measured memory_bytes: 34104
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

string s, t;
int dp[3005][3005];
pair<int, int> par[3005][3005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>s>>t;
    int n = s.length(), m = t.length();
    f(i, n + 1) {
        f(j, m + 1) par[i][j] = {-1, -1};
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = {i - 1, j - 1};
            }
            if(dp[i - 1][j] > dp[i][j]) {
                dp[i][j] = dp[i - 1][j];
                par[i][j] = {i - 1, j};
            }
            if(dp[i][j - 1] > dp[i][j]) {
                dp[i][j] = dp[i][j - 1];
                par[i][j] = {i, j - 1};
            }
        }
    }
    string to;
    int cx = n, cy = m;
    while(par[cx][cy].first != -1) {
        int ncx = par[cx][cy].first, ncy = par[cx][cy].second;
        if(ncx == cx - 1 && ncy == cy - 1) to += s[ncx];
        cx = ncx;
        cy = ncy;
    }
    r(to);
    cout<<to;
    return 0;
}

Measured memory_bytes: 106112