akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    string ans = "";
    rep(i,n) ans += 'x';
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = arrayOf(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)
    println(t[sc.nextInt() - 1])
}

Measured memory_bytes: 31132
#include<cstdio>
#include<cctype>

template<class I>
inline I max(I a, I b) {return a > b ? a : b;}

template<class I>
inline I min(I a, I b) {return a < b ? a : b;}

template<class I>
inline void read(I & x) {
	x = 0;
	char c = ' ';
	int w = 1;
	while (!isdigit(c) && c != '-') c = getchar();
	if (c == '-') c = getchar(), w = -1;
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	x *= w;
}

long long a, b, c, d;

int main(void) {
	read(a), read(b), read(c), read(d);
	printf("%lld\n", max(max(a * c, a * d), max(b * c, b * d)));
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<long long int>P(N), M(N);
	std::vector<bool> C(N, true);

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

	int ans = 1;
	int min = P[0];
	for (int i = 1; i < N; i++)
	{		
		if (P[i] <= min)
		{
			ans++;
			min = P[i];
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3456
import math

n = int(input())
ans_list = [0 for i in range(n+1)]

for i in range(1,101):
    for j in range(1, 101):
        for k in range(1, 101):
            temp = i*i + j*j + k*k + i*j + j*k + k*i
            if temp <= n:
                ans_list[temp] += 1

for i in range(1, n+1):
    print(ans_list[i])


Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	
	if(b >= 0 && a <= 0){
		cout << "Zero" << endl;
	}else if(a > 0){
		cout << "Positive" << endl;
	}else{
		cout << ((b-a)%2 ? "Positive" : "Negative") << endl;
	}
	
	return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const unsigned int mod = 1e9 + 7;

using namespace std;

int32_t main() {
	fastio;

	int r;
	cin >> r;
	cout << 2.0 * 3.14 * r;

	return 0;
}

/*
A - Circle Pond / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 
100
 points

Problem Statement
Print the circumference of a circle of radius 
R
.

Constraints
1
≤
R
≤
100
All values in input are integers.
Input
Input is given from Standard Input in the following format:

R

Output
Print the circumference of the circle. Your output is considered correct if and only if its absolute or relative error from our answer is at most 
10
−
2
.

Sample Input 1 
Copy
1
Sample Output 1 
Copy
6.28318530717958623200
Since we accept an absolute or relative error of at most 
10
−
2
, 
6.28
 is also an acceptable output, but 
6
 is not.

Sample Input 2 
Copy
73
Sample Output 2 
Copy
458.67252742410977361942
*/


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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define INF 100000000

int N;
int S[3];
int L[10];
int U[10];

int calc2(int abc)
{
  int num = 0;
  int sum = 0;
  REP(i, N) if (U[i] == abc) {
    num++;
    sum += L[i];
  }

  if (num == 0) return INF;

  return 10 * (num - 1) + abs(sum - S[abc]);
}

int calc()
{
  int res = 0;
  REP(i, 3) res += calc2(i);
  return res;
}

int loop(int dep)
{
  if (dep == N) { return calc(); }

  int res = INF;
  REP(i, 4) {
    U[dep] = i;
    res = min(res, loop(dep+1));
  }
  return res;
}

int main()
{
  cin >> N;
  REP(i, 3) cin >> S[i];
  REP(i, N) cin >> L[i];
  cout << loop(0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int answer = 1000 - N % 1000;
  if (N % 1000 == 0) answer = 0;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3648
import java.util.*;

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

		long sum = 0;
		long min = Long.MAX_VALUE / 2;
		int minusCnt = 0;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			sum += Math.abs(A[i]);
			min = Math.min(min, Math.abs(A[i]));
			if (A[i] < 0) {
				minusCnt++;
			}
		}
		sc.close();

		if (minusCnt % 2 == 0) {
			System.out.println(sum);
		} else {
			System.out.println(sum - (2 * min));
		}
	}
}


Measured memory_bytes: 60596
#include "bits/stdc++.h"
#define readInt(x) scanf("%d", &x)
#define readStr(x) scanf("%s", x)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1 << 28;
const int MAX = 1e5 + 10;

int N;
int A[2][110];

int main()
{
    cin >> N;
    rep(i, 2)
        rep(j, N)
        cin >> A[i][j];

    int ans = 0;
    int sum = 0;
    rep(b, N) {
        rep(j, N) {
            if (j < b) sum += A[0][j];
            else if (j > b) sum += A[1][j];
            else sum += A[0][j] + A[1][j];
        }
        if (sum > ans) ans = sum;
        sum = 0;
    }
    write(ans);
}

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

bool isOk(vector<string> const& words) {
    map<string, bool> checked;
    
    char before = words[0][0];
    
    for (auto const& word : words) {
        if (word[0] != before) {
            return false;
        }
        if (checked[word]) {
            return false;
        }
        before = *word.rbegin();
        checked[word] = true;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    
    vector<string> words(N);
    for (auto& word : words) {
        cin >> word;
    }
    
    if (isOk(words)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v)                               \
    cout << #v << "-->" << endl;               \
    for (auto it : v)                          \
    {                                          \
        cout << it.fi << " " << it.se << endl; \
    }
#define mod 100000000000007
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

#define MAXN 10000001

void solve()
{
    int n;
    cin >> n;
    vec v(n);
    //int ans = 0;
    stack<int> ss;
    fo(i, n)
    {
        cin >> v[i];
    }
    vec ans(n, 0);
    int anss = 0;
    ans[n - 1] = 0;
    for(int i=n-2;i>=0;i--){
        if(v[i+1]<=v[i]){
            ans[i] = 1 + ans[i + 1];
        }
        else{
            ans[i] = 0;
        }
        anss = max(anss, ans[i]);
    }
    cout << anss;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(0));

    // FILE *fin = freopen("ip.txt","r",stdin);
    // FILE *fout = freopen("op.txt","w",stdout);
    int t = 1, nn = 1;
    //cin >> t;
    while (t--)
    {
        // cout << "Case #" << nn << ":"
        //      << " ";
        // nn++;
        solve();
    }
}

Measured memory_bytes: 4756
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
  long n;
  long[] xs = new long[](5);
  readf("%d\n", &n);

  foreach (i; 0..5) {
    readf("%d\n", &xs[i]);
  }


  long m = cast(long)(1e16);
  long mi = -1;
  foreach (i, x; xs) {
    if (x <= m) {
      m = x;
      mi = i;
    }
  }

  // 最短で5ターン + 最も細い道を全員が通過するまでのターン数
  long ans = 5 + (n % m == 0 ? n / m - 1 : n / m);
  writeln(ans);
}


Measured memory_bytes: 256
package main

import "fmt"

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

	x := 1
	for i := 0; i < d; i++ {
		x *= 100
	}

	ans := 0
	if n == 100 {
		ans = x * 101
	} else {
		ans = x * n
	}

	fmt.Println(ans)
}


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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

int main(){
  int n; cin>>n;
  vector<int> l(n); 
  for(int i=0;i<n;i++){
    cin >> l[i];
  }

  sort(l.begin(),l.end());

  int ans=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        bool A=(i!=j && i!=k && j!=k);
        bool B=(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k]);
        if(A && B){
          if(abs(l[j]-l[k])<l[i] && l[i]<l[j]+l[k]){
            ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;
}

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

int main() {

  int n,m,l,r,ml,mr;
  cin >> n >> m;
  
  ml = 0;
  mr = n;
  
  for ( int i = 0; i < m; i++){
    cin >> l >> r;
    ml = max(ml,l);
    mr = min(mr,r);
  }
  
  if ( ml <= mr ){
    cout << mr - ( ml - 1 ) << endl;
  }else{
    cout << 0 << endl;
  }
  
}

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

    using namespace std;
    using ll=long long;

    #define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define pii pair<int,int>
    #define cint int t;cin>>t;while(t--)
    #define rep(i,a,b) for(int i=a;i<b;i++)

    int mod=1e9;

    int main(){
        faster;

        int n,k,s;
        cin>>n>>k>>s;

        for(int i=0;i<k;i++) cout<<s<<" ";
        for(int i=0;i<n-k;i++) {
            if(s==mod){
                cout<<s-1<<" ";
                continue;
            }
            cout<<s+1<<" ";}
        cout<<endl;
    }


Measured memory_bytes: 1280
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n, a, b = map(int, input().split())
    d = b - a
    if d % 2 == 1:
        return "Borys"
    else:
        return "Alice"

print(main())


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int, int> P;
int n, m;
int dp[80][200][20], kosu[1600];
P stone[1600][20];
int main()
{
	while(cin >> n >> m && n)
	{
		for(int i = 0; i < n; i++)
		{
			cin >> kosu[i];
			for(int j = 0; j < kosu[i]; j++)
			{
				cin >> stone[i][j].F >> stone[i][j].S;
			}
		}
		for(int i = 0; i <= m; i++)
			for(int j = 0; j < n; j++)
				for(int k = 0; k < kosu[j]; k++)
					dp[i][j][k] = 1 << 30;
				for(int i = 0; i < kosu[0]; i++)
					dp[0][0][i] = 0;
				for(int i = 0; i < kosu[1]; i++)
					dp[1][1][i] = 0;
				for(int i = 0; i < n - 1; i++)
				{
					for(int j = 0; j < kosu[i]; j++)
					{
						for(int k = 0; k < kosu[i + 1]; k++)
						{
							for(int l = 0; l <= m; l++)
							{
								if(dp[l][i][j] < 1 << 30)
									dp[l][i + 1][k] = min((stone[i + 1][k].S + stone[i][j].S) * abs(stone[i + 1][k].F - stone[i][j].F) + dp[l][i][j], dp[l][i + 1][k]);
							}
						}
						if(i + 2 < n)
						{
							for(int k = 0; k < kosu[i + 2]; k++)
							{
								for(int l = 0; l < m; l++)
								{

									if(dp[l][i][j] < 1 << 30)
									{
										dp[l + 1][i + 2][k] = min((stone[i + 2][k].S + stone[i][j].S) * abs(stone[i + 2][k].F - stone[i][j].F) + dp[l][i][j], dp[l + 1][i + 2][k]);
									}
								}
							}
						}
					}
				}
				int ans = INT_MAX;
				for(int i = 0; i <= m; i++)
					for(int j = 0; j < kosu[n - 1]; j++)
						ans = min(ans, dp[i][n - 1][j]);
					for(int i = 0; i < m; i++)
						for(int j = 0; j < kosu[n - 2]; j++)
							ans = min(ans, dp[i][n - 2][j]);
						cout << ans << endl;
					}
				}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
int x[105];
int main()
{
    int n;
    cin>>n;
    int p,q,sum1=0,sum2=0;
    for(int i=0;i<n;i++){
            cin>>x[i];
            sum1+=x[i];
    }
    q=sum1%n;
    if(q<=n/2) p=sum1/n;
    else p=sum1/n+1;
    for(int i=0;i<n;i++)
            sum2+=(x[i]-p)*(x[i]-p);
    cout<<sum2;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000ll;

int main(){
        ios_base::sync_with_stdio(false);
        int N, M, L;
        cin >> N >> M >> L;
        vector<ll> K(N);
        for(int i = 0; i < N; ++i){
                cin >> K[i];
                --K[i];
        }
        sort(K.begin(), K.end());
        vector<ll> S(M);
        for(int i = 0; i < M; ++i){ cin >> S[i]; }
        vector<ll> Si(M + 1);
        for(int i = 1; i <= M; ++i){ Si[i] = Si[i - 1] + S[i - 1]; }
        vector< vector<ll> > dp(N + 1, vector<ll>(N + 1, INF));
        dp[0][0] = 0;
        for(int i = 0; i < N - 1; ++i){
                for(int j = 0; j <= i; ++j){
                        ll head = dp[i][j] + (Si[K[i + 1] + 1] - Si[K[i]]) / L;
                        dp[i + 1][j] = min(dp[i + 1][j], head);
                        ll tail = dp[i][j] + (Si[K[i + 1] + 1] - Si[K[j]]) / L;
                        dp[i + 1][i] = min(dp[i + 1][i], tail);
                }
        }
        ll answer = INF;
        for(int i = 0; i < N - 1; ++i){
                answer = min(answer, dp[N - 1][i] + (Si[K[N - 1] + 1] - Si[K[i]]) / L);
        }
        cout << answer << endl;
        return 0;
}

Measured memory_bytes: 34004
#include<stdio.h>
long long dp[105][15][1050];//count,sum
long long i, j, k, n, s;



int main(){
    dp[0][0][0] = 1;
    dp[0][1][0] = 1;
    for(i = 1;i < 105;i++){
	for(j = 0;j < 15;j++){
	    for(k = 0;k < 1050;k++){
		if(k - i >= 0 && j - 1 >= 0)
		    dp[i][j][k] = dp[i - 1][j - 1][k - i] + dp[i - 1][j][k];
		else
		    dp[i][j][k] = dp[i - 1][j][k];

	    }
	}
    }
    while(1){
	scanf("%lld%lld", &n, &s);
	if(n == 0 && s == 0)return 0;
	printf("%lld\n",dp[100][n][s]);
    }
    return 0;
}

Measured memory_bytes: 13404
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def is_prime(n):
        if n==0 or n==1: return False
        for i in range(2, int(n**0.5)+1):
            if n%i==0:
                return False
        return True

    print([is_prime(i) for i in A].count(True))

if __name__ == '__main__':
    resolve()


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<bool> vis(n + 1, 0);
    vector<int> cnt(n + 1, 0);
    int ac = 0, wa = 0;
    for (int i = 0; i < m; i++) {
        int prob;
        string verd;
        cin >> prob >> verd;
        if (verd == "AC") {
            if (!vis[prob]) {
                vis[prob] = true;
                ac++;
            }
        } else {
            if (!vis[prob]) {
                cnt[prob]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (vis[i]) wa += cnt[i];
    }
    cout << ac << " " << wa << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


string s;
int a[114514], b[114514], c[114514], q[114514];
signed main() {
	cin >> s;
	if (s[0] == 'A')a[0]++;
	else if (s[0] == 'B')b[0]++;
	else if (s[0] == 'C')c[0]++;
	else q[0]++;
	REP(i, s.size()) {
		a[i] = a[i - 1]; b[i] = b[i - 1]; c[i] = c[i - 1]; q[i] = q[i - 1];
		if (s[i] == 'A')a[i]++;
		else if (s[i] == 'B')b[i]++;
		else if (s[i] == 'C')c[i]++;
		else q[i]++;
	}
	int ans = 0;
	for (int i = 1; i < s.size() - 1; i++) {
		if (s[i] != 'B'&&s[i] != '?')continue;

		int ri = a[i] * mod_pow(3, q[i - 1], moder) % moder;
		int le = (c[s.size() - 1] - c[i])*mod_pow(3, q[s.size() - 1] - q[i], moder) % moder;
		if (q[i - 1]) {
			ri += q[i - 1] * mod_pow(3, q[i - 1] - 1, moder) % moder;
		}
		if (q[s.size() - 1] - q[i]) {
			le += (q[s.size() - 1] - q[i])*mod_pow(3, q[s.size() - 1] - q[i] - 1, moder) % moder;
		}
		ans += ri * le%moder;
		ans %= moder;
	}
	cout << ans << endl;
	endre;
}


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

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

    if (S == "AAA") {
        cout << "No";
    } 
    else if (S == "BBB") {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define MAXV 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


struct edge {int to, cost; };
vector<edge> G[MAXV];

int color[MAXV];

void dfs(int v, int p, int c) {
    color[v] = c;
    for(auto e : G[v]) {
        if (e.to == p) continue;
        if (e.cost & 1) dfs(e.to, v, 1-c);
        else dfs(e.to, v, c);
    }
}

int main() {
    int V, E;
    cin >> V;
    int s, t, w;
    rep(i, V-1) {
        cin >> s >> t >> w;
        --s; --t;
        G[s].push_back(edge{t, w});
        G[t].push_back(edge{s, w});
    }
    int root = 0;
    dfs(root, -1, 1);

    rep(i, V) cout << color[i] << endl;
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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 a,b;
    cin >> a >> b;
    cout << 6 -a -b << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

int main(){
    
    int A,B,T;
    cin>>A>>B>>T;
    cout<<(T/A)*B<<endl;

}


Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
char mp[8][8]; int x[8],y[8],res,g;
signed main()
{
    int h,w,k;
    cin>>h>>w>>k;
    for(ri int i=0;i<h;i++)
    for(ri int j=0;j<w;j++)
    {
        cin>>mp[i][j];
        if(mp[i][j]=='#') x[i]++, y[j]++, res++;
    }
    for(ri int i=0;i<(1ll<<h);i++)
    for(ri int j=0;j<(1ll<<w);j++)
    {
        int now=res;
        for(ri int a=0;a<h;a++) if(i&(1ll<<a)) now-=x[a];
        for(ri int b=0;b<w;b++) if(j&(1ll<<b)) now-=y[b];
        for(ri int a=0;a<h;a++)
        for(ri int b=0;b<w;b++)
        {
            if((i&(1ll<<a)) &&(j&(1ll<<b))) if(mp[a][b]=='#') now++;
        }
        if(now==k) g++;
    }
    printf("%lld\n",g);
    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,i,j,k,A[200002],num[200002],all,ans,M;


int main()
{
  cin>>N;
  
  for(i=0;i<N;i++)
  {
    num[i]=0;
  }
  
  for(i=0;i<N;i++)
  {
    cin>>k;
    k--;
    A[i]=k;
    num[k]++;
  }
  
  all=0;
  for(i=0;i<N;i++)
  {
    all+=num[i]*(num[i]-1)/2;
  }
  
  for(i=0;i<N;i++)
  {
    k=A[i];
    M=num[k]*(num[k]-1)/2-(num[k]-2)*(num[k]-1)/2;
    ans=all-M;
    
    cout <<ans<<endl;
    
  }
  
}

Measured memory_bytes: 5760
import java.util.Scanner;

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

	String s = sc.next();
	String zero = "0";
	String one = "1";
//	String backspace = " ";
	String[] splitS = s.split("");
	String ans = "";


	for(int i = 0;i < s.length();i++) {
		if(zero.equals(splitS[i])) {
			ans += zero;
		}else if(one.equals(splitS[i])) {
			ans += one;
		}else if("B".equals(splitS[i])){
			if(ans.length() > 0) {
			ans = ans.substring(0,ans.length()-1);
			}
		}
	}
	System.out.println(ans);

	}



}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
using namespace std;
vector<long long> divisor(long long n){//nの約数列挙
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}
int main(){
    int N;
    cin >> N;
    vector<int> a(N + 1);
    for(int i = 1; i < N + 1; i++) cin >> a[i];
    vector<int> sum(N + 1, 0);
    vector<int> ko(N + 1, 0);
    int cnt = 0;
    for(int i = N; i > 0; i--){
        if(sum[i] % 2 != a[i]){
            ko[i]++;
            sum[i]++;
            cnt++;
            vector<long long> d = divisor(i);
            for(int j = 0; j < d.size(); j++){
                if(d[j] != i){
                    sum[d[j]]++;
                }
            }
        }
    }
    cout << cnt << endl;
    for(int i = 1; i <= N; i++){
        if(ko[i] == 1){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 5516
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n;
	long long int W;
	cin >> n >> W;
	long long int sw;
	long long int sv;
	cin >> sw >> sv;
	vector<vector<long long int> > vals(4);
	vals[0].push_back(sv);
	for(int i = 1; i < n; i++){
		long long int w;
		long long int v;
		cin >> w >> v;
		vals[w - sw].push_back(v);
	}
	for(int i = 0; i < 4; i++){
		sort(vals[i].begin() ,vals[i].end());
		vals[i].push_back(0);
		reverse(vals[i].begin(), vals[i].end());
		for(int j = 1; j < vals[i].size(); j++){
			vals[i][j] += vals[i][j - 1];
		}
	}
	long long int ans = 0;
	for(int i = 0; i < vals[0].size(); i++){
		for(int j = 0; j < vals[1].size(); j++){
			for(int k = 0; k < vals[2].size(); k++){
				long long int tmp = sw * i + (sw + 1) * j + (sw + 2) * k;
				if(tmp > W) continue;
				long long int tmp2 = min((W - tmp) / (sw + 3), (long long int)vals[3].size() - 1);
				ans = max(ans, vals[0][i] + vals[1][j] + vals[2][k] + vals[3][tmp2]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

def fizzbuzz(n):
    text = ''
    text += 'Fizz' if n%3==0 else ''
    text += 'Buzz' if n%5==0 else ''
    text += f"{n}" if text == '' else ''
    return text

fizzbuzzs = [i for i in range(1,n+1) if fizzbuzz(i) not in ['Fizz','Buzz','FizzBuzz']]
print(sum(fizzbuzzs))


Measured memory_bytes: 29952
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
if __name__ == '__main__':
    a = int(input())
 
    count = 0
 
    for i in range(1,a+1):
        for j in range(1, a + 1):
            for k in range(1, a + 1):
                count += gcd(i,j,k)
 
    print(count)

Measured memory_bytes: 74116
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;

ll h  ,ans; 
map<ll , ll> dp ; 
ll pd(ll x)
{
	if(dp[x] != 0) return dp[x] ; 
	else 
	{
		return 1 + 2 * pd(x/2) ; 
	}
}

int main()
{
	migmig ;
	dp[1] = 1 ; 
	cin>>h ; 
	cout<<pd(h) ; 	
}
//////
////////
///////////




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

#define ll long long

int main() {
  int N, K;
  cin >> N >> K;
  
  ll H[N];
  
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  
  sort(H, H+N);
  
  ll ans = 0;
  
  if (K >= N) {
    cout << 0 << endl;
  } else {
    for (int i = 0; i < N-K; i++) {
      ans += H[i];
    }
  cout << ans << endl;
  }
  
}




Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
char ss[55];
int main()
{
	scanf("%s",ss);
	bool flag=1;
	if(ss[2]!=ss[3]||ss[4]!=ss[5])flag=0;
	if(flag)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;
const int N = 200010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

int main() {
    ll n, m;
    cin >> n >> m;

    fact[0] = invf[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
    }

    ll ans = 1;
    for (ll x = 2; x * x <= m; x++){
        if (m % x) continue;
        ll c = 0;
        while (m % x == 0){
            m /= x;
            c++;
        }
        ans = (ans * nCr(n - 1 + c, n - 1)) % mod;
    }
    if (m > 1){
        ans = (ans * n) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	static int gcd(int a, int b){

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

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

		while(stdIn.hasNext()){
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int gcd_ans = gcd(a,b);
			int lcm_ans = a/gcd_ans*b;

			System.out.println(gcd_ans+" "+lcm_ans);
		}
	}
}

Measured memory_bytes: 11000
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    ans="CODEFESTIVAL2016"
    cnt=0
    for i in 1:16
        if s[i]!=ans[i]
            cnt+=1
        end
    end
    println(cnt)
end
main()

Measured memory_bytes: 111424
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
//const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
const LL INF = 1e18;

int N, num[(int)1e5 + 7];
LL memo[(int)1e5 + 7][2];

LL solve(int idx, bool change){
  if(idx == N - 1){
    if(change) return num[idx] * -1LL;
    return num[idx];
  }

  LL &sum = memo[idx][change];
  if(sum != -1) return sum;
  sum = -INF;

  max_self(sum, num[idx] * (change ? -1LL : 1LL) + solve(idx + 1, false));
  max_self(sum, num[idx] * (change ? 1LL : -1LL) + solve(idx + 1, true));

  return sum;
}

int main(){
  FAST_IO
  memset(memo, -1, sizeof memo);
  cin >> N;
  for(int idx = 0; idx < N; ++idx) cin >> num[idx];

  cout << solve(0, false) << '\n';
  return 0;
}


Measured memory_bytes: 8448
#include <iostream>

int main(int argc, char const *argv[]) {
	int a,b;
	std::cin >> a >> b;
	if (a + b < 10) {
		std::cout << a+b << '\n';
	}
	else{
		std::cout << "error" << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

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

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

template<typename T>
constexpr T gcd(T m, T n) noexcept {
	T g = 1;

	while (m != 0) {
		if (m < n) swap(m, n);

		if (m & 1) {
			if (n & 1) m = (m - n) >> 1;
			else n = n >> 1;
		}
		else {
			if (n & 1) {
				m = m >> 1;
			}
			else {
				n = n >> 1;
				m = m >> 1;
				g = g << 1;
			}
		}
	}

	return g * n;
}

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

	int k;
	cin >> k;
	ll ans = 0;
	llREP(a, 1, k+1) {
		llREP(b, a, k+1) {
			ll t = gcd(a, b);
			llREP(c, b, k + 1) {
				ll d = gcd(t, c);
				if (a != b && a != c && b != c) {
					ans += d * 6;
				}
				else if (a == b && b == c) {
					ans += d;
				}
				else {
					ans += d * 3;
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


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

int main() {
    string a,b;
    cin >> a >>b;
    bool ans =true;
        for(int i=0;i<a.size();i++){
            for(int j=0;j<a.size();j++){
                swap(a.at(j),a.at(a.size()-1));
            }
            if(a==b){
                cout<<"Yes"<<endl;
                ans =false;
                break;
            }
            
        }
   if(ans)cout <<"No"<<endl;
}



Measured memory_bytes: 256
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {
    int n, x, t; cin >> n >> x >> t;

    int ans = 0;
    int sum = 0;
    while(1) {
        ans += t;
        sum += x;

        if(n <= sum) {
            break;
        }
    }

    cout << ans << endl;
}

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

int main() {
  
  int h,w;
  cin >> h >> w;
  
  vector<vector<char>> a(h,vector<char>(w));
  for ( int i = 0; i < h; i++){
    for ( int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }
  
  
  
  int hanteiyoko,hanteitate;
  
  for ( int i = 0; i < h; i++){
    hanteiyoko = 1;
    for ( int j = 0; j < w; j++){
      if ( a[i][j] == '#' ){
        hanteiyoko = 0;
      }
    }
    if ( hanteiyoko == 1 ){
      for ( int j = 0; j < w; j++){
        a[i][j] = ' ';
      }
    }
  }
  
  for ( int j = 0; j < w; j++){
    hanteitate = 1;
    for ( int i = 0; i < h; i++){
      if ( a[i][j] == '#' ){
        hanteitate = 0;
      }
    }
    if ( hanteitate == 1 ){
      for ( int i = 0; i < h; i++){
        a[i][j] = ' ';
      }
    }
  }
  
  
  for ( int i = 0; i < h; i++){
    hanteiyoko = 1;
    for ( int j = 0; j < w; j++){
      if ( a[i][j] == ' ' ){
      	continue;
      }else{
        cout << a[i][j];
        hanteiyoko = 0;
      }
    }
    if ( hanteiyoko == 0 ){
      cout << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 mypow(s64 x, s64 n)
{
    s64 ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret *= x;
            ret %= MOD;
        }
        x = x * x;
        x %= MOD;
        n >>= 1;
    }
    return ret;
}

s64 Fac(s64 n, s64 r) {
    s64 ret = 1;
    for (s64 i = n; i >= r; --i){
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

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

    s64 n, a, b;
    cin >> n >> a >> b;

    s64 x, y, z;
    x = mypow(2, n) - 1;
    y = Fac(n, n - a + 1) * mypow(Fac(a, 1), MOD - 2);
    y %= MOD;
    z = Fac(n, n - b + 1) * mypow(Fac(b, 1), MOD - 2);
    z %= MOD;

    while (y + z > x) x += MOD;
    cout << (x - y - z) % MOD << "\n";
    return 0;
}



Measured memory_bytes: 256
class Dice():
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def get_top(self):
        return self.top

    def rotate_north(self):
        self.top,self.south,self.north,self.bottom = self.south,self.bottom,self.top,self.north
    
    def rotate_south(self):
        self.top,self.south,self.north,self.bottom = self.north,self.top,self.bottom,self.south

    def rotate_west(self):
        self.top,self.west,self.bottom,self.east = self.east,self.top,self.west,self.bottom

    def rotate_east(self):
        self.top,self.west,self.bottom,self.east = self.west,self.bottom,self.east,self.top

    def rotate_horizon(self):
        self.south,self.east,self.north,self.west = self.west,self.south,self.east,self.north

    def get_east(self):
        return self.east
        
dice = Dice(list(map(int,input().split())))
q = int(input())

for i in range(q):
    rot = list(map(int,input().split()))
    if rot[0]==dice.top:
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    elif rot[0]==dice.west:
        dice.rotate_east()
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    elif rot[0]==dice.bottom:
        dice.rotate_east()
        dice.rotate_east()
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    elif rot[0]==dice.east:
        dice.rotate_west()
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    elif rot[0]==dice.north:
        dice.rotate_south()
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    else:
        dice.rotate_north()
        for _ in range(4):
           dice.rotate_horizon()
           if dice.south==rot[1]:
               h=dice.get_east()
    print(h)

Measured memory_bytes: 7824
n,m = list(map(int,input().split()))
a = []
res_list = []
res = ""
flag = True

for i in range(m):
    a.append(list(map(int,input().split())))

for i in range(n):
    res_list.append("0")

for i in range(m):
    res_list[a[i][0]-1] = str(a[i][1])
    if a[i][0] == 1 and a[i][1] == 0 and n != 1:
        flag = False
        break
    for j in range(m):
        if a[i][0] == a[j][0] and a[i][1] != a[j][1]:
            flag = False
            break

if n == 1 and int(res_list[0]) == 0:
    flag = flag

elif res_list[0] == "0":
    res_list[0] = "1"

for i in res_list:
    res += i

if flag == False:
    print(-1)
else:
    print(res)



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

long long total(long long a, long long b, long long c)
{
  long long sum = a;
  sum -= a / b;
  sum -= a / c;
  sum += a / (b / __gcd(b, c) * c);
  return sum;
}

int main()
{
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << total(B, C, D) - total(A-1, C, D) << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(3);
	REP(i, n) {
		cin >> v[0] >> v[1] >> v[2];
		sort(ALL(v));
		if (v[2] * v[2] == v[1] * v[1] + v[0] * v[0])cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	int n,a;
	cin >> n;
	int ans = 0;
	for(int i=1;i<=n;i++) {
		cin >> a;
		if(i%2 == 1 && a%2 == 1) 
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}


ll dp[3030][6060],sum[3030][6060];
int main(){
    mod_build();
    int n,x;
    cin>>n>>x;
    ll ans=0;
    rep(i,n+1)rep(j,2*n+1){
        dp[i][j]=comb(i,j-i);
        sum[i][j]=comb(i,j-i);
    }
    rep(i,n)rep(j,2*n+1){
        (dp[i+1][j]+=dp[i][j])%=mod;
    }
    rep(i,n+1)rep(j,2*n){
        (sum[i][j+1]+=sum[i][j])%=mod;
    }
    rep(k,n+1){
        ll res=0;
        rep(i,k){
            if(x<2*i+2)break;
            int s=x-2*i-2;
            res+=sum[k-i-1][x-2*i-3];
            res+=dp[k-i-1][x-2*i-2]-(k-2*i-2>=0?dp[k-2*i-2][x-2*i-2] : 0);
            res=(res+mod)%mod;
        }
        if(x%2==1||2*k<x)++res;
        ans+=res*comb(n,k)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 289280
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int A, B, C;
    cin >> A >> B >> C;
    cout << (A == B && B == C ? "Yes" : "No") << endl;


    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int x = 0;
  while (1) {
    if (1+x*(a-1) >= b) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

import math
g = math.gcd(c, d)
l = int(c * d / g)

less_b = b - (b // c + b // d - b // l)
less_a = (a-1) - ((a-1)//c + (a-1) // d - (a-1)//l)
print(less_b-less_a)

Measured memory_bytes: 9112
#include<iostream>
using namespace std;
int main()
{
    int n,m,total,count,i;
    cin>>n>>m;
    total=1;
    count=0;
    for(int i=0;;i++)
    {	
        
        if(total<m){
            count++;
        	total=total+(n-1);
        }
        else{
        	break;}
        
        
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 256