akhauriyash/Code-Regression huggingface dataset:
l = list(input())
ans = []
ans.append(0)
count = 0
for i in range(len(l)):
  if l[i] == "A" or  l[i] == "G" or  l[i] == "T" or  l[i] == "C":
    count += 1
  else:
    ans.append(count)
    count = 0
    
ans.append(count)
print(max(ans))
  


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

string FMT_F = "%.10f";

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

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

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	long[string] to;
	to["Vacant"] = 0;
	to["Male"] = 1;
	to["Female"] = 2;

	writeln(0);
	stdout.flush();
	auto state = to[RD!string];
	if (state == 0) return;

	long pos;
	int ok, ng;
	ok = 0; ng = cast(int)N+1;
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng) / 2;
		auto eo = (mid - pos) % 2;
		writeln(mid);
		stdout.flush();
		auto state2 = to[RD!string];
		if (state2 == 0)
			return;

		bool same;
		if (eo == 0)
			same = state == state2;
		else
			same = state != state2;
		if (same)
		{
			pos = mid;
			state = state2;
			ok = mid;
		}
		else
			ng = mid;
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 852
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    minp = P[0]
    cnt = 1
    for i in range(1, N):
        if P[i]<minp:
            minp = P[i]
            cnt += 1
    print(cnt)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


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

