akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 目的の値の key index を返す
int binary_search(const vector<int>& vec, int key)
{
	int ng = -1;
	int ok = (int)vec.size();	// [index = a.size()-1]が条件を満たさないこと

	while (abs(ok - ng) > 1)
	{
		int mid = (ok + ng) / 2;

		if (vec[mid] <= key) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	return ok;
}

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

	vector<int> Ai(N);
	vector<int> Bi(N);
	vector<int> Ci(N);
	rep(i, N) cin >> Ai[i];
	rep(i, N) cin >> Bi[i];
	rep(i, N) cin >> Ci[i];

	sort(Ai.begin(), Ai.end());
	sort(Bi.begin(), Bi.end());
	sort(Ci.begin(), Ci.end());

	ll ans = 0;
	for (int j = 0; j < N; ++j)
	{
		auto ita = lower_bound(Ai.begin(), Ai.end(), Bi[j]);
		auto itc = upper_bound(Ci.begin(), Ci.end(), Bi[j]);
		ans += (ita - Ai.begin()) * (Ci.end() - itc);
	}

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

Measured memory_bytes: 4584
#include <stdio.h>

int main()
{
	int a=0,i;
	char s[32],t[32]="CODEFESTIVAL2016";
	scanf("%s",&s);
	
	for(i = 0;i < 16;i++){
		if(s[i] != t[i]){
			a++;
		}
	}
	
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll maxi = max(a, b);
    ll mini = min(a, b);
    if (a % 2 == b % 2) {
        cout << (maxi - mini) / 2 << "\n";
    } else {
        ll c    = mini + (maxi - mini - 1) / 2;
        ll max2 = n - mini + 1;
        ll min2 = n - maxi + 1;
        ll d    = min2 + (max2 - min2 - 1) / 2;
        cout << min(c, d) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#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 <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}
 
  

int main(){
  int n;
  int ans = 0;
  cin >> n;
  int sum = n * (n+1) / 2;
  int target = sum - n;
  if (n%2 == 0)target -= 1;
  vector<pair<int,int> > all;
  for(int i = 1;i <= n;i++){
    int mysum = sum - i;
    for(int j = i+1;j <= n;j++){
      if (mysum - j != target){
	all.pb({i,j});
      }
    }
  }
  cout << all.size() << endl;
  for(int i = 0;i < all.size();i++){
    cout << all[i].first <<" " << all[i].second << endl;
  }
}


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

#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1,i;
    for( i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
         p *= 5;
    }
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1+(key % (M-1));}

int insert(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i = 0;;i++){
        h = (h1(key) + i * h2(key))% M;
        if (strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int find(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key)+i * h2(key))%M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}


int main(){
    int i,n,h;
    char str[L], com[9];
    for(i = 0; i < M;i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);

        if(com[0] == 'i'){
            insert(str);
        } else{
            if(find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

string S;
ll K;

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

	ll ans = 0;
	
	auto f = [](string s) {
		ll base = 0;
		int renzoku = 1;
		for (int i = 1; i < s.size(); i++) {
			if (s[i] == s[i - 1])renzoku++;
			else {
				base += renzoku / 2;
				renzoku = 1;
			}
		}
		base += renzoku / 2;
		return base;
	};

	if (count(S.begin(), S.end(), S[0]) == S.size()) {
		cout << S.size() * K / 2 << endl;
		return 0;
	}
	ll a = f(S + S);
	ll b = f(S);
	cout << b + (a - b) * (K - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100005

typedef struct{
  int p;
  int l;
  int r;
}Node;

void getDepth(Node*,int,int,int*);
void Print(Node*,int);

int main(){
  int n,i,j,num,d,q[MAX],D[MAX];
  Node data[MAX];


  scanf("%d",&n);
   for(i=0;i<n;i++){
    data[i].p=-1;
    data[i].l=-1;
    data[i].r=-1;
   }

  for(i=0;i<n;i++){

    scanf("%d",&num);

    scanf("%d",&d);


    
    for(j=0;j<d;j++){
      scanf("%d",&q[j]);
      data[q[j]].p=num;

        data[num].l=q[0];

      if(j>=1){
        data[q[j-1]].r=q[j];
     }
    }
  }
  

 for(i=0;i<n;i++){
   if(data[i].p==-1){
     d=i;
    }
 }
  getDepth(data,d,0,D);


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,data[i].p);
    printf("depth = %d, ",D[i]);
    if(data[i].p==-1){
      printf("root, ");
    }else if(data[i].l==-1){
      printf("leaf, []\n");
      continue;
    }else{
      printf("internal node, ");
    }
    Print(data,i);
    printf("\n");
  }

  return 0;
}

void getDepth(Node *data,int x,int j,int *D){
   D[x]=j;
   if(data[x].r!=-1){
     getDepth(data,data[x].r,j,D);//ここは右兄弟                                  
   }
   if(data[x].l!=-1){
     getDepth(data,data[x].l,j+1,D);//ここは左子                                  
   }

 }

void Print(Node *data,int x){
  int i=0,c;

  printf("[");
  for(c=data[x].l;c!=-1;c=data[c].r){
   if(i>0) printf(", ");
   i++;
   printf("%d",c);
  }
  printf("]");
}


Measured memory_bytes: 8444
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


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

    	int a = sc.nextInt();
    	int b = sc.nextInt();

    	if((a*b) % 2 == 0)
    		System.out.println("Even");
    	else
    		System.out.println("Odd");
    }
}

Measured memory_bytes: 21972
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }


void main()
{
	auto n = RD;
	auto a = RD;
	auto b = RD;
	if (a < b)
		swap(a, b);

	long ans = 2;
	ans.modpow(n);
	ans.mods(1);

	long x1 = 1, x2 = 1, y1 = 1, y2 = 1;
	foreach (i; 0..a)
	{
		x1.modm(n);
		y1.modm(a);
		--a;
		if (b != 0)
		{
			x2.modm(n);
			y2.modm(b);
			--b;
		}
		--n;
	}
	
	y1.modpow(mod - 2);
	x1.modm(y1);
	ans.mods(x1);
	y2.modpow(mod - 2);
	x2.modm(y2);
	ans.mods(x2);

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a*b) + " " + (2*(a+b)));
		
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





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

