akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

struct word{
  char data[33];
};
struct word in[400];

int main(){
 
  char a[33];
  int count[400];
  int i,j,ans1,ans2,p=0,temp,max,lengs;
  
  for(i=0;i<400;i++){
    if(scanf("%s", &a)==EOF){
      p=1;
      temp=i;
    }
    in[i]=*(struct word *)a;
    if(p==1) break;
  }
  max=-1;

  for(i=0;i<temp;i++){
    lengs=strlen(in[i].data);
    if(lengs>max){
      max=lengs;
      ans1=i;
    }
  }
  for(i=0;i<temp;i++){
    count[i]=0;
  }
  for(i=0;i<temp;i++){
    for(j=0;j<i;j++){
      if(strcmp(in[i].data,in[j].data)==0){
	count[j]++;
      }
    }
  }
  max=-1;
  for(i=0;i<temp;i++){
    if(max<count[i]){
      max=count[i];
      ans2=i;
    }
  }
  
  printf("%s %s\n", in[ans2].data, in[ans1].data);

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int N,A,B,i,d,copy,sum,s=0;
    cin >> N >> A >> B;
    for(i=1;i<=N;i++)
    {
        copy = i;
        sum=0;
        while(copy>0)
        {
            d=copy%10;
            sum+=d;
            copy=copy/10;
        }
        if(sum>=A && sum<=B)
            s+=i;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
k = int(input())
from collections import deque
q = deque()
a = list(map(str, list(range(1, 10))))
ans = a + []
illist = []
for i in range(10):
    if i == 0:
        illist.append(["0","1"])
    elif i == 9:
        illist.append(["8","9"])
    else:
        illist.append([str(i-1),str(i),str(i+1)])
for i in range(1,10):
    q.append(str(i))

node = "0"
while node != "323456667":
    node = q.popleft()
    for j in illist[int(node[-1])]:
        nodej = node+j
        q.append(nodej)
        a.append(nodej)

print(a[k - 1])

Measured memory_bytes: 10892
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <stack>
 
template<class T>
class UnionFindTree{
public:
    UnionFindTree(const T N){
        tree = std::vector<T>(N);
        for(T i=0; i<N; ++i){
            tree[i] = i;
        }
        nGroup = N;
    }

    T root(const T idx){
        T tmp = idx;
        std::stack<T> stack;
        while(tree[tmp] != tmp){
            stack.push(tmp);
            tmp = tree[tmp];
        }
        while(!stack.empty()){
            tree[stack.top()] = tmp;
            stack.pop();
        }
        return tmp;
    }

    void merge(const T idx1, const T idx2){
        if(!same(idx1, idx2)){
            tree[root(idx1)] = root(idx2);
            --nGroup;
        }
    }

    bool same(const T idx1, const T idx2){
        return root(idx1) == root(idx2);
    }

    T groups(){
        return nGroup;
    }

private:
    std::vector<T> tree;
    T nGroup;
};



int main(int argc, char *argv[]){
  int N;
  std::cin >> N;
  std::vector<long int>A(N);
  for(auto &a : A){
    std::cin >> a;
  }
  std::vector<int>AIdx(N);
  std::iota(AIdx.begin(),AIdx.end(),0);
  std::sort(AIdx.begin(),AIdx.end(),
    [&A](const auto &lhs, const auto &rhs){
      return A[lhs] > A[rhs] || (A[lhs] == A[rhs] && lhs < rhs);
    });

  std::set<int> set;

  UnionFindTree<int> tree(N);
  for(const auto &idx : AIdx){
    auto pIter = set.upper_bound(idx);
    if(pIter != set.end()){
      tree.merge(*pIter, idx);
      set.erase(*pIter);
    }
    set.emplace(idx);
  }
  std::cout << tree.groups() << std::endl;
}

Measured memory_bytes: 6528
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(2e5)+5;
const int mo=(int)(1e9)+7;
int a[maxn];

int main() {
    int n;
    read(n);LL res=1;
    REP(i,1,n) read(a[i]);
    for(int i=1,d=0,p=0;i<=n;i++) {
        d=max(d,i-1-(a[i-1]+1)/2);
        res=1LL*res*(i-d)%mo;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 640
# pypyはnumpyが使えないみたい
#import numpy as np
# dp[i][j]: i+1個目までの品物で重量の総和がj以下である時の価値の最大値

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
    
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            #dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 171656
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int N,M;                                                       
   scanf("%d %d",&N,&M);                                          
   int day[M];                                                    
                                                                  
   for(int i = 0; i < M; i++){                                    
      scanf("%d ",&day[i]);                                       
      N -= day[i];                                                
   }                                                              
   if(N < 0){                                                     
      printf("-1");                                               
   }else{                                                         
      printf("%d",N);                                             
   }                                                              
}       

Measured memory_bytes: 1768
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    
    int a = 0;
    
    cin >> a;
    
    string s1, s2;
    
    for(int k = 0; k < a; k ++) {
        
        cin >> s1 >> s2;
        
        int m = s1.size();
        
        int n = s2.size();
        
        int c[1005][1005] = {};
        
        int Amax = 0;
        
        s1 = ' ' + s1;
        
        s2 = ' ' + s2;
        
        for (int i = 1; i <= m; i ++) {
            
            c[i][0] = 0;
            
        }
        
        for (int j = 1; j <= n; j ++) {
            
            c[0][j] = 0;
            
        }
        
        for (int i = 1; i <= m; i ++) {
            
            for (int j = 1; j <= n; j ++) {
                
                if (s1[i] == s2[j]) {
                    
                    c[i][j] = c[i-1][j-1] +1;
                    
                } else if(c[i-1][j] >= c[i][j-1]) {
                    
                    c[i][j] = c[i-1][j];
                    
                } else {
                    
                    c[i][j] = c[i][j-1];
                    
                }
                
                Amax = max(Amax,c[i][j]);
                
            }
            
        }
        
        cout << Amax << endl;
        
    }
    
    return 0;
    
}


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

int64_t solve(char *begin, char *end);

int main(int argc, char const* argv[])
{
  char buf[32];
  char *next;
  int64_t N, Q;
  fgets(buf, sizeof(buf), stdin);
  N = strtol(buf, &next, 10);
  Q = strtol(next + 1, NULL, 10);
  // fprintf(stderr, "N = %ld, Q = %ld\n", N, Q);
  
  char *S = malloc((size_t)N + 1);
  fgets(S, N + 1, stdin);
  S[N] = '\0';
  // tolerate '\n'
  getchar();

  int64_t R[N];
  memset(R, 0, 8 * N);
  for (int i = 0; i < N - 1; i++) {
    R[i + 1] = R[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);
  }

  int64_t l, r, res;

  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = R[r - 1] - R[l - 1];
    printf("%lu\n", res);
  }

  /*
  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = solve(S + l - 1, S + r - 1);
    printf("%lu\n", res);

  }
  */
  free(S);
  return 0;
}

int64_t solve(char *begin, char *end) {
  int64_t res = 0;
  for (; begin < end; begin++) {
    if ((begin[0] == 'A') && (begin[1] == 'C')) {
      res++;
      begin++;
    }
  }
  return res;
}



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

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

    ll N, M;
    cin >> N >> M;

    vector<bool> broken(N+1);
    vector<ll> step(N+1);

    rep(i,M) {
        ll tmp; cin >> tmp;
        broken[tmp-1] = true;
    }

    step[N-1] = 1;
    step[N] = 0;
    for (int i = N - 2; i >= 0; i--) {
        if (broken[i]) continue;
        step[i] = step[i+1] + step[i+2];
        step[i] %= 1000000007;
    }

    cout << (step[0] + step[1]) % 1000000007 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;




int main()
{
    long long int r,d,x,form;
    cin>>r>>d>>x;
    form=r*x-d;
    cout<<form<<endl;
    for (int i=0;i<9;i++)
    {
        long long temp=form;
        form=r*temp-d;
        cout<<form<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<map<int, int>> v(m);
    for (int i = 0; i < m; ++i) {
        int k;
        scanf("%d", &k);
        for (int j = 0; j < k; ++j) {
            int y;
            cin >> y;
            v[i][y-1]++;
        }
    }
    vector<int> u(m);
    for (auto &&l : u) scanf("%d", &l);
    int ans = 0;
    for (int i = 0; i < (1<<n); ++i) {
        vector<int> cnt(m);
        for (int j = 0; j < n; ++j) {
            if(!(i & (1<<j))) continue;
            for (int k = 0; k < m; ++k) {
                if(v[k][j]) cnt[k] ^= 1;
            }
        }
        if(u == cnt) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   string s;
   cin>>s;
   
   if(s == "ABC")
        cout<<"ARC";
   else cout<<"ABC";        
   
   
   return 0;        
}  
  
   

Measured memory_bytes: 3648
#include <cstdio>
#define NIL -1

struct Node {
    int parent, left, right;
};

Node *T;

void prePerse(int u) {
    if (u == NIL) { return; }
    printf(" %d", u);
    prePerse(T[u].left);
    prePerse(T[u].right);
}

void inPerse(int u) {
    if (u == NIL) { return; }
    inPerse(T[u].left);
    printf(" %d", u);
    inPerse(T[u].right);    
}

void postPerse(int u) {
    if (u == NIL) { return; }
    postPerse(T[u].left);
    postPerse(T[u].right);
    printf(" %d", u);  
}

int main() {
    int n;
    scanf("%d", &n);

    T = new Node[n];

    // initialize tree
    for (int i = 0; i < n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for (int i = 0; i < n; i++) {
        int v, left, right;
        scanf("%d %d %d", &v, &left, &right);
        T[v].left = left;
        T[v].right = right;
        if (left != NIL) { T[left].parent = v; }
        if (right != NIL) { T[right].parent = v; }
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) {
            root = i;
            break;
        }
    }
    printf("Preorder\n");
    prePerse(root);
    printf("\n");
    printf("Inorder\n");
    inPerse(root);
    printf("\n");
    printf("Postorder\n");
    postPerse(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2712
#Atcoderではmathではなく，fractionsを使用するため．基本fractions
#a/2が全て同じ数の2の倍数を素因数に持つ必要がある．

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def waru2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count

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

half_a = []
waru = []

for i in a:
    half_a.append(i//2)
    waru.append(waru2(i))

if max(waru) == min(waru):
    half_lcm = lcm_list(half_a)
    print(-(-(M//half_lcm)//2))
else:
    print(0)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    double sum = 0;
    vector<double> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    sum = v[0];
    for (int i = 1; i < n; ++i) {
        sum = (sum + v[i]) / 2;
    }
    cout.setf(ios::fixed);
    cout << setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
 
    String S = sc.next();
    char[] s = S.toCharArray();
    int[] list = new int[s.length];
    
    for(int i = 0; i < s.length ; i++){
       char M = s[i];
       int m = Character.getNumericValue(M);
       list[i] = m;
    }
    
    int Min = 753;
    int G = 0;
    for(int i = 2; i <= list.length-1 ; i++){
      int g = list[i-2]*100 + list[i-1]*10 + list[i];
      if(g >= 753){
        G = g - 753;
      }else{
        G = 753 - g;
      }
     
      if(Min > G){
        Min = G;
      }
    }
  
    System.out.println(Min);
    
  }
}

Measured memory_bytes: 35564
H,W = [ int(it) for it in input().split() ]
N = int(input())
li = [ int(it) for it in input().split() ]
chk = [ [i+1]*li[i] for i in range(len(li)) ]
from itertools import chain
chk = list(chain.from_iterable(chk))

mp = [ [0]*W for i in range(H) ]

x = 0
y = 0
dx = 1
for i in range(H*W):
  mp[y][x] = chk[i]
  x += dx
  if (x==W):
    x = W-1
    y += 1
    dx = -1
  if (x==-1):
    x = 0
    y += 1
    dx = 1
    
    
[ print( " ".join( map(str,line) )  ) for line in mp ]
  



Measured memory_bytes: 40944
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

set<int> e[100000];
bool used[100000];
int color[100000];

bool dfs(int u, int c) {
    used[u] = true;
    color[u] = c;
    for (auto v: e[u]) {
        if (used[v] && 1-c != color[v] || !used[v] && !dfs(v,1-c)) return false;
    }
    return true;
}

int main(void) {
    int i, j, n, m;
    scanf("%d%d",&n,&m);
    REP (i,m) {
        int a, b;
        scanf("%d%d",&a,&b);
        a--,b--;
        e[a].insert(b);
        e[b].insert(a);
    }
    if (!dfs(0,0)) {
        printf("%lld\n",(ll)n * (n-1) / 2 - m);
    }
    else {
        int cnt = 0;
        REP (i,n) cnt += color[i];
        printf("%lld\n",cnt * (n - cnt) - m);
    }
    return 0;
}

Measured memory_bytes: 15104
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int dfs(vector<vector<int>> const& g, int v) {
	if (g[v].size() == 0) {
		return 0;
	}
	vector<int> ch;
	for (auto to : g[v]) {
		ch.push_back(dfs(g, to));
	}
	sort(ALL(ch),greater<int>());
	int res = 0;
	for (int i = 0; i < ch.size(); i++) {
		res = max(res, ch[i] + i + 1);
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<vector<int>> g(n);
	for (int i = 1; i <= n - 1; i++) {
		int a;
		cin >> a;
		g[a - 1].push_back(i);
	}

	cout << dfs(g, 0) << endl;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

i64 log2_(i64 x) {
  i64 ans = 0;
  while(x % 2 == 0) {
    ++ans;
    x /= 2;
  }
  return ans;
}

int main(int argc, char *argv[]) {

  i64 N, i;
  cin >> N;
  // vi a(N);
  getchar();
  string S;
  getline(cin, S);

  bool f = false;
  i64 c1 = 0, c2 = 0;
  i64 t1 = 0, t2 = 0;
  REP(0, N, i) {

    if(i != 0 && i != N-1) {
      t1 += log2_(N-i);
      t2 += log2_(i);
    }

    if(S[i] == '2') {
      f = true;
    }
    if(i == 0 || i == N-1 || t1 == t2) {
      switch(S[i]) {
      case '2':
	c1++;
	break;
      case '3':
	c2++;
	break;
      }
    }
  }

  if(f) {
    cout << (c1 % 2) << endl;
  }
  else {
    cout << (c2 % 2) * 2 << endl;
  }

  
  return 0;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int my_pow(int A,int B){
  if(B==0)
    return 1;
  if(B%2==1)
    return my_pow(A,B-1)*A%mod;
  int C=my_pow(A,B/2);
  return C*C%mod;
}
signed main(){
  int N,K;
  vector<int> A(2010);
  cin>>N>>K;
  int M=N-K;
  A[0]=1;
  for(int i=1;i<2010;i++)
    A[i]=A[i-1]*i%mod;
  for(int i=1;i<=K;i++){
    if(i>M+1)
      puts("0");
    else
      cout<<(A[M+1]*my_pow(A[M+1-i]*A[i]%mod,mod-2)%mod)*
            (A[K-1]*my_pow(A[K-i]*A[i-1]%mod,mod-2)%mod)%mod<<endl;
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define fo(i, a, b) for (ll i = (a); i <= (b); ++i)
#define fd(i, b, a) for (ll i = (b); i >= (a); --i)
 
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    int ans = 0;
    int a[100012] = {};
 
    fo(i, 1, n)
    {
        int x;
        cin >> x;
        a[x + 1]++;
        a[x + 2]++;
        a[x + 3]++;
    }
    fo(j, 0, 100010) if (ans < a[j]) ans = a[j];
    cout << ans;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    lint W, H, x, y;
    cin >> W >> H >> x >> y;
    fcout << W * H / 2.0 << " " << (x * 2 == W && y * 2 == H) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll ans=0;
	range(i,1,n+1){
		if(to_string(i).size()%2==1)ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

ld dist(LDP a, LDP b) {
	ld dx = b.first - a.first;
	ld dy = b.second - a.second;
	return sqrt(dx*dx + dy * dy);
}
void solve() {
	int n; cin >> n;
	vector<LDP> v(n);
	rep(i, n) {
		ld x, y; cin >> x >> y;
		v[i] = { x,y };
	}
	vector<int> a(n);
	rep(i, n)a[i] = i;
	ld sum = 0; ld tmp = 0;
	while (true) {
		tmp++;
		rep(i, n - 1) {
			LDP le = v[a[i]];
			LDP ri = v[a[i + 1]];
			sum += dist(le, ri);
		}
		if (!next_permutation(a.begin(), a.end()))break;
	}
	cout << sum / tmp << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	//init();
	solve();
	stop
		return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    double L;
    cin >> L;

    double ans = L/3 * L/3 * L/3;

    cout << setprecision(10) << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define repeq(i,j,n) for(int i=j;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}
	string mkstr(int n,char c){
		string s;
		s+=c;
		if(n==1 || n==0) return s;
		string s1,s2;
		s1=mkstr(n/2,c);
		s2=mkstr(n/2,c);
		return s1+s2;
	}
	int fun(string s,int n,char c){
		if(n==1){
			if(s[0]==c) return 0;
			else return 1;
		}
		else if(n==0) return 0;
		string s1=s.substr(0,n/2);
		string s2=s.substr(n/2,n);
		int ans1=0,ans2=0;
		for(int i=0;i<n/2;i++){
			if(s1[i]!=c) ans1++;
			if(s2[i]!=c) ans2++;
		}
		ans1+=fun(s2,n/2,c+1);
		ans2+=fun(s1,n/2,c+1);
		return min(ans1,ans2);

	}
	// void dfs(int v,vector<int> visited,vector<vector<int>> adjd,vector<vector<int>> adjud) {
    	
 //    	visited[v] = 1;
 //    	for (int u : adjd[v]){
 //        	if (color[u] == 0){
 //        	    dfs(u);
 //        	}
 //    	}
    	

 //   	 	visited[v] = 2;
    	
	// }
	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			string s;
			cin>>s;
			int ck=1;
			rep(i,s.length()){
				if(i%2==1) {
					if(s[i]=='R') {ck=0;break;}
				}
				else {
					if(s[i]=='L') {ck=0;break;}	
				}
			}
			if(ck) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		return 0;
	}

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

class Dice
{
protected:
  int number[6], num;

public:
  void SetNumber(int a, int b)
  {
    number[a] = b;
  }
  void SetData()
  {
    for(int i = 0; i < 6; i++)
    {
      cin >> num;
      SetNumber(i, num);
    }
  }
  int Number(int a)
  {
      return number[a];
  }

private:
    int temporary;

public:
  void SetTemporary(int a)
  {
    temporary = a;
  }
  int Temporary()
  {
    return temporary;
  }
  void Rotation(int a, int b, int c, int d)
  {
    a--;
    b--;
    c--;
    d--;

    SetTemporary( Number(a) );
    SetNumber( a, Number(d) );
    SetNumber( d, Number(c) );
    SetNumber( c, Number(b) );
    SetNumber( b, Temporary() );
  }

  void Prepare(int a, int b)
  {
    if( a == Number(1) )
    {
      Rotation(1, 5, 6, 2);
    }
    if( a == Number(2) )
    {
      Rotation(1, 4, 6, 3);
    }
    if( a == Number(3) )
    {
      Rotation(1, 3, 6, 4);
    }
    if( a == Number(4) )
    {
      Rotation(1, 2, 6, 5);
    }
    if( a == Number(5) )
    {
      Rotation(1, 2, 6, 5);
      Rotation(1, 2, 6, 5);
    }

    if( b == Number(2) )
    {
      Rotation(3, 2, 4, 5);
    }
    if( b == Number(3) )
    {
      Rotation(4, 2, 3, 5);
    }
    if( b == Number(4) )
    {
      Rotation(5, 3, 2, 4);
      Rotation(5, 3, 2, 4);
    }
  }
};

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

  Dice dice[n];

  for(int i = 0; i < n; i++)
  {
    dice[i].SetData();
  }

  int count, judge = 0, finalJudge = 0;

  for(int i = 0; i < n -1; i++)
  {
    for(int j = i + 1; j < n; j++)
    {
      count = 0;
      judge = 0;

      for(int k = 0; k < 2; k++)
      {
        for(int  l = 0; l < 6; l++)
        {
          if( dice[i].Number(k) == dice[j].Number(l) )
          {
            count++;
          }
        }
      }
      if( 2 <= count )
      {
        dice[j].Prepare( dice[i].Number(0), dice[i].Number(1) );
        for(int m = 0; m < 6; m++)
        {
          if( dice[i].Number(m) == dice[j].Number(m) )
          {
            judge++;
          }
        }
        if( judge == 6 )
        {
          finalJudge++;
        }
      }
    }
  }


  if( finalJudge == 0 )
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3116
#include <iostream>

using namespace std;

const int MaxN = 100005;

int n;
int v[MaxN];

int main() {
  cin >> n;
  int sum = 0;
  int minDif = 0x3f3f3f3f;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    sum += v[i];
    if (v[i] % 10) {
      minDif = min(minDif, v[i]);
    }
  }

  if (sum % 10 == 0) {
    if (minDif != 0x3f3f3f3f) {
      cout << sum - minDif << '\n';
    }
    else {
      cout << 0 << '\n';
    }
  }
  else {
    cout << sum << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    if(k < a) {
        ans = k;
    }
    else if (a <= k && k < a + b) {
        ans = a;
    }
    else if(a + b <= k && k < a + b + c) {
        ans = a - (k - a - b);
    }
    else {
        ans = a - c;
    }

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


Measured memory_bytes: 3556
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
template<class T>inline
bool is_prime(T n) {
  if(n==2)return true;
  if(n<2||n%2==0)return false;
  for(T i=3;i*i<=n;i++){
    if(n%i==0)return false;
  }
  return true;
}
int main(void){
  long N;
  cin>>N;
  long num;
  long cnt=0;
  for(int i=0;i<N;i++){
    cin>>num;
    if(is_prime(num))cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int x, y;
    while(cin >> x >> y){
        if(x<y) swap(x, y);
        cout << GCD(x, y) << endl;
    }
	return 0;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD = 1000000007;
int main() {
    ll X,Y,A,B,C;cin >> X >> Y >> A >> B >> C;
    ll p[A] = {};ll q[B] = {};ll r[C] = {};
    for (int i = 0;i < A;i++){
        cin >> p[i];
    }
    for (int i = 0;i < B;i++){
        cin >> q[i];
    }
    for (int i = 0;i < C;i++){
        cin >> r[i];
    }
    sort(p,p + A);sort(q,q + B);sort(r,r + C);
    ll Red[X] = {};ll Blue[Y] = {};ll Apple[X + Y] = {};
    for (int i = 0;i < X;i++){
        Red[i] = p[A - 1 - i];
        Apple[i] = Red[i];
    }
    for (int i = 0;i < Y;i++){
        Blue[i] = q[B - 1 - i];
        Apple[X + i] = Blue[i];
    }
    sort(Apple,Apple + X + Y);
    int cc = 0;ll res = 0;
    for(int i = 0;i < X + Y;i++){
        if (cc < C) {
            if (Apple[i] < r[C - 1 - cc]) {
                Apple[i] = r[C - 1 - cc];
                cc++;
            }
        }
        res += Apple[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
using namespace std;
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; }
const long long INF = 1LL<<60;

string s, t;

int dp[3100][3100] = {0};

int main() {
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    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 {
            res = s[i-1] + res; 
            --i, --j; 
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 37120
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        map: [Chars;h],
    }

    let mut ans = 0;

    for i in 0..1 << h {
        for j in 0..1 << w {
            let mut k_count = 0;

            for cur_h in 0..h {
                if i >> cur_h & 1 == 1 {
                    continue;
                }
                for cur_w in 0..w {
                    if j >> cur_w & 1 == 1 {
                        continue;
                    }

                    if map[cur_h][cur_w] == '#' {
                        k_count += 1;
                    }
                }
            }

            if k_count == k {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2192
while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break

Measured memory_bytes: 4492
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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

   int cnt = 0;
   for(int i = 0; i < s.size(); i++){
      if(s[i] == 'o'){cnt++;}
   }


   if(cnt + 15 - (int)s.size() >= 8){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N; cin >> N;
  vector<int> data(N+1);
  ll sum = 0;
  
  FOR(i,1,N+1){
    if(i % 3 == 0) data[i] = 0;
    else if(i % 5 == 0) data[i] = 0;
    else data[i] = 1;
  }
  FOR(i,1,N+1) sum += i * data[i];
  cout << sum << endl;
}

Measured memory_bytes: 7140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int a, b; 
	string s;
	cin >> a >> b >> s;

	bool O = false;
	for (int i = 0; i < a; i++) {
		if (s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9' || s[i] == '0') {
			O = true;
		}
		else {
			O = false;
		}
	}

	bool P = false;
	for (int i = a + 1; i < a + b + 1; i++) {
		if (s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9' || s[i] == '0') {
			P = true;
		}
		else {
			P = false;
		}
	}
	bool Q = false;
	if (s[a] == '-') {
		Q = true;
	}
	if (O == true && P == true && Q == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)

const int maxN = 50000;
const double eps=1e-6;
double x[maxN],r[maxN];
pair<double,int> p[maxN*2];
int n;

bool Check(double l){
	double l2=l*l;
	int c=0;
	REP(i,n){
		if(r[i]<=l2)
			continue;
		double s=sqrt(r[i]-l2);
		p[c++]=make_pair(x[i]-s,1);
		p[c++]=make_pair(x[i]+s,-1);
	}
	sort(p,p+c);
	double a;
	double b=0;
	int k=0;
	REP(i,c){
		if(!k)
			a=p[i].first;
		if((k+=p[i].second)==0)
			b=max(b,p[i].first-a);
	}
	return b>=l*2;
}
	
int main(){
	while(1){
		
	scanf("%d",&n);
	if(!n) break;
	double b=0,t=0;
	REP(i,n){
		double a;
		scanf("%lf%lf",&x[i],&a);
		r[i]=a*a;
		t=max(t,a);
	}
	while(t-b>eps){
		double m=(b+t)/2;
		if(Check(m))
			b=m;
		else
			t=m;
	}
	printf("%.6lf\n",b*2);
	
	}
}

Measured memory_bytes: 5032
import itertools

N = int(input())

syougen_list = []
for i in range(N):
    a_i = int(input())
    a_i_list = []
    for j in range(a_i):
        a_i_list.append(list(map(int, input().split())))
    syougen_list.append(a_i_list)


output = 0
for i in itertools.product([1,0], repeat=N):
    legal = True
    for index, j in enumerate(i):
        if j == 1:
            syougen = syougen_list[index]
            for k in syougen:
                if i[k[0] - 1] != k[1]:
                    legal = False
                    break
            if not legal:
                break
    if legal:
        number = i.count(1)
        if number >= output:
            output = number

print(output)

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

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    if (A == 5 && B == 5 && C == 7) { cout << "YES" << endl; }
    else if (A == 5 && B == 7 && C == 5) { cout << "YES" << endl; }
    else if (A == 7 && B == 5 && C == 5) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int L, R, d;
	cin >> L >> R >> d;
	int r = 0;
	for (int i = d; i <= R; i += d) {
		if (i >= L) ++ r;
	}
	cout << r << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

    int N, D, X;
    cin >> N >> D >> X;

    int ans = X;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;

        ans += 1 + (D - 1) / A;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from functools import reduce

tmp=input().split(" ")
a=int(tmp[0])
b=int(tmp[1])

length = b-a+1

arr=[]
if a % 2 == 1:
    length -= 1
    arr.append(a)

if b % 2 == 0:
    length -= 1
    arr.append(b)

arr.append((length // 2 ) % 2)

print(reduce(lambda a,b:a^b, arr, 0))

Measured memory_bytes: 3572
#include <iostream> // 速度を求める場合はstdioを使う
using namespace std;

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

    unsigned int min_train_price = A > B ? B : A;
    unsigned int min_bus_price = C > D ? D : C;
    unsigned int min_total_price = min_train_price + min_bus_price;

    cout << min_total_price;

    return 0;
}

Measured memory_bytes: 256
def look(S, i,j):
    if S[i][j] is '#': return '#'
    h = len(S)
    w = len(S[0])
    cnt=0
    for ii in range(-1, 2):
        for jj in range(-1, 2):
            if ii+i<0 or ii+i >= h or jj+j<0 or jj+j >= w or (ii==0 and jj==0): continue
            t = S[i+ii][j+jj]
            if t is '#': cnt += 1
    return cnt


h,w=map(int,input().split())
mat = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        print(look(mat, i, j), end='')
    print('')

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

int main() {
    int x;
    cin>>x;
    cout<<x/500*1000+(x%500)/5*5<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N; 
	cin >> N; 
	long long int P = 998244353; 
	int A[310] = {}; 
	int S = 0; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		S += A[i]; 
	}
	long long int dp[310][90010] = {}; // はじめi枚まででRがjになるようなRGBの組の個数
	dp[0][0] = 1; 
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= 300 * i; j++){
			if(j >= A[i]) dp[i][j] = (dp[i-1][j-A[i]] + dp[i-1][j] * 2) % P; 
			else dp[i][j] = (dp[i-1][j] * 2) % P; 
		}
    }
	long long int exceed = 0; 
	for(int i = (S + 1)/2; i <= S; i++){
		exceed += dp[N][i]; 
	}
	exceed = exceed % P; 
	dp[0][0] = 1; // はじめi枚まででRがjになるようなRの組の個を同じ配列で再計算
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= 300 * i; j++){
			if(j >= A[i]) dp[i][j] = (dp[i-1][j-A[i]] + dp[i-1][j]) % P; 
			else dp[i][j] = dp[i-1][j]; 
		}
    }
	long long int pow3[314] = {};
	pow3[0] = 1; 
	for(int i = 1; i <= 310; i++){
		pow3[i] = (pow3[i-1] * 3) % P; 
	}
	if(S % 2 == 1) cout << (3 * P + pow3[N] - exceed * 3) % P << endl; 
	else cout << (3 * P + pow3[N] + dp[N][S / 2] * 3- exceed * 3) % P << endl; 
}

Measured memory_bytes: 218240
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>

using namespace std;

int main(){

    int mod = 1e9 + 7;

    string L;
    cin >> L;
    int N = (int)L.size();
    vector<long long> dp(N);
    dp[0] = 1;
    for(int i = 1; i < N; i++){
        dp[i] = (dp[i - 1] * 3) % mod;
    }

    long long ans = 0;
    long long cnt = 1;

    for(int i = 0; i < N; i++){
        char c = L[i];
        if(c == '0'){
            continue;
        }
        else{
            ans = (ans + (cnt * dp[N - 1 - i]) % mod) % mod;
            cnt = (cnt * 2) % mod;
        }
    }
    ans = (ans + cnt) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int d, n;
	cin >> d >> n;
	if (d == 0)
	{
		if (n == 100) cout << 101 << endl;
		else cout << n << endl;
		
	}
	else if (d == 1)
	{
		if (n == 100) cout << 10100 << endl;
		else cout << 100 * n << endl;
	}
	else
	{
		if (n == 100) cout << 1010000 << endl;
		else cout << 10000 * n << endl;
	}
}

Measured memory_bytes: 256