int main(){
  int a,b,i;
  int count=0;
  cin>>a>>b;
  
  int retsu[100000];
  for(i=0;i<a;i++){
    retsu[i]=0;
    cin>>retsu[i];
    if(retsu[i]>=b){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 640
A = []
B = []
for i in range(5):
    x = int(input())
    if x % 10 == 0:
        a = x
    else:
        a = (x // 10 + 1) * 10
    A.append(a)
    
    b = a - x
    B.append(b)
    
print(sum(A) - max(B))

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll euclidean_gcd(ll a, ll b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    ll r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

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

    ll K;
    cin >> K;

    ll sum = 0;
    ll tmp = 0;

    //cout << euclidean_gcd(2, 4) << endl;
    

    for (ll i = 1; i <= K; i++) {
        for (ll j = 1; j <= K; j++) {
            for (ll k = 1; k <= K; k++) {
                
                tmp = euclidean_gcd(euclidean_gcd(i, j), k);
                sum += tmp;
            }
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int k;
    scanf("%d",&k);
    char s[100];
    scanf("%s",s);
    
    int size = strlen(s);
    if(k>=size){
    printf("%s",s);
    }
    else{
    s[k]='\0';
    printf("%s...",s);  
    }
    return 0;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

long long int gcd( long long int a, long long int b ) {

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

}

int main() {

    long long int a, b;
    cin >> a >> b;

    cout << a / gcd( a, b ) * b << endl;

    return 0;

}


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


typedef pair<ll,ll> pll;


ll l, r;
int main()
{
        cin >> l >> r;
        if(r - l >= 4000){
                cout << "0\n"; return 0;
        }
        ll ans = 2018;
        for(ll i=l;i<=r;i++){
                for(ll j=i+1;j<=r;j++){
                        ans = min(ans , (i*j)%2019);
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

s = sys.stdin.readline().rstrip()
t = sys.stdin.readline().rstrip()
n = len(s)

ret = 0
for i in range(n):
    if s[i] != t[i]:
        ret += 1

print(ret)


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

int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double hc = 30 * h + 0.5 * m;
    long double mc = (m*6.0);
    long double angle = min(abs(hc - mc), 360 - abs(hc - mc));
    long double length = sqrt(a * a + b * b - 2 * a * b * cos(angle * M_PI/180));
    printf("%.10Lf\n", length);
    return 0;
}   

Measured memory_bytes: 4168
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long n = sc.nextLong();
		long k = sc.nextLong();
		if (k == 0) {
			System.out.println(n * n);
			return;
		}
		long ans = 0;
		for (long b = k + 1; b <= n; b++) {
			ans += (b - k) * (n / b) + Math.max(n % b - k + 1, 0);
		}
		System.out.println(ans);
	}
}

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


Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long
#define pb push_back
#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>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
ll mod = 1000000007;
int c[1000005];

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

    for(int i = 1; i < 1000005; ++i){
        for(int j = 1; j <= 1000005/i; j++){
            c[i*j]++;
        }
    }

    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; ++i){
        ans +=  (c[n-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7540
#include <stdio.h>
typedef long long int64;
int A = 0, G = 1, C = 2, T = 3;
int main(int argc, const char *argv[])
{
  int n, MOD = 1000000007;
  scanf("%d", &n);
  int64 dp[n+1][4][4][4];
  for (int j = 0; j < 4; j++) {
    for (int k = 0; k < 4; k++) {
      for (int l = 0; l < 4; l++) {
        dp[3][j][k][l] = 0;
        if ( j == A && k == C && l == G ) continue;
        if ( j == A && k == G && l == C ) continue;
        if ( j == G && k == A && l == C ) continue;
        dp[3][j][k][l] = 1;
      }
    }
  }

  for (int i = 4; i <= n; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          dp[i][j][k][l] = 0;
          if ( j == A && k == C && l == G ) continue;
          if ( j == A && k == G && l == C ) continue;
          if ( j == G && k == A && l == C ) continue;
          for (int m = 0; m < 4; m++) {
            // AG?C
            if ( m == A && j == G && l == C ) continue;
            // A?GC
            if ( m == A && k == G && l == C ) continue;
            dp[i][j][k][l] += dp[i-1][m][j][k] % MOD;
          }
        }
      }
    }
  }

  int64 sum = 0;
  for (int j = 0; j < 4; j++) {
    for (int k = 0; k < 4; k++) {
      for (int l = 0; l < 4; l++) {
        sum += dp[n][j][k][l];
      }
    }
  }
  printf("%lld\n", sum % MOD);
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
inf = 10**10
G = [{} for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    G[l-1][r-1] = d
    G[r-1][l-1] = -d
V = [False for i in range(n)]
D = [inf for i in range(n)]
for i in range(n):
    if V[i]:
        continue
    Q = [i]
    D[i] = 0
    while Q:
        j = Q.pop()
        V[j] = True
        for k in G[j].keys():
            if not V[k]:
                Q.append(k)
            if D[k] == inf:
                D[k] = D[j]+G[j][k]
            elif D[k] != D[j]+G[j][k]:
                print('No')
                exit()
print('Yes')


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int n,t; 
vector<P<int,int>>v;

int Rec(int i,int j){
  static int mem[3000][3000];
  static bool used[3000][3000];
  if(j >= t)return 0;
  if(i == n)return 0;
  if(used[i][j])return mem[i][j];
  used[i][j] = true;
  mem[i][j] = max(Rec(i+1,j+v[i].first)+v[i].second,Rec(i+1,j));
  return mem[i][j];
}

int main(){
  cin >> n >> t;
  v = move(vector<P<int,int>>(n));
  for(int i = 0; i < n; ++i)cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  cout << Rec(0,0) << endl;
}


Measured memory_bytes: 46948
def allz(arr)
    arr = arr.uniq
    arr.length == 1 and arr[0] == 0
end

# find_allのindex版
# https://qiita.com/pocari/items/0b4e632ef2a2b6a97ba9
def zidx(arr)
    arr.map.with_index { |e,i| e == 0 ? i : nil }.compact
end

def sub1(arr, s, g)
    #print "#{s} #{g}\n"
    arr[s..g] = arr[s..g].map {|x| x > 0 ? x-1 : 0}
    arr
end

def cc
    n = gets.chomp.to_i
    hh = [0] + gets.chomp.split(/\s/).map{|x| x.to_i} + [0]

    cnt = 0
    until allz(hh)
        idz = zidx(hh)
        if idz.length == 2
            hh = sub1(hh, 0, hh.length-1)
            #p hh
            cnt += 1
        else
            # 0 2 4 6
            # 1..1, 3..3, 5..5
            for i in 0..(idz.length-2)
                next if idz[i]+1 > idz[i+1]-1
                hh = sub1(hh, idz[i]+1, idz[i+1]-1)
                #p hh
                cnt += 1
                if allz(hh)
                    break
                end
            end
        end
    end

    puts cnt
end

cc

Measured memory_bytes: 2300
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var nm = ReadSplitInt();
            Println((nm[0] - 1) * (nm[1] - 1));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 11348
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let input: String = read().unwrap();
    let september = input.chars().filter(|&c| c == '9').collect::<Vec<char>>();
    if september.is_empty() {
        println!("No")
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
	



int main(){
   IOS

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

	vector<ll> v;
	v.pb(0); v.pb(0);
	for(int i = 1; i <= n; i++){
		v.pb(v.back() + i);
	}

	ll ans = 0;
	for(int r = k; r <= n+1; r++){
		ll lo = v[r] - v[0];
		ll hi = v[n + 1] - v[n + 1 - r];
		//cout<<lo<<" "<<hi<<"\n";
		ans += (hi - lo + 1 + mod)%mod;
		if(ans >= mod)ans -= mod;
	}

	cout<<ans<<"\n";







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
	if(b&1)
		res = res * a % mod;
		a = a * a % mod;
	b >>= 1;
	}

	return res;
}



Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	double pi=3.14159265358979323846;
	double a,b,x;
	cin>>a>>b>>x;
	double h=x/(a*a);
	double remh=b-h;
	double base=x/(.5*b*a);
	double ans;
	if(remh<=b/2)
	ans=atan(remh/(a/2.0))*180/pi;
	else
	 ans=atan(b/(base))*180/pi;
	cout<<setprecision(10)<<ans;
}

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

using namespace std;
int main(int argc, char *argv[]) {
	long n;
	cin >> n;
	
	long ans = LONG_MAX;
	for (long a = 1; a <= floor(sqrt(n)); a++) {
		if (n % a == 0) {
			long b = n / a;
			ans = min(ans, a+b-2);
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
        char string[1000];
        int operation_number = 0;
        char operation[10];
        char p[1000];
        char tmp;
        int a = 0, b = 0, i = 0;

        scanf("%s", string);
        scanf("%d", &operation_number);

        while ( operation_number > 0 )
        {
                scanf("%s %d %d", operation, &a, &b);
                if ( strcmp( operation, "replace" ) == 0 )
                {
                        scanf("%s", p);
                }

                if ( strcmp( operation, "print" ) == 0 )
                {
                        while ( a <= b )
                        {
                                printf("%c", string[a]);
                                if ( a == b )
                                        printf("\n");
                                a = a + 1;
                        }
                }
                else if ( strcmp( operation, "reverse" ) == 0 )
                {
                        while ( a <= b )
                        {
                                tmp = string[b];
                                string[b] = string[a];
                                string[a] = tmp;
                                b = b - 1;
                                a = a + 1;
                        }
                }
                else if ( strcmp( operation, "replace" ) == 0 )
                {
                        i = 0;
                        while ( a <= b )
                        {
                                string[a] = p[i];
                                a = a + 1;
                                i = i + 1;
                        }
                }
                operation_number = operation_number - 1;
        }

        return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    if(A%3 == 0){
        cout << "Possible" << endl;
        return 0;
    }
    if(B%3 == 0){
        cout << "Possible" << endl;
        return 0;
    }
    if((A+B)%3 == 0){
        cout << "Possible" << endl;
        return 0;
    }
    cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> a(1);
    vector<int> b(1);
    for (int i = 0; i < n; i++) {
        if (i == 0 || s[i] == s[i - 1]) {
            b.back()++;
        } else {
            b.emplace_back(1);
        }
    }
    if (s[0] == '0') {
        b.erase(b.begin());
    }
    if (!b.empty() && s[n - 1] == '0') {
        b.pop_back();
    }
    if (b.empty()) {
        cout << 0 << '\n';
        return 0;
    }
    for (int i = 0; i < b.size(); i += 2) {
        if (i != 0 && b[i - 1] != 1) {
            a.emplace_back();
        }
        a.back().emplace_back(b[i]);
    }
    int ans = 0;
    for (auto v : a) {
        int m = v.size();
        if (m == 1) {
            continue;
        }
        vector<int> dp(3);
        dp[2] = v[0];
        for (int i = 1; i < m; i++) {
            vector<int> ndp(3);
            ndp[2] = max({dp[0], dp[1], dp[2] - 1}) + v[i];
            ndp[0] = dp[0] + v[i] - 1;
            ndp[1] = dp[0] + v[i];
            ndp[0] = max(ndp[0], dp[1]);
            if (v[i] != 1) {
                ndp[0] = max(ndp[0], dp[2]);
            }
            ndp[1] = max(ndp[0], ndp[1]);
            ndp[1] = max(ndp[1], dp[2]);
            swap(dp, ndp);
        }
        ans += max(dp[0], dp[1]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
ll n, p; 
string s;
void solve2(){
	ll ans = 0;
	for (ll i = 0; i < n; i++){
		if ((s[i] - '0') % 2 == 0) ans += (i + 1);
	}
	cout << ans << endl;
}
void solve5(){
	ll ans = 0;
	for (ll i = 0; i < n; i++){
		if ((s[i] - '0') % 5 == 0) ans += (i + 1);
	}
	cout << ans << endl;
}
ll suffix[200005];
ll occ[200005];
int main(){
	cin >> n >> p >> s;
	if (p == 2) solve2();
	else if (p == 5) solve5();
	else{
		suffix[0] = 0;
		ll cur = 10;
		for (ll i = 1; i <= s.length(); i++){
			suffix[i] = (suffix[i - 1] + (s[n - i] - '0') * cur) % p;
			cur = (cur * 10) % p;
		}
		for (ll i = 0; i <= s.length(); i++) occ[suffix[i]]++;
		ll ans = 0;
		for (ll i = 0; i < p; i++) ans += (occ[i] * (occ[i] - 1) / 2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
   int i,s=0;
   for(i=1;i<=b/c;i++)
   {
   	  if(c*i>=a&&c*i<=b)
   	  {
   	  	s++;
		 }
   }
   printf("%d",s);
   return 0;
   }

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define int long long
const int N=110;
int n,a[N];
namespace isap{
    const int N=110,M=5000;
    int tot=1,fi[N],ne[M],a[M],c[M];
    inline void add(int x,int y,int z){
        a[++tot]=y;c[tot]=z;ne[tot]=fi[x];fi[x]=tot;
        a[++tot]=x;c[tot]=0;ne[tot]=fi[y];fi[y]=tot;
    }
    int n,s,t,gap[N],cur[N],h[N];
    inline int dfs(int x,int f){
        if (x==t) return f;
        int rst=0;
        for (int &i=cur[x];i;i=ne[i]) if (c[i]&&h[x]==h[a[i]]+1){
            int temp=dfs(a[i],min(f,c[i]));
            c[i]-=temp;c[i^1]+=temp;f-=temp;rst+=temp;
            if (!f) return rst;
        }
        if (--gap[h[x]]==0) h[s]=n+1;
        ++gap[++h[x]];cur[x]=fi[x];
        return rst;
    } 
    inline int maxflow(int _n,int _s,int _t){
        n=_n;s=_s;t=_t;
        memcpy(cur,fi,sizeof fi);gap[0]=n;
        int mf=0;
        while (h[s]<=n) mf+=dfs(s,1e9);
        return mf;
    }
}
signed main(){
	scanf("%lld",&n);
	int s=n+1,t=n+2,ans=0;
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]),ans+=max(a[i],0ll);
	for (int i=1;i<=n;++i) if (a[i]<0){
		isap::add(s,i,-a[i]);
		for (int j=2*i;j<=n;j+=i) if (a[j]>0) isap::add(i,j,1e9);
	}else if (a[i]>0) isap::add(i,t,a[i]);
	printf("%lld",ans-isap::maxflow(n+2,s,t));
	return 0;
}

Measured memory_bytes: 384
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev, *next;
};
 
struct Node *nil;
 
void init() {
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}
 
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
 
struct Node* listSearch(int key) {
    struct Node *cur = nil->next;
    while(cur != nil && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}
 
void deleteNode(struct Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
 
void deleteFirst() {
    deleteNode(nil->next);
}
 
void deleteLast() {
    deleteNode(nil->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}
 
void printList() {
    struct Node *cur;
    cur = nil->next;
    int isf = 0;
 
    while(1) {
        if (cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
 
 
int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d",com, &key);
        if(com[0] == 'i') {
            insert(key);
            np ++;
            size++;
        }else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if( com[6] == 'F') {
                    deleteFirst();
                }else if(com[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
                nd ++;
            }
            size --;
        }
    }
    printList();
    return 0;
 
}

Measured memory_bytes: 32964
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<utility>
#include<set>
using namespace std;

vector<long int>r;
vector<long int>a;
vector<long int>b;
vector<long int>size;
vector<long int>ans;

long int n,m;

long int root(long int x){
  if(r.at(x)==x)return x;
  else{
    long int p=root(r.at(x));
    r.at(x)=p;
    return p;
  }
}

long int getsize(long int x){
  return size.at(root(x));
}

void conect(long int x, long int y){
  long int p=root(x);
  long int q=root(y);
  if(p==q)return;
  size.at(q)+=size.at(p);
  r.at(p)=q;
  size.at(p)=0;
  return;
}

bool notsame(long int x,long int y){
  if(root(x)!=root(y))return true;
  else return false;
}

int main(void){
  int i;
  cin >> n >> m;
  r=vector<long int>(n);
  a=vector<long int>(m);
  b=vector<long int>(m);
  size=vector<long int>(n,1);
  ans=vector<long int>(m+1,0);
  ans.at(m)=n*(n-1)/2;
  for(i=0;i<m;i++)cin >> a.at(i) >> b.at(i);
  for(i=0;i<n;i++)r.at(i)=i;
  for(i=m-1;i>-1;i--){
    if(notsame(a.at(i)-1,b.at(i)-1)){
      ans.at(i)=ans.at(i+1)-getsize(a.at(i)-1)*getsize(b.at(i)-1);
      conect(a.at(i)-1,b.at(i)-1);
    }else{
      ans.at(i)=ans.at(i+1);
    }
  }
  for(i=1;i<=m;i++)cout << ans.at(i) << endl;
}

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

int main()
{
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>



using namespace std;

pair<int,int> stu[100];
pair<int, int> check[100];

int man(int x1, int x2, int y1, int y2){
	return abs(x1-y1) + abs(x2-y2); 
}

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	for(int i=1; i<=N; i++){
		scanf("%d %d", &stu[i].first, &stu[i].second);
	}
	for(int i=1; i<=M; i++){
		scanf("%d %d", &check[i].first, &check[i].second);
	}
	for(int i = 1; i<=N; i++){
		int ind = 1;
		for(int j=2; j<=M; j++){
			if(man(stu[i].first, stu[i].second, check[j].first, check[j].second) < 
				man(stu[i].first, stu[i].second, check[ind].first, check[ind].second) ){
				ind = j;
			}
		}
		printf("%d\n", ind);
	}
	
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
string s;
 
int main() {
	cin >> s;
 
    if(s.size()>3 and s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    int N, cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
    string S;
    cin >> N;
    rep(i, N) {
        cin >> S;
        if (S == "AC") {
            cnt++;
        } else if (S == "WA") {
            cnt2++;
        } else if (S == "TLE") {
            cnt3++;
        } else if (S == "RE") {
            cnt4++;
        }
    }

    cout << "AC x " << cnt << endl;
    cout << "WA x " << cnt2 << endl;
    cout << "TLE x " << cnt3 << endl;
    cout << "RE x " << cnt4 << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,two,five;
int main()
{
	scanf("%lld",&n);
	if(n&1)puts("0");
	else 
	{
		n/=2;two=n;
		for(ll x=n;x>0;x/=2)
		two+=x/2;
		for(ll x=n;x>0;x/=5)
		five+=x/5;
		printf("%lld\n",min(two,five));
	}
	return 0;
} 

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a, b, c, d] <- readIntegers
  print $ solve a b c d

solve :: Integer -> Integer -> Integer -> Integer -> Integer
solve a b c d = b - a + 1 - (b `div` c + b `div` d - (a - 1) `div` c - (a - 1) `div` d - b `div` (lcm c d) + (a - 1) `div` (lcm c d))
-- 4 9 2 3
-- 6 - (4 + 3 - 1 - (2 + 1 + 0))

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

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

  ll N;
  char x[256];
  int ac,wa,tle,re = 0;

int main(){
  cin >> N;
  rep (i,N){
    cin >> x;
    if(strcmp(x,"AC")==0){
      ac += 1;
    }else if(strcmp(x,"WA")==0){
      wa += 1;
    }else if(strcmp(x,"TLE")==0){
      tle += 1;
    }else{
      re += 1;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

}


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

int G[110][110];
int n;
int u, k, v;

void Hyoji(int N) {
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      printf("%d", G[i][j]);
      if (j < N-1) {
	printf(" ");
      }
    }
      printf("\n");
  }
}

int main() {
  fill(&G[0][0], &G[0][0]+110*110, 0);
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d%d", &u, &k);
    u--;
    for (int j=0; j<k; j++) {
      scanf("%d", &v);
      v--;
      G[u][v] = 1;
    }
  }
  Hyoji(n);
}

Measured memory_bytes: 1236
import java.util.Arrays;
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();
		int K = sc.nextInt();
		Integer[] count = new Integer[N];
		for (int i = 0; i < count.length; i++)
			count[i] = 0;
		for (int i = 0; i < count.length; i++) {
			count[sc.nextInt() - 1]++;
		}
		Arrays.sort(count);
		int ans = 0;
		if (N - K > 0) {
			for (int i = 0; i < N - K; i++) {
				ans += count[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 81060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=200010;
ll fact[N+5];
int m=1e9+7;
void pre_calc()
{
    fact[0]=1;
    for(int i=1;i<=N;i++)
        fact[i]=(fact[i-1]*i)%m;
}
ll power(ll a,ll b)     ///calculate a^b%m
{
    ll res=1;
    ll y=a;
    while(b>0)
    {
        if(b%2==1)
            res=(res*y)%m;
        y=(y*y)%m;
        b/=2;
    }
    return res;
}
///(1/a)%m=a^(m-2)%m

ll mmi(ll n)
{
    return power(n,m-2);
}

ll ncr(ll n,ll r)
{
    r=max(r,n-r);
    ll res=1;
    for(ll i=r+1;i<=n;i++)
        res=(res*i)%m;
//    cout<<"res = "<<res<<endl;
    res=(res*mmi(fact[n-r]));
    return res;
}
int main()
{
    IOS;
    pre_calc();

//    cout<<ncr(100000000,2)<<endl;
    ll n,a,b;cin>>n>>a>>b;

    ll res=(power(2,n)-ncr(n,a)-ncr(n,b)-1)%m;
    if(res<0)res+=m;
    cout<<res<<endl;
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
char s[55][55];
int h,w;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    bool flag=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int c=s[i][j];
            if(c=='#'){
                if(i==0&&j==0&&s[i+1][j]=='.'&&s[i][j+1]=='.'){
                    flag=false;
                    break;
                }
                if(i==0&&j!=0&&s[i+1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.'){
                    flag=false;
                    break;
                }
                if(i!=0&&j==0&&s[i+1][j]=='.'&&s[i][j+1]=='.'&&s[i-1][j]=='.'){
                    flag=false;
                    break;
                }
                if(i!=0&&j!=0&&s[i+1][j]=='.'&&s[i][j+1]=='.'&&s[i][j-1]=='.'&&s[i-1][j]=='.'){
                    flag=false;
                    break;
                }
            }

        }
        if(!flag)break;
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

long long F[60][2601],n,K,a[210];
long long ans,tmp[60][2601];
int main()
{
	scanf("%lld%lld",&n,&K);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]); F[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		memset(tmp,0,sizeof tmp);
		for(int j=0;j<i;j++)
			for(int k=0;k<=2501;k++)
			{		
				tmp[j+1][k+a[i]]+=F[j][k];
				tmp[j][k]+=F[j][k];
			}
		for(int j=0;j<=i;j++)
			for(int k=0;k<=2501;k++) 
				F[j][k]=tmp[j][k];
	}
	for(int i=1;i<=n;i++) if(i*K<=2500) ans+=F[i][i*K];
	cout << ans << endl; return 0;
}

Measured memory_bytes: 2560
def solve():
    N, M = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]
    c = 0
    for i in range(N):
        for j in range(i+1, N):
            tmp = 0
            for k in range(M):
                tmp += (A[i][k] - A[j][k]) ** 2
            if tmp % (tmp ** 0.5) == 0:
                c += 1
    return c

print(solve())

Measured memory_bytes: 3188
// agrawal117
//chahat agarwal
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll d;
    cin>>d;
    ll val=(2*d)+1;
    ll ans=n/val;
    if(n%val!=0) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back


#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64_t
#endif

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int b[MAXN];
vector <int> v[MAXN];

int dp[229];
int n;

bool check(ll mask) {
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 50; j++) {
			dp[j] = 0;
		}	
		dp[a[i]] = 1;
		for (int j = 50; j > 0; j--) {
			if (((mask >> j) & 1) == 0) continue;
			for (int k = 50; k >= 0; k--) {
				dp[k % j] |= dp[k];
			}
		}
		if (!dp[b[i]]) {
			return false;		
		}
	}
	return true;
}

 main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    n = readInt();
    for (int i = 1; i <= n; i++) {
		a[i] = readInt();
    }
    for (int i = 1; i <= n; i++) {
    	b[i] = readInt();
    }
    ll mask = (1ll << 51) - 2;
	if (!check(mask)) {
		cout << -1;
		return 0;
	}
	for (int i = 50; i >= 1; i--) {
		mask ^= (1ll << i);
		if (!check(mask)) {
			mask ^= (1ll << i);
		}
	}
	cout << mask;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long m;
  vector<long long> a(n);
  cin >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long lcm = 1;
  const long long MAX = (long long) 1e9 + 10;
  for (int i = 0; i < n; i++) {
    if (i) {
      if (__builtin_ctz(a[i]) != __builtin_ctz(a[i - 1])) {
        cout << 0 << '\n';
        return 0;
      }
    }
    long long x = __gcd(lcm, a[i] / 2);
    lcm *= a[i] / 2;
    lcm /= x;
    if (lcm > MAX) {
      cout << 0 << '\n';
      return 0;
    }
  }
  //cerr << lcm << '\n';
  int ans = 0;
  if (lcm <= m) {
    ++ans;
  }
  int lcm2 = lcm * 2;
  cout << ans + max((long long) 0, (m - lcm) / lcm2) << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans;
	cin>>a>>b;
	int s[53][2];
	for(int i=0;i<b;i++)
	for(int j=0;j<2;j++)
	cin>>s[i][j];
	for(int i=0;i<a;i++)
	{
		ans=0;
		for(int j=0;j<b;j++)
		if(s[j][0]==i+1||s[j][1]==i+1)
		ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long

using namespace std;

const int N = 2*1e5;

int n, a[N], b[N], c[N], dp[10][N];
// 0 - ab, 1 - ac, 2 - bc, 3 - ba, 4 - ca, 5 - cb

int32_t main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;

    for (int i = 0; i < n; ++ i)
        cin >> a[i] >> b[i] >> c[i];

    if (n == 1) {
        cout << max(a[0], max(b[0], c[0])) << endl;
        return 0;
    }

    dp[0][1] = a[0] + b[1];
    dp[1][1] = a[0] + c[1];
    dp[2][1] = b[0] + c[1];
    dp[3][1] = b[0] + a[1];
    dp[4][1] = c[0] + a[1];
    dp[5][1] = c[0] + b[1];

    dp[0][2] = a[1] + b[2] + max(b[0], c[0]);
    dp[1][2] = a[1] + c[2] + max(b[0], c[0]);
    dp[2][2] = b[1] + c[2] + max(a[0], c[0]);
    dp[3][2] = b[1] + a[2] + max(a[0], c[0]);
    dp[4][2] = c[1] + a[2] + max(a[0], b[0]);
    dp[5][2] = c[1] + b[2] + max(a[0], b[0]);

    for (int i = 3; i < n; ++ i) {
        dp[0][i] = a[i-1] + b[i] + max(dp[0][i-2], max(dp[1][i-2], max(dp[2][i-2], dp[5][i-2])));
        dp[1][i] = a[i-1] + c[i] + max(dp[0][i-2], max(dp[1][i-2], max(dp[2][i-2], dp[5][i-2])));
        dp[2][i] = b[i-1] + c[i] + max(dp[3][i-2], max(dp[1][i-2], max(dp[2][i-2], dp[4][i-2])));
        dp[3][i] = b[i-1] + a[i] + max(dp[3][i-2], max(dp[1][i-2], max(dp[2][i-2], dp[4][i-2])));
        dp[4][i] = c[i-1] + a[i] + max(dp[0][i-2], max(dp[3][i-2], max(dp[4][i-2], dp[5][i-2])));
        dp[5][i] = c[i-1] + b[i] + max(dp[0][i-2], max(dp[3][i-2], max(dp[4][i-2], dp[5][i-2])));
    }

    int ans = 0;
    for (int i = 0; i < 6; ++ i)
        ans = max(ans, dp[i][n-1]);
    cout << ans << endl;

    return 0;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i, N) { cin >> w[i] >> v[i]; }

  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  for (int i = N - 1; i >= 0; i--) {
    for (int j = W; j >= 0; j--) {
      if ((j - w[i]) >= 0)
        dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]);
      else
        dp[i][j] = dp[i + 1][j];
    }
  }
  cout << dp[0][W] << endl;
  return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int main()
{
	long long n;
	cin>>n;
	cout<<2*n/gcd(2,n);
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().rstrip().split())
s = input()
li1 = []
li2 = []
A = []
if n == 1:
    ans = 1
else:
    for i in range(n - 1):
        if s[i] == "0" and s[i + 1] == "1":
            li1.append(i)
        elif s[i] == "1" and s[i + 1] == "0":
            li2.append(i)
    if s[n - 1] == "0":
        li1.append(n - 1)
    if len(li1) <= k:
        ans = n
    else:
        if s[0] == "1":
            for j in range(len(li1) - k + 1):
                if j == 0:
                    A.append(li2[k] + 1)
                elif j == len(li1) - k:
                    A.append(n - li1[j - 1] - 1)
                else:
                    A.append(li2[k + j] - li1[j - 1])
        else:
            for j in range(len(li1) - k + 1):
                if j == 0:
                    A.append(li2[k - 1] + 1)
                elif j == len(li1) - k:
                    A.append(n - li1[j - 1] - 1)
                else:
                    A.append(li2[k + j - 1] - li1[j - 1])
        ans = max(A)
print(ans)

Measured memory_bytes: 8796