akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# coding: utf-8

# In[35]:


N, M = map(int, input().split())
pS = []
for _ in range(M):
    pS.append(list(map(str, input().split())))


# In[38]:


mydict = {}
for i in range(N):
    mydict[i+1] = {}
    mydict[i+1]["time"] = 0
    mydict[i+1]["AC"] = False
for x in pS:
    if x[1] == "AC":
        mydict[int(x[0])]["AC"] = True
    else: # x[1] == "WA"
        if mydict[int(x[0])]["AC"] == False:
            mydict[int(x[0])]["time"] += 1
t = sum([d["time"] for d in list(mydict.values()) if d["AC"]])
ac = sum([1 for d in list(mydict.values()) if d["AC"]])
print(ac, t)


# In[ ]:






Measured memory_bytes: 72808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int k;
    cin >> k;
    cout << (k / 2) * ((k + 1)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
n= int(input())
ls= []
for _ in range(n):
    a, b= map(int, input().split())
    if a==b:
        ls.append(1)
    else:
        ls.append(0)

ans=0
cont=0
for i in ls:
    ans = (ans+i)*i
    cont=max(cont, ans)

if cont >=3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9196
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, k, i, j, h, t;
   
    int l[51];

    int a = 0;
   
      
    scanf("%d %d", &n, &k);


    for( i = 0 ; i < n ; i = i + 1 ){

       scanf("%d", &l[i] );

       }

    
    for( j = 0 ; j < n ; j = j + 1 ){

       for( h = j + 1 ; h < n ; h = h + 1 ){

           if( l[j] < l[h] ){

               t = l[j];

               l[j] = l[h];

               l[h] = t;

               }

            }

        }


    for( t = 0 ; t < k ; t = t + 1 ){

        a += l[t];

        }
   

    printf("%d\n", a );


    return 0;
                                                          
}

Measured memory_bytes: 128
#include<stdio.h>

int n,k;
int cnt[105];

int main()
{
    scanf("%d%d",&n,&k);
    while(k--)
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            int a;
            scanf("%d",&a); cnt[a]++;
        }
    }
    int ans= 0;
    for(int i=1;i<=n;i++) if(cnt[i]==0) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int main (){
    int N;
    scanf("%d", &N);
  
   if (N % 10 ==2 || N%10 ==4 || N %10 == 5 || N% 10 
         == 7 || N% 10 == 9 ){
        cout << "hon" << endl;
  }
  else if (N % 10 == 0 ||N %10 == 1 || N % 10 == 6 || N % 10 == 8 ){
        cout << "pon" << endl;
}
else if (N % 10 == 3){
      cout << "bon" << endl;
}
return 0;
}


Measured memory_bytes: 3636
import sys
def input():
    return sys.stdin.readline()[:-1]

N,M,P = list(map(int,input().split()))
 
e_list = []
for i in range(M):
    A,B,C = list(map(int,input().split()))
    A,B = A-1,B-1
    e_list.append((A,B,P-C))
    
 
#ベルマンフォード法
#e_listの用意
vi=0
min_dis_list = [10**27]*N
min_dis_list[vi] = 0
 
for i in range(N-1):
    for e in e_list:
        u,v,d = e
        if min_dis_list[v]>min_dis_list[u]+d:
            min_dis_list[v]=min_dis_list[u]+d
 
neg_loop_flag=[False]*N
 
for i in range(N):
    for e in e_list:
        u,v,d = e
        if min_dis_list[u] < 10**26:
            if min_dis_list[u] + d < min_dis_list[v]:
                neg_loop_flag[v]=True
                min_dis_list[v] = min_dis_list[u] + d
            if neg_loop_flag[u]:
                neg_loop_flag[v]=True
 
 
if neg_loop_flag[N-1]:
    print(-1)
else:
    print(max(0,-min_dis_list[N-1]))

