akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// 方針:
// ユークリッドの互除法的な何かで攻める。
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t N, X;
    cin >> N >> X;
    int64_t a = min(X, N - X), b = max(X, N - X);
    int64_t ans = N;
    int64_t c;
    while (a) {
        c = a;
        ans += (b / a) * 2 * a;
        if(b % a == 0) ans -= a;
        a = b % a;
        b = c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void)
{
    int x, y, z;
    std::cin >> x;
    std::cin >> y;    
    std::cin >> z;
    if (x < y && y < z) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#!/usr/bin/env python3
#ABC97 D

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def union(x,y):
    x = root(x)
    y = root(y)

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
n,m = LI()
p = LI()
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for _ in range(m):
    x,y = LI()
    if root(x-1) != root(y-1):
        union(x-1,y-1)

ans = 0
for i in range(n):
    if root(p[i]-1) == root(i):
        ans += 1
print(ans)


Measured memory_bytes: 92300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

string inf = "-";

void chmax(string &a, string b){
    if(a == inf){
        a = b;
    } else if(a.size() < b.size()){
        a = b;
    } else if(a.size() == b.size()){
        if(a < b) a = b;
    }
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> a(M);
    for(int i=0; i<M; i++) cin >> a[i];

    vector<int> match{0,2,5,5,4,5,6,3,7,6};
    vector<string> dp(N+100, inf);
    dp[0] = "";

    for(int i=0; i<N; i++){
        if(dp[i]==inf) continue;
        for(int j=0; j<M; j++){
            chmax(dp[i+match[a[j]]], dp[i]+(char)(a[j]+'0'));
        }
    }

    cout << dp[N] << endl;

}

Measured memory_bytes: 43776
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int tag,num;
}nd[200010];
vector<int>ed[200010];
int a,b,n,q,p,v;
inline void pushdown(int bas,int pre)
{
	int tgt;
	for(int i=0;i<ed[bas].size();i++)
	{
		tgt=ed[bas][i];
		if(tgt==pre)
			continue;
		nd[tgt].num+=nd[bas].tag;
		nd[tgt].tag+=nd[bas].tag;
		pushdown(tgt,bas);
	}
	nd[bas].tag=0;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>q;
	for(int i=1;i<n;i++)
	{
		cin>>a>>b;
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	for(int i=1;i<=q;i++)
	{
		cin>>p>>v;
		nd[p].tag+=v;
		nd[p].num+=v;
	}
	pushdown(1,0);
	for(int i=1;i<=n;i++)
		cout<<nd[i].num<<' ';
	return 0;
}

Measured memory_bytes: 22528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[55][2555];
int main()
{
	int n,a;
	cin>>n>>a;
	int ar[n+1];
	for(int i=1;i<=n;i++)cin>>ar[i];
	dp[0][0]=1;
	ll t=0;
	for(int i=1;i<=n;i++)
	{
		for(int i2=i-1;i2>=0;i2--)
		{
			for(int j=t;j>=0;j--)
			{
				dp[i2+1][j+ar[i]]+=dp[i2][j];
			}
		}
		t+=ar[i];
	}
	ll res=0LL;
	for(int i=1;i<=n;i++)
	{
		res+=dp[i][i*a];
	}
	cout<<res;

}

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


def solve(s: str):
    N = len(s)
    
    for i in range(N-1):
        if(s[i] == s[i+1]):
            print(i+1, i+2)
            exit()
        else:
            if(i < N-2 and s[i] == s[i+2]):
                print(i+1, i+3)
                exit()
    
    print(-1,-1)

    return


# 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()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 fact_memo[3000001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}
i64 fact_inv(i64 x) {
  return inv(fact(x));
}
i64 perm(i64 a, i64 b) {
  return fact(a) * fact_inv(a - b) % mod;
}
i64 conb(i64 a, i64 b) {
  return fact(a) * fact_inv(b) % mod * fact_inv(a - b) % mod;
}



i64 x, y;
int main() {
  fact_memo[0] = 1;
  for (i64 i = 1; i <= 3000000; ++i) {
    fact_memo[i] = i * fact_memo[i - 1] % mod;
  }
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  i64 a = (x + y) / 3, b = x - a;
  i64 ans = 0;
  if (0 <= b && b <= a) ans = conb(a, b);

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

Measured memory_bytes: 23680
/** Bismillahir Rahmanir Rahim **/
    #include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define endl '\n'
    #define fi first
    #define se second
    #define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define debug(x) cerr << #x << " "<< x << endl
     
    int main()
    {
        ll n, sum = 0;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 and i % 5 != 0) sum += i;
        }
        cout << sum << endl;
     
        return 0;
    }

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007;
LL f(LL a, LL b) {
	if (a%b == 0) return b*(2 * (a / b) - 1);
	return f(b, a%b) + 2 * b*(a / b);
}
int main() {
	LL N, X;
	cin >> N >> X;
	LL a = X, b = N - X;
	if (a > b) swap(a, b);
	cout << N + f(a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int D,dp[90005];
struct node
{
	int x,y;
}a[100000];
int magic(node n,node m)
{
	return abs(n.x-m.x)+abs(n.y-m.y);
}
long long int func(int q)
{
  if(dp[q]!=-1)return dp[q];
  if(q<=D) return dp[q]=0;
  else return dp[q]=func(q-D)+magic(a[q-D],a[q]);	
}
int main()
{
	int H,W,Q,l,r;
	memset(dp,-1,sizeof(dp));
	scanf("%d%d%d",&H,&W,&D);
	for(int i=1;i<=H;++i)
	{
		for(int j=1;j<=W;++j)
		{
			int t;
			scanf("%d",&t);
			a[t].x=i;
			a[t].y=j;
		}
	} 
	scanf("%d",&Q);
	for(int k=0;k<Q;++k)
	{
	 scanf("%d%d",&l,&r);
	 printf("%lld\n",func(r)-func(l));
    }
    return 0;
}

Measured memory_bytes: 3584
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000000007

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const ll maxn = 2*100005;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main(){
    fast;
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<endl;
}


Measured memory_bytes: 19204
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
#define LONG long long int
using namespace std;


int main() {
	int n;
	int *v;
	int *c;
	cin >> n;
	v = new int[n];
	c = new int[n];

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}


	for (int i = 0; i < n; i++)
	{
		if (c[i] < v[i])ans += (v[i] - c[i]);
	}

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

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right

n,m,k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

a_cumsum = list(accumulate(a_list))
#print(a_cumsum)
#print(bisect_right(a_cumsum, 59))
b_cumsum = list(accumulate(b_list))

ans=0
for i in range(n):
  if k<a_cumsum[i]:
    continue
  b_max=k-a_cumsum[i]
  b_index=bisect_right(b_cumsum, b_max)-1
  if b_index==-1:
    koho=i+1
  else:
    koho=i+1+b_index+1
  ans = max(ans,koho)

for i in range(m):
  if k<b_cumsum[i]:
    continue
  a_max=k-b_cumsum[i]
  a_index=bisect_right(a_cumsum, a_max)-1
  if a_index==-1:
    koho=i+1
  else:
    koho=i+1+a_index+1
  ans = max(ans,koho)
  
print(ans)

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

int main ()
{
	int n;  cin>>n;
	string ans;
	
	if(n<1200){
		ans="ABC";
	}
	else if(n<2800){
		ans="ARC";
	}
	else {
	ans="AGC";
}

   cout<<ans<<endl;
	


}


Measured memory_bytes: 3600
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        //out.println("AMAN");
        String s1 = sc.next(),s2=sc.next();
        int n = s1.length(), m = s2.length();
        int dp[][] = new int[n+1][m+1];
        for(int i=1;i<n+1;i++) {
            for(int j=1;j<m+1;j++) {
                if(s1.charAt(i-1)==s2.charAt(j-1))
                    dp[i][j] = dp[i-1][j-1]+1;
                else
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
            }
        }
        ArrayList<Character> ch = new ArrayList<>();
        int i=n,j=m;
        while(i!=0 && j!=0) {
            if(dp[i][j]==dp[i-1][j]) --i;
            else if(dp[i][j]==dp[i][j-1]) --j;
            else {
                ch.add(s1.charAt(i - 1));
                --i;
                --j;
            }
        }
        for(i=ch.size()-1;i>=0;i--) {
            out.print(ch.get(i));
        }
        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 82516
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

int S[MAX];
int top=0;

void initialize(){
   top = 0;
 }

int isEmpty(){
   if(top==0)return 0;
   return -1;
}
 int isFull(){
   if(top>=MAX)return 0;
   return -1;
}

 void push(int x){
   if(isFull()==0){
     fprintf(stderr,"Push ERROR\n");
     exit(1);
   }
   top++;
   S[top] = x;
}

int pop(){
    if (isEmpty()==0){
      fprintf(stderr,"Pop ERROR\n");
      exit(2);
    }
      top--;
      return S[top+1];
}

int main(void){
  int num, Masato1, Masato2, N;
  char C[100];

  initialize();

  while(scanf("%s", C)!=EOF){

    if('1'<=C[0]&&C[0]<='9')num=1;
    else if(C[0]=='+')num=2;
    else if(C[0]=='-')num=3;
    else if(C[0]=='*')num=4;
    else {
      fprintf(stderr,"Input ERROR\n");
      exit(3);
    }
    switch(num){
      case 1:/*数字*/
      N=atoi(C);
      push(N);
      break;

      case 2:/*足し算*/
      Masato1=pop();
      Masato2=pop();
      push(Masato1+Masato2);
      break;

      case 3:/*引き算*/
      Masato2=pop();
      Masato1=pop();
      push(Masato1-Masato2);
      break;

      case 4:/*掛け算*/
      Masato1=pop();
      Masato2=pop();
      push(Masato1*Masato2);
      break;
    }
    Masato1=0;
    Masato2=0;
  }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
ll w[200010], b[200010];
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == '.') {
			w[i] = 1;
		}
		else {
			b[i] = 1;
		}
	}
	for (int i = 1; i < N; i++) {
		w[i] += w[i - 1];
		b[i] += b[i - 1];
	}
	ll ans = min(w[N-1], b[N-1]);
	for (int i = 1; i < N; i++) {
		ans = min(ans, b[i - 1] + (w[N-1]-w[i-1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3732
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main (void) {
int d,n;
scanf("%d %d",&d,&n);
if ((d<=9 && d>=1)&&(n<=9 && n>=1))
{
printf("%d",d*n);
}
else printf("-1");

return EXIT_SUCCESS;
}



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

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

    map<int, int> drinkPriceAndLimitMap;

    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;

        if (drinkPriceAndLimitMap.count(a))
        {
            drinkPriceAndLimitMap.at(a) += b;
        }
        else
        {
            drinkPriceAndLimitMap.insert(make_pair(a, b));
        }
    }

    long long priceSum = 0;
    int drinkCount = 0;
    for (const auto &singlePriceAndLimit : drinkPriceAndLimitMap)
    {
        if (singlePriceAndLimit.second > m - drinkCount)
        {
            priceSum += (long long)singlePriceAndLimit.first * (m - drinkCount);
            break;
        }
        else
        {
            priceSum += (long long)singlePriceAndLimit.first * singlePriceAndLimit.second;
            drinkCount += singlePriceAndLimit.second;

            if (drinkCount == m)
            {
                break;
            }
        }
    }

    cout << priceSum << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF 1001001001
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int c[10][1005];

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector <string> s(h);
    REP(i,h) cin>>s[i];
    int ans = INF;
    REP(div,1<<(h-1)) {
        int g = 0;
        vector <int> id(h);
        REP(i,h){
            id[i] = g;
            if(div >> i & 1) ++g;
        }
        ++g;
        REP(i,g) REP(j,w) c[i][j] = 0;
        REP(i,h) REP(j,w) c[id[i]][j] += (s[i][j] - '0');

        int num = g-1;
        vector<int> now(g);
        auto add = [&](int j){
            REP(i,g) now[i] += c[i][j];
            REP(i,g) if(now[i] > k) return false;
            return true;
        };
        REP(j,w){
            if(!add(j)){
                num++;
                now = vector <int> (g);
                if(!add(j)){
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans,num);

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    //Weather Prediction
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny")) System.out.println("Cloudy");
        else if (s.equals("Cloudy")) System.out.println("Rainy");
        else System.out.println("Sunny");
        sc.close();
    }
}


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

int main() {
	int n,tmp;
	cin >> n;
	vector<int>a, b, c;
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		b.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		c.push_back(tmp);
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	for (int i = 0; i < n; i++) {
		auto Itera = lower_bound(a.begin(),a.end(), b.at(i));
		auto Iterc = upper_bound(c.begin(), c.end(), b.at(i));
		ans += (Itera - a.begin()) * (c.end() - Iterc);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4704
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> b(N);
    for (int i=0; i<N; i++)
    {
        int a;
        cin>>a;
        b[a]++;
    }

    int d = 0;
    for (int i=0; i<N; i++)
        if (b[i]>0)
            d = i;

    bool ok = true;
    for (int i=0; i<(d+1)/2; i++)
        if (b[i]>0)
            ok = false;
    for (int i=d/2+1; i<=d; i++)
        if (b[i]<2)
            ok = false;
    if (d%2==0 && b[d/2]!=1)
        ok = false;
    if (d%2!=0 && b[d/2+1]!=2)
        ok = false;

    cout<<(ok ? "Possible" : "Impossible")<<endl;
}


Measured memory_bytes: 384
for i in range(1000):
    
    a, b, c = input().split()
    
    if b == '?': break
    
    a = int(a)
    c = int(c)
    
    if b == '+': print(a + c)
    if b == '-': print(a - c)
    if b == '*': print(a * c)
    if b == '/': print(int(a / c))







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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i, m)
    {
        int k;
        cin >> k;
        s[i].resize(k);
        rep(j, k) cin >> s[i][j];
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int sw = 0;
        rep(i, m)
        {
            int cnt = 0;
            rep(j, s[i].size())
            {
                if (bit & (1 << (s[i][j] - 1)))
                {
                    cnt++;
                }
            }
            if (cnt % 2 == p[i])
            {
                sw++;
            }
        }
        if (sw == m)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<int, pi> node;
#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    lli a, b, x, y;
    cin >> a >> b >> x >> y;
    cout << fixed << setprecision(10) << 1.0*a*b/2.0 << " ";
    if(a%2==0 && b%2==0 && a/2==x && b/2==y){
        printf("1\n");
    }
    else{
        printf("0\n");
    }

    return 0;
}


Measured memory_bytes: 3736
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#色を塗るタイプの操作は逆順に見ていけば確定した色が上書きされることは無いと思える
N,K = map(int,input().split())
a = list(map(int,input().split()))
A = [0]*(N+1)
S = [0]*(N+1)

for i in range(N):
    A[i+1] = A[i]+max(0,a[i])
    S[i+1] = S[i]+a[i]

ans = -inf
for i in range(0,N-K+1):
    ans = max(ans,A[i]+max(0,S[i+K]-S[i])+(A[N]-A[i+K]))

print(ans)


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

int main ()
{
    double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
    while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2)
    {
        if (ax1 <= bx2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
str_len = int(input())
str_list = list(input().split())
first_str = list(str_list[0])
second_str = list(str_list[1])

List = [""]
for i in range(str_len):
  List.append(first_str[i])
  List.append(second_str[i])
  
print("".join(List))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<ll,Pi> P1i;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,sx,sy,total;
};
int k[11],s[11][11];
int p[11];
int main(){

	int n,m;
	cin>>n>>m;
	rep(i,m){
		cin>>k[i];
		rep(j,k[i]){
			cin>>s[j][i];
		}
	}
	int total=0;
	rep(i,m)cin>>p[i];
	for(int i=0; i<(1<<n); i++){
		int f=0;
		rep(l,m){
			int t=0;
			rep(j,k[l]){
				if(i&(1<<(s[j][l]-1)))t++;
			}
			if(t%2!=p[l]){
				f=1;
				break;
			}
		}
		if(f==0)total++;
	}
	cout<<total<<endl;
	return 0;

}




Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);

    //let mut cakes: Vec<(i64, i64, i64)> = Vec::new();
    let mut cakes: Vec<Vec<i64>> = Vec::new();

    for _ in 0..n{
        let line = read_as_vec();

        cakes.push(line);
    }

    let mut ans = 0;
    for i in 0..8{
        let mut h = cakes.clone();
        h.sort_by_key(|x|{
            let mut sum = 0;
            for j in 0..3{
                if (i >> j & 1) == 0{
                    sum += x[j];
                }else{
                    sum -= x[j];
                }
            }
            return -sum;
        });

        let mut point = 0;
        for j in 0..3{
            point += h.iter().take(m).map(|x| x[j]).sum::<i64>().abs();
        }
        if ans < point{
            ans = point;
        }
    }

    println!("{}", ans);


}


Measured memory_bytes: 4352
X = []
for a in range(1, 10):
    X.append(a)
    for b in range(10):
        if abs(b-a) > 1: continue
        X.append(a * 10 + b)
        for c in range(10):
            if abs(c-b) > 1: continue
            X.append(a * 10 ** 2 + b * 10 + c)
            for d in range(10):
                if abs(d-c) > 1: continue
                X.append(a * 10 ** 3 + b * 10 ** 2 + c * 10 + d)
                for e in range(10):
                    if abs(e-d) > 1: continue
                    X.append(a * 10 ** 4 + b * 10 ** 3 + c * 10 ** 2 + d * 10 + e)
                    for f in range(10):
                        if abs(f-e) > 1: continue
                        X.append(a * 10 ** 5 + b * 10 ** 4 + c * 10 ** 3 + d * 10 ** 2 + e * 10 + f)
                        for g in range(10):
                            if abs(g-f) > 1: continue
                            X.append(a * 10 ** 6 + b * 10 ** 5 + c * 10 ** 4 + d * 10 ** 3 + e * 10 ** 2 + f * 10 + g)
                            for h in range(10):
                                if abs(h-g) > 1: continue
                                X.append(a * 10 ** 7 + b * 10 ** 6 + c * 10 ** 5 + d * 10 ** 4 + e * 10 ** 3 + f * 10 ** 2 + g * 10 + h)
                                for i in range(10):
                                    if abs(i-h) > 1: continue
                                    X.append(a * 10 ** 8 + b * 10 ** 7 + c * 10 ** 6 + d * 10 ** 5 + e * 10 ** 4 + f * 10 ** 3 + g * 10 ** 2 + h * 10 + i)
                                    for j in range(10):
                                        if abs(j-i) > 1: continue
                                        X.append(a * 10 ** 9 + b * 10 ** 8 + c * 10 ** 7 + d * 10 ** 6 + e * 10 ** 5 + f * 10 ** 4 + g * 10 ** 3 + h * 10 ** 2 + i * 10 + j)

print(sorted(X)[int(input()) - 1])

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    lint n, m; cin >> n >> m;
    if(n==1 && m>=2) out(m-2);
    else if(m==1 && n>=2) out(n-2);
    else if(n==1 && m==1) out(1);
    else out((n-2)*(m-2));
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

n,m,l=map(int,input().split())
ans=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=[int(j) for j in input().split()]
    ans[a-1][b-1]=c
    ans[b-1][a-1]=c
q=int(input())
st=[]
for i in range(q):
    st.append([int(j)-1 for j in input().split()])

ans=floyd_warshall(ans)

for i in range(n):
    for j in range(n):
        if ans[i][j]<=l:
            ans[i][j]=1
        else:
            ans[i][j]=0

ans=floyd_warshall(ans)

for i,j in st:
    if ans[i][j]==float("inf"):
        print(-1)
    else:
        print(int(ans[i][j])-1)



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

int main()
{
  long long int a;
  long long int ans=0;
  cin>>a;
  if(a==0)
  cout<<0;
  else if(a%2==1)
  {
    cout<<0;
  }
   else
  {
    long long int ans1=10;
    while(a>=ans1)
    {
      ans+=a/ans1;
      ans1*=5;
    }


    cout<<ans;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a;
  cin >>a;
  string b;
  cin >> b;
  if (a % 2 == 1) {
    cout << "No";
    return 0;
  }
  a /= 2;
  for (int i = 0; i < a; i++) {
    if (b[i] != b[a + i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;

    if (y > 4*x){
        cout << "No" << endl;
        return 0;
    }else if(y%2 == 1){
        cout << "No" << endl;
        return 0;
    }else if(y < 2*x){
        cout << "No" << endl;
        return 0;
    }else{
        cout << "Yes" << endl;
        return 0;
    }


}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
	String input;
	ArrayList<String> printevenlist, evenlist, printoddlist, oddlist;
	int strlen;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String inputline = sc.nextLine();
			input = inputline.replaceAll("[^a-zA-Z]", "").toUpperCase();
			oddlist = new ArrayList<String>();
			evenlist = new ArrayList<String>();
			printoddlist = new ArrayList<String>();
			printevenlist = new ArrayList<String>();
			strlen = input.length();
			int mid = (strlen + 1) / 2 - 1;
			for(int i = mid; i >= 0; i--){
				//odd
				palindrome(i, 1);
				//even
				palindrome(i, 0);
			}
			for(int i = mid + 1; i < strlen; i++){
				//odd
				palindrome(i, 1);
				//even
				palindrome(i, 0);
			}
			print();

		}
	}
	
	private void palindrome(int mid, int checkdigit){
		String lastadd = null;
		if(checkdigit == 1){
			for(int i = 1;(mid - i) >= 0 && (mid + i) < strlen ; i++){
				int first = mid - i;
				int last = mid + i;
				if(input.charAt(first) == input.charAt(last)){
					String subpalindrome = input.substring(first, last + 1);
					oddlist.add(subpalindrome);
					lastadd = subpalindrome;
				}
				else{
					break;
				}
			}
			if(lastadd != null && ! printoddlist.contains(lastadd))
				printoddlist.add(lastadd);
			if(lastadd != null)
				oddlist.remove(oddlist.size()-1);
		}
		else{
			for(int i = 0;(mid - i) >= 0 && (mid + 1 + i) < strlen ; i++){
				int first = mid - i;
				int last = mid + 1 + i;
				if(input.charAt(first) == input.charAt(last)){
					String subpalindrome = input.substring(first, last + 1);
					if(i != 0){
						evenlist.add(subpalindrome);
						lastadd = subpalindrome;
					}
				}
				else{
					break;
				}
			}
			if(lastadd != null && ! printevenlist.contains(lastadd))
				printevenlist.add(lastadd);
			if(lastadd != null)
				evenlist.remove(evenlist.size() - 1);
		}
	}
	
	private void print(){
		int len = printoddlist.size();
		boolean isfirstprint = true;
		for(int i = 0; i < len; i++){
			String nowstr = printoddlist.get(i);
			if(oddlist.contains(nowstr)) continue;
			if(isfirstprint){
				System.out.print(nowstr);
				isfirstprint = false;
			}
			else{
				System.out.print(" " + nowstr);
			}
		}
		len = printevenlist.size();
		for(int i = 0; i < len; i++){
			String nowstr = printevenlist.get(i);
			if(evenlist.contains(nowstr)) continue;
			if(isfirstprint){
				System.out.print(nowstr);
				isfirstprint = false;
			}
			else{
				System.out.print(" " + nowstr);
			}
		}
		System.out.println();
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
	
	
}

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

using namespace std;

#define intt long long
const int MAXN = 1003;
const int INF = 2000000003;
int a[MAXN];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i ++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.size() - 2; i ++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())

a = list(map(int, input().split()))

num = sum(a[:k])
num_max = num
for i in range(k, n):
    num = num-a[i-k]+a[i]
    if num>num_max:
        num_max=num

print((num_max+k)/2)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    for (int b = K + 1; b <= N; b++) {
        ans += ((N - (b - 1)) / b + 1) * (b - K);
        if (K <= N % b && N % b < b - 1) ans += N % b - K + 1;
    }
    cout << ans << endl;
}


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

int main(){
	int n, count = 0;
	cin >> n;

	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		if(i % 2 == 0){
			if(arr[i] % 2 != 0){
				count += 1;
			}
		}
	}
	cout << count << endl;
}


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

int main()
{
    int N, D, X;
    cin >> N >> D >> X;
    int cnt = X + N;
    for(int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        cnt += (D-1)/A;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[21], B[21], C[21];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];
    int ans = 0;
    rep(i, N) A[i]--;
    rep(i, N) {
        ans += B[A[i]];
        if(i > 0 && A[i - 1] + 1 == A[i]) {
            ans += C[A[i - 1]];
            
        }
    }


    cout << ans << endl;

    return 0;
}


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

struct panel{
  char t[3][3];
};

panel ra(panel p){
  char u[3][3];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)u[i][j]=p.t[i][j];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)p.t[i][j]=u[j][2-i];
  return p;
}

panel rb(panel p){
  char u[3][3];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)u[i][j]=p.t[i][j];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)p.t[i][j]=u[2-i][j];
  return p;
}

