akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T, class = enable_if_t<is_integral<T>::value, T>>int size(T a) { return a; }
#define REP(t,a,N)for(int t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(int t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)(a).begin(),(a).end()
typedef long long ll;
typedef unsigned long long ull;
void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  int n, l;
  in, n, l;
  auto s = in.Array<string>(n);
  sort(all(s));
  string ans;
  for (auto& i : s) {
    ans += i;
  }
  cout << (ans) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	ll n = 0, ar[10000] = {};
	ll count = 0;
	std::cin >> n;
	rep(i, n) {
		std::cin >> ar[i];
		count += ar[i];
	}
	std::sort(ar, ar + n,std::greater<int>());
	std::cout << ar[n - 1] << " " << ar[0] << " " << count << std::endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    double r, g;
    cin >> r >> g;


    cout << (g * 2) - r << endl;
}


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

int32_t main(){

	int n,k;
	cin>>n>>k;
	int array[n];
	REP(i,n)cin>>array[i];
	sort(array, array+n, greater<int>());
	if(k>=n)cout<<0;
	else{
	REP(i,k)array[i] = 0;
	int ans=0;
	REP(i,n)ans+=array[i];
	cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 1792
/*input
27
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k - 1];

    return 0;
}

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


string ans;

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

    while(n != 0){
        long long r = n % 2;
        if(r < 0) r += 2;

        n = (n-r)/(-2);
        ans += ('0'+r);
    }

    reverse(ans.begin(), ans.end());

    if(ans == ""){
        ans = "0";
    }

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

Measured memory_bytes: 3608
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = a[i];
  }
  ll ans = INFLL;
  for (int k = 0; k <= 2 * n; k++) {
    ll cur = 0;
    for (int i = 0; i < n; i++) {
      int p = i - k;
      while (p < 0) {
        p += n;
      }
      dp[i] = min(dp[i], a[p]);
      cur += dp[i];
    }
    ans = min(ans, cur + 1LL * k * x);
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    if (s == "SUN")
        cout << 7 << "\n";
    else if (s == "MON")
        cout << 6 << "\n";
    else if (s == "TUE")
        cout << 5 << "\n";
    else if (s == "WED")
        cout << 4 << "\n";
    else if (s == "THU")
        cout << 3 << "\n";
    else if (s == "FRI")
        cout << 2 << "\n";
    else if (s == "SAT")
        cout << 1 << "\n";
    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int point[33];
  int out[33];
  for(int i=0;i<33;i++){
    point[i]=0;
    out[i]=0;
  }
  int first=0;
  int second=0;
  int third=0;
  int number=0;
  char input[10];
  for(int i=0;i<n;i++){
    while(out[i]<3){
      cin>>input;
      if(strcmp(input,"HIT")==0){
	if(third==1){
	  point[i]++;
	}
	if(second==1){
	  third=1;
	}
	if(first==1){
	  second=1;
	}
	first=1;
      }
      if(strcmp(input,"HOMERUN")==0){
	int number=0;
	if(first==1){
	  number++;
	}
	if(second==1){
	  number++;
	}
	if(third==1){
	  number++;
	}
	point[i]+=(number+1);
	first=0;second=0;third=0;
      }
      if(strcmp(input,"OUT")==0){
	out[i]++;
      }
      if(out[i]==3){
	first=0;second=0;third=0;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<point[i]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[0] == 5 && a[1] == 5 && a[2] == 7)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 256
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

h1, m1, h2, m2, k = map(int, input().split())
ans = (h2-h1)*60
ans += m2-m1
ans -= k
print(ans)


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

using namespace std;

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=500005;
int n,m,v1[N],x[N],y[N],co[N],ans[N];
pii v2[N];
vector<int> e[N];
void color(int x){
	for (auto i:e[x]) if (!co[i])
		co[i]=co[x]^3,color(i);
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n){
		scanf("%d",&v1[i]);
		v2[i].fi=1ll<<30;
	}
	For(i,1,m){
		scanf("%d%d",&x[i],&y[i]);
		v2[y[i]]=min(v2[y[i]],pii(v1[x[i]],i));
		v2[x[i]]=min(v2[x[i]],pii(v1[y[i]],i));
	}
	For(i,1,n) if (v2[i].fi>v1[i]) return puts("-1"),0;
	For(i,1,m) ans[i]=1000000000;
	For(i,1,n) ans[v2[i].se]=v1[i];
	For(i,1,n) e[x[v2[i].se]].PB(y[v2[i].se]);
	For(i,1,n) e[y[v2[i].se]].PB(x[v2[i].se]);
	For(i,1,n) if (co[i]==0) co[i]=1,color(i);
	For(i,1,n) putchar(co[i]==1?'B':'W');
	puts("");
	For(i,1,m) printf("%d\n",ans[i]);
}

Measured memory_bytes: 30208
#include <iostream>

using namespace std;

int main(void) {
	char a,b;
	cin >> a >> b;
	if (a > b) {
		cout << ">" << endl;
	}
	else if (a < b) {
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

q = list(range(1, N+1))

for i, (x, y) in enumerate(zip(p, q)):
    if x != y:
        if p[x - 1] != (i + 1):
            print("NO")
            quit()
        _ = p[x - 1]
        p[x - 1] = x
        p[i] = _
        break

for i, (x, y) in enumerate(zip(p, q)):
    if x != y:
        print("NO")
        quit()


print("YES")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

  char s[11];
  scanf("%s", s);
  if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    a_max = max(a)
    a_min = min(a)
    if a_max - a_min > 1:
        return print("No")
    elif a_max == a_min:
        if 1 <= a_min <= n // 2 or a_min == n - 1:
            return print("Yes")
        else:
            return print("No")
    else:
        c_min = a.count(a_min)
        c_max = a.count(a_max)

        if 1 <= a_max - c_min <= c_max // 2:
            return print("Yes")
        else:
            return print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 84300
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    max = Math.max(max, arr[i]);
		}
		int maxValue = -1;
		int maxNum = 0;
		for (int i = 0; i < n; i++) {
		    if (arr[i] == max) {
		        continue;
		    }
		    int value = Math.min(arr[i], max -arr[i]);
		    if (maxValue < value) {
		        maxValue = value;
		        maxNum = arr[i];
		    }
		}
	    System.out.println(max + " " + maxNum);
   }
}




Measured memory_bytes: 50160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AEroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int min = Integer.MAX_VALUE;
            int max = -1;

            for (int i = 0; i < n; i++) {
                int tmp = in.nextInt();
                max = Math.max(max, tmp);
                min = Math.min(min, tmp);
            }

            out.println(max - min);
        }

    }
}



Measured memory_bytes: 21716
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

l = [k for k in d if d[k] >= 2]
l.sort(reverse=True)

if len(l) == 0:
    print(0)
elif d[l[0]] >= 4:
    print(l[0] * l[0])
elif len(l) == 1:
    print(0)
else:
    print(l[0] * l[1])


Measured memory_bytes: 17960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 文字列の入力
            string s = Console.ReadLine();

            Console.WriteLine(s.Replace("2017", "2018"));
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define mod 1000000007
#include<numeric>
using namespace std;
int gcd(int a, int b)
{if (a % b == 0)	return(b);
	else return(gcd(b, a % b));}
int lcm(int a, int b)
{return a * b / gcd(a, b);}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000,s = 1;
	rip(i, 30000)s = (s * a) % mod;ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	ll a,b;
	cin >> a >> b;
	if (a < b)cout << "a < b" << endl;
	else if (a == b)cout << "a == b" << endl;
	else cout << "a > b" << endl;
}


Measured memory_bytes: 3096
n = int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    x[i][1] = int(x[i][1])
    x[i].append(i+1)

x.sort(key= lambda a: a[1])
x.reverse()
x.sort(key= lambda b: b[0])

for i in range(n):
    print(x[i][2])

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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < N; ++i) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;

    return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
int n;
int min,max;
cin>>n;
vector<int> R(n);
REP(i,n)cin>>R[i];
max=R[1]-R[0];
min=R[0];
REP(j,n-1){
    max= max>R[j+1]-min? max:R[j+1]-min;
    min= min<R[j+1]? min:R[j+1];
}
cout<<max<<endl;
}


Measured memory_bytes: 3604
import java.io.*
import java.util.*

fun solve(N: Long, d: LongArray){
    val sa = d.sum()
    val sb = d.map{it*it}.sum()
    println((sa * sa - sb)/2)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val d = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        d[i] = sc.next().toLong()
    }
    solve(N, d)
}



Measured memory_bytes: 32292
#include <iostream>

using namespace std;

int count_keta(int i){
    int cnt = 0;
    while(i > 0){
        cnt++;
        i /= 10;
    }
    return cnt;
}

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

    int cnt = 0;
    int i = 1;
    while (i <= N){
        cnt++;
        i++;
        if (count_keta(i) % 2 == 0){
            i *= 10;
        }
        //cout << i << endl;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

void solve(ll n) {
        vector<ll> v(n);
    vector<ll> w{5,7,5,7,7};
    rep(i, n) {
        string s; cin >> s;
        v[i] = s.size();
    }
    rep(i, n) {
        ll j = i;
        vector<ll> need = w;
        try {
            each(c, need) {
                while (c) {
                    if (j >= n) throw 1;
                    c -= v[j++];
                }
            }
            cout << i+1 << endl;
            return;
        }
        catch (int err) {
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) solve(n);
}

Measured memory_bytes: 3180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

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

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) {
        for(int i=0;i<n;++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        return ((par[x] == x) ? x : par[x] = find(par[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, m, x, y, z;
    cin >> n >> m;

    UnionFind uf = UnionFind(n);

    for(int i=0;i<m;++i) {
        cin >> x >> y >> z;
        --x; --y;
        uf.unite(x, y);
    }

    set<int> st;
    for(int i=0;i<n;++i){
        st.insert(uf.find(i));
    }

    cout << st.size() << endl;
}


Measured memory_bytes: 5748
/*
* @author:  liangxianfeng
* @mail: liangxianfeng96@qq.com
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <ctime>

using namespace std;
#define ll long long
#define rep(i,n) for(int i =0; i < n; ++i)
#define repp(i,n,x) for(int i =x; i < n+x; ++i)
#define CLR(x) memset(x,0,sizeof x)
#define MEM(a,b) memset(a,b,sizeof a)
#define pr(x) cout << #x << " = " << x << " ";
#define prln(x) cout << #x << " = " << x <<  endl;
const int MOD = 1e9+7;
const int maxn = 1e5+100;
int x[maxn], y[maxn], c[maxn],d[maxn];
int getd(int a, int b){
	return abs(x[a] - c[b]) + abs(y[a] - d[b]);
}
int main(){
#ifdef LOCAL
    freopen("C:\\Users\\liangxianfeng\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\liangxianfeng\\Desktop\\out.txt","w",stdout);
#endif
    int n, m;
    while(cin >> n >> m){
    	for(int i = 0; i < n; ++i){
    		cin >> x[i] >> y[i];
    	}
    	for(int j = 0; j < m; ++j){
    		cin >> c[j] >> d[j];
    	}
    	for(int i = 0; i < n; ++i)
    	{
    		int ans = 0, dis = getd(i, 0);
    		for(int j = 0; j < m; ++j){
    			if(getd(i, j) < dis){
    				dis = getd(i, j);
    				ans = j;
    			}
    		}
    		cout << ans + 1 << endl;
    	}
    }
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 N;
  cin >> N;
  string s;
  cin >> s;
  REP(i, s.size()) {
    s[i] = (char)((s[i]-'A'+N)%26+'A');
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

v = sorted(v)
avg = 0

#小さい順に計算していく
for i in range(len(v)):
  if i == 0:
    pass
  elif i == 1:
    avg = (v[0]+v[1])/2
  else:
    avg = (avg+v[i])/2
  
print(avg)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{
	ll cost,value;
};

struct Data{
	ll base,limit;
};

int N,M;
Info info[NUM];
Data data[NUM];


int main(){

	scanf("%d %d",&N,&M);

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

		scanf("%lld %lld",&info[i].cost,&info[i].value);
	}

	int index = 0;
	ll tmp_base,tmp_limit,pre_base = -1;

	for(int i = 0; i < M; i++){

		scanf("%lld %lld",&tmp_base,&tmp_limit);
		if(tmp_base == pre_base){

			data[index-1].limit = min(data[index-1].limit,tmp_limit); //一番制約がきついものを残す
		}else{

			data[index].base = tmp_base;
			data[index].limit = tmp_limit;

			index++;
		}
	}

	M = index;

	data[M].base = BIG_NUM;
	data[M].limit = BIG_NUM;

	ll ans = 0;
	priority_queue<ll> Q,TMP;

	//最小制約より小さいものは解に計上
	for(index = 0; index < N && info[index].cost < data[0].base; index++){

		ans += info[index].value;
	}

	int current_limit = BIG_NUM;

	for(int i = 0; i < M; i++){

		if(current_limit > data[i].limit){ //制約が厳しくなるなら、既に条件を満たしているものを解に計上

			if(current_limit != BIG_NUM){

				for(int k = 0; k < (current_limit-data[i].limit) && Q.empty() == false; k++){

					ans += Q.top();
					Q.pop();
				}
			}
			current_limit = data[i].limit;
		}

		//data[i].base <= info[index].cost < data[i+1].baseとなるものをPQにpush
		for(;index < N && data[i].base <= info[index].cost && info[index].cost < data[i+1].base; index++){

			Q.push(info[index].value);
		}
	}

	for(int i = 0; i < current_limit-1 && Q.empty() == false; i++){

		ans += Q.top();
		Q.pop();
	}

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

	return 0;
}



Measured memory_bytes: 7104
#include <stdio.h>

int main(void) {
	int H,W,i;
	char C[101][101];
	scanf("%d%d",&H,&W);
	for(i=1;i<=H;i++){
		scanf("%s",C[i]);
	}
	for(i=1;i<=H;i++){
		printf("%s\n",C[i]);
		printf("%s\n",C[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")  
#define pb push_back
#define F first
#define S second
using ll = long long;
using namespace std;



void solve(){
	     int a;
	     cin>>a;
	     cout<<a*a*a+a*a+a;
	
	






	
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}






Measured memory_bytes: 3572
# 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>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
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))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int x[101010];
int l, q;
int p[30][101010];

int main() {
	cin >> n;
	REP(i, n)cin >> x[i];
	cin >> l;
	x[n] = x[n-1]+1;
	REP(i, n+1) {
		p[0][i] = upper_bound(x, x + n+1, x[i] + l) - 1 - x;
	}
	for (int i = 1; i <= 16;i++) {
		REP(j, n+1) {
			p[i][j] = p[i-1][p[i-1][j]];
		}
	}
	int q;
	cin >> q;
	REP(Q, q) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		if (a > b)swap(a, b);
		int pos = a,ans = 0;
		for (int i = 16; i >= 0; i--) {
			if (p[i][pos] <= b) {
				pos = p[i][pos];
				ans += 1 << i;
			}
		}
		if (pos < b)ans++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define mp unordered_map
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll ct(string s1, list<char>l)
{
    string s2="";
    for(auto it: l)
    {
        s2+=it;
    }
    ll res=0,i;
    for(i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        {
            res++;
        }
    }
    return res;
}

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

     ll n1 = s.length(), n2 =t.length();
     ll i,j;
     list<char>l;

     for(i=0;i<n2;i++)
     {
        l.pb(s[i]);
     }
     ll ans = ct(t,l);

     for(i=n2;i<n1;i++)
     {
         l.pop_front();
         l.pb(s[i]);
         ans = min(ans , ct(t,l));
     }

     cout<<ans<<endl;
}



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

int main()
{
    int n;
    cin >> n;
    string s(n, '0'), t(n, '0');
    cin >> s >> t;
    for (int i =0 ; i < n;i++){
        cout << s.at(i) << t.at(i) ;
    }
        cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a-b < c) cout << c - a + b;
  else cout << 0;
}

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

vector<vector<int>> v =
    {
        {0, 1, 2},
        {3, 4, 5},
        {6, 7, 8},
        {0, 3, 6},
        {1, 4, 7},
        {2, 5, 8},
        {0, 4, 8},
        {2, 4, 6}};

int main()
{
    int a[9];
    rep(i, 9) cin >> a[i];

    int n;
    cin >> n;

    bool exist[9];
    rep(i, 9) exist[i] = false;

    while (n--)
    {
        int b;
        cin >> b;
        rep(i, 9) if (a[i] == b) exist[i] = true;
    }

    for (auto r : v)
    {
        bool yn = true;
        for (auto e : r)
        {
            if (exist[e] == false)
                yn = false;
        }
        if (yn == true)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> s;
    long long ans = 0;
    for (int i=0; i < n; ++i) {
        string t;
        cin >> t;
        sort(t.begin(), t.end());
        if (s.find(t) == s.end()) {
            s[t] = 1;
        }
        else {
            ans += s[t];
            ++s[t];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int n, m, s, g;
vector<int> et[40];
vector<string> ec[40];
string dp[481][40];

int main() {
	int i, j, k;
	
	while (cin >> n >> m >> s >> g) {
		if (!n) break;
		for (i = 0; i < n; i++) { et[i].clear(); ec[i].clear(); }
		for (i = 0; i <= 12 * n; i++) { for (j = 0; j < n; j++) { dp[i][j] = "{"; } }
		for (i = 0; i < m; i++) {
			int a, b; string spell;
			cin >> a >> b >> spell;
			et[a].push_back(b);
			ec[a].push_back(spell);
		}
		
		dp[0][s] = "";
		for (i = 0; i < 12 * n; i++) {
			for (j = 0; j < n; j++) {
				for (k = 0; k < et[j].size(); k++) {
					int v = et[j][k];
					int len = ec[j][k].length();
					if (i + len > 12 * n) continue;
					dp[i + len][v] = min(dp[i + len][v], dp[i][j] + ec[j][k]);
				}
			}
		}
		
		int id = 0;
		for (i = 1; i <= 12 * n; i++) {
			if (dp[id][g] > dp[i][g]) id = i;
		}
		if (id >= 6 * n || dp[id][g] == "{") { cout << "NO" << endl; }
		else { cout << dp[id][g] << endl; }
	}
	return 0;
}

Measured memory_bytes: 11724
S = input()

def dfs(op):
    if len(op) == 3:
        res = int(S[0])
        for i in range(3):
            if op[i] == "+":
                res += int(S[i+1])
            elif op[i] == "-":
                res -= int(S[i+1])
        if res == 7:
            formula = S[0]
            for i in range(3):
                formula += op[i] + S[i+1]
            formula += "=7"
            return formula
        else:
            return ""
    
    s1 = dfs(op + "+")
    s2 = dfs(op + "-")
    if len(s1) > len(s2):
        return s1
    else:
        return s2

print(dfs(""))


Measured memory_bytes: 3064
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld a, b, c;
    cin >> a >> b >> c;
    ld d = 2.000 * sqrt(a * b);
    if (a + b + d < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=3010,mod=998244353;
int n,m;
long long f[N][N];
#define add(x,y) (x+y>=mod?x+y-mod:x+y)
#define sub(x,y) (x-y<0?x-y+mod:x-y)
inline long long po(long long x,long long y)
{
    long long u=1ll;
    while(y)
    {
        if(y&1) (u*=x)%=mod;
        (x*=x)%=mod;
        y>>=1;
    }
    return u;
}
int main()
{
    int x,y;
    scanf("%d%d%d%d",&x,&y,&n,&m);
    long long inv=po(2,mod-2);
    for(int k=x;k<=n;k++)
    {
        for(int i=y;i<=m;i++)
        {
            if(k==x&&i==y) f[k][i]=1ll;
            else f[k][i]=sub(add(f[k-1][i]*i%mod,f[k][i-1]*k%mod),f[k-1][i-1]*(k-1)%mod*(i-1)%mod);
        }
    }
    printf("%lld\n",f[n][m]);
}


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

int main()
{
	string S;

	cin >> S;
	int ans = 700;

	for (int i = 0; i < 3; i++)
		if (S[i] == 'o')ans += 100;

	cout << ans << endl;

	return 0;
}

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

int main() {
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);
	set<int> st;
	for(int i = a; i < a + k; i++) {
		st.insert(i);
	}
	for(int i = b - k + 1; i <= b; i++) {
		st.insert(i);
	}
	for(auto itr = st.begin(); itr != st.end(); itr++) {
		if(*itr >= a && *itr <= b) {
			printf("%d\n", *itr);
		}
	}
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
mod=998244353
ma=[1]
for i in range(1,k+1):
    mad=ma[-1]*(n-i)*pow(i,mod-2,mod)
    ma.append(mad)
    ma[-1]%=mod
ans=0
for i in range(k+1):
    ans+=ma[i]*m*pow(m-1,n-i-1,mod)
    ans%=mod
print(ans)

Measured memory_bytes: 16912
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<List<Integer>> numList = args.stream().skip(1)
                    .map(s -> Arrays.stream(s.split(" ")).map(Integer::valueOf).collect(Collectors.toList()))
                    .sorted(Comparator.comparingInt(o -> o.get(1)))
                    .collect(Collectors.toList());
            int curr = 0;
            boolean ans = true;
            for (List<Integer> intPair: numList) {
                int load = intPair.get(0);
                int deadline = intPair.get(1);
                if (curr + load <= deadline) {
                    curr += load;
                } else {
                    ans = false;
                    break;
                }
            }
            System.out.println(ans ? "Yes" : "No");
        };
    }

}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
    
    int n;cin>>n;
    vs s(n);
    rep(i,n){
        cin>>s[i];
    }
    int m;cin>>m;
    vs t(m);
    rep(i,m)cin>>t[i];
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    
    int b=0;
    int ans=0;
    while(b<n){
        int tmp=1;
        while(b+1<n){
            if(s[b]==s[b+1]){
                b++;
                tmp++;
            }else{
                break;
            }
        }
        rep(i,m){
            if(s[b]==t[i])tmp--;
        }
        if(ans<tmp)ans=tmp;
        b++;
    }
    cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N,M;cin>>N>>M;
    std::vector<int> v(M);
    for(int i=0; i<N; i++){
      int K; cin>>K;
      for(int j=0; j<K; j++){
        int A; cin>>A;
        v[--A]++;
      }
    }
    int cnt=0;
    for(int i=0; i<M;i++){
      if(v[i]==N) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
# Date [ 2020-08-11 10:50:12 ]
# Problem [ test.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from collections import Counter
import bisect;   from itertools import combinations

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = int(input())
    print((n - 2) * 180)

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 9864
import itertools as itl

N=int(input())
d_i=(int(x) for x in input().split())
c_list=list(itl.combinations(d_i,2))

sum=0
for i in range(0,len(c_list)):
  d=c_list[i][0]*c_list[i][1]
  sum += d

print(sum)

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

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

using namespace std;

using int64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  const int mx = n * 1000;
  vector<int> dp(mx + 1, w + 1);
  dp[0] = 0;
  while (n--) {
    int x, y;
    cin >> x >> y;
    for (int i = mx; i >= y; i--) {
      dp[i] = min(dp[i], dp[i - y] + x);
    }
  }
  for (int i = mx; ~i; i--) {
    if (dp[i] <= w) {
      cout << i;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <bitset>
#include <iostream>
#include <algorithm>

const int N=4005,P=998244353;
int n,m,Ans,h[N],p,Fl;
std::bitset<N> a,b,c;

int main()
{
    std::cin>>n>>a;
    for(int i=1;i<=n;++i)
        for(std::cin>>c;c.any();std::swap(b,c))
        {
            for(p=4000;;--p)if(c[p])break;
            for(int j=4000;j>=p;--j)if(b[j])b^=c<<(j-p);
        }
    for(p=4000;;--p)if(b[p])break;
    c=a,h[0]=Fl=1;
    for(int i=1;i<=4000;++i)h[i]=(h[i-1]<<1)%P;
    for(int i=p;i<=4000;++i)if(a[i])Ans=(Ans+h[i-p])%P;
    for(int i=4000;i>=p;--i)if(a[i])a^=b<<(i-p);
    for(int i=p;i>=0;--i)if(a[i])Fl=c[i],i=0;
    printf("%d\n",(Ans+Fl)%P);
    return 0;
}


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

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, m;
    cin >> n >> m;
    VE a(n);
    REP(i, n) cin >> a[i];
    VE sum(n + 1, 0);
    rep(i, 1, n + 1) sum[i] = sum[i - 1] + a[i - 1];
    jkl;
    map<ll, ll> mp;
    REP(i, n + 1) mp[sum[i] % m]++;
    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second < 2)continue;
        ans += itr->second * (itr->second - 1) / 2;
    }
    print(ans);
}


Measured memory_bytes: 5760
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
days(int y, int m, int d)
{
	static const int md[12] = {0, 31, 59, 90,120,151,181,212,243,273,304,334};

	int y1 = y - 1;
	int u = y1 * 365 + md[m - 1] + d + (y1 / 4 - y1 / 100 + y1 / 400);
	if (m >= 3 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
		u++;

	return u;
}

int
main(int argc, char **argv)
{
	int y2, m2, d2;
	int y1, m1, d1;

	while (true)
	{
		scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
		if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0)
			break;

		printf("%d\n", days(y2, m2, d2) - days(y1, m1, d1));
	}

	return 0;
}

Measured memory_bytes: 1656