Measured memory_bytes: 72284
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  long long n, a, b;
  cin >> n >> a >> b;
  long long x = abs(a - b);
  if(x & 1) {
    if(a > b) swap(a, b);
    cout << min(a + (b - a) / 2, n - b + 1 + (b - a)/ 2) << endl;
  } else {
    cout << x / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A1003
Title Extraordinally Grid II
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
char s[10001];
char result[10001];
//
char key_table(char key,int times)
{
  if(key=='1')
    return("',.!?"[times-1]);
  if(key=='7')
    return("pqrsPQRS"[times-1]);
  if(key=='8')
    return("tuvTUV"[times-1]);
  if(key=='9')
    return("wxyzWXYZ"[times-1]);
  return(((times>3)?('A'-'a'):0)+'a'+(key-'0'-2)*3+((times+2) % 3));
}
void translate()
{
  int key,times,prevkey;
  char *p,*r;

  p=s;r=result;prevkey=-1;
  while(key=*p++)
    {
      if(key=='0')
	{

	  if(prevkey=='0')
	    *r++=' ';
	  else if (prevkey != -1)
	    *r++=key_table(prevkey,times);
	  prevkey='0';
	}
      else
	if(prevkey==key)
	  {
	    times++;
	    if(key=='7' || key=='9')
	      {
		if(times >= 9)
		  times=1;
	      }
	    else if(key=='1')
	      {
		if(times >= 6)
		  times=1;
	      }
	    else
	      {
		if(times >= 7)
		  times=1;
      	      }
	  }
        else
	  {
	    if(prevkey > '0')
	      *r++=key_table(prevkey,times);
	    prevkey=key;
	    times=1;
	  }
    }
}
main()
{
  while(NULL!=fgets(s,sizeof(s),stdin))
    {
      translate();
      printf("%s\n",result);
      memset(result,0,sizeof(result));
    }
return(0);
}

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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;



int main() {
    int n, m;
    cin >> n >> m;
    string ss[n];
    for (string& z : ss)
        cin >> z;
    for (string s : ss)
        cout << s << endl << s << endl;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vll l(n);
  vin(l);
  sort(all(l), greater<ll>());
  ll sum = 0;
  rep(i, 0, k) sum += l.at(i);
  cout << sum << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  bool b=0;
  rep1(i,9)rep1(j,9){
  if(i*j==a)
    b=1;
  }
  if(b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
while True:
    score = [int(i) for i in input().split()]
    if score == [-1, -1, -1]:
        break
    sum = score[0] + score[1]
    if sum < 30 or score[0] == -1 or score[1] == -1:
        print('F')
    elif sum < 50 and score[2] < 50:
        print('D')
    elif sum < 65 or (sum < 65 and score[2] >= 50):
        print('C')
    elif sum < 80:
        print('B')
    elif sum >= 80:
        print('A')



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int S;
  cin >> S;
  
  int L = S/100;
  int R = S%100;
  
  bool flag1 = 1<=L && L<=12;
  bool flag2 = 1<=R && R<=12;
  
  if (flag1 && flag2)
    cout << "AMBIGUOUS" << endl;
  else if (flag1 && !(flag2))
    cout << "MMYY" << endl;
  else if (!(flag1) && flag2)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

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

ll calc1(ll a,ll d,ll n) {return (a*2+(n-1)*d)*n/2;}
ll calc2(ll a,ll d,ll n) {return calc1(a,d,n+1)-calc1(a,d,n);}
ll n,m,t,a[111111],b[111111],c[111111],d[111111],e[111111];

ll calc(ll k,ll mid) {
  ll sum=calc1(calc2(a[k],b[k],mid),b[k],m-mid);
  if(c[k]+t+mid>n*m) return -1;
  ll l=k+e[mid];
  sum+=d[l-1]-d[k+1];
  sum+=calc1(a[l-1],b[l-1],t-m*(l-k-1)+mid);
  return sum;
}

int main() {
  cin >> n >> m >> t;
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];
  c[0]=d[0]=0;
  for(int i=0; i<n; i++) {
    c[i+1]+=c[i]+m;
    d[i+1]+=d[i]+calc1(a[i],b[i],m);
  }
  for(int i=0; i<=m; i++) e[i]=lower_bound(c,c+n,t+i)-c;
  ll ans=0;
  for(int i=0; i<n; i++) {
    ll l=max(0LL,m-t),r=m;
    while(l+2<r) {
      ll m1=(l*2+r)/3,m2=(l+r*2)/3;
      ll d1=calc(i,m1),d2=calc(i,m2);
      if(d1<d2) l=m1;
      else r=m2;
    }
    for(int j=l; j<=r; j++) ans=max(ans,calc(i,j));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6892
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
 
const double PI = acos(-1);
const int M=998244353;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define oo 1e16


int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	
	string s,t;
	cin>>s>>t;
	int c=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s[i]!=t[i])
			c++;
	}
	printf("%d\n",c );
	return 0;
}

Measured memory_bytes: 3520
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M, ans = 0;
	static int Num[100000];
	static bool Red[100000];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		Num[i] = 1;
		Red[i] = false;
	}
	Red[0] = true;
	for (int i = 0; i < M; i++) {
		int X, Y;
		cin >> X >> Y;
		X--, Y--;
		if (Red[X]) Red[Y] = true;
		Num[X]--, Num[Y]++;
		if (Num[X] == 0) Red[X] = false;
	}
	for (int i = 0; i < N; i++) {
		if (Red[i]) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    vector <int> a(3);
    for(int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    int ans(0);
    ans += a[2] - a[0];
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{int n;
cin>>n;
int p[n];
for(int i=0;i<n;i++)
{
cin>>p[i];	
}
int count=0;
for(int i=1;i<n-1;i++)
{
	if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))
	{
		count+=1;
	}
}cout<<count;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N,b[111],a[111],mk[111];
ll i,j,k,l,r,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &b[i]);
    }
    fornum(i,0,N){
        k = 0;
        l = -1;
        fornum(j,0,N){
            if(mk[j]==1)
                continue;
            if(b[j]==k+1){
                l = j;
            }
            k++;
        }
        if(l==-1){
            printf("-1");
            return 0;
        }
        a[N-1-i] = b[l];
        mk[l] = 1;
    }
    fornum(i,0,N){
        printf("%lld\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
memo = {}

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans  += gcd(i,j,k)
print(ans)


Measured memory_bytes: 69544
#include <iostream>

using namespace std;

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

  int n;
  cin >> n;
  int *a = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  long **dp = new long *[n + 1];
  for (int i = 0; i <= n; i++) {
    dp[i] = new long[n + 1];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = 0;
      // if (i == j)
      //   dp[i][j] = 0;
      // else
      //   dp[i][j] = -1;
    }
  }

  for (int len = 1; len <= n; len++) {
    for (int i = 0; i + len <= n; i++) {
      int j = i + len;
      if ((n - len) % 2 == 0)
        dp[i][j] = (dp[i + 1][j] + a[i]) > (dp[i][j - 1] + a[j - 1])
                       ? (dp[i + 1][j] + a[i])
                       : (dp[i][j - 1] + a[j - 1]);
      else
        dp[i][j] = (dp[i + 1][j] - a[i]) < (dp[i][j - 1] - a[j - 1])
                       ? (dp[i + 1][j] - a[i])
                       : (dp[i][j - 1] - a[j - 1]);
    }
  }

  cout << dp[0][n] << endl;

  for (int i = 0; i < n; i++) {
    delete[] dp[i];
  }
  delete[] dp;
  delete[] a;
  return 0;
}


