akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
	for (int i = 0; i < 1000; i++){
		int a,b;

		cin >> a >> b;

		if (a == 0 && b == 0)
			break;

		int j,r,COUNT = 1;

		if (b > a){
			j = a;
			a = b;
			b = j;
		}

		while((r = a % b) != 0)
			{ a = b; b = r; COUNT++;}

		cout << b << " " <<COUNT << endl;
	}

	return 0;
}



Measured memory_bytes: 2992
N = int(input())
S = list(input())
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
print("".join([a[a.index(i)+N] if a.index(i)+N < len(a) else a[a.index(i)+N-len(a)]  for i in S]))

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

class r
{
  public:
    string s;
    int p;
    int rank;
    int prank;
};

bool cmp(r a,r b)
{
  if(a.s==b.s)
    return a.p>b.p;
  return a.s<b.s;
}

int main()
{
 int n;
  cin>>n;
  vector<r> v(n),np(n);
  for(auto &i:v) cin>>i.s>>i.p;
  for(int i=0;i<n;i++) v[i].prank=i;
  np=v;
  sort(v.begin(),v.end(),cmp);
  for(int i=0;i<n;i++) np[v[i].prank].rank=i;
  for(auto i:v) cout<<i.prank+1<<"\n";
  
  
  return 0;
}


Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
    string s,t;
    cin>>s>>t;
    int diff=0;
    int ans=10000;
    for(int i=0;i<s.size()-t.size()+1;i++){
        diff=0;
        rep(j,t.size()){
            //cout<<"j"<<j<<"i+j"<<i+j<<endl;
            if(t.at(j)!=s.at(i+j)){
                diff+=1;
            }
        }
        if(diff<ans){
            ans=diff;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3588
import java.util.*;

class Main {
	static int N;
	static char[] s;
	static int[] ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		s = sc.next().toCharArray();
		ans = new int[N];
		int[] animals = new int[N];
		Arrays.fill(animals, -1);
		Arrays.fill(ans, -1);
		dfs(animals, 0);
		if (ans[0] == -1) {
			System.out.println(-1);
		} else {
			for (int i = 0; i < N; ++i) {
				System.out.print(ans[i] == 0 ? 'S' : 'W');
			}
			System.out.println();
		}
	}

	static void dfs(int[] arr, int cur) {
		if (cur == N) {
			for (int i = 0; i < N; ++i)
				ans[i] = arr[i];
			return;
		}
		if (arr[cur] == -1) {
			for (int i = 0; i < 2; ++i) {// 0:羊,1:狼
				arr[cur] = i;
				if ((s[cur] == 'o' && i == 0) || (s[cur] == 'x' && i == 1)) {
					arr[(cur + 1) % N] = 0;
					arr[(cur - 1 + N) % N] = 0;
					dfs(arr, cur + 1);
					arr[(cur + 1) % N] = 1;
					arr[(cur - 1 + N) % N] = 1;
					dfs(arr, cur + 1);
					arr[(cur + 1) % N] = -1;
					arr[(cur - 1 + N) % N] = -1;
				} else {
					arr[(cur + 1) % N] = 1;
					arr[(cur - 1 + N) % N] = 0;
					dfs(arr, cur + 1);
					arr[(cur + 1) % N] = 0;
					arr[(cur - 1 + N) % N] = 1;
					dfs(arr, cur + 1);
					arr[(cur + 1) % N] = -1;
					arr[(cur - 1 + N) % N] = -1;
				}
			}
		} else {
			if ((s[cur] == 'o' && arr[cur] == 0) || (s[cur] == 'x' && arr[cur] == 1)) {
				if (arr[(cur + 1) % N] == -1 || arr[(cur + 1) % N] == arr[(cur - 1 + N) % N]) {
					arr[(cur + 1) % N] = arr[(cur - 1 + N) % N];
					dfs(arr, cur + 1);
					if ((cur + 1) % N != 0)
						arr[(cur + 1) % N] = -1;
				}
			} else {
				if (arr[(cur + 1) % N] == -1 || arr[(cur + 1) % N] == (arr[(cur - 1 + N) % N] ^ 1)) {
					arr[(cur + 1) % N] = arr[(cur - 1 + N) % N] ^ 1;
					dfs(arr, cur + 1);
					if ((cur + 1) % N != 0)
						arr[(cur + 1) % N] = -1;
				}
			}
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;

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

    string S;
    cin >> S;
    for (int i = 0; i + 1 < 4; ++i) {
        if (S[i] == S[i + 1]) {
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 0;
	for (int ii = 0; ii < N; ++ii){
		int num;
		cin >> num;
		if (ii % 2 == 0){
			if (num % 2 == 1){
				ans++;
			}
		}
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3592
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)
elif blue_count + red_count > n:
  print(blue_count)
else:
  set_count = blue_count + red_count

  margin = 0
  if n % set_count == 0:
    c =  n // set_count
  else:
    c =  n // set_count
    margin = n % set_count

  # NOTE: あまり部分が 青 -> 赤 の途中である事を前提としてしまっているので変更が必要
  if margin > blue_count:
    margin = blue_count
    
  print(blue_count * c + margin )


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var A, B, C, X int
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	fmt.Scan(&X)
	ans := 0
	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if 500 * a + 100 * b + 50 * c == X {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m,k;

int cal(int x,int y){
	int re=0;
	re=x*m;
	re+=y*((n-x)-x);
	return re;
}

int main(){
	scanf("%d%d%d",&n,&m,&k);
	if(k%m==0 || k&n==0){
		puts("Yes");
		return 0;
	}
	int i,j;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(cal(i,j)==k){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

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

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

ll mem[300000][3] = {0};

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int margin = N%2 + 1;
    REP(i, N+3) REP(m, margin+1) mem[i][m] = LONG_LONG_MIN;
    mem[0][margin] = 0;
    REP(i, N+margin) {
        REP(m, margin+1) if (mem[i][m] != LONG_LONG_MIN) {
            if (i+2 <= N+1) {
                mem[i+2][m] = max(mem[i+2][m], mem[i][m]+A[i]);
            }
            if (m > 0) {
                mem[i+1][m-1] = max(mem[i+1][m-1], mem[i][m]);
            }
        }
    }
    cout << mem[N+1][0] << endl;
    
    return 0;
}

Measured memory_bytes: 8772
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 2e5 + 10;
lli tree[4*N];
lli dp[N];
pair<lli, lli> nums[N];
void update(int v, int l, int r, int pos, lli newVal) {
	if(l > r || l > pos || r < pos) return;
	if(l == r && l == pos) {tree[v] = newVal; return;}
	int v1 = 2 * v + 1;
	int v2 = 2 * v + 2;
	int mid = (l + r) / 2;
	update(v1, l, mid, pos, newVal);
	update(v2, mid + 1, r, pos, newVal);
	tree[v] = max(tree[v1], tree[v2]);
}
lli query(int v, int l, int r, int L, int R) {
	if(l > r || l > R || r < L) return -INF64;
	if(L <= l && r <= R) return tree[v];
	int v1 = 2 * v + 1;
	int v2 = 2 * v + 2;
	int mid = (l + r) / 2;
	lli q1 = query(v1, l, mid, L, R);
	lli q2 = query(v2, mid + 1, r, L, R);
	return max(q1, q2); 
}
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<pair<lli, lli>> qq;
	for(int i = 1; i <= n; i++)
		cin >> nums[i].first;
	for(int i = 1; i <= n; i++)
		cin >> nums[i].second;
	for(int i = 1; i <= n; i++) 
		qq.push_back({nums[i].first, i});
	sort(qq.begin(), qq.end());
	
	for(auto jj : qq) {
		lli i = jj.second;
		dp[i] = query(0, 1, n, 1, i) + nums[i].second;
		update(0, 1, n, i, dp[i]);
	}
	cout << *max_element(dp + 1, dp + n + 1) << "\n";
	return 0;
}

Measured memory_bytes: 14700
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,Z=1<<29;
int n,k,i,a,b,ans[N];
struct atom{
	int v,l,r;
	inline bool ask(int x){return v==-1?1:l<=x && x<=r && (x&1)==v;}
	inline bool empty(){return v!=-1 && (l>r || (l==r && (l&1)!=v));}
	inline void operator&=(atom rhs){
		if(rhs.v==-1)return;
		if(v==-1)*this=rhs;else if(rhs.v!=v)l=Z,r=-Z;
			else l=max(l,rhs.l),r=min(r,rhs.r);
	}
	inline void mdy(){
		if(v!=-1)v^=1,--l,++r;
	}
}f[N],t;
vector<int>e[N];
void dfs(int u,int fa){
	for(int v:e[u])if(v!=fa)dfs(v,u),t=f[v],t.mdy(),f[u]&=t;
	if(f[u].empty()){puts("No");exit(0);}
}
void dfs2(int u,int fa){for(int v:e[u])if(v!=fa)ans[v]=ans[u]-1+f[v].ask(ans[u]+1)*2,dfs2(v,u);}
int main(){
	scanf("%d",&n);for(i=1;i<n;++i)scanf("%d%d",&a,&b),e[a].push_back(b),e[b].push_back(a);
	for(i=1;i<=n;++i)f[i].v=-1;for(scanf("%d",&k);k--;)scanf("%d%d",&a,&b),f[a]=(atom){b&1,b,b};
	dfs(1,0);ans[1]=f[1].v==-1?0:f[1].l;dfs2(1,0);
	puts("Yes");for(i=1;i<=n;++i)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 15744
#include <stdio.h>
#include <string.h>
int main(void){
    char s[11],t[11];
    scanf("%s",s);
    scanf("%s",t);
    if(strlen(s)+1!=strlen(t)){
        printf("No");
        return 0;
    }
    for(int i=0;i<strlen(s);i++){
        if(s[i]!=t[i]){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int n;
	int m;
	int c;
	
	cin >> n >> m >> c;
			
	vector<ll> b;
	for (int i = 0; i < m; ++i) {
		ll k;
		cin >> k;
		b.pb(k);
	}
	
	int count = 0;
	
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			ll k;
			cin >> k;
			sum += (k*b.at(j));
		}
		if (sum + c > 0) {
			count++;
		}
		sum = 0;
	}
	
	cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<ctime>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

/*n
i =0 to 9
j = 0 to K
  k=0 to junle[i](é«ãæ¹ãã)
  kåå£²ããªã k*(k-1)åã®å©ç
*/

const int N = 2001;
int dp[10][N];
int solve(int n,int K,vector<int> in[10]){
  int tmp = 0;
  //ini
  rep(i,10)rep(j,K+1)dp[i][j] = 0;

  //prec
  rep(i,in[0].size()){
    tmp += in[0][i];
    int t = i+1;
    dp[0][i+1] = tmp + t*max(0,t-1);
  }

  //dp
  REP(i,1,10){
    rep(j,K+1){
      dp[i][j] = dp[i-1][j];
      int tmp = 0;
      rep(k,in[i].size()){
	int t = k + 1;
	tmp += in[i][k];
	if (j-(k+1) >= 0){
	  dp[i][j] = max(dp[i][j],dp[i-1][j-(k+1)] + tmp + t*max(0,t-1));
	}
      }
    }
  }
  return dp[9][K];
}

main(){
  int n,k;
  while(cin>>n>>k){
    vector<int> in[10];
    rep(i,n){
      int a,b;
      cin>>a>>b;
      in[b-1].push_back(a);
    }
    rep(i,10)sort(in[i].begin(),in[i].end(),greater<int>());
    cout << solve(n,k,in) << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
    }  
    int lcm(int a,int b){return a*b/gcd(a,b);}
struct bou{
    int l,r,x,y;
    };
    int n[100];bou m[101];
int mincost(int a){
    if(n[a-1]!=-1)return n[a-1];
    int b=1,c=1;
    if(m[a].x)b=mincost(m[a].x);
    if(m[a].y)c=mincost(m[a].y);
    b/=gcd(b,m[a].r);c/=gcd(c,m[a].l);
    n[a-1]=lcm(b,c)*(m[a].l+m[a].r);
    return lcm(b,c)*(m[a].l+m[a].r);
    }
signed main(){
   int a;
   while(cin>>a,a){
       memset(n,-1,sizeof(n));
       bou g;
       for(int b=1;b<=a;b++){
	   int c,d;
	  scanf("%lld%lld%lld%lld",&c,&d,&g.x,&g.y);
	  g.l=c/gcd(c,d);g.r=d/gcd(c,d);
	  m[b]=g;
	   }
	 for(int i=0;i<a;i++){
	     if(n[i]==-1)mincost(i+1);
	     }  
	     int MAX=0;
	for(int i=0;i<a;i++){
	     MAX=max(MAX,n[i]);
	    }  
	    cout<<MAX<<endl;
       }
    }

Measured memory_bytes: 3152
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        for (int i = 0; i < n; i++)
        {
            a[i]--;
        }
        bool[] flag = new bool[n];
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (!flag[a[i]] && a[a[i]] == i)
            {
                ans++;
                flag[i] = true;
                flag[a[i]] = true;
            }
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { for(; a; swap(a, b)) b %= a; return b; }

string s1, s2;
ll n, m;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll i, k;
	
	cin >> n >> m >> s1 >> s2;
	
	k = gcd(n, m);
	
	for(i=0; i<k; i++){
		if(s1[n / k * i] != s2[m / k * i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << n * m / k << endl;
	
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &a[i], &b[i], &c[i])
	}
	answer := maxPoints(a, b, c)
	fmt.Println(answer)
}

func maxPoints(a, b, c []int) int {
	var dp [100001][3]int // i: n, j: a/b/c in last choice
	dp[1][0] = a[0]
	dp[1][1] = b[0]
	dp[1][2] = c[0]

	for i := 1; i < len(a); i++ {
		dp[i+1][0] = max(dp[i][1]+a[i], dp[i][2]+a[i])
		dp[i+1][1] = max(dp[i][0]+b[i], dp[i][2]+b[i])
		dp[i+1][2] = max(dp[i][0]+c[i], dp[i][1]+c[i])
	}
	return max(dp[len(a)][0], max(dp[len(a)][1], dp[len(a)][2]))
}

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


Measured memory_bytes: 8320
while gets
    board = $_.chomp.scan(/./)
    def board.judge ( x, y, z )
        (r=self.values_at(x,y,z).uniq).size==1 ? (r.reject{|x|x=='s'}[0]) : nil
    end
    puts (r=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].map{|x| board.judge(x[0],x[1],x[2])}.reject{|x|x==nil}.uniq[0])==nil ? 'd':r
end

Measured memory_bytes: 6104
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int N; cin >> N;
	const int base = 100000;
	int ans = base;
	
	for(int i = 0; i < N; i++)
	{
		ans += (ans * 0.05);
		
		int diff = (ans % 1000);
		if( diff != 0 )ans += (1000 - diff);
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

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

    int ans = 0;
    vector<vector<int>> v(n, vector<int>(2));
    rep(i, n){
        int x, y; cin >> x >> y;
        v.at(i).at(0) = x;
        v.at(i).at(1) = y;
    }
    rep(i, n){
        if(v.at(i).at(0) == v.at(i).at(1)){
            ans++;
            if(ans >= 3) break;
        }
        else ans = 0;
    }
    if(ans >= 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        vector<int> a(n + 1);
        for (int i = 1; i <= n; i++) cin >> a[i];

        vector<int> b(n + 1, 0);
        vector<int> ans;
        for (int i = n; i > 0; i--) {
            int cnt = 0;
            for (int j = i; j <= n; j += i) {
                cnt ^= b[j];
            }
            if (cnt != a[i]) {
                b[i] = 1;
                ans.push_back(i);
            }
        }
        cout << (int)ans.size() << endl;
        for (auto x : ans) cout << x << " ";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 3192
def main():
  a, b = input().split()
  
  from decimal import Decimal, ROUND_FLOOR
  
  a = Decimal(a)
  b = Decimal(b)
  
  c = a * b
  c = c.quantize(Decimal('1.'), rounding=ROUND_FLOOR)
  
  print(c)
  

    


if __name__ == "__main__":
  main()


Measured memory_bytes: 71208
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    if(n%k!=0){
        cout << 1 << endl;
    }else if(n%k==0){
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int stack[200];
int top;
int main(){
	char item[10];
	while(scanf("%s",item)!=EOF){
		if(isNum(item)){
			instack(string2int(item));
		}else if(isSign(item)){
			int num1 = outstack();
			int num2 = outstack();
			int rst = calculate(item,num2,num1);
			instack(rst);
		}
	}
	printf("%d\n",outstack());
	return 0;
}
void instack(int num){
	stack[top] = num;
	top++;
}
int outstack(){
	top--;
	return stack[top];
}

int isNum(char item[]){
	char c = item[0];
	if(c >= '0' && c <= '9'){
		return 1;
	}
	return 0;
}
int isSign(char item[]){
	char c = item[0];
	return c=='+' || c=='-' || c=='*';
} 
int string2int(char string[]){
	int i,rst = 0,num;
	for(i=0;string[i];i++){
		num = string[i]-'0';
		rst = rst * 10;
		rst = rst + num;
	}
	return rst;
}
int calculate(char string[],int a,int b){
	switch(string[0]){
		case '+':
			return a + b;
		case '-':
			return a - b;
		case '*':
			return a * b;
		default:
			return 0;
	}
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, A, B;
  string S, T;
  cin >> N >> A >> B;
  ll ab = A+B;
  ll ans = (N/ab)*A;
  //cout << ans << endl;
  if (N%ab>=A) ans += A;
  else ans +=N%ab;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(void){
    char s[2000000];
    int l=0,len,n=0,f;
    scanf("%s",s);
    len = strlen(s);
    for(int i=0;i<len;i++){
        if(s[i]=='O'){
            f=1;
            int j=1,m=n;
            for(;j<n;j++){
                if(s[j+i]!='O'){
                    m=j;
                    break;
                }
            }
            //printf("n=%d j=%d i=%d m=%d\n",n,j,i,m);
            i+=max(--j,0);
            for(j=1;j<=m;j++){
                if(s[j+i]!='I'){
                    f=0;
                    break;
                }
            }
            //puts("r");
            //printf("n=%d k=%d i=%d f=%d\n",n,k,i,f);
            if(f>0){
                i+=max(j-1,0);
                l=max(l,m);
            }
        }
        if(s[i]=='J'){
            n++;
        }else n=0;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 1952
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  priority_queue<int> q;
  REP(i, N){
    int a;
    cin >> a;
    q.push(a);
  }

  while(M--){
    int p = q.top();
    q.pop();
    q.push(p/2);
  }

  int ans = 0;
  while(!q.empty()){
    ans += q.top(); q.pop();
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        ArrayList<Integer> s = new ArrayList<>();
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        for (int i = 0; i < n; i++) {
            s.add(Integer.parseInt(tokenizer.nextToken()));
        }
        Collections.sort(s);
        int sum = 0;
        for (int i = 1; i < n; i++) {
            sum += s.get(i) - s.get(i-1);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	int n;
	cin>>n;
	vector<int> A;
	int a;
	int max = 0, max2 = 0;
	rep(i,n){
		cin>>a;
		A.push_back(a);
		if(max <= a){
			max2 = max;
			max = a;
		}else if(max2 <= a){
			max2 = a;
		}
	}
	if(max == max2){
		rep(i,n){
			cout<<max<<endl;
		}
		return 0;
	}
	rep(i,n){
		if(A[i] == max){
			cout<<max2<<endl;
		}else{
			cout<<max<<endl;
		}
	}
	return 0;
}


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

int main(){
  int n,A[100010];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int k,key,ans=0;
  cin>>k;
  for(int i=0;i<k;i++){
    cin>>key;
    if(*lower_bound(A,A+n,key)==key){ans++;}
  }
  
  cout <<ans<<endl;
}


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

int main(){
   
    int N,M;
    cin>>N>>M;
    int X=0,Y=200000;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        X=max(a,X);
        Y=min(b,Y);
    }
    if(X<=Y) cout<<Y-X+1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
a, b, m=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
mprice=min(a)+min(b)
for _ in range(m):
  x, y, c=map(int, input().split())
  p=a[x-1]+b[y-1]-c
  if p<mprice:
    mprice=p
print(mprice)

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

int main()
{
    int A, B, C;
    cin >> A >> B>>C;

    if(A==B&&B==C){
        cout << "1" << endl;
    }
    else if(A==B||A==C||B==C){
        cout << "2" << endl;
    }
    else
    {
        cout << "3" << endl;
    }
    
    
}

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

int k, n;
int a[500][500];
void cr(int m) {
  n = m;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      a[i][j] = (i + j) % m;
    }
  }
}

void cr2(int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i % 2 == 0) continue;
      if (a[i][j] >= m) continue;
      a[i][j] += 500;
    }
  }
}

int main() {
  cin >> k;
  if (k <= 500) {
    cr(k);
  } else {
    cr(500);
    cr2(k - 500);
  }
  
  cout << n << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cout << a[i][j] + 1 << (j == n - 1 ? '\n' : ' ');
    }
  }
}

Measured memory_bytes: 2176
function Main(inputData) {
	init(inputData);
	
	var a = inI();
	var b = inI();

	outln(((a*b)/(a+b)).toFixed(10));
	
}

////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8584
#include<stdio.h>
     
 int main() {
    int X;
    int happy = 0;
    scanf("%d", &X);

    while(X >= 5) {
       if(X >= 500) {
          happy += 1000;
          X -= 500;
       } else {
          happy += 5;
          X -= 5;
       }
    }
    printf("%d\n", happy);
    return 0;
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  int i = N % 500;
  
  if (i <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys

N=int(input())
line=input().split(" ")
dp=[]
for i in range(N):
    line[i]=int(line[i])
    dp.append(sys.maxsize)
dp[0]=0
dp[1]=abs(line[1]-line[0])
for j in range(2,N):
    dp[j]=min(dp[j], dp[j-1]+abs(line[j]-line[j-1]))
    dp[j]=min(dp[j], dp[j-2]+abs(line[j]-line[j-2]))
print(dp[N-1])

Measured memory_bytes: 11332
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    V<ll> a(n),b(m);
    V<ll> sa(n+1,0),sb(m+1,0);
    rep(i,n){
        cin>>a[i];
        sa[i+1]=sa[i]+a[i];
    }
    rep(i,m){
        cin>>b[i];
        sb[i+1]=sb[i]+b[i];
    }
    ll ans=0;
    rep(i,n+1){
        if(sa[i]>k) break;
        ll x=ub(all(sb),k-sa[i])-sb.begin();
        x--;
        if(sa[i]+sb[x]<=k)chmax(ans,i+x);
    }
    /*cinf(n,a);
    cinf(m,b);
    ll sa=0,sb=0;
    ll ans=0;
    ll cnt=0;
    while(true){
        if(sa==n&&sb==m) break;
        ll x;
        if(sa==n){
            x=b[sb];
            if(x+cnt>k) break;
            ans++;
            cnt+=b[sb];
        }else if(sb==m){
            x=b[sb];
            if(x+cnt>k) break;
            ans++;
            cnt+=b[sb];
        }else{

        }
    }*/
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 9532
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int n, m;
    if (a < b) {
        n = b;
        m = a;
    } else {
        n = a;
        m = b;
    }
    for (int i = 0; i < n; i++) {
        printf("%c", '0' + m);
    }
    return 0;
}

Measured memory_bytes: 256
#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 () {
  int n, l = 0, u = 0;
  vector<int> used(8, 0);

  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    int r = a / 400;
    if(r < 8 && !used[r]) {
      used[r] = 1;
      l++;
      u++;
    }
    if(r >= 8) u++;
  }

  if(l == 0) l = 1;

  printf("%d %d\n", l, u);
  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(input())
memo=[{} for i in range(n+1)]

def ok(last4):
    for i in range(4):
        t=list(last4)
        if i>=1:
            t[i-1],t[i]=t[i],t[i-1]
        if "".join(t).count("AGC")>=1:
            return 0
    return 1

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur==n:
        return 1
    ret=0
    for c in "ACGT":
        if ok(last3+c):
            ret=(ret+dfs(cur+1,last3[1:]+c))%mod
    memo[cur][last3]=ret
    return ret
print(dfs(0,"TTT"))

Measured memory_bytes: 48348
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int ans[n+2];
    memset(ans , 0 , sizeof(ans));
    int d,a;
    for (size_t i = 0; i < k; i++) {
        cin>>d;
        for (size_t j = 0; j < d; j++) {
            cin>>a;
            ans[a]++;
        }
    }
    int cnt = 0;
    for (size_t i = 1; i <= n; i++) {
        if(ans[i] == 0){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3656
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

class Program
{
    static void Main()
    {
        int n = ToInt32(ReadLine());
        int s = 0, t = n;
        while(t > 0)
        {
            s += t % 10;
            t /= 10;
        }
        if (n % s == 0)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


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

using namespace std;

int main() {
	int n; cin >> n;
	long long ans=0;
	for(int i=0;i<n;++i) {
		int v; cin >> v;
		ans+=v-i-1;
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
void swap(int& x, int& y){
    int tmp = x;
    x=y;
    y=tmp;
    
}
int main(){
    int a,b,c;
    cin >> a>> b>> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    
    cout << a << " " <<b<< " "<< c<<endl;
    
}



Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int N = sc.nextInt() % 500;
	    int A = sc.nextInt();
	    
	    if (N <= A) {
	    	System.out.println("Yes");
	    } else {
	    	System.out.println("No");
	    }
	}    
}	

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

int main(){
    int n;
    cin>>n;
    vector<int>t(13);
    t[0]=1;
    rep(i,n){
        int d; cin>>d;
        t[d]++;
    }
    rep(i,13){
        if(i==0||i==12){
            if(t[i]>=2){cout<<0<<endl; return 0;}
        }
        else{
            if(t[i]>=3){cout<<0<<endl; return 0;}
        }
    }
    vector<bool>solo(13,false);
    for(int i=1; i<=11; ++i){
        if(t[i]==1)solo[i]=true;
    }
    vector<int>x;
    rep(i,13){
        if(!solo[i]&&t[i]!=0){
            if(i==0||i==12){
                x.push_back(i);
            }
            else{
                x.push_back(i);
                x.push_back(24-i);
            }
        }
    }
    int ans=0;
    rep(bit,1<<13){
        vector<int>y=x;
        rep(i,13){
            if(!solo[i])continue;
            if(bit&(1<<i))y.push_back(i);
            else y.push_back(24-i);
        }
        sort(y.begin(),y.end());
        int cnt=1e9,m=y.size();
        rep(i,m-1){
            cnt=min(cnt,abs(y[i]-y[i+1]));
        }
        cnt=min(cnt,abs(y[0]+24-y[m-1]));
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
//
// Created on 2020/05/09.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = INF;
    int n;
    cin>>n;
    vector<int>s(n);
    int sum_w = 0;
    for (int i = 0; i < n; ++i) {
        int w;
        cin>>w;
        sum_w += w;
        s[i] = sum_w;
    }

    for (int j = 0; j < n; ++j) {
        int a = abs(s[j]-(s[n-1]-s[j]));
        ans = min(ans,a);
    }

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


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long K){

    vector<lli> dp(K+1,0);

    lli ten = 10;
    lli now = 7;
    lli mod = K;
    lli cnt = 1;

    while(1){
        if(now%mod == 0){
            cout<<cnt<<endl;
            return;
        }
        if(dp[now%mod]){
            cout<<-1<<endl;
            return ;
        }
        dp[now%mod]++;
        now *= 10;
        now += 7;
        now %= mod;
        cnt++;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long K;
    scanf("%lld",&K);
    func(K);
    return 0;
}


Measured memory_bytes: 11096
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
bool solve() {
	lli n = 1;
	string s;
	if ( cin >> n );
	else return false;
	
	vcL num( 6, 0 );
	
	for (int i = 0; i < 6; ++i) {
		cin >> num[i];
	}
	
	bool a = false, b = false, c = false;
	if ( num[0] < num[3] ) a = true;
	if ( num[1] < num[4] ) b = true;
	if ( num[2] < num[5] ) c = true;
	
	lli _max = 0;
	
	if ( a and b and c ) {
		for (int i = 0; i <= n/num[0]; ++i) {
			for (int j = 0; j <= (n-i*num[0])/num[1]; ++j) {
				lli k = (n-i*num[0]-j*num[1])/num[2];
				_max = max( _max, i*(num[3]-num[0]) + j*(num[4]-num[1]) + k*(num[5]-num[2]) );
			}
		}
		n += _max;
	}
	else if ( a and b ) {
		for (int i = 0; i <= n/num[0]; ++i) {
			_max = max( _max, i*(num[3]-num[0]) + (n-i*num[0])/num[1]*(num[4]-num[1]) );
		}
		n += _max;
		n += (n/num[5])*(num[2]-num[5]);
	}
	else if ( a and c ) {
		for (int i = 0; i <= n/num[0]; ++i) {
			_max = max( _max, i*(num[3]-num[0]) + (n-i*num[0])/num[2]*(num[5]-num[2]) );
		}
		n += _max;
		n += (n/num[4])*(num[1]-num[4]);
	}
	else if ( b and c ) {
		for (int i = 0; i <= n/num[1]; ++i) {
			_max = max( _max, i*(num[4]-num[1]) + (n-i*num[1])/num[2]*(num[5]-num[2]) );
		}
		n += _max;
		n += (n/num[3])*(num[0]-num[3]);
	}
	else if ( a ) {
		n += (n/num[0])*(num[3]-num[0]);
		for (int i = 0; i <= n/num[4]; ++i) {
			_max = max( _max, i*(num[1]-num[4]) + (n-i*num[4])/num[5]*(num[2]-num[5]) );
		}
		n += _max;
	}
	else if ( b ) {
		n += (n/num[1])*(num[4]-num[1]);
		for (int i = 0; i <= n/num[3]; ++i) {
			_max = max( _max, i*(num[0]-num[3]) + (n-i*num[3])/num[5]*(num[2]-num[5]) );
		}
		n += _max;
	}
	else if ( c ) {
		n += (n/num[2])*(num[5]-num[2]);
		for (int i = 0; i <= n/num[3]; ++i) {
			_max = max( _max, i*(num[0]-num[3]) + (n-i*num[3])/num[4]*(num[1]-num[4]) );
		}
		n += _max;
	}
	else {
		for (int i = 0; i <= n/num[3]; ++i) {
			for (int j = 0; j <= (n-i*num[3])/num[4]; ++j) {
				lli k = (n-i*num[3]-j*num[4])/num[5];
				_max = max( _max, i*(num[0]-num[3]) + j*(num[1]-num[4]) + k*(num[2]-num[5]) );
			}
		}
		n += _max;
	}
	cout << n << '\n';
	
	return true;
}
 
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	sc.Scan()
	i := Sliceconvtoi()
	price := i

	menu := map[int]string{
		price[0]: "A",
		price[1]: "B",
		price[2]: "C",
	}

	sort.Ints(i)

	fmt.Println(menu[i[2]])
}



Measured memory_bytes: 1144
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int K, S;
    int result = 0;
    cin >> K >> S;
    repto(x, K) {
        repto(y, K) {
            int z = S - (x + y);
            if (0 <= z && z <= K) result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL a;
    cin >> a;
    cout << (a+(a*a)+(a*a*a)) << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

#define DEBUG 0
#define A3 0x001
#define A5 0x002
#define A7 0x004
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

void func(set<lli> *s,lli flag,lli num,lli cnt){
	if(flag == (A3|A5|A7)){
		if(DEBUG)cout<<flag<<endl;
		s->insert(num);
	}
	if(cnt>12)return;

	lli nextNum = num*=10;
	func(s,flag|A3,nextNum+3,cnt+1);
	func(s,flag|A5,nextNum+5,cnt+1);
	func(s,flag|A7,nextNum+7,cnt+1);
}

int main(){

	lli n;
	lli flag=0;
	cin>>n;

	set<lli> s;
	func(&s,flag,0,0);

	lli cnt=0;
	for(auto itr : s){
		if(itr>n)break;
		cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  
  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  vector<int> dA(N - 1);
  
  for (int i = 0; i < N - 1; i++) {
    dA.at(i) = A.at(i + 1) - A.at(i);
  }
  
  sort(dA.begin(), dA.end());
    
cout << K - max((K - A.at(N - 1) + A.at(0)), dA.at(N - 2)) << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

int main(){
    ll n;
    cin >> n;
    vl ue,shita;
    rep(i,n){
        ll a,b;
        cin >> a >>b;
        shita.pb(a);
        ue.pb(b);
    }
    isort(ue);
    isort(shita);
    if(n%2==0){
        ll m=ue[n/2-1]+ue[n/2];
        ll mi=shita[n/2-1]+shita[n/2];
        kaku(m-mi+1);
    }
    else{
        ll m=ue[n/2];
        ll mi=shita[n/2];
        kaku(m-mi+1);
    }
}

Measured memory_bytes: 6644