akhauriyash/Code-Regression huggingface dataset:
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] X = new int[N][D];

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				X[i][j] = sc.nextInt();
			}
		}

		int result = 0;
		for (int i = 0; i < N; i++) {
			for (int k = i+1; k < N; k++) {
				int tmp = 0;
				for (int j = 0; j < D; j++) {
					tmp+= Math.pow(Math.abs(X[i][j] - X[k][j]),2);
				}
				if (Math.round(Math.sqrt(tmp)) == Math.sqrt(tmp)) {
					result++;
				}
			}
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=2000005;
const int MOD=1000000007;

int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6,jc[N],ny[N];
struct data{int x,y,c;}a[4],b[4];

int C(int x1,int y1,int x2,int y2)
{
	return (LL)jc[x2-x1+y2-y1]*ny[x2-x1]%MOD*ny[y2-y1]%MOD;
}

int solve(data a,data b)
{
	int x1=a.x,y1=a.y,x2=b.x,y2=b.y,ans=0;
	for (int i=x3;i<=x4;i++) (ans+=(LL)C(x1,y1,i,y3-1)*C(i,y3,x2,y2)%MOD*(-i-y3)%MOD)%=MOD;
	for (int i=y3;i<=y4;i++) (ans+=(LL)C(x1,y1,x3-1,i)*C(x3,i,x2,y2)%MOD*(-i-x3)%MOD)%=MOD;
	for (int i=x3;i<=x4;i++) (ans+=(LL)C(i,y4+1,x2,y2)*C(x1,y1,i,y4)%MOD*(i+y4+1)%MOD)%=MOD;
	for (int i=y3;i<=y4;i++) (ans+=(LL)C(x4+1,i,x2,y2)*C(x1,y1,x4,i)%MOD*(i+x4+1)%MOD)%=MOD;
	return ans;
}

int main()
{
	scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=x6+y6;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=x6+y6;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
	a[0]=(data){x2,y2,1};a[1]=(data){x2,y1-1,-1};a[2]=(data){x1-1,y2,-1};a[3]=(data){x1-1,y1-1,1};
	b[0]=(data){x6+1,y6+1,1};b[1]=(data){x6+1,y5,-1};b[2]=(data){x5,y6+1,-1};b[3]=(data){x5,y5,1};
	int ans=0;
	for (int i=0;i<4;i++)
		for (int j=0;j<4;j++)
			(ans+=a[i].c*b[j].c*solve(a[i],b[j]))%=MOD;
	printf("%d",(ans+MOD)%MOD);
	return 0;
}

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

int main() {
    string n;
    cin >> n;
    string ans="No";
    ll t=0;
    rep(i,n.size()) {
        t += (n[i] - '0');
    }
    if(t%9==0) ans="Yes";

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

Measured memory_bytes: 3660
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

    int res = k;
    REP2(i,n,1) {
        res *= k-1;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef  long long int ll;
typedef long double ld;

int main()
{
    fast;
    ld a,b,product;
    ll v;
    cin>>a>>b;
    product=a*b;
    v=floor(product);
    cout<<v;
    return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N + 1];
		for(int i = 1;i <= N - 1;i++) {
			B[i] = sc.nextInt();
		}
		sc.close();

		int[] A = new int[N + 1];
		A[1] = B[1];
		for(int i = 2;i <= N - 1;i++) {
			A[i] = Math.min(B[i], B[i - 1]);
		}
		A[N] = B[N - 1];
		int sum = 0;
		for(int i = 1;i <= N;i++) {
			sum += A[i];
		}
		System.out.println(sum);

	}
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    var max = 0
    var now = 0
    
    for (c in s) {
        if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
            now++
        } else {
            if (now >= max) {
                max = now
            }
            now = 0
        }
    }
    
    if (now >= max) {
        max = now
    }
    
    println(max)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

map<pii, int> dist;
map<pii, vector<tuple<int,int,int>>> edge;

int main() {
	int n, m;	cin >> n >> m;
	rep(i, m) {
		int p, q, c;	cin >> p >> q >> c;	p--;	q--;
		edge[mp(p, c)].push_back(mt(q, c, 0));
		edge[mp(p, c)].push_back(mt(p, -1, 0));
		edge[mp(p, -1)].push_back(mt(p, c, 1));
		edge[mp(q, c)].push_back(mt(p, c, 0));
		edge[mp(q, c)].push_back(mt(q, -1, 0));
		edge[mp(q, -1)].push_back(mt(q, c, 1));
	}
	dist[mp(0, -1)] = 0;
	priority_queue<tuple<int, int, int>> pq;
	pq.push(mt(0, 0, -1));
	while (!pq.empty()) {
		auto it = pq.top();	pq.pop();
		int d, p, c;	tie(d, p, c) = it;	d *= -1;
		if (dist[mp(p, c)] < d)	continue;
		if (p == n - 1) {
			cout << d << endl;
			return 0;
		}
		rep(i, edge[mp(p, c)].size()) {
			int to, toc, tod;	tie(to, toc, tod) = edge[mp(p, c)][i];
			if (dist.find(mp(to, toc)) == dist.end() || dist[mp(to, toc)] > d + tod) {
				dist[mp(to, toc)] = d + tod;
				pq.push(mt(-d - tod, to, toc));
			}
		}
	}
	if (dist.find(mp(n - 1, -1)) == dist.end()) {
		cout << -1 << endl;
	}
	else {
		cout << dist[mp(n - 1, -1)] << endl;
	}
	return 0;
}

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

const int MOD=1e9+7;

bool AGC(int a,int g,int c){
    return (a==0&&g==2&&c==1);
}

int main(){
    int n; cin>>n;
    int dp[n+1][4][4][4]={0};
    dp[0][3][3][3]=1;
    for(int i=1;i<=n;++i){
        for(int a=0;a<4;++a){
            for(int b=0;b<4;++b){
                for(int c=0;c<4;++c){
                    for(int d=0;d<4;++d){
                        if(AGC(b,c,d)||AGC(c,b,d)||AGC(b,d,c))continue;
                        if(AGC(a,c,d)||AGC(a,b,d))continue;
                        (dp[i][b][c][d]+=dp[i-1][a][b][c])%=MOD;
                    }
                }
            }
        }
    }
    int ans=0;
    for(int a=0;a<4;++a){
        for(int b=0;b<4;++b){
            for(int c=0;c<4;++c){
                (ans+=dp[n][a][b][c])%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  string s,t="CODEFESTIVAL2016";
  cin >> s;
  int ans=0;
  for(int i=0;i<16;++i){
    if(s[i]!=t[i]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
inline int in(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
int n;
ll sum=1,fix[27];
string s;
int main(){FAST;xRand;
cin>>n;
cin>>s;
for(int i=0;i<n;i++){
	fix[(int)s[i]-(int)'a']++;
}
for(int i=0;i<26;i++){
	sum*=fix[i]+1;
	sum%=P;
}
cout<<(sum-1+P)%P<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/






Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    string str = readln.chomp;
    writeln(str[0..4], " ", str[4..$]);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int main()
{
	ll a,b;
	cin>>a>>b;
	if(a<b)
	{
		a=b-a;
	}
	else{
		a-=b;
	}
	if(a>1)
	{
		cout<<"Alice"<<endl;
	}
	else{
		cout<<"Brown"<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c, x, y, ans1, ans2, ans3;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b >> c >> x >> y;
    ans1 = x > y ? y * c * 2 + (x - y) * a : x * c * 2 + (y - x) * b;
    ans2 = a * x + y * b;
    ans3 = max(x, y) * 2 * c;
    cout << min(ans1, min(ans2, ans3)) << endl;
    return 0;
}

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

int k, a[35] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
	cin >> k;
	cout << a[k-1];
	return 0;
}


Measured memory_bytes: 3588
n = int(input())
N = str(input())

bangos = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            moji = ""
            moji += str(i)
            moji += str(j)
            moji += str(k)
            bangos.append(moji)

ans = 0
for val in bangos:
    j = 0
    for i in N:
        if val[0] == i:
            j += 1
            break
        else:
            j += 1
    if j > n-1:
        continue
    tmp = N[j:]
    for i in str(tmp):
        if val[1] == i:
            j += 1
            break
        else:
            j += 1
    if j > n-1:
        continue
    tmp = N[j:]
    for i in str(tmp):
        if val[2] == i:
            ans += 1
            break
        else:
            j += 1

print(ans)

Measured memory_bytes: 60892
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;
int n, ans=0; string s;

int main(){
	IOS
	cin >> n >> s;
	int l=0, r=n-1;
	while(l<r){
		if(s[l]=='R') ++l;
		else if(s[r]=='W') --r;
		else{
			++l, --r, ++ans;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

ll A, B, C, D, E, F;
ll M1 = 100, M2 = 0;

bool done[3001][3001] = {};

void dfs(ll m1, ll m2) {
    if (m1 > F) return;
    if (m2 > (m1-m2)/100.0 * E) return;
    if (done[m1][m2]) return;

    done[m1][m2] = true;

    if (m2 / (double)m1 >= M2 / (double)M1) {
        M1 = m1;
        M2 = m2;
    }

    dfs(m1+100*A, m2);
    dfs(m1+100*B, m2);
    dfs(m1+C, m2+C);
    dfs(m1+D, m2+D);
}

int main() {
    cin >> A >> B >> C >> D >> E >> F;

    dfs(100*A, 0);

    cout << M1 << " " << M2 << endl;
    return 0;
}

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

#define INF 1000000001
#define N 100001
int n, k, h[N], dp[N];

signed main() {
        scanf("%d%d", &n, &k);
        for (int i = 1; i <= n; i++) {
                scanf("%d", &h[i]);
                dp[i] = INF;
        }

        dp[1] = 0;
        dp[2] = abs(h[1]-h[2]);
        for (int i = 3; i <= n; i++)
                for (int j = 1; j <= k; j++)
                        if (j < i)
                                dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
                        else
                                break;
        printf("%d \n", dp[n]);

        return 0;
}


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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

int binary_search(VI& a, int key) {
    int left = 0, right = (int)a.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (a[mid] == key) return mid;
        else if (a[mid] > key) right = mid - 1;
        else if (a[mid] < key) left = mid + 1;
    }
    return -1;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

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

	int n;
	cin>>n;

  PII p1=MP(-1,0);
  PII p2=MP(-1,0);
  PII p3=MP(-1,0);
  
  REP(i,n){
    int a;cin>>a;
    if(p1.first==-1||p1.first==a){
      p1=MP(a,++p1.second);
    }
    else if(p2.first==-1||p2.first==a){
      p2=MP(a,++p2.second);
    }
    else if(p3.first==-1||p3.first==a){
      p3=MP(a,++p3.second);
    }
  }
  
  // cout << (p1.first^p2.first^p3.first) << endl;
  string ans = "No";
  if(p2.first==-1&&p3.first==-1){
    if(p1.first==0) ans="Yes";
  }else if(p3.first==-1){
    if(p1.first==0){
      if(p1.second*3==n) ans="Yes";
    }
    else if(p2.first==0){
      if(p2.second*3==n) ans="Yes";
    }
  }else{
    if((p1.first^p2.first^p3.first)==0){
      if(p1.second*3==n&&p2.second*3==n&&p3.second*3==n) ans="Yes";
    }
  }

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

Measured memory_bytes: 256
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
a,b=INPUT()
A=min(a,b)
B=max(a,b)
X=[]
P=[]
for i in range(1,int(M.sqrt(A)+1)):
    if A%i==0:
        if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i)
Q=[]

for i in range(1,int(M.sqrt(B)+1)):
    if B%i==0:
        if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i)
X=list(set(P)&set(Q))
X.sort()
ans=0
#sprint(X)
bool=[True]*len(X)
for i in range(len(X)):
    if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False

for i in range(len(X)):
    if bool[i]==True:
        ans+=1

print(ans)


Measured memory_bytes: 83648
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int Q;
    cin >> Q;

    vector<ll> A(Q);
    vector<ll> B(Q);

    for(int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i];
        if(A[i] > B[i]) {
            swap(A[i], B[i]);
        }
    }

    for(int i = 0; i < Q; i++) {
        if(A[i] == B[i]) {
            cout << A[i] * 2LL - 2LL << endl;
            continue;
        }
        if(A[i] == B[i] + 1LL) {
            cout << A[i] * 2LL - 2LL << endl;
            continue;
        }

        ll C = ll(sqrt(A[i] * B[i]));

        if(C * C == A[i] * B[i]) C--;

        if(C * (C + 1LL) < A[i] * B[i]) {
            cout << C * 2LL - 1LL << endl;
        } else {
            cout << C * 2LL - 2LL << endl;
        }
    }
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

const int cuth = 9;
int maxw = 1e5;
int lb[(1<<cuth)];

void init(){
    for(int msk = 1;msk < (1<<cuth); ++msk){
        for(int j = 0; j < cuth; j++){
            if(msk & (1<<j)){
                lb[msk] = j;
                break;
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    int n, i, j;
    cin >> n;
    vi v(n), w(n);
    for(i=0;i<n;i++){
        cin >> v[i] >> w[i];
    }
    /*
        dp[v][l] = max value selecting itens in v-path
        s.t total_weight <= l

        1) compute dp[v][l] for h(v) <= 9 ; O(2^10 * maxL)
        2) for v in query q s.t h(v) > 9
            try all subsets of S(v) = {w | w anc v ^ h(w) > 9}
            rt : O(2^|S(v)|)) <= 2^9

        Total rt O(2^9 * maxL + Q*2^9)
    */
    int limv = (1<<(cuth+1)) - 1;
    limv = min(limv, n);
    vvi dp(limv, vi(maxw + 1, 0));
    for(j = w[0];j<=maxw;j++){
        dp[0][j] = v[0];
    }
    for(i=1;i<limv;i++){
        int p = (i-1)>>1;
        for(j=0;j<=maxw;j++){
            dp[i][j] = dp[p][j];
            if(w[i] <= j){
                dp[i][j] = max(dp[i][j] , dp[p][j - w[i]] + v[i]);
            }
        }
    }
    int q;
    cin >> q;
    while(q--){
        int u, l;
        cin >> u >> l;
        u--;
        vi S;
        while(u >= limv){
            S.push_back(u);
            u = (u-1)>>1;
        }
        int ans = dp[u][l];
        int N = (S.size());
        assert(N <= cuth);
        int M = (1<<N);
        vi capm(M), valm(M);
        for(int msk = 1; msk < M; msk++){
            capm[msk] = capm[msk ^ (1<<lb[msk])] + w[S[lb[msk]]];
            valm[msk] = valm[msk ^ (1<<lb[msk])] + v[S[lb[msk]]];
            if(capm[msk] <= l){
                ans = max(ans , dp[u][l-capm[msk]] + valm[msk]);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

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

int main() {
	int a, b;
	char op = ' ';
	for(int i = 0;i < 1000;i++) {
		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a*b << endl;
		}
		else if (op == '/') {
			cout << a / b << endl;
		}
		else {
			break;
		}
	}
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;

long long int dp[1001][1001];
const long long int mod(1e9 + 7);
int main() {
	string t, b; cin >> t >> b;
	for (int i = 0; i < 1001; ++i) {
		for (int j = 0; j < 1001; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < t.size(); ++i) {
		for (int j = 0; j <= b.size(); ++j) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			if (j != b.size()&&t[i]==b[j]) {
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j+1] %= mod;
			}
		}
	}
	cout << (dp[t.size()][b.size()] % mod) << endl;
	return 0;
}

Measured memory_bytes: 11028
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(e, i) for (auto e: i)
#define all(x) x.begin(), x.end()


using namespace std;
const int maxn = 105;
const int inf = 0x3f3f3f3f;
typedef long long ll;


// DFS Ver
int main() {
#ifdef AZUKI_LOCAL
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    string s1, s2;
    while (cin >> s1 >> s2) {
        int ans = 0;
        rep(i, s1.size()) {
            ans += (s1[i] != s2[i]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

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

int main()
{
	ll n, k, ans;
	string s;

	cin >> n >> k;

	ans = n;

	while (ans > abs(ans - k))
	{
		ans = abs(ans - (k*max((ll)1,ans/k)));
	}
	   
	cout << ans << endl;

}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n;
    cin>>n;
    int pa[n+2],pb[n+2];
    int a[n+2],b[n+2];
    f(i,1,n)
    {
        cin>>a[i];
        pa[i]=a[i];
    }
    f(i,1,n)
    {
        cin>>b[i];
        pb[i]=b[i];
    }
    sort(pa+1,pa+n+1);
    sort(pb+1,pb+n+1);
    map<int,int>yo;
    f(i,1,n)
    {
        if(pa[i]>pb[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
        yo[pa[i]]=pb[i];
    }
    f(i,1,n-1)
    {
        if(pa[i+1]<=pb[i])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    map<int,int>bidx;
    map<int,int>ses;
    f(i,1,n)
    {
        bidx[b[i]]=i;
    }
    f(i,1,n)
    {
        int x=i;
        int y=bidx[yo[a[i]]];
        ses[x]=y;
    }
    map<int,int>vis;
    int cur=1,cnt=1;
    while(1)
    {
        cur=ses[cur];
        if(cur==1)break;
        cnt++;
    }
    if(cnt!=n)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;

}





































Measured memory_bytes: 25300
/**
 * ???????????????

????????? str ?????????????????????????????????????????????????????????????????°???????????????????????????????????????????????\?????????????????????????????§??????

print a b: str ??? a ??????????????? b ??????????????§??????????????????
reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????

????????§??????????????? str ????????????????????? 0 ???????????¨????????????

Input
1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

Output
??? print ???????????¨???????????????????????????????????????????????????

Constraints
1???str????????????1000
1???q???100
0???a???b<str?????????
replace ????????§??? b???a+1=p?????????

Sample Input 1
abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4

Sample Output 1
xaze

Sample Input 2
xyz
3
print 0 2
replace 0 2 abc
print 0 2

Sample Output 2
xyz
abc
 */

#include <iostream>
#include <sstream>
#include <algorithm>

int main(int argc, char const *argv[]) {
  std::string Source;
  std::string Param;
  unsigned short q = 0;
  std::istringstream iss;

  getline(std::cin, Source);
  getline(std::cin, Param);
  iss.str(Param);
  iss >> q;
  iss.clear();

  for (size_t i = 0; i < q; i++) {
    std::string Command, Arg3;
    unsigned short Arg1, Arg2;
    getline(std::cin, Param);
    iss.str(Param);
    iss >> Command;
    if (Command == "print") {
      iss >> Arg1 >> Arg2;
      std::string Dest;
      Dest = Source.substr(Arg1, Arg2 - Arg1 + 1);
      std::cout << Dest << std::endl;
    } else if (Command == "reverse") {
      iss >> Arg1 >> Arg2;
      std::reverse(Source.begin() + Arg1, Source.begin() + Arg2 + 1);
    } else if (Command == "replace") {
      iss >> Arg1 >> Arg2 >> Arg3;
      Source.replace(Arg1, Arg2 - Arg1 + 1, Arg3);
    }
    iss.clear();
  }

  return 0;
}

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

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

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 main() {
  ll n;
  cin >> n;
  vector<int> v;
  while (true) {
    if (n == 0) {
      break;
    }
    v.push_back(n % 26);
    n--;
    n = n / 26;
  }

  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i] == 0) {
      cout << 'z';
    } else
      cout << (char)('a' + v[i] - 1);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
x, y = [int(i) for i in input().split()]

if (x*2==y or x*4==y):
    print('Yes')
else:
    poss = 0
    for i in range(1, x+1):
        legs = i*2 + (x-i)*4
        if(legs==y):
            poss=1
            break
    if(poss):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 9176
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

LL gcd(LL a,LL b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int N;
    cin>>N;
    LL T[101];
    REP(i,N){
        cin>>T[i];
    }
    sort(T,T+N,greater<LL>());
    LL res=1;
    REP(i,N){
        if(res%T[i]!=0){
            res*=(T[i]/gcd(T[i],res));
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int,int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    pii p[n];
    for(int i = 0; i < n; i++) {
        cin >> p[i].se >> p[i].fi;
    }
    sort(p, p + n);
    int t = 0;
    for(int i = 0; i < n; i++) {
        t += p[i].se;
        if(t > p[i].fi) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vii a;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        a.pb(mp(x,i));
    }
    sort(all(a));
    for(int i=0;i<n;i++){
        cout<<a[i].S+1<<" ";
    }
    
    

    return 0;
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin >>A>>B;
    int ans=-1;
    if(A<10&&B<10){
        ans=A*B;
    }
    cout << ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <random>
//#include <chrono>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    MotoHaiyaku
    ll k,cnt=0;
    cin>>k;
    if(k%2==0||k%5==0)
    {
        cout<<-1;
        return 0;
    }
    rep1(i,k)
    {
        cnt=(cnt*10%k+7)%k;
        if(cnt==0)
        {
            cout<<i;
            return 0;
        }
    }
}


Measured memory_bytes: 3652
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    /*static long fib_recur(int n){
        //TLE
            if (n==0){
                return 1;
            }else if(n==1){
                return 1;
            }else{
                return fib(n-1)+fib(n-2);
            }
        }
	*/
    static long fib(int n){
        if (n==0) return 1;
        else if (n==1) return 1;
        
        long val = 2;           //fib(n)
        long val_pre = 1;       //fib(n-1)
        long val_prepre = 1;    //fib(n-2) 
        for (int i = 2; i < n; i++){
            val_prepre = val_pre;
			val_pre = val;
            val = val_pre + val_prepre;
        }
        return val;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(fib(n));
    }
}

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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<pair<ll, ll>> CB(M);
    ll b, c;
    rep(i, M) {
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }
    sort(CB.begin(), CB.end(), greater<pair<ll, ll>>());
    sort(A.begin(), A.end());
    ll left = 0;
    for (pair<ll, ll> p : CB) {
        b = p.first;
        c = p.second;
        rep(i, c) {
            if (A[left] < b) {
                A[left] = b;
                left++;
                if (left == A.size()) break;
            } else {
                break;
            }
        }
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
    return 0;
}


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

ll N, K;
const int MAX = 1.0e5 + 10;
ll A[MAX];

ll f(bitset<64> X) {
    ll X_ll = X.to_ullong();
    ll ret = 0;
    for (int i = 0; i < N; i++) {
        ret += (X_ll xor A[i]);
    }
    return ret;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    ll ans = 0;
    for (int i = 63; i >= 0; i--) {
        bitset<64> bt0(ans);
        bitset<64> bt1(ans);
        bt1.set(i, 1);

        if ((ll)bt1.to_ullong() <= K) {
            if (f(bt0) < f(bt1)) {
                ans += pow(2, i);
            }
        }
    }

    bitset<64> a_bt(ans);
    cout << f(a_bt) << endl;

    return 0;
}


Measured memory_bytes: 1024
#ABC104 B
#Sが次をみたすかどうか判定せよ
#先頭の文字が'A'
#2文字目は小文字
#末尾の文字は小文字
#3文字目から末尾から2文字目までには'C'がちょうど1回だけ登場し,残りは全部小文字
#
import re
r = re.compile(r'^A[a-z]+C[a-z]+$')
msg = ['WA','AC']
print(msg[len(r.findall(str(input())))])

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(int n){
    //vector<int> r(n),w(n);
    vector<pii> ps(n);
    int sumr=0,sumw=0;
    rep(i,0,n){
        cin >> ps[i].first >> ps[i].second;
        sumr+=ps[i].first;
        sumw+=ps[i].second;
    }

    sort(ps.rbegin(),ps.rend());
    if(ps[0].first<=sumr-ps[0].first){
        cout << sumr+sumw << endl;
        return;
    }

    const int t=ps[0].first*2-sumr;
    vector<vector<bool>> dp(n+1,vector<bool>(t+1));
    dp[1][0]=true;
    if(ps[1].second<=t) dp[1][ps[1].second]=true;
    rep(i,2,n){
        rep(j,0,t+1){
            if(dp[i-1][j]){
                dp[i][j]=true;
                continue;
            }
            if(j-ps[i].second<0) continue;
            if(!dp[i-1][j-ps[i].second]) continue;
            dp[i][j]=true;
        }
    }
    int maxi=0;
    rep(i,0,t+1) if(dp[n-1][i]) maxi=max(maxi,i);
    cout << sumr+sumw+(t-maxi) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int n;
        cin >> n;
        if(n==0) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stack>
#include <map>
#include <ctype.h>

using namespace std;

#define loop(n) for(int i=0; i<n; i++)
#define loopb(n) for(int i=n; i>=0; i--)
#define remove_space(x) x.erase(remove(x.begin(), x.end(), ' '), x.end())

int main(){

	int n1,n2;
	cin >> n1 >> n2;

	if(n1 > 9 || n2 > 9){
		cout << -1;
	}

	else{
		cout << n1 * n2;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private void Process()
        {
            string line;
            char tmp;
            bool isBalance;

            Stack<char> start = new Stack<char>(100);
            HashSet<char> sCheck = new HashSet<char>();
            HashSet<char> eCheck = new HashSet<char>();
            sCheck.Add('(');
            sCheck.Add('[');
            eCheck.Add(')');
            eCheck.Add(']');

            while (true)
            {
                start.Clear();
                isBalance = true;

                line = Console.ReadLine();

                if (line == ".")
                    break;

                for (int i = 0; isBalance && i < line.Length; i++)
                {
                    if (sCheck.Contains(line[i]))
                    {
                        start.Push(line[i]);
                    }
                    else
                    {
                        if (eCheck.Contains(line[i]))
                        {
                            isBalance = start.Count > 0;
                            if (isBalance)
                            {
                                tmp = start.Pop();
                                isBalance = (line[i] == ')' && tmp == '(' || line[i] == ']' && tmp == '[');
                            }
                        }
                    }
                }

                Console.WriteLine(isBalance && start.Count == 0 ? "yes" : "no");
            }
        }
    }
}

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

using namespace std;
const int N_CNTST = 26;
int D;
vector <long long> C;
vector <vector<long long> > S;
long long CSum = 0;

vector<int> LAST(26, 0);

vector<int> T;
int main(){
    cin >> D;
    cin.ignore();
    
    long long tmp;
    for(int i = 0; i < N_CNTST; i++){
        cin >> tmp;
        C.push_back(tmp);
        CSum += tmp;
    }
    cin.ignore();
    for(int i = 0; i < D; i++){
        vector<long long> S_;
        for(int j = 0; j < N_CNTST; j++){
            cin >> tmp;
            S_.push_back(tmp);
        }
        cin.ignore();
        S.push_back(S_);
    }

    // tを算出
    long long sum = 0;
    long long msum = 0; // 減算Sum
    for(int i = 0; i < D; i++){
        cin >> tmp;
        T.push_back((int)tmp);
        cin.ignore();
        
        int idx = ((int) tmp) - 1;
        msum += CSum - C[idx] * (i - LAST[idx] + 1);
        LAST[idx] = i+1;
        //cout << CSum - C[idx] << endl;
        //cout << msum << endl;
        sum += S[i][idx] - msum;
        cout << sum << endl;
    }
    return 0;
}

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

int N, X[10], Y[10];

int factorial(int n) {
  if (n == 0) return 1;
  else return n * factorial(n - 1);
}

double dist_sum(double prev_sum, int prev, bool used[], int used_count) {
  if (used_count >= N) return prev_sum;
  double sum = 0;
  for (int i = 0; i < N; i++) {
    if (used[i]) continue;
    used[i] = true;
    if (prev == -1) {
      sum += dist_sum(prev_sum, i, used, used_count + 1);
    } else {
      int dx = X[i] - X[prev], dy = Y[i] - Y[prev];
      sum += dist_sum(prev_sum + sqrt((double) (dx * dx + dy * dy)), i,
                      used, used_count + 1);
    }
    used[i] = false;
  }
  return sum;
}

int main() {
  cin >> N; for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
  bool all_false[N]; for (int i = 0; i < N; i++) all_false[i] = false;
  double res = dist_sum(0, -1, all_false, 0) / factorial(N);
  cout << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

ll m,d;

int find(int n){
	return (n/10)*(n%10);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll ans=0;
	cin>>m>>d;
	
	fore(i,1,m){
		fore(j,10,d){
			if((j/10)<2||j%10<2) continue;
			if(find(j)==i) ans++;
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N,M,C;
int B[21];
int A[21][21];
int ans=0;

signed main(){
	cin>>N>>M>>C;
	REP(i,M){
		cin>>B[i];
	}
	REP(i,N)REP(j,M){
		cin>>A[i][j];
	}
	REP(i,N){
		int sum=C;
		REP(j,M){
			sum+=B[j]*A[i][j];
		}
		if(sum>0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<int> x(N),y(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i];

    double ans=0;
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(i!=j){
        ans+=hypot(x[i]-x[j],y[i]-y[j]);
    }
    ans/=N;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def dist(p, q)
  Math.sqrt((0..2).reduce(0){ |s, i| s + (p[i] - q[i]) ** 2 })
end

gets.to_i.times do
  real = gets.split.map(&:to_f)
  rank_k = real.map{ |r| real.sort.index(r) }
  real.sort!
  m = gets.to_i
  ps = m.times.map{ gets.split.map(&:to_f) }
  (0...m).to_a.combination(3) do |i, j, k|
    p = [i + 1, j + 1, k + 1]
    imag = [dist(ps[j], ps[k]), dist(ps[k], ps[i]), dist(ps[i], ps[j])]
    rank_im = imag.map{ |im| imag.sort.index(im) }
    imag.sort!
    if imag.zip(real).map{ |i, r| i / r }.combination(2).map{ |x, y| x / y }.all?{ |v| (1 - v).abs < 0.001 }
      puts (0..2).map{ |i| p[rank_im.index(rank_k[i])]}.join(' ')
      break
    end
  end
end

Measured memory_bytes: 8860
buf = [str(i) for i in range(1,10)]
next = []
ans = []
flag = False
k = int(input())

while True:
    next = []
    if flag:
        break
    for b in buf:
        ans.append(int(b))
        if b[0] == "4" and len(b) >= 10:
            flag = True
            break
        if b[-1] == "0":
            next.append(b+"0")
            next.append(b+"1")
        elif b[-1] == "9":
            next.append(b+"8")
            next.append(b+"9")
        else:
            base = int(b[-1])
            for i in range(3):
                next.append(b+str(base+i-1))
    buf = next

ans.sort()
print(ans[k-1])

Measured memory_bytes: 26216