Measured memory_bytes: 70656
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		Set<String> set = new HashSet<>();
		for(int i= 0; i < N; ++i) {
			set.add(in.readLine());
		}
		System.out.println(set.size());
	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 65768
N=int(input())

t0=0
x0=0
y0=0

for i in range(N):
    t,x,y=map(int,input().split())
    d=abs(x-x0)+abs(y-y0)
    if d>t-t0:
        print("No")
        exit()
    else:
        if ((t-t0)-d)%2!=0:
            print("No")
            exit()
    t0=t
    x0=x
    y0=y

print("Yes")

Measured memory_bytes: 3064
N=int(input())
*V,=map(int,input().split())

from collections import*
C1=Counter(V[::2]).most_common()+[(0,0)]
C2=Counter(V[1::2]).most_common()+[(0,0)]

K1=C1[0][0]
V1=C1[0][1]
K2=C2[0][0]
V2=C2[0][1]
if K1==K2:
    if V1>V2:
        V2=C2[1][1]
    elif V2>V1:
        V1=C[1][1]
    else:
        V2=max(C1[1][1],C2[1][1])

print(N-V1-V2)


Measured memory_bytes: 25256
import time
import random


class Problem:

    def __init__(self, D, s, c):
        self.last_days = [0] * 26
        self.D = D
        self.s = s
        self.c = c
        self.answer = [0] * self.D
        self.best_answer = [0] * self.D

    def scoring(self, day, ind):
        day_score = self.s[day][ind]
        minus_score = 0
        for i in range(26):
            if i != ind:
                minus_score += self.c[i] * (day + 1 - self.last_days[i])
        day_score -= minus_score
        return day_score

    def get_all_scores(self, day):
        """全ての選択肢のscoreを返す"""
        minus_score = 0
        all_scores = [0] * 26
        for i in range(26):
            if i == 0:
                for j in range(1, 26):
                    minus_score += self.c[j] * (day + 1 - self.last_days[j])
                all_scores[0] = self.s[day][0] - minus_score

            else:
                minus_score += self.c[i - 1] * (day + 1 - self.last_days[i - 1])
                minus_score -= self.c[i] * (day + 1 - self.last_days[i])
                all_scores[i] = self.s[day][i] - minus_score
        return all_scores

    def _strategy_greedy(self, day):
        all_scores = self.get_all_scores(day)
        all_scores_with_ind = [[i, all_scores[i]] for i in range(26)]
        all_scores_with_ind.sort(key=lambda x: x[1])
        ind = all_scores_with_ind[-1][0]
        score = self.scoring(day, ind)
        return score, ind

    def solve(self):
        self.init()

        sum_score = 0
        for i in range(self.D):
            score, ind = self._strategy_greedy(i)
            self.last_days[ind] = i + 1
            self.answer[i] = ind
            sum_score += score
        return sum_score, self.answer

    def _strategy_perturbation(self):
        # ランダムに１日を取り出し、一番その日の期待コストが大きくなるよう変化させる
        # 貪欲法に摂動を加えてみる
        day = random.randint(0, 3)

        # scores = [self.scoring()]

        random.randint(0, 3)

    def solve_greed(self):
        self.init()

    def init(self):
        self.last_days = [0] * 26
        self.answer = [0] * self.D


