akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i=0,a[10000];
	a[0]=n%10;
	a[2]=n/100;
	for (i=0;i<1;i++)
	{
		if (a[0]!=a[2])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Security;
using System.Threading;
using System.Xml.Serialization;

namespace AtCoderCs
{

    class Program
    {

        const int mod = 1000000007;

        static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var num = args[0];
            var roop = args[1];
            var data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var inner = 0L;
            var outer = 0L;
            var list = new int[2000];

            for (int i = 0; i + 1 < num; i++)
            {
                for (int j = i; j < num; j++)
                {
                    if (data[i] > data[j]) inner++;

                }
                list[data[i] - 1]++;
            }

            list[data[num - 1] - 1]++;

            inner %= mod;
            inner = (inner * roop) % mod;

            outer = ((num * (num - 1)) >> 1) -
                list.Sum(x => (x < 2 ? 0 : ((x * (x - 1)) >> 1)));

            outer %= mod;
            outer *= ((roop * (roop - 1)) >> 1) % mod;

            Console.WriteLine((outer + inner) % mod);

        }



    }
}


Measured memory_bytes: 13472
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli N, K;
  cin >> N >> K;
 N=N%K;
  cout << min(N,abs(N-K)) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;

int main(){
   int h,w;
   while(scanf("%d%d",&h,&w),w){
      int nh = 10000;
      int nw = 10000;
      reps(i,1,151){
         reps(j,i+1,151){
            if(i*i+j*j >= h*h+w*w && nh*nh+nw*nw > i*i+j*j){
               if(i*i+j*j == h*h+w*w && i <= h)continue;
               nh = i;
               nw = j;
            }
            else if(i*i+j*j >= h*h+w*w && nh*nh+nw*nw == i*i+j*j && nh > i){
               nh = i;
               nw = j;
            }
         }
      }
      printf("%d %d\n",nh,nw);
   }
   return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'
 
const ll MOD = 1000000007;

vector<pi> a = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
vector<pi> b = {{-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2},
   {-1, -2}, {-1, -1}, {-1, 1}, {-1, 2}, {0, -2}, {0, 2}, 
   {1, -2}, {1, -1}, {1, 1}, {1, 2}, {2, -2}, {2, -1}, 
   {2, 0}, {2, 1}, {2, 2}};

struct cmp {
   bool operator() (vector<int> a, vector<int> b) {
      return a[0] > b[0];
   }
};

int main() {
   int h, w; scanf("%d%d", &h, &w);
   int ch, cw, dh, dw;
   scanf("%d%d%d%d", &ch, &cw, &dh, &dw);
   vector<vector<int>> s(h, vector<int>(w));
   for (int i = 0; i < h; i++) {
      char temp[w]; scanf("%s", temp);
      for (int j = 0; j < w; j++)
         if (temp[j] == '#') s[i][j] = -1;
   }
   deque<vector<int>> pq;
   pq.push_front({1, ch - 1, cw - 1});
   while (!pq.empty()) {
      vector<int> temp = pq.front();
      pq.pop_front();
      if (s[temp[1]][temp[2]] == 0 || s[temp[1]][temp[2]] > temp[0]) {
         s[temp[1]][temp[2]] = temp[0];
         for (pi i : a) {
            if (temp[1] + i.f >= 0 && temp[1] + i.f < h
               && temp[2] + i.s >= 0 && temp[2] + i.s < w &&
               (s[temp[1] + i.f][temp[2] + i.s] == 0 ||
               s[temp[1] + i.f][temp[2] + i.s] > temp[0])) {
               pq.push_front({temp[0], temp[1] + i.f, temp[2] + i.s});
            }
         }
         for (pi i : b) {
            if (temp[1] + i.f >= 0 && temp[1] + i.f < h
               && temp[2] + i.s >= 0 && temp[2] + i.s < w &&
               (s[temp[1] + i.f][temp[2] + i.s] == 0 ||
               s[temp[1] + i.f][temp[2] + i.s] > temp[0])) {
               pq.push_back({temp[0] + 1, temp[1] + i.f, temp[2] + i.s});
            }
         }
      }
   }
   if (s[dh - 1][dw - 1] < 1) {
      printf("-1");
   } else {
      printf("%d", s[dh - 1][dw - 1] - 1);
   }
   return 0;
}

Measured memory_bytes: 10872
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>

int main(){
	int n, m;
	while (std::cin >> n >> m, n || m){

		int data[1001];
		for (int i = 0; i < n; i++)std::cin >> data[i];

		std::sort(data, data + n, std::greater<int>());

		int ans = 0;
		for (int i = m - 1; i < n; i += m)ans += data[i];
		ans = std::accumulate(data, data + n, 0) - ans;
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1176
class Solution(object):
	def is_hitachi_string(self, string):

		if len(string) == 0:
			print 'No'
			return

		hi_str = 'hi'
		hi_idx = 0
		for idx in xrange(len(string)):
			if idx > 9:
				print 'No'
				return

			if string[idx] != hi_str[hi_idx]:
				print 'No'
				return

			hi_idx = (hi_idx + 1) % 2

		if hi_idx == 0:
			print 'Yes'
		else:
			print 'No'

if __name__ == '__main__':
	sol = Solution()
	string = raw_input()
	sol.is_hitachi_string(string)

Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll K,A,B; cin >> K >> A >> B;
    if(A <= B){
        if(K <= A){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    ll res = LLONG_MAX;
    for(int i = -1; i <= 1;i++){
        ll cost = B*i;
        ll tmp = (K + cost)/(A-B);
        if((K+cost)%(A-B) != 0) tmp++;
        res = min(res,tmp*2 + i);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

func init() {
	nextReader = newScanner()
}

func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	p := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = i
	}
	for i := 1; i < n; {
		p[i]--
		j := 0
		if i%2 == 1 {
			j = p[i]
		}

		nums[i], nums[j] = nums[j], nums[i]
		*ret = append(*ret, makeCopy(nums))
		for i = 1; p[i] == 0; i++ {
			p[i] = i
		}
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}

func SortedPermute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(makeCopy(nums), &ret)
	ret = SortPermutation(ret)
	return ret
}

func SortPermutation(nums [][]int) [][]int {
	is := Ints2dToInts(nums)
	sort.Ints(is)
	nums = IntsToInts2d(is)
	return nums
}

func Ints2dToInts(is2d [][]int) []int {
	is := make([]int, len(is2d))
	for i, v := range is2d {
		is[i] = IntsToInt(v)
	}
	return is
}

func IntsToInt(is []int) int {
	s := IntsToString(is)
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func IntsToString(is []int) string {
	var ss = make([]string, len(is), len(is))
	for i, v := range is {
		ss[i] = strconv.Itoa(v)
	}
	return strings.Join(ss, "")
}

func IntsToInts2d(is []int) [][]int {
	is2d := make([][]int, len(is), len(is))
	for i, v := range is {
		is2d[i] = IntToInts(v)
	}
	return is2d
}

func IntToInts(a int) []int {
	s := strconv.Itoa(a)
	is := StringToInts(s)
	return is
}

func StringToInts(s string) []int {
	is := make([]int, len(s))
	var err error
	for i := 0; i < len(s); i++ {
		is[i], err = strconv.Atoi(string(s[i]))
		if err != nil {
			panic(err)
		}
	}
	return is
}

func Equals(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	} else {
		return a
	}
}

func main() {
	N := nextInt()
	P := nextInts(N)
	Q := nextInts(N)
	permutation := SortedPermute(P)
	var a, b int
	for i, v := range permutation {
		if Equals(P, v) {
			a = i + 1
		}
		if Equals(Q, v) {
			b = i + 1
		}
	}
	fmt.Println(abs(a - b))
}


Measured memory_bytes: 9856
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
using namespace std;

typedef pair<string,int> P;

int n;
set<string> closed;

bool check(string s){
  for(int i = 0; i < n - 1; i++){
    if(s[i] != s[i + 1]){
      return false;
    }
  }
  return true;
}

void solve(string s){
  queue<P> open;
  open.push(P(s, 0));
  closed.clear();
  closed.insert(s);

  while(!open.empty()){
    P p = open.front(); open.pop();
    s = p.first;

    if(check(s)){
      cout << p.second << endl;
      return;
    }

    for(int i = 0; i < n - 1; i++){
      if(s[i] != s[i + 1]){
        string next = s;
        if(s[i] != 'r' && s[i + 1] != 'r') next[i] = next[i + 1] = 'r';
        if(s[i] != 'g' && s[i + 1] != 'g') next[i] = next[i + 1] = 'g';
        if(s[i] != 'b' && s[i + 1] != 'b') next[i] = next[i + 1] = 'b';

        if(closed.find(next) == closed.end()){
          closed.insert(next);
          open.push(P(next, p.second + 1));
        }
      }
    }
  }

  cout << "NA\n";
}

int main(){
  string s;

  while(cin >> s, s != "0"){
    n = s.length();
    solve(s);
  }
}

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

int main() {
  int s;
  cin >> s;
  int l, r;
  l = s / 100;
  r = s % 100;
  if (r <= 12 && r >= 1) {
    if (l <= 12 && l >= 1) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "YYMM" << endl;
    }
  }
  else {
    if (l <= 12 && l >= 1) {
      cout << "MMYY" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
  
}


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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}
};

typedef vector<Point> Polygon;

double getArea(const Polygon &p){
    int N = p.size();
    double res = 0;
    for(int i = 1 ; i < N+1 ; i++){
        res += (p[i%N].x-p[i-1].x)*(p[i%N].y+p[i-1].y);
    }
    res /= 2.0;
    return abs(res);
}

int main(){
    int N;
    cin >> N;
    Polygon p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p[i].x >> p[i].y;
    }
    printf("%.1f\n",getArea(p));
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A1=in();
    int A2=in();
    int A3=in();
    if(A1+A2+A3>21){
        print("bust");
    }else{
        print("win");
    }
        return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

int ans;
char s[222];

int judge(char *s);

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

  cin >> s;

  int len = strlen(s);
  ans = len;
  s[len-1] = '\0';
  len--;
  ans--;
  while(len % 2 || judge(s)){
    s[len-1] = '\0';
    len = strlen(s);
    ans--;
  }

  cout << ans << endl;

  return 0;
}

int judge(char *s){

  int len = strlen(s);
  for(int i=0;i<len/2;i++){
    if(s[i] != s[i+(len/2)])return 1;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<string>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)

int inf=1000200000;

int t;
int n,k;
int x[100001];
int dx[100001];


int main() {
	cin>>t;
	rep(hoge,t){
		cin>>n>>k;
		rep(i,n) cin>>x[i];
		rep(i,n-1) dx[i] =x[i+1]-x[i];
		sort(dx+1,dx+n);
		int sum = 0;
		rep(i,n-k) sum+= dx[i];
		cout<<sum<<endl;
	}
	
	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    long long a[n],b[n];
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    long long c[m],d[m];
    rep(i,m){
        cin>>c[i]>>d[i];
    }
    rep(i,n){
        long long tmp = 1010010000;
        int id =-1;
        for(int j=m-1;j>=0;j--){
            if (tmp>=abs(a[i]-c[j])+abs(b[i]-d[j])){
                id=j;tmp=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout<<id+1<<endl;
    }
    
    
}


Measured memory_bytes: 3600
import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0

for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
print(ans*2/n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define TT pair<long long, long long>
#define ordered_set tree<TT, null_type, less<TT>, rb_tree_tag, tree_order_statistics_node_update>
#define fo(i,n)   for(i=0;i<n;i++)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mp make_pair
#define For(m) for(auto it = m.begin();it!=m.end();it++)
#define fi first
#define se second
typedef long long ll;
typedef long double mytype;
ll n,w;
ll a[200005]={},b[200005]={};
ll dp[104][100010];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //priority_queue <int, vector<int>, greater<int> > pq;
    //cout << fixed << setprecision(9) <<ans<<endl;
    //ordered_set os;//os.order_of_key();//os.find_by_order();
    ll flag=0,l,r,count,m,sum=0,ans=0,i,j,k,tt,t,x,y,z,c;
    string ss;
    set<ll> s;
    vector<ll> v;
    map<ll,ll> ma;
    cin>>n>>w;
    fo(i,n)
    cin>>a[i+1]>>b[i+1];
    m=999999999999999;
    fo(i,n+3)
    fo(j,100005)
    dp[i][j]=m;
    dp[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=0;j<=100001;j++){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(dp[i-1][j]==m)
            continue;
            if((dp[i-1][j]+a[i])<=w){
                dp[i][j+b[i]]=min(dp[i][j+b[i]],dp[i-1][j]+a[i]);
            }
        }
    }
    ans=0;
    fo(i,100005)
    if(dp[n][i]!=m)
    ans=max(ans,i);
    cout<<ans<<endl;
}

Measured memory_bytes: 84116
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
}


Measured memory_bytes: 70380
#include <iostream>
#include <vector>

template<class T>
struct heap{
	std::vector<T> a;
	void push(T);
	T pop();
};

template<class T>
void heap<T>::push(T x){
	size_t i = a.size();
	a.push_back(x);
	while(i > 0 && a[(i - 1) / 2] < x){
		a[i] = a[(i - 1) / 2];
		i = (i - 1) / 2;
	}
	a[i] = x;
}

template<class T>
T heap<T>::pop(){
	T ret = a.front();
	T x = a.back();
	a.pop_back();
	size_t i = 0;
	while(true){
		int j = i * 2 + 1;
		if(j + 1 < a.size() && a[j + 1] > x) j += (a[j] < a[j + 1]);
		else if(!(j < a.size() && a[j] > x)) break;
		a[i] = a[j];
		i = j;
	}
	a[i] = x;
	return ret;
}

int main(){
	int n, m;
	std::cin >> n >> m;

	heap<int> q;
	for(int i = 0; i < n; ++i){
		int a;
		std::cin >> a;
		q.push(a);
	}

	for(int i = 0; i < m; ++i){
		int a = q.pop();
		q.push(a / 2);
	}
	unsigned long long ans = 0;
	while(!q.a.empty()){
		ans += q.pop();
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 892
import math


n=int(input())

sums=0
dicts={}
for i in range(1,n+1):
    for j in range(1, n+1):
        pre_gcd = math.gcd(i,j)
        for k in range(1, n+1):
            sums += math.gcd(pre_gcd,k)

print(sums)

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

int main() {
  int ABC[9] = {
    111, 222, 333, 444, 555, 666, 777, 888, 999
  };
  int N; cin >> N;
  int ans;
  for (int i = 0; i < 9; i++) {
    if (N <= ABC[i]) {
      ans = ABC[i];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  int ans=0;
  cin >> n;
  vi h(n),a(n);
  REP(i,n) cin>>h[i];
  int flag=0;
  for(int i=n-2;i>=0;i--)
  {
	  if (h[i]>=h[i+1]){
		  flag++;
		  a[i]=flag;
		  ans=max(ans,flag);
	  }else{
		  flag=0;
	  }
  }


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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool ans = true;
  rep(i,a){
    if(s[i]<'0'||s[i]>'9'){
      ans = false;
    }
  }
  if(s[a]!='-'){
    ans = false;
  }
  for (ll i = a + 1; i < a + b + 1;i++){
    if(s[i]<'0'||s[i]>'9'){
      ans = false;
    }
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}


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

using namespace std;

typedef long long LL;
#define PB push_back
#define IFOR(v,it) for(string::iterator it=(v).begin();it!=(v).end();++it)

typedef vector<LL> V;

LL solve(const V::iterator &it, const V::iterator &end, LL x, LL sum) {
  if (it == end)
    return x + sum;
  return solve(it + 1, end, *it, sum + x) + solve(it + 1, end, x*10 + *it, sum);
}

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

  V v;
  IFOR(S,it)
    v.PB((LL)(*it - '0'));

  cout << solve(v.begin() + 1, v.end(), v[0], 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

vector<vector<int>> graph;

int main() {
    int n, m;
    cin >> n >> m;
    graph.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> ans(n, -1);
    queue<int> que;
    auto push = [&](int v, int p){
        ans[v] = p;
        que.push(v);
    };
    push(0, -1);

    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int to: graph[v]) {
            if (ans[to] == -1)
                push(to, v);
        }
    }

    cout << "Yes" << endl;
    repr(i, 1, n) {
        cout << ans[i] + 1 << endl;
    }
}

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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) {
    init(newn);
  }
  SegmentTree(vector<T> v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for(int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for(int i = n - 1; i; --i)
      dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while(n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while(k >>= 1) {
      dat[k] = f(dat[k << 1], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, dat[l++]);
      if(r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

long long n, q;
string s;
SegmentTree<long long> seg;

int main() {
  cin >> n >> s >> q;
  // prepair
  auto f = [](long long l, long long r) { return l | r; };
  seg = SegmentTree<long long>(n, f, 0);
  for(int i = 0; i < n; ++i)
    seg.update(i, 1LL << (s[i] - 'a'));
  // query
  for(int i = 0; i < q; ++i) {
    int p;
    cin >> p;
    if(p == 1) {
      int k;
      char c;
      cin >> k >> c;
      seg.update(k - 1, 1LL << (c - 'a'));
    }
    else {
      int l, r;
      cin >> l >> r;
      cout << popcount(seg.query(l - 1, r)) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 9092
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18+9;
const int N=1001;
int a[no]={},b[no]={},cc[no]={},suma[no]={},mat[N][N]={{0}};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

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

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

vi adj[no];
int used[no]={};

void solve(){
    int n,m;
    string s;
    cin>>s;
    vector<pair<char,int>> v;
    for(int i=0 ; i<s.size() ; i++){
        if(v.size()==0 || v.back().fi!=s[i]) v.PB({s[i],1});
        else v.back().se++;
    }
    int maxi=0;
    for(int i=0 ; i<v.size() ; i++){
        if(v[i].fi=='R') maxi=max(maxi,v[i].se);
    }
    cout<<maxi;
}

void runn(){
        #ifndef ONLINE JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
    }

signed main()
{
    night_rider
    //runn();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 73956
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

long long dp[500][500];
int a[500];
long long rec(int left, int right){
   if(left >= right) return LLONG_MAX/2;
   if(dp[left][right] != LLONG_MAX/2) return dp[left][right];
   if(left+1 == right) return 0;
   long long base = 0;
   for(int i = left; i < right; i++){
      base += a[i];
   }
   long long tmp = LLONG_MAX/2;
   for(int mid = left+1; mid < right; mid++){
      tmp = min(tmp, rec(left,mid)+rec(mid,right));
   }
   return dp[left][right] = tmp+base;
}

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++) cin >> a[i];
  for(int i =0 ;i <500;i++){
     for(int j=0;j <500;j++) dp[i][j] = LLONG_MAX/2;
  }
  cout << rec(0, N) << endl;
  return 0;
}


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

int main(){
	long long n,a=0;
	cin>>n;
	long long b[5]={};
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		switch(s[0]){
			case 'M':
				b[0]++;
				break;
			case 'A':
				b[1]++;
				break;
			case 'R':
				b[2]++;
				break;
			case 'C':
				b[3]++;
				break;
			case 'H':
				b[4]++;
				break;
		}
	}
	for(int i=0;i<3;i++){
		for(int j=i+1;j<4;j++){
			for(int k=j+1;k<5;k++){
				a+=(b[i]*b[j]*b[k]);
			}
		}
	}
	cout<<a;
	return 0;
}


Measured memory_bytes: 256
char t[10][4];M(int*a){return*a-*1[&a];}main(n,i,j,r){for(;~scanf("%d\n",&n);){for(i=n;i--;){*(int*)t[i]=getchar()+i*256;for(j=n;--j;){scanf("%d\n",&r);t[i][3-r]+=r<2;}t[i][2]^=15;}for(qsort(t,n,4,M);n--;puts(&j))j=*t[n];}}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int[] d = new int[N];
        for(int i=0;i<N;i++){
            d[i]=sc.nextInt();            
        }
        int sum=0;
        for(int i=0;i<N-1;i++){
            for(int j=i+1;j<N;j++){
                sum += d[i]*d[j];
            }
        }
        System.out.println(sum);
        return;
    }
}



Measured memory_bytes: 21716
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> y >> z;
	Yes(x + y >= z);
	please AC;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    rep(i, k+1) {
        rep(j, k+1) {
            if(s-i-j >= 0 && s-i-j <= k) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int swap(int a,int b){
	if (a<b)printf("%d %d\n",a,b);
	else printf("%d %d\n",b,a);
}

int main(void){
	int x,y,i;
	
	for(i=1;i<i+1;i++){
		
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		swap(x,y);
	}
	
	return 0;
}

Measured memory_bytes: 600
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	if (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    int max1 = 0;
    int max2 = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] >= max1){
            max2 = max1;
            max1 = A[i];
        }
        else if(A[i] >= max2){
            max2 = A[i];
        }
    }

    for(int i = 0; i < N; i++){
        if(A[i] == max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

#define INF 1e18

int n, m, l;
vector<vector<long long> > H, G;

int main() {
	cin >> n >> m >> l;
	H.assign(n, vector<long long>(n, INF));
	G.assign(n, vector<long long>(n, INF));
	for (int i = 0; i < n; ++i) H[i][i] = G[i][i] = 0;
	for (int i = 0; i < m; ++i) {
		int a, b, c; cin >> a >> b >> c;
		--a, --b;
		H[a][b] = c;
		H[b][a] = c;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; ++i) {
			if (H[i][k] == INF) continue;
			for (int j = 0; j < n; ++j) {
				if (H[k][j] == INF) continue;
				H[i][j] = min(H[i][j], H[i][k] + H[k][j]);
			}
		}
	}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (H[i][j] <= l) G[i][j] = 0;
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; ++i) {
			if (G[i][k] == INF) continue;
			for (int j = 0; j < n; ++j) {
				if (G[k][j] == INF) continue;
				G[i][j] = min(G[i][j], G[i][k] + G[k][j] + 1);
			}
		}
	}
	int q; cin >> q;
	while (q--) {
		int s, t; cin >> s >> t;
		--s, --t;
		long long ans = min(G[s][t], G[t][s]);
		cout << (ans == INF ? -1 : ans) << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] str = new String[1];
		int x, y, temp;
		
		LOOP : do {
			str = br.readLine().split("\\s+");
			
			if (str.length > 1) {
				try {
					x = Integer.parseInt(str[0]);
					y = Integer.parseInt(str[1]);
				
					if (x == 0 && y == 0) break LOOP;
					
					if (x > y) {
						temp = x;
						x = y;
						y = temp;
					}
					
					System.out.println(x + " " + y);

				} catch (Exception NumberFormatException) {
					continue LOOP;
				}
			}
		} while (true);
	}
}

Measured memory_bytes: 30592
#include <stdio.h>

int main(){
    int a,b,c,x;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    int cnt=0;
    for (int i=0; i<=a; i++){
        for (int j=0; j<=b; j++){
            for (int k=0; k<=c; k++){
                if (500*i+100*j+50*k==x){
                    cnt++;
                }
            }
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 2136
#include<iostream>


using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;    
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}




Measured memory_bytes: 3072
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A;

  std::cin >> N;

  std::set<int> set;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    if (set.count(A)) {
      set.erase(A);
    }
    else {
      set.insert(A);
    }
  }

  std::cout << set.size() << std::endl;
  
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>



int main(){
  	long long A, B;
  	std::cin>>A>>B;
  
  	long long C;
  
  	for (int i = 1; i<=B; i++){
     	C = A*i;
      	if (C%B == 0){
         	break;          
        }     
    }
  	std::cout<<C;
  	
  
  
  
  
 	return 0; 
}

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

int num[110]={};

int main() {
	int X, N;
	cin >> X >> N;
	for(int i=0; i<N; ++i){
		int p;
		cin >> p;
		++num[p];
	}
	int ans=0;
	for(int i=1; i<=101; ++i){
		if(num[i]==0){
			if(abs(ans-X)>abs(i-X)){
				ans=i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int l,q,n[1<<20],m[1<<20],a,b,c,x[21],y[21],z[21],ans,p;
char s[(1<<20)+1],t[21];
int main(void){
    scanf("%d%d %s",&l,&q,s);
    for(int i=0;i<1<<l;i++){
        n[i]=s[i]-'0';
        m[i]=s[i]-'0';
    }
    for(int i=0;i<l;i++){
        for(int k=0;k<1<<l;k++){
            if((k&(1<<i))==0)n[k]+=n[k|(1<<i)];
            else m[k]+=m[k^(1<<i)];
        }
    }
    while(q--){
        scanf(" %s",t);
        a=0,b=0,c=0,ans=0,p=0;
        for(int i=0;i<l;i++){
            if(t[l-i-1]=='0')x[a++]=i;
            else if(t[l-i-1]=='1'){
                y[b++]=i;
                p+=(1<<i);
            }else z[c++]=i;
        }
        if(a<=6){
            for(int i=0;i<1<<a;i++){
                int o=p,w=0;
                for(int j=0;j<a;j++){
                    if(i>>j&1){
                        o+=(1<<x[j]);
                        w++;
                    }
                }
                if(w%2)ans-=n[o];
                else ans+=n[o];
            }
        }else if(b<=6){
            for(int i=0;i<c;i++)p+=(1<<z[i]);
            for(int i=0;i<1<<b;i++){
                int o=p,w=0;
                for(int j=0;j<b;j++){
                    if(i>>j&1){
                        o-=(1<<y[j]);
                        w++;
                    }
                }
                if(w%2)ans-=m[o];
                else ans+=m[o];
            }
        }else{
            for(int i=0;i<1<<c;i++){
                int o=p;
                for(int j=0;j<c;j++)if(i>>j&1)o+=(1<<z[j]);
                ans+=(s[o]-'0');
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 12452
/*input
5 1
1
2
3
4
5
*/
/**
    Author: Kristopher Paul
    Date Created: 07-07-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 0x3f3f3f3f //0x3f3f3f3f = 63
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n,d;
    cin >> n >> d;
    int arr[n][d];
    FOR(i,0,n){
        FOR(j,0,d){
            cin >> arr[i][j];
        }
    }
    int ans = 0;
    FOR(i,0,n){
        FOR(j,i+1,n){
            int s = 0;
            FOR(k,0,d){
                s += ceil(pow(arr[i][k]-arr[j][k],2.0));
            }
            int a = floor(sqrt(double(s)));
            int b = ceil(sqrt(double(s)));
            if(a == b){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


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

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

    long long A[N];
    long long memo[N + 1] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        memo[A[i]]++;
    }

    long long totalCount = 0;
    for (int i = 1; i <= N; ++i) {
        totalCount += memo[i] * (memo[i] - 1) / 2;
    }

    for (int i = 0; i < N; ++i) {
        cout << totalCount - ((memo[A[i]] * (memo[A[i]] - 1) / 2) - ((memo[A[i]] - 1) * (memo[A[i]] - 2) / 2)) << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	long long ans = 1;
	cin >> n;
	REP(i,1, n+1) ans = ans*i % ((int)pow(10, 9) + 7);
	cout << ans  << endl;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = tuple(map(int, input().split()))

l = A[0]
for i in range(1, N):
    l = l * A[i] // gcd(l, A[i])
l = l - 1

f = 0 
for a in A:
    f += l % a
print(f)


Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

vector<int> adj[N], adj2[N], v;
int vis[N], ans[N];

void dfs(int node){
    v.push_back(node);
    vis[node] = 1;
    for(auto i: adj[node]){
        if(vis[i]) continue;
        dfs(i);
    }
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 0; i < k; i++){
        int u, v;
        cin >> u >> v;
        adj2[u].push_back(v);
        adj2[v].push_back(u);
    }
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            v.clear();
            dfs(i);
            sort(v.begin(), v.end());
            ll sz = v.size();
            for(int j = 0; j < v.size(); j++){
                ans[v[j]] = sz - 1;
                for(auto x: adj[v[j]]){
                    if(binary_search(v.begin(), v.end(), x)) ans[v[j]]--;
                }
                for(auto x: adj2[v[j]]){
                    if(binary_search(v.begin(), v.end(), x)) ans[v[j]]--;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << ' ';


    return 0;
}


Measured memory_bytes: 20640
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <regex>

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

using namespace std;

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;
}

int A, B;
char op;

int main() {
    cin >> A >> op >> B;

    if (op == '+') {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char s[201],p[101],t[101];
    scanf("%s%s",s,p);
    strcpy(t,s);
    strcat(s,t);
    if(strstr(s,p)==NULL)puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 2148
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

const double EPS=1e-8;
const double INF=1e9;

typedef complex<double>Point;

#define EQ(a,b) (fabs((a)-(b))<EPS)
#define EQV(a,b) (abs((a)-(b))<EPS)
struct Segment{
    Point p1,p2;
    Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};

typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

typedef vector<Point>Polygon;

double dot(Point a,Point b){
    return real(a)*real(b)+imag(a)*imag(b);
}

double cross(Point a,Point b){
    return real(a)*imag(b)-imag(a)*real(b);
}

bool isOrthogonal(Point a,Point b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return EQ(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Point a,Point b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return EQ(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


int main(){
    int N;
    scanf("%d",&N);
    while(N--){
        Point a,b,c,d;
        scanf("%lf%lf",&a.real(),&a.imag());
        scanf("%lf%lf",&b.real(),&b.imag());
        scanf("%lf%lf",&c.real(),&c.imag());
        scanf("%lf%lf",&d.real(),&d.imag());
        if(isParallel(a,b,c,d))puts("2");
        else if(isOrthogonal(a,b,c,d))puts("1");
        else puts("0");
    }

    return 0;
}

Measured memory_bytes: 1204