struct die{
  panel t[6];
  bool operator < (const die &p)const{
    for(int i=0;i<6;i++)
      for(int j=0;j<3;j++)
        for(int k=0;k<3;k++)
          if(t[i].t[j][k]!=p.t[i].t[j][k])
            return (t[i].t[j][k]<p.t[i].t[j][k]);
    return false;
  }
};

die ra(die p){
  panel tmp=p.t[0];
  p.t[0]=p.t[4];
  p.t[4]=ra(ra(p.t[2]));
  p.t[2]=ra(ra(p.t[5]));
  p.t[5]=tmp;
  p.t[1]=ra(p.t[1]);
  p.t[3]=ra(ra(ra(p.t[3])));
  return p;
}

die rb(die p){
  panel tmp=p.t[1];
  p.t[1]=ra(ra(ra(p.t[4])));
  p.t[4]=ra(ra(ra(p.t[3])));
  p.t[3]=ra(ra(ra(p.t[5])));
  p.t[5]=ra(ra(ra(tmp)));
  p.t[0]=ra(ra(ra(p.t[0])));
  p.t[2]=ra(p.t[2]);
  return p;
}

char str[100];

bool input(panel &p){
  for(int i=0;i<3;i++){
    scanf("%s",str);
    if(str[0]=='#')return false;
    for(int j=0;j<3;j++)p.t[i][j]=str[j];
  }
  return true;
}