def main():
    time_start = time.time()
    DO_TIME = 2 * 0.90
    D = int(input())
    c = list(map(int, input().split()))
    s = []

    for _ in range(D):
        s.append(list(map(int, input().split())))

    max_score = 0

    problem = Problem(D, s, c)
    ite = 0
    while time.time() - time_start < DO_TIME:
        ite += 1
        score, answer = problem.solve()

        if score > max_score:
            # print("hit")
            # print(max_score)
            max_score = score
            problem.best_answer = answer

    for i in range(D):
        problem.best_answer[i] += 1
        print(problem.best_answer[i])
        # print(1)
    # print(ite)
    # print(max_answer)
    #     print(max_score)
    # print(problem.get_all_scores(1))


main()


Measured memory_bytes: 83288
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  cout << S[0] << S.size()-2 << S[S.size()-1] << endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,sum=0,mi=1000000001;
	cin>>n;
	vector<ll>a(n);
	for(ll i=0;i<n;i++){
		cin>>a.at(i);
		sum+=a.at(i);
		if(i>=1){
			a.at(i)=sum;
		}
	}
	for(ll i=1;i<n-1;i++){
		mi=min(abs(a.at(i)-(sum-a.at(i))),mi);
	}
	if(n==2) mi=abs(a.at(0)-(sum-a.at(0)));
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n, m;
    cin >> n >> m;
    vi k(m);
    vvi s(m);
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            int a;
            cin >> a;
            s[i].push_back(a);
        }
    }
    vi p(m);
    rep(i, m) {
        cin >> p[i];
    }


    int c=0;
    rep(i, 1<< n) {
        bitset<10> bits(i);
        rep(j, m) {
            int cc=0;
            rep(k, s[j].size()) {
                if(bits.test(s[j][k]-1)) {
                    ++cc;
                    //cout << cc << '\n';
                }
            }
            if((cc&1) != p[j]){
                goto OUT;
            }
        }
        //cout << bits << '\n';
        ++c;
        OUT:;
        
    }
    cout << c << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

//素数判定o(√n)
bool is_prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return n!=1;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int x;
  cin>>x;
  while(1){
      if(is_prime(x)){
          break;
      }
      x++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int main()
{
    vector<long long int> data;
    long long int N, i, a, val=0;
    cin>>N;
    for(i=0;i<N;i+=1)
    {
        cin>>a;
        data.push_back(a);
        val = val^a;
    }
    for(i=0;i<N;i+=1)
    {
        data[i] = val^data[i];   
    }
    for(i=0;i<N;i+=1)
    {
        cout<<data[i]<<" ";
    }
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;
const ll N = 1e6;

ll mod_pow(ll x,ll n,ll mod){

  if(n==0)return 1;

  ll res=mod_pow( x*x%mod , n/2 , mod );

  if( n & 1 )res = res*x%mod;

  return res;

}

ll fact[N];
ll infact[N];

void make_factorial(void){

  fact[0] = 1;

  for( ll i = 1 ; i < N ; i++ ){

    fact[i] = fact[i-1] * i;

    fact[i] %= MOD;

  }

  for( ll i = 0 ; i < N ; i++ ){

    infact[i] = mod_pow( fact[i] , MOD-2 , MOD );

  }

}

ll comb(ll a,ll b){

  if(a == 0 && b == 0)return 1;

  if(a < b || a < 0)return 0;

  ll tmp = infact[a-b]* infact[b] % MOD;

  return tmp * fact[a] % MOD; 

}

ll dp[1111];

ll f(ll n,ll k){
  
  if(dp[k]!=-1)return dp[k];
  
  ll ex=1;
  for(int i=0;i<n;i++){
	ex*=k;
	ex%=MOD;
  }
  
  ll sum=0;
  for(int i=1;i<k;i++){
	sum+=(f(n,i)*comb(k,i))%MOD;
	sum%=MOD;
  }
  
  return dp[k]=(MOD+ex-sum)%MOD;
}


int main(){
  ll n,k;
  cin>>n>>k;
  if(n<k){
	cout<<0<<endl;
	return 0;
  }
  make_factorial();
  fill_n(dp,1111,-1);
  dp[1]=1;
  cout<<(f(n,k)*infact[k])%MOD<<endl;
  return 0;
}



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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define li long long
#define ld long double
#define x first
#define y second
#define pt pair<int, int>
#define pll pair<li, li>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

using namespace std;


const int INF = 1e9;
const int MOD = 1e9 + 7;
const li INF64 = 1e18;
const ld EPS = 1e-7;

mt19937 myrand(time(NULL));

const int N = 100 * 1000 + 13;

int n;
int a[N];


bool read(){
	if(scanf("%d", &n) != 1)
		return 0;
	forn(i, n + 1){
		scanf("%d", &a[i]);
		--a[i];
	}
	return 1;
}


int cnt[N];
li fact[N], rfact[N];


li binpow(li a, li b){
	if (b == 0)
		return 1;
	if (b % 2 == 0){
		li z = binpow(a, b / 2);
		return z * z % MOD;
	}
	else
		return a * binpow(a, b - 1) % MOD;
}


li cnk(li k, li n){
	if (k > n || k < 0)
		return 0;
	return fact[n] * rfact[k] % MOD * rfact[n - k] % MOD;
}


void solve(){
	memset(cnt, 0, sizeof(cnt));
	int pos2 = -1, pos1 = -1;
	forn(i, n + 1){
		++cnt[a[i]];
		if (cnt[a[i]] == 2)
			pos2 = i;
	}
	forn(i, n + 1)
		if (a[pos2] == a[i]){
			pos1 = i;
			break;
		}
	
	fact[0] = 1;
	fore(i, 1, n + 2)
		fact[i] = fact[i - 1] * i % MOD;
	forn(i, n + 2)
		rfact[i] = binpow(fact[i], MOD - 2);
	
	int cnt1 = pos1;
	int cnt2 = n - pos2;
	
	forn(i, n + 1)
		printf("%lld\n", ((cnk(i + 1, n + 1) - cnk(i, cnt1 + cnt2)) % MOD + MOD) % MOD);
}


int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	while(read())
		solve();
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n-1){
    ans = max(ans, a[i+1]-a[i]);
  }
  ans = max(ans, a[0]+k-a[n-1]);
  cout << k-ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>

using namespace std;

#define ll long long
#define MAX 500000
#define MAX1 1148576
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int c[MAX + 5], tree[MAX1 + 5], last[MAX + 5];
struct node {
    int l, r, id;
} query[MAX + 5];
int ans[MAX + 5];

bool compare(node a, node b) {
    return a.r < b.r;
}

void update(int id, int l, int r, int pos, int val) {
    if (l == r) {
        tree[id] += val;
        return;
    }
    int lt = id << 1, rt = lt | 1, mid = (l + r) >> 1;
    if (pos <= mid) {
        update(lt, l, mid, pos, val);
    } else {
        update(rt, mid + 1, r, pos, val);
    }
    tree[id] = tree[lt] + tree[rt];
}

int get(int id, int l, int r, int rl, int rr) {
    if (l > r or r < rl or l > rr) {
        return 0;
    }
    if (l >= rl and r <= rr) {
        return tree[id];
    }
    int lt = id << 1, rt = lt | 1, mid = (l + r) >> 1;
    return get(lt, l, mid, rl, rr) + get(rt, mid + 1, r, rl, rr);
}

int main() {

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

    int n, q, i, j, l, r;
    cin >> n >> q;
    for (i = 1; i <= n; ++i) {
        cin >> c[i];
    }
    for (i = 0; i < q; ++i) {
        cin >> l >> r;
        query[i] = {l, r, i};
    }
    sort(query, query + q, compare);
    for (j = 0, i = 1; i <= n; ++i) {
        if (last[c[i]]) {
            update(1, 1, n, last[c[i]], -1);
        }
        last[c[i]] = i;
        update(1, 1, n, last[c[i]], 1);
        while (j < q and query[j].r == i) {
            ans[query[j].id] = get(1, 1, n, query[j].l, query[j].r);
            ++j;
        }
    }
    for (i = 0; i < q; ++i) {
        cout << ans[i] << "\n";
    }

    return 0;
}


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

int main(void){
 int ins, h, m;
 cin >> ins;
 h = ins / 3600;
 ins = ins - h*3600;
 m = ins / 60;
 ins = ins - m*60;

 cout << h << ":" << m << ":" << ins << endl;
  return 0;
}

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


int main()
{
    int n,m;
    std::cin >> n;
    std::vector<int> t(n);
    for(int i = 0; i < n; i++)std::cin >> t[i];
    std::cin >> m;


    int res = std::accumulate(t.begin(), t.end(),0);
    for(int i = 0; i < m; i++){
        int p,x;
        std::cin >> p >> x;
        p--;
        std::cout << res - (t[p] - x) << std::endl;
    }
}

Measured memory_bytes: 256
def calc(x,y):
    n = len(x)
    m = len(y)
    dp1 = [0]*(m+1)
    for i in range(n):
        s = x[i]
        dp2 = dp1[:]
        for j in range(m):
            if s == y[j]:
                dp1[j+1] = dp2[j]+1
            elif dp1[j+1] < dp1[j]:
                dp1[j+1] = dp1[j]
    return dp1[-1]

q = int(input())
ans = []
for i in range(q):
    x = input()
    y = input()
    print(calc(x,y))


Measured memory_bytes: 5624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  rep(k,450){
    if(k*(k-1)/2==n){
      cout << "Yes" << endl;
      cout << k << endl;
      vector<vector<int> > v(k,vector<int>(0));
      int cnt=0;
      rep(i,k){
        for(int j=i+1;j<k;j++){
          cnt++;
          v[i].emplace_back(cnt);
          v[j].emplace_back(cnt);
        }
      }
      rep(i,k){
        cout << v[i].size() << " ";
        rep(j,v[i].size()){
          cout << v[i][j] << " ";
        }cout << endl;
      }
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 2304
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)

print(' '.join(map(str, [x3, y3, x4, y4])))


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];
    sort(all(h));
    ll ans = MOD;
    rep(i, 0, n - k + 1) ans = min(ans, abs(h[i] - h[i + k - 1]));
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp1[5010][5010]={0};
int dp2[5010][5010]={0};
int main(){
	string s;
	cin>>s;
	if(s[0]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}











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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,W; cin>>n>>W;
	vector<int>w(n),v(n);
	for(int i=0;i<n;++i){
		cin>>w.at(i)>>v.at(i);
	}
	vector<vector<int64_t>>dp(n+1,vector<int64_t>(W+1));
	dp.front().front()=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<=W;++j){
			if(j<w.at(i))dp.at(i+1).at(j)=dp.at(i).at(j);
			else dp.at(i+1).at(j)=max(dp.at(i).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
		}
	}
	cout<<dp.back().back()<<"\n"s;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<int> las(20,-1);
    long long res = 0;
    int l = 0;
    for (int r = 0; r < n; r++) {
        int x = a[r];
        for (int i = 0; i < 20; i++) {
            if (x & (1<<i)) {
                l = max(l, las[i]+1);
                las[i] = r;
            }
        }
        res += r-l+1;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC087C - Candies
int main(){
  int N;
  cin >> N;
  VECTOR_DIM2(int, a, 2, N, INT_MAX);
  rep(i,2){
    rep(j,N){
      cin >> a[i][j];
    }
  }

  int maxNum = 0;
  for (int n = 0; n < N; ++n) { // どこで下の列に降りるか
    int i = 0;
    int num = 0;
    for (int j = 0; j < N; ++j) {
      num += a[i][j];
      if (j == n) { // 降りる
        i = 1;
        num += a[i][j];
      }
      //cout << "n=" << n << ",j=" << j << ",num=" << num << endl;
    }
    if (maxNum < num) {
      maxNum = num;
    }
  }

  cout << maxNum << endl;
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll M,D; cin >> M >> D;
    for(ll d = 10; d <= D; d++){
        string sd = to_string(d);
        if(sd[0] < '2' || sd[1] < '2') continue;
        ll m = (d%10) * (d/10);
        if(m <= M)  res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  int N, Q;
  string S;
  
  cin >> N >> Q;
  cin >> S;
  
  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; i++){
    cin >> l[i] >> r[i];
  }
  
  vector<int> sum(N + 1, 0);
  
  for (int i = 0; i < N - 1; i++) {
    sum[i + 1] = sum[i];
    if (S[i] == 'A' && S[i + 1] == 'C'){
      sum[i + 1]++;
    }
  }
  
  for (int i=0; i<Q; i++){
    int ans = sum[r[i]-1] - sum[l[i]-1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#define rep(i, n) for (int i=0; i<(n); i++)
#define ll long long
using namespace std;

int main() {
  string S; cin>>S;
  int n=S.size();
  int P=2019;
  vector<ll> val(P, 0);
  ll tenfactor=1;
  ll cur=0;
  val[cur]++;
  rep(i, n) {
    cur=(cur+(S[n-i-1]-'0')*tenfactor)%P;
    tenfactor=(tenfactor*10)%P;
    val[cur]++;
  }
  ll res=0;
  rep(p, P) res+=val[p]*(val[p]-1)/2;
  cout<<res<<endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int n, m;
vector<int> e[50];

bool judge(int a,int b){
  bool checked[50];
  fill(checked, checked + 50, false);
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int x = q.front();
    q.pop();
    checked[x] = true;
    for(int y : e[x]){
      if(checked[y]) continue;
      if((x == a && y == b)|| (x == b && y == a)) continue;
      q.push(y);
      
    }
  }
  for(int i = 0; i < n; i++) if(!checked[i]) return true;
  return false;
}

int main(){
  cin >> n >> m;
  P p[50];
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    e[a].push_back(b); e[b].push_back(a);
    p[i] = P(a, b);
  }
  int ans = 0;
  for(int i = 0; i < m; i++){
    if(judge(p[i].first, p[i].second)) ans++;
  }
  cout << ans <<endl;
}
  

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int i,j,n,temp;
	int data[10];
	n = 1;
	for(i=0; i<10; i++){
		n++;
		scanf("%d",&data[i]);
	}

	for(i=0; i<9; i++){
		for(j=i+1; j<10; j++){
			if(data[i] > data[j]){
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}

	}

		printf("%d\n",data[9]);
		printf("%d\n",data[8]);
		printf("%d\n",data[7]);
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    ll ans = 0;
    REP(i, N) {
        if (S[i] != S[N - 1 - i]) {
            ans++;
            S[i] = S[N - 1 - i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String s = br.readLine();
    int max = 0;
    
    for(int i = 1; i < n; i++) {
      String b = s.substring(i);
      int value = s.substring(0, i).chars().distinct().map(x -> {
        if(b.indexOf(x) != -1) {
          return 1;
        }
        else {
          return 0;
        }
      }).sum();
      
      max = Math.max(max, value);
    }
    
    System.out.println(max);
  }
}


Measured memory_bytes: 27604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> ii;
typedef std::pair<int, ii> iii;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ii> vii;
typedef std::vector<iii> viii;
const int INF=10000000;
#define pb(a) push_back(a)
#define m0(x) memset(x,-1,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define all(x) (x).begin(), (x).end()
const ll mod=1e9+7;
int N,mingroup,maxgroup,minsize,maxsize;
ll factorial[1005];
ll rfactorial[1005];

ll pow(ll a, ll b){
  if (b==0) return 1;
  else if (b%2==0) {
    ll temp=pow(a,b/2);
    return (temp*temp)%mod;
  }
  else {
    return (a*pow(a,b-1))%mod;
  }
}

void start(){
  ll temp=1;
  factorial[0]=1;
  for (int i=1; i<=1000; i++){
    temp=(temp*i)%mod;
    factorial[i]=temp;
  }
}





ll inverse(ll curr){
  return pow(curr,mod-2);
}

ll memo[1001][1001];


ll DP(ll remaining, ll current){
  //cerr<<remaining<<" "<<current<<endl;
  if (remaining==0) return 1;
  else if (remaining<0 or current>maxgroup) return 0;
  else {
    if (memo[remaining][current]==-1){
      ll ans=DP(remaining,current+1);
      
      for (ll i=minsize; i<=maxsize and i*current<=remaining; i++){
          
          ll num=factorial[remaining];
          ll denom=(pow(factorial[current],i)*factorial[remaining-i*current])%mod;
          denom=(denom*factorial[i])%mod;
          denom=inverse(denom);

          ll temp=DP(remaining-i*current,current+1);
          temp=(temp*num)%mod;
          temp=(temp*denom)%mod;

          ans=(ans+temp+mod)%mod;
          //ans=(ans+DP(remaining-i*current,current+1))%mod;
        
      }
      memo[remaining][current]=ans;

    }
    return memo[remaining][current];
  }





}




int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  start();
  m0(memo);
  cin >> N >> mingroup >> maxgroup >> minsize >> maxsize;
  cout<<DP(N,mingroup)<<endl;

  

  



}


Measured memory_bytes: 8192
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int m, min, max; m = in(), min = in() - 1, max = in();) {
		vector<int> v(m), w;
		for (int &p: v)
			p = in();
		int j = 0;
		for (int i = min, m = 0; i < max; i++) {
			int t = v[i] - v[i + 1];
			if (t >= m) {
				j = i;
				m = t;
			}
		}
		outl(j + 1);
	}
}


Measured memory_bytes: 2636
#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 int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    map<string,int> mp;
    int mx = -1;
    REP(i,n){
        string s;
        cin>>s;
        mp[s]++;
        chmax(mx, mp[s]);
    }

    for(auto& e : mp){
        if(e.second==mx) cout<<e.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 23808
s = gets.chomp
n = gets.to_i
lr = 0
op = "+"
s.each_char do |c|
    if c == "+" || c == "*"
        op = c
    else
        if op == "+"
            lr += c.to_i
        else
            lr *= c.to_i
        end
    end
end
while s.include?("*")
    opi = s.index("*")
    l = opi - 1
    while s[l - 1] =~ /[0-9]/ && l > 0
        l -= 1
    end
    r = opi + 1
    while s[r + 1] =~ /[0-9]/ && r < s.length - 1
        r += 1
    end
    rep = (s[l..(opi - 1)].to_i * s[(opi + 1)..r].to_i).to_s
    s[l..r] = rep
end
ma = s.split("+").map(&:to_i).inject(:+)
if n == lr
    puts "L" if n != ma
    puts "U" if n == ma
else
    puts "I" if n != ma
    puts "M" if n == ma
end

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

using namespace std;

using ll = long long;

const int mod = 924844033, N = (int)2e3 + 5;
int n, K, f[N][N][4], dp[N], fact[N];

int add(int _a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
    return _a;
}
int sub(int _a, int _b) { return add(_a, mod - _b); }
int mul(int _a, int _b) { return (int)((ll)_a * _b % mod); }

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

    fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = mul(fact[i - 1], i);

    dp[0] = 1;
    for (int r = 0; r < K; ++r) {
        for (int i = 0; i <= n; ++i) f[r][i][0] = dp[i];
        for (int u = r; ; u += K) {
            if (u + K >= n) {
                for (int i = 0; i <= n; ++i) {
                    dp[i] = 0;
                    for (int mask = 0; mask < 4; ++mask) dp[i] = add(dp[i], f[u][i][mask]);
                }
                break ;
            }
            for (int i = 0; i <= n; ++i) {
                for (int mask = 0; mask < 4; ++mask) if (f[u][i][mask]) {
                    for (int nMask = 0; nMask < 4; ++nMask) if (!( (mask >> 1) & nMask) && !( (nMask >> 1) & mask) ) {
                        f[u + K][i + __builtin_popcount(nMask)][nMask] = add(f[u + K][i + __builtin_popcount(nMask)][nMask], f[u][i][mask]);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (i & 1) ans = sub(ans, mul(fact[n - i], dp[i]) );
        else ans = add(ans, mul(fact[n - i], dp[i]) );
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 62848
pypy -cn,a,b="`tr \  ,`
m=10**9+7
def c(x,r=1):
 for i in range(x):r=r*(n-i)*pow(i+1,m-2,m)%m
 return r
print(pow(2,n,m)-1-c(a)-c(b))%m"

Measured memory_bytes: 90160