#define int long long int
#define double long long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

int32_t main()
{
	IOS;
	string s, t;
	cin >> s >> t;
	string nn = t.substr(0, s.size());
	if (nn == s && t.size() == s.size() + 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        // 値の取得
        String target = sc.nextLine();
        String[] arr;
        arr = target.split("");

        int sum = 0;

        for (String item : arr) {
        	sum += Integer.parseInt(item);
        }

        if (Integer.parseInt(target) % sum == 0) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }

    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
    
    int n;
    cin >> n;
    if(n >= 30){
    	cout << "Yes";
    }
    else{
    	cout << "No";
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (a == b) {
        cout << 1 << endl;
    } else if (a > b || n == 1) {
        cout << 0 << endl;
    } else {
        ll mn = a + b;
        ll mx = a + b;
        ll cnt = n - 2;
        mn += a * cnt;
        mx += b * cnt;
        cout << (mx - mn + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
vector< pair<LL,LL> > v[ N ];
bool vst[ N ];
int n , m;
void init(){
  n = getint();
  m = getint();
  while( m -- ){
    int li = getint();
    int ri = getint();
    int di = getint();
    v[ li ].push_back( { ri , +di } );
    v[ ri ].push_back( { li , -di } );
  }
}
LL mx , mn , vl[ N ];
void no(){
  puts( "No" );
  exit(0);
}
void go( int now ){
  vst[ now ] = true;
  for( auto e : v[ now ] )
    if( vst[ e.first ] ){
      if( vl[ now ] + e.second != vl[ e.first ] )
        no();
    }else{
      vl[ e.first ] = vl[ now ] + e.second;
      go( e.first );
    }
}
void solve(){
  for( int i = 1 ; i <= n ; i ++ ){
    if( vst[ i ] ) continue;
    mx = mn = 0;
    go( i );
    if( mx - mn > 1000000000 )
      no();
  }
  puts( "Yes" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

i64 gcd(i64 n, i64 m){return m?gcd(m, n%m):n;} 

int main(){
    i64 A, B;
    cin >> A >> B;
    i64 G = gcd(A, B);

    vector<i64> prime;
    {
        const int N = 1500001;
        vector<bool> is_prime(N, true);
        is_prime[0] = is_prime[1] = false;
        for(i64 i = 2; i * i < N; i++){
            if(!is_prime[i]) continue;
            for(i64 j = i * 2; j < N; j += i){
                is_prime[j] = false;
            }
        }
        for(i64 i = 2; i < N; i++){
            if(is_prime[i]) prime.push_back(i);
        }
    }
    auto is_prime = [&] (const i64& N) -> bool {
        for(auto& i : prime){
            if(i * i > N) break;
            if(N % i == 0) return false;
        }
        return true;
    };

    i64 ans = 0;
    for(i64 i = 1; i*i <= G; i++){
        if(G % i == 0){
            ans += is_prime(i);
            if(i*i != G) ans += is_prime(G/i);
        }
    }

    Cout(ans);
}

Measured memory_bytes: 1528
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    p=[tupin() for _ in range(N)]
    def fact(k):
        if k==0:return 1
        return k*fact(k-1)
        
    ans=dict()
    for i in range(N-1):
        for j in range(i+1,N):
            temp=0
            for k in range(2):
                temp+=(p[i][k]-p[j][k])**2
            ans.setdefault(temp,0)
            ans[temp]+=1
    x=0
    for a in ans.items():
        x+=(a[0]**0.5)*a[1]
    #print(ans)
    print((x*2)/(N))
        
#%%submit!
resolve()

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

int main() {
    string N;
    cin >> N;
    
    bool se = false;
    for (int i = 0; i < N.size(); i++) {
        if (N.at(i) == '7')
            se = true;
    }
    
    if (se)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int room[][][]=new int[4][3][10];
		int n=stdIn.nextInt();
		for(int i=0;i<n;i++){
			int b=stdIn.nextInt();
			int f=stdIn.nextInt();
			int r=stdIn.nextInt();
			int v=stdIn.nextInt();
			room[b-1][f-1][r-1]+=v;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<10;k++)
					System.out.print(" "+room[i][j][k]);
				System.out.println("");
			}
			if(i<3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29948
# -*- coding: utf-8 -*-
# B - Sum of Three Integers
# 標準入力の取得
K,S = list(map(int, input().split()))

# 全探索を行う
available_value_list = range(K+1)

result = 0
for x in available_value_list:
    for y in available_value_list:
        z = S - x - y # x + y + z = Sより算出
        if 0 <= z and z <= K:
            result += 1

# 結果出力
print(result)

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

int main(){
  int N, M, f = 0, kazu, keta;
  cin >> N >> M;
  vector<vector<int>> vec(M, vector<int>(2));
  for(int i = 0; i < M; i++){
    cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    vec.at(i).at(0) = N - vec.at(i).at(0);
  }
  int kaihi;
  if(N == 1) kaihi = 0;
  else kaihi = pow(10, N - 1);
  for(int i = kaihi; i <= pow(10, N) -1; i++){
    for(int j = 0; j < M; j++){
      kazu = i;
      for(int k = 0; k < vec.at(j).at(0); k++){
        kazu /= 10;
      }
      keta = kazu % 10;
      if (keta != vec.at(j).at(1)){
        f = 1;
        break;
      }
    }
    if (f == 0){
      cout << i;
      return 0;
    }
    f = 0;
  }
  cout << -1;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int x, n;
    cin >> x >> n;
    int p[n];
    map<int, int> m;
    int flag = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        m[p[i]] = 1;
        if(p[i] == x){
            flag = 1;
        }
    }

    if(flag == 0){
        cout << x << endl;
    }else{
        flag = 0;
        int now = 1;
        while(1){
            int a = x - now;
            int b = x + now;
            auto itr_a = m.find(a);
            auto itr_b = m.find(b);

            if(itr_a == m.end()){
                flag = a;
                break;
            }else if(itr_b == m.end()){
                flag = b;
                break;
            }

            now++;
        }

        cout << flag << endl;
    }


}

Measured memory_bytes: 3608
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //整数nが条件にあっているか確認
	    if(0 <= n && n <= 10000){
	    
	        //n回、整数を読み取り、配列に入れる
	        for(int i = 0; i <= n-1; i++){
	        	String s2 = sc.next();
		        int j = Integer.parseInt(s2);
		        
		        //入力された整数が条件（−１００００００から１００００００）内か確認
		        if(-1000000 <= j && j <=1000000){
		            a[i] = j;
		        }
	        }
	    
	        //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	        for(int i = 0; i <= a.length-1; i++){
	        	for(int j = 0; j <= a.length-2; j++){
	    		    if(a[j] < a[j+1]){
	    		    	    int w = a[j];
	    		    	    a[j] = a[j+1];
	    		    	    a[j+1] = w;
	    	    	}
	    	    }
	        }
	    
	        //配列に格納されている整数の合計を計算
	        for(int i = 0; i < a.length; i++){
	    	    sum = sum + (long)a[i];
	        }
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	}
}

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

int main(){
	int n;
	cin>>n;
	string str;
	cin>>str;
	int ans = 1e9;
	int black[n], b=0;
	for(int i=0; i<n; i++){
		if(str[i]=='#'){
			b++;
		}
		black[i] = b;
	}
	int w= 0;
	ans = black[n-1];
	for(int i=n-1; i>=0; i--){
		if(str[i]=='.'){
			w++;
		}
		int val = w;
		if(i!=0){
			val += black[i-1];
		}
		ans= min(ans, val);
	}
	cout<<ans<<'\n';
	
}

Measured memory_bytes: 1284
def comb(n, r, p):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    return fac[n] * (facinv[r] * facinv[n - r] % p) % p


def comb_pre(N, p):
    for i in range(2, N + 1):
        fac.append(fac[i - 1] * i % p)
        inv.append(-inv[p % i] * (p // i) % p)
        facinv.append(facinv[-1] * inv[-1] % p)


fac = [1, 1]
facinv = [1, 1]
inv = [0, 1]

N, K = map(int, input().split())
MOD = 1_000_000_007
comb_pre(N, MOD)
for i in range(1, K + 1):
    tmp = comb(N - K + 1, i, MOD)
    tmp %= MOD
    tmp *= comb(K - 1, i - 1, MOD)
    tmp %= MOD
    print(tmp)


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> dp(h + 1, vector<ll>(w));
    dp[0][0] = 1;
    if(w == 1){
        cout << 1 << endl; 
        return 0;  
    }

    for(int d = 0; d < h; d++){
        //bit全探索
        for(int bit = 0; bit < (1 << (w - 1)); bit++){
            //適切かどうか
            bool cur = false;
            vector<bool> f(w - 1);
            bool flag = false;


            for(int i = 0; i < w - 1; i++){
                if(bit & (1 << i)){
                    if(cur)flag = true;
                    else{
                        f[i] = true;
                        cur = true;
                        }
                }else{
                    cur = false;
                }
            }
            if(flag)continue;

            if(f[0]){
                dp[d + 1][1] += dp[d][0];
            }else{
                dp[d + 1][0] += dp[d][0];
            }

            if(f[w - 2]){
                dp[d + 1][w - 2] += dp[d][w - 1];
            }else{
                dp[d + 1][w - 1] += dp[d][w - 1];
            }

            //cerr << bitset<2>(bit) << endl;
            for(int i = 1; i < w - 1; i++){
                if(f[i - 1]){
                    dp[d + 1][i - 1] += dp[d][i];
                }else if(f[i]){
                    dp[d + 1][i + 1] += dp[d][i]; 
                }else{
                    dp[d + 1][i] += dp[d][i] %= mod;
                }
            }

            for(int i = 0; i < w; i++)dp[d + 1][i] %= mod;
        }
    }
    cout << dp[h][k - 1] % mod << endl;

}

Measured memory_bytes: 384
P=->*a{puts a.join" "};l=gets.to_i;n=l.bit_length;P[n,n*2+l.to_s(2).count(?1)-3];(n-1).times{|i|P[i+1,i+2,0];P[i+1,i+2,1<<i];l[i]==1&&P[i+1,n,l-=1<<i]}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<(2*a);
    else cout<<(max(a,b)+max(a,b)-1);
    //while(1);
    return 0;
}

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

int main(){
    int n;  cin >> n;
    vector<ll> a(n+2);
    for(int i=1; i<=n; i++){
        cin >> a.at(i);
    }
    ll sum=0;
    for(int i=0; i<=n; i++)
        sum += abs(a.at(i)-a.at(i+1));
    for(int i=0; i<n; i++){
        cout << sum-(abs(a.at(i)-a.at(i+1))+abs(a.at(i+1)-a.at(i+2)))
            + abs(a.at(i+2)-a.at(i)) << endl;
    }

}

Measured memory_bytes: 2048
#include <iostream>
#include <map>
#include <stdio.h>

#define N_MAX 100

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    char s;
    cin >> s;
    if (s == 'Y') {
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int max_cnt(IN(vector<pii>) tasks) {
    var tks = tasks;
    int N = tks.size();
    sort(all(tks), [](IN(pii) left, IN(pii) right){
        return left.first > right.first;});
    reverse(all(tks));

    int cnt = 1;
    int t = tks[N-1].first;
    for(int i = N-2; i>=0; i--) {
        if (tks[i].second <= t) {
            t = tks[i].first;
            cnt += 1;
        }
    }

    return cnt;
}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N; cin>>N;
    vi X(N), L(N); REP(i,N) cin>>X[i]>>L[i];

    vector<pii> se;
    REP(i,N)
        se.emplace_back(mkpr(X[i]-L[i], X[i]+L[i]));

    int ans = max_cnt(se);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    FOR(i,1,k+1){
        if(i*2%k==0){
            ll t=n/k+(n%k>=i);
            ans+=t*t*t;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(){
  int n,i=1;
  cin>>n;
  while(1){
    int count=0;
    for(int j=1;j<i+1;j++){
      if(i%j==0) count++;
    }
    if(count==n) break;
    i++;
  }
  cout<<i<<endl;
  
  return 0;
}



Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    H = inputInt()
    W = inputInt()
    
    ans = 0
    if N == H:
        if N == W:
            print(1)
        else:
            print(N-W+1)
    else:
        if N == W:
            print(N-H+1)
        else:
            print((N-H+1) * (N-W+1))
                
    
if __name__ == "__main__":
	main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

#define MOD 998244353

int n;
char s[252521];
ll tpow[252521];
ll fa[1<<19], fc[1<<19];
ll conv[1<<19];

#define THR 8

inline ll modadd(ll b, ll c){
	ll a = b+c;
	return a>=MOD ? a-MOD : a;
}
inline ll modadd(ll b, ll c, ll d){
	ll a = b+c;
	a = a>=MOD ? a-MOD : a;
	a = a+d;
	return a>=MOD ? a-MOD : a;
}

ll tmp[1<<19];
void k1(int n, ll *ret, ll *a, ll *b, ll *tmp);
void k2(int n, ll *ret, ll *a, ll *b, ll *tmp);
// HUPC2019Day2H向けチューニング
// 偶数しか参照しない性質で処理をサボる
// ref: @koba_procon
ll ain[1<<18], bin[1<<18];
void asym_comb_even(int n, ll *ret, ll *a, ll *b, ll *tmp){
	int m = n/2;
	REP(i,m)ain[i] = a[2*i];
	REP(i,m)bin[i] = b[2*i];
	k1(m, ret, ain, bin, tmp);
	REP(i,m)ain[i] = a[2*i+1];
	REP(i,m)bin[i] = b[2*i+1];
	k1(m, ret+n+1, ain, bin, tmp);
	REP(i,n)ret[i] = modadd(ret[i], ret[i+n]);
	fill(ret+n,ret+2*n,0ll);
	FORR(i,0,n)swap(ret[i], ret[2*i]);
}
void k1(int n, ll *ret, ll *a, ll *b, ll *tmp){
	if(n<=THR){
		REP(i,n)FOR(j,i+1,n)ret[i+j] = modadd(ret[i+j],a[i]*b[j]%MOD);
		return;
	}else{
		int m = n/2;
		fill(tmp,tmp+n,0);
		k2(m, tmp, a, b+m, tmp+n);
		k1(m, ret, a, b, tmp+n);
		k1(m, ret+n, a+m, b+m, tmp+n);
		REP(i,n)ret[i+m] = modadd(ret[i+m], tmp[i]);
		return;
	}
}
void k2(int n, ll *ret, ll *a, ll *b, ll *tmp){
	if(n<=THR){
		REP(i,n)REP(j,n)ret[i+j] = modadd(ret[i+j],a[i]*b[j]%MOD);
		return;
	}else{
		int m = n/2;
		REP(i,m)ret[i] = modadd(a[i], a[i+m]);
		REP(i,m)ret[i+m] = modadd(b[i], b[i+m]);
		fill(tmp,tmp+n,0);
		k2(m, tmp, ret, ret+m, tmp+n);
		fill(ret,ret+n,0);
		k2(m, ret, a, b, tmp+n);
		k2(m, ret+n, a+m, b+m, tmp+n);
		REP(i,n)tmp[i] = modadd(tmp[i],MOD-ret[i],MOD-ret[i+n]);
		REP(i,n)ret[i+m] = modadd(ret[i+m], tmp[i]);
		return;
	}
}

int main(){
	scanf("%s",s);
	n = strlen(s);
	REP(i,n){
		if(s[i]=='U'){
			s[i] = 'A';
		}else if(s[i]=='M'){
			s[i] = 'B';
		}else if(s[i]=='G'){
			s[i] = 'C';
		}
	}
	tpow[0] = 1;
	FOR(i,1,252521)tpow[i] = tpow[i-1]*3%MOD;
	ll iv3 = (MOD+1)/3;
	// O(N^2)
	int qcnt = count(s,s+n,'?');
	ll ans = 0;
	REP(i,n){
		if(s[i]=='A')fa[i] = 1;
		if(s[i]=='?')fa[i] = iv3;

		if(s[i]=='C')fc[i] = 1;
		if(s[i]=='?')fc[i] = iv3;
	}
	// sum_k (fa[i-k] * fc[i+k])
	// (fa * fc)[2i]
	// ntt oboete nai
	asym_comb_even(1<<18,conv,fa,fc,tmp);
	REP(i,n){
		if(s[i]=='B'){
			ll sum = conv[2*i];
			ans = (ans + sum * tpow[qcnt]) % MOD;
		}else if(s[i]=='?'){
			ll sum = conv[2*i];
			ans = (ans + sum * tpow[qcnt-1]) % MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
    int h, w; cin >> h >> w;
    char s[50][50];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> s[i][j];
        }
    }
    bool flg = true;
    int cnt =0;
    const int dx[4] = {0, 1, 0, -1}; // 上　右　下　左
    const int dy[4] = {1, 0, -1, 0};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '.') continue;
            cnt = 0;
            for(int k=0; k<4; k++){
                int ni = i + dx[k];
                int nj = j + dy[k];
                if (ni < 0 || h <= ni) continue;
                if (nj < 0 || w <= nj) continue;
                if(s[ni][nj] == '#') cnt++;
            }
            if(cnt == 0){
                flg = false; break;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else    cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


int main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll b(n);
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(k,29){
        ll two = (1 << (k+1));
        ll t = (1 << k);
        ll cnt = 0;
        vll c(n);
        rep(i, n) c[i] = b[i] % two;
        sort(all(c));
        rep(i,n){
            ll idx1, idx2, idx3, idx4;
            idx1 = lower_bound(all(c), max(0ll,(t - (a[i] % two)))) - c.begin();
            idx2 = lower_bound(all(c), 2*t - (a[i] % two)) - c.begin();
            idx3 = lower_bound(all(c), 3*t - (a[i] % two)) - c.begin();
            idx4 = lower_bound(all(c), 4*t - (a[i] % two)) - c.begin();
            cnt += (idx2 - idx1 + idx4 - idx3) % 2;
        }
        ans += (1 << k) * (cnt % 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

class Dice
{
public:
	int f1, f2, f3, f4, f5, f6;
public:
	Dice() 
	{
		f1 = f2 = f3 = f4 = f5 = f6 = 0;
	};
	~Dice() {};
public:
	void roll(char angle)
	{
		int temp;
		if (angle == 'N')
		{
			temp = f1;
			f1 = f2;
			f2 = f6;
			f6 = f5;
			f5 = temp;
		}
		else if (angle == 'S')
		{
			temp = f1;
			f1 = f5;
			f5 = f6;
			f6 = f2;
			f2 = temp;
		}
		else if (angle == 'W')
		{
			temp = f1;
			f1 = f3;
			f3 = f6;
			f6 = f4;
			f4 = temp;
		}
		else
		{
			temp = f1;
			f1 = f4;
			f4 = f6;
			f6 = f3;
			f3 = temp;
		}
	}
	int face(int above, int front)
	{
		if (above == f1)
		{
			if (front == f2) return f3;
			else if (front == f3) return f5;
			else if (front == f5) return f4;
			else if (front == f4) return f2;
		}
		else if (above == f2)
		{
			if (front == f6) return f3;
			else if (front == f4) return f6;
			else if (front == f1) return f4;
			else if (front == f3) return f1;
		}
		else if (above == f3)
		{
			if (front == f2) return f6;
			else if (front == f6) return f5;
			else if (front == f5) return f1;
			else if (front == f1) return f2;
		}
		else if (above == f4)
		{
			if (front == f2) return f1;
			else if (front == f1) return f5;
			else if (front == f5) return f6;
			else if (front == f6) return f2;
		}
		else if (above == f5)
		{
			if (front == f1) return f3;
			else if (front == f3) return f6;
			else if (front == f6) return f4;
			else if (front == f4) return f1;
		}
		else
		{
			if (front == f2) return f4;
			else if (front == f4) return f5;
			else if (front == f5) return f3;
			else if (front == f3) return f2;
		}
	}

};

int main()
{
	Dice d;
	int n;

	cin >> d.f1 >> d.f2 >> d.f3 >> d.f4 >> d.f5 >> d.f6;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		cout << d.face(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
N = input()

if len(N) == 1:
    ans = int(N[0])
elif N[1:] == '9' * (len(N) - 1):
    ans = int(N[0]) + 9 * (len(N) - 1)
else:
    ans = int(N[0]) - 1
    ans += 9 * (len(N) - 1)
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		boolean flag;
		if(x + r > W){
			flag = false;
		} else if(x - r < 0){
			flag = false;
		} else if(y + r > H){
			flag = false;
		} else if(y - r < 0){
			flag = false;
		} else{
			flag = true;
		}
		System.out.println(flag? "Yes" : "No");
	}
}

Measured memory_bytes: 26288
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int A,B,C,D,area_1=0,area_2=0;
    cin >> A >> B >> C >> D;
    area_1=A*B,area_2=C*D;
    if(area_1>=area_2){
        cout << area_1 << endl;
    }else{
        cout << area_2 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

int history[50][50];
int w,h;
int cnt;

using namespace std;

int search_map(int x,int y,int flag_new,int m[50][50]){

  if(!(x>=0 && x<w && y>=0 && y<h)) return 0;

  if(history[y][x] == 1) return 0;
  else{
    history[y][x]=1;

    if(m[y][x]){

      if(flag_new) cnt++;

      for(int i=-1 ; i<2;i++){
        for(int j=-1 ; j<2;j++){
          if(i==0 && j==0) continue;
          search_map(x+i,y+j,0,m);
        }
      }

    }
    else{
      return 0;
    }

  }

}

int main(void){

  int map[50][50];

  for(cin>>w,cin>>h;w>0 && h>0;cin>>w,cin>>h){
    cnt=0;
    for(int i=0;i<50;i++){
      for(int j=0;j<50;j++){
        history[i][j]=0;
      }
    }
    //cout << w << "," << h << endl;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> map[i][j];
        //cout << map[i][j] << " ";
      }
      //cout << endl;
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        search_map(j,i,1,map);
        //cout << map[i][j] << " ";
      }
      //cout << endl;
    }
    cout << cnt << endl;
  }

  return 0;
}



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

using namespace std;

int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        int C[16];
        long long dp[2][256];
        
        for (int i = 0; i < m; i++) scanf("%d", C + i);
        
        fill (dp[0], dp[0] + 256, 1000000000000000000ll);
        fill (dp[1], dp[1] + 256, 1000000000000000000ll);
        
        dp[0][128] = 0;
        
        int t = 0;
        for (int i = 0; i < n; i++){
            int x;
            scanf("%d", &x);
            
            fill(dp[1 - t], dp[1 - t] + 256, 1000000000000000000ll);
            for (int j = 0; j < m; j++){
                for (int k = 0; k < 256; k++){
                    int y = max(0, min(255, k + C[j]));
                    dp[1 - t][y] = min(dp[1 - t][y], dp[t][k] + (x - y) * (x - y));
                }
            }
            t = 1 - t;
        }
        
        printf("%lld\n", *min_element(dp[t], dp[t] + 256));
    }
    
    return (0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> K(M), p(M);
    vector<vector<int>> s(M, vector<int>(10));
    for (int i = 0; i < M; i++) {
        cin >> K[i];
        for (int j = 0; j < K[i]; j++) cin >> s[i][j];
    }
    for (auto& i : p) cin >> i;
    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int cnt1 = 0;
        for (int j = 0; j < M; j++) {
            int cnt2 = 0;
            for (int k = 0; k < K[j]; k++) if (i & (1 << (s[j][k] - 1))) cnt2++;
            if (cnt2 % 2 == p[j]) cnt1++;
        }
        if (cnt1 == M) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int h=sc.nextInt();
			System.out.println((a+b)*h/2);
		}
	}
}

Measured memory_bytes: 9800
def main():
    w = input()
    d = dict()

    for i in range(len(w)):
        if (w[i] in d):
            d[w[i]] += 1
        else:
            d[w[i]] = 1

    correct = 0
    for v in d.values():
        if v % 2 == 0:
            correct += 1

    if correct == len(d):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

vector<long long> R;
long long ans, sa, sb;
int n;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long a, b;
  	cin >> a >> b; 
    R.push_back(a + b);
    sa += a, sb += b;
  }
  sort(R.begin(), R.end());
  reverse(R.begin(), R.end());
  for (int i = 0; i < n; i++) {
  	if (i % 2 == 0)
      ans += R[i];
    else
      ans -= R[i];
  }
  cout << (ans + sa - sb) / 2;
}

Measured memory_bytes: 1400
#include <stdio.h>
int main(void){
int a,b,c,s; // Your code here!
    scanf("%d %d %d",&a ,&b,&c);
    if (a < b) {
        s=b;
        b=a;
        a=s;
    }
   if(b < c) {
        s=c;
        c=b;
        b=s;
   }
    if (a < b) {
        s=b;
        b=a;
        a=s;
    }
   printf("%d %d %d\n",c,b,a);
   
   
}


Measured memory_bytes: 2688
import math

def sieve_of_erastosthenes(num):
    is_prime = [True for i in range(num+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(num**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, num + 1, i):
            is_prime[j] = False
    return [i for i in range(num + 1) if is_prime[i]]

N = int(input())
A = [int(i) for i in input().split()]
ans = math.gcd(A[0], A[1])
tmp = math.gcd(A[0], A[1])
for i in range(2, N):
    ans = math.gcd(ans, A[i])
if ans > 1:
    print('not coprime')
    exit()
maxA = max(A)
l = sieve_of_erastosthenes(maxA)
B = [False for i in range(maxA+1)]
for i in range(N):
    B[A[i]] = True
flag = False
for each in l:
    tmp = each
    counter = 0
    while True:

        if B[tmp]:
            counter += 1
        tmp += each
        if tmp > maxA:
            break
    if counter > 1:
        flag = True
        break


if flag:
    print('setwise coprime')
else:
    print('pairwise coprime')

Measured memory_bytes: 226192
n = gets.to_i
nums = gets.split.map(&:to_i)

h = Hash.new(0)
nums.each do |i|
  h[i] += 1
end

total = 0

h.each do |k,v|
  total += v * (v-1) / 2
end

nums.each do |i|
  v = h[i]
  diff = (v * (v-1) / 2) - ((v-1) * (v-2) / 2)
  puts total - diff
end

Measured memory_bytes: 28676
package main

import (
	"fmt"
)

func main() {
	var K int
	fmt.Scan(&K)
	sum := 0
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				sum += gcd(i, gcd(j, k))
			}
		}
	}
	fmt.Printf("%d\n", sum)
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	}
	return gcd(y, x%y)
}


Measured memory_bytes: 1852