bool check(panel &p){
  for(int i=0;i<3;i++)
    if(p.t[2][i]=='*')return true;
  return false;
}

int main(){
  die A;
  while(input(A.t[0])){
    for(int i=1;i<6;i++)input(A.t[i]);
    map< die , int > d;
    queue< die > Q;
    d[A]=0;
    Q.push(A);
    while(!Q.empty()){
      die s=Q.front();Q.pop();
      int cost=d[s];
      if( check(s.t[0]) && check(s.t[2]) ){
        cout<<cost<<endl;
        break;
      }
      die next=ra(s);
      if(d.count(next)==0){
        d[next]=cost+1;
        Q.push(next);
      }

      next=ra(ra(ra(s)));
      if(d.count(next)==0){
        d[next]=cost+1;
        Q.push(next);
      }

      next=rb(s);
      if(d.count(next)==0){
        d[next]=cost+1;
        Q.push(next);
      }
      
      next=rb(rb(rb(s)));
      if(d.count(next)==0){
        d[next]=cost+1;
        Q.push(next);
      }
      
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll h,m,n,i;
	cin>>h>>n;
	ll s=0;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		cin>>m;
		s=s+m;
	}
	if(s>=h) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,x=0;
	scanf("%d",&a);
	if(a/100==1){
		x++;
	}if(a%100/10==1){
		x++;
	}if(a%100%10==1){
		x++;
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  vi v;
  int cnt = 0, cnt2 = 0, count = 0;
  if(s[0] == '0') v.push_back(0);
  rep(i, n){
    if(s[i] == '1'){
      if(cnt2){
        v.push_back(cnt2);
        count++;
      }
      cnt++;
      cnt2 = 0;
    }else{
      if(cnt) v.push_back(cnt);
      cnt2++;
      cnt = 0;
    }
  }
  if(cnt) v.push_back(cnt);
  if(cnt2){
    v.push_back(cnt2);
    count++;
  }
  if(s[n - 1] == '0') v.push_back(0);
  if(count <= k) cout << n << endl;
  else{
    int ans = 0, num = 0;
    for(int i = 0; i < k * 2; i += 2){
      ans += v[i] + v[i + 1];
    }
    ans += v[k * 2];
    num = ans;
    for(int i = k * 2 + 1; i < v.size(); i += 2){
      num += v[i] + v[i + 1];
      num -= v[i - k * 2 - 1] + v[i - k * 2];
      ans = max(ans, num);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1148
import math
N = int(input())
max_div = math.ceil(math.sqrt(N))
ans = 10 ** 18

for i in range(1, max_div + 1):
    if N % i == 0:
        ans = min(ans, int(max((math.log10(N // i) + 1, math.log10(i) + 1))))

print(ans)


Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

int T[maxN];

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	printf("%d\n", n*m);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





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

using namespace std;

int main(){
	int n,k,e;
	cin >> n >> k;
	double ans=0.0;
	for(int i=1;i<=n;i++){
		e=ceil(log2(double(k)/double(i)));
		if(e<0) e=0;
		ans+=((1.0/double(n))*pow((1.0/2.0),e));
	}
	cout << setprecision(9) <<fixed;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define vll(a)	  vector<ll>a
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll n;
		sll(n);
		vector<ll>v;
		for (int i=0 ; i<n ; i++)
		{
			ll x;
			sll(x);
			v.pb(x);
			//cerr << imie(v[i]);
		}
		vector<ll>ans(n+5);
		for (int i=0 ; i<n ; i++)
			{
			ans[v[i]-1]=i+1;
			//cerr << imie(ans[i]);
			}
		for (int i=0 ; i<n ; i++)
		cout << ans[i] << " ";
		cout << endl;
		return 0;  
}  


Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n){
        cin>>l[i];
    }
    ll ans=0;
    sort(l.begin(),l.end());
    for(int longest=n-1;longest>1;longest--){
      for(int middle=longest-1;middle>0;middle--){
        for(int shortest=middle-1;shortest>=0;shortest--){
                if(l[shortest]+l[middle]<=l[longest])break;
                else ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        ArrayList<String> li = new ArrayList<String>();
        for(int i = 0; i < n; i++){
            li.add(sc.next());
        }
        Collections.sort(li);
        String ans = "";
        for(String s : li){
            ans += s;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
int main()
{
        int n,t;
        cin>>n>>t;
        vector<pair<int,int> > v;
        for(int i=0;i<n;i++)
        {
                int x,y;
                cin>>x>>y;
                if(y>t) continue;
                v.push_back(make_pair(x,y));
        }
        sort(v.begin(),v.end());
        if(v.size()==0) cout<<"TLE"<<endl;
        else cout<<v[0].first<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 100055
char ch[MN];
int f[MN],tot[MN];
int Find(int a){
	return a==f[a]?a:(f[a]=Find(f[a]));
}
int main(){
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=n;++i){
		if(ch[i]=='L')f[i]=Find(i-1);
		if(ch[i]=='R'&&ch[i+1]=='R')f[i]=Find(i+1);
	}
	for(int i=1;i<=n;++i){
		if(ch[i]=='L')f[i]=Find(i-1);
		if(ch[i]=='R'&&ch[i+1]=='R')f[i]=Find(i+1);
		int ans=((abs(f[i]-i))&1)?(f[i]+1):f[i];
		tot[ans]++;
	}
	for(int i=1;i<=n;++i)printf("%d ",tot[i]);
	return 0;
} 

Measured memory_bytes: 2432