akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N, T;
    static int[] t;

    static void input()
    {
        cin = new Scanner();

        N = cin.nextInt();
        T = cin.nextInt();

        t = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        int endTime = T;
        int currentTime = 0;
        long ans = 0;
        int i = 0;
        while(i < N)
        {
            if(endTime >= t[i])
            {
                endTime = t[i] + T;
            }
            else
            {
                ans += endTime - currentTime;
                currentTime = t[i];
                endTime = t[i] + T;
            }
            i++;
        }
        ans += endTime - currentTime;
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 31876
n = int(input())

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;


int main(){
    
    ll N, K ;
    cin >> N >> K;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    vector<ll> cnt(N, -1);
    ll next = 0;
    ll times = 0;
    ll loop_start = 0;
    ll loop_end = 0;
    while (true){
        //cout << next << endl;

        if(cnt[next] != -1){
            loop_start = cnt[next];
            loop_end = times;
            break;
        }

        cnt[next] = times;
        times ++;
        
        next = v[next] - 1;

    }
    
    if(DEBUG){
        cout << "times = " << times << endl;
        for(int i = 0; i < N; i++){
            cout << cnt[i] << endl;
        }
        cout << endl;
    }


    if(K <= loop_start){
        for(int i = 0; i < N; i++){
            if(  K == cnt[i] ){
                cout << i + 1 << endl;
                return 0;
            }
        }
    }

    K -= loop_start;
    K %= (loop_end - loop_start);

    for(int i = 0; i < N; i++){
        cnt[i] -= loop_start;
        if(loop_start < 0) continue;
        if(  K == cnt[i] ){
            cout << i + 1 << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 6428
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> x[n];
    for (ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        x[a-1].push_back(b-1);
        x[b-1].push_back(a-1);
    }
    ll visited[n];
    fill(visited,visited+n,INF);
    queue<ll> que;
    que.push(0);
    visited[0]=0;
    while(!que.empty()){
        ll c=que.front();
        if (c==n-1){
            break;
        }
        que.pop();
        for (ll i=0;i<x[c].size();i++){
            if (visited[x[c][i]]==INF){
                que.push(x[c][i]);
                visited[x[c][i]]=min(visited[c]+1,visited[x[c][i]]);
            }
        }
    }
    if (visited[n-1]==2){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] int_input = new int[input.Length];
            for(int i = 0; i < input.Length; i++)
            {
                int_input[i] = int.Parse(input[i]);
            }

            //int_input[3] = k
            Console.WriteLine(output(int_input));
            Console.Read();

        }

        public static int output(int[] x)
        {
            int print = 0;
            int count = x[3];
            if(count < x[0] || count - x[0] < x[1])
            {
                print = 1 * count;
            }else
            {
                count = count - x[0] - x[1];
                print = (1 * x[0]) + (-1 * count);
            }
            return print;
        }
    }
}


Measured memory_bytes: 27540
#include<cstdio>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
bool chk(long long A,long long B,long long C,long long D){
	if(B>A||D<B)return 0;
	long long g=gcd(B,D),t=A+B-C-1;
	if(t<0&&t%g!=0)t=t/g-1;
	else t/=g;
	return A-g*t>=0;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
		long long A,B,C,D;
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		puts(chk(A,B,C,D)?"Yes":"No"); 
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::vector<long> a;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	a.resize(n, 0);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a[i];
#else
		std::cin >> a[i];
#endif
	}

	a.erase(std::unique(a.begin(), a.end()), a.end());

	if(!a.empty()){
		std::cout << a[0];
		for(int i = 1; i < a.size(); i++){
			std::cout << " " << a[i];
		}
		std::cout << std::endl;
	}

	return 0;
}



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

int main(){
    int m, h;
    char cards[256], temp[256], result[256];
    int i, j=0, len;

    while(1){
        scanf("%s", cards);
        len=strlen(cards);
        if(strcmp(cards, "-")==0&&len==1)break;
        scanf("%d", &m);
        for(;m>0;m--){
            scanf("%d", &h);
            strcpy(temp, cards);
            for(i=0;i<h;i++){
                cards[len-h+i]=temp[i];
            }
            for(i=0;i<len-h;i++){
                cards[i]=temp[i+h];
            }
        }
        for(i=0;i<len;i++){
            result[j++]=cards[i];
        }
        result[j++]='\n';
    }
    result[j]='\0';
    printf("%s", result);

    return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
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 long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    ll h,w;cin>>h>>w;
    if(h%3==0||w%3==0){
        cout<<0<<endl;
    }
    else{
        ll ans = min(h,w);
        //cout<<ans<<endl;
        REP(m,1,h){
            ll hm=h+m;
            ll mw = m*w;
            ll k1 = mw%hm;
            ll k2 = hm-k1;
            ll n1 = (mw-k1)/hm;
            ll hmwn1 = (h-m)*(w-n1);
            ll n2 = (mw+k2)/hm;
            ll hmwn2 =(h-m)*(w-n2);
            ll hn1 = h*n1;
            ll hn2 =h*n2;
            ll mwn1 =m*(w-n1);
            ll mwn2 =m*(w-n2);
            if(0<hmwn1&&(hn1<=hmwn1&&hmwn1<=mwn1)){
                chmin(ans,k1);
            }
            if(0<hmwn2&&(mwn2<=hmwn2&&hmwn2<=hn2)){
                chmin(ans,k2);
            }
          //cout<<k1<<k2<<" "<<ans<<endl;
        }
      //cout<<ans<<endl;
        REP(m,1,w){
            ll hm=w+m;
            ll mw = m*h;
            ll k1 = mw%hm;
            ll k2 = hm-k1;
            ll n1 = (mw-k1)/hm;
            ll hmwn1 = (w-m)*(h-n1);
            ll n2 = (mw+k2)/hm;
            ll hmwn2 =(w-m)*(h-n2);
            ll hn1 = w*n1;
            ll hn2 =w*n2;
            ll mwn1 =m*(h-n1);
            ll mwn2 =m*(h-n2);
            if(0<hmwn1&&(hn1<=hmwn1&&hmwn1<=mwn1)){
                chmin(ans,k1);
            }
            if(0<hmwn2&&(mwn2<=hmwn2&&hmwn2<=hn2)){
                chmin(ans,k2);
            }
            //cout<<k1<<k2<<" "<<ans<<endl;
        }
        cout<<ans<<endl;
    }
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    vector<int> score = { R, S, P };
    vector<vector<int>> t(K);
    for (int i = 0; i < N; i += K) {
        for (int j = 0; j < K; ++j) {
            if (i + j >= N) continue;
            if (T[i + j] == 'r') t[j].push_back(0);
            if (T[i + j] == 's') t[j].push_back(1);
            if (T[i + j] == 'p') t[j].push_back(2);
        }
    }
    int ans = 0;
    for (int i = 0; i < K; ++i) {
        int n = t[i].size();
        vector<vector<int>> dp(n + 1, vector<int>(3, 0));
        for (int j = 1; j <= n; ++j) {
            for (int k = 0; k < 3; ++k) {
                dp[j][k] = max(dp[j - 1][(k + 1) % 3], dp[j - 1][(k + 2) % 3]);
                if ((t[i][j - 1] + 2) % 3 == k) dp[j][k] += score[k];
            }
        }
        ans += max({dp[n][0], dp[n][1], dp[n][2]});
    }
    cout << ans << endl;
}


Measured memory_bytes: 6216
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
s = input().strip()
t = input().strip()

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

def cond(candidate):
    count = gcd(n, m)
    n_step = n // count
    m_step = m // count

    for i in range(count):
        if s[n_step * i] != t[m_step * i]:
            return False
    return True

candidate = lcm(n, m)

if cond(candidate):
    print(candidate)
else:
    print(-1)


Measured memory_bytes: 64008
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int a1[110];
int a2[110];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a1[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a2[i];
    }

    int m = 0;

    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j <= i; j++) {
            c += a1[j];
        }
        for (int j = i; j < n; j++) {
            c += a2[j];
        }
        m = max(c, m);
    }
    cout << m << endl;
}


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

int main() {
  int N;
  cin >> N;
  int ichi, jyu, hyaku, sen;
  ichi = N % 10;
  jyu = ((N % 100) - ichi) / 10;
  hyaku = ((N % 1000) - (jyu * 10) - ichi) / 100;
  sen = (N - (hyaku * 100) - (jyu * 10) - ichi) / 1000;
  if (ichi == jyu && ichi == hyaku && ichi == sen) {
    cout << "Yes" << endl;
  }
  else if (ichi == jyu && ichi == hyaku) {
    cout << "Yes" << endl;
  }
  else if (jyu == hyaku && jyu == sen) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

long long inversionNumber(const vector<int>& v)
{
    int n = v.size();
    vector<pair<int, int> > p(n);
    for(int i=0; i<n; ++i)
        p[i] = make_pair(v[i], i);
    sort(p.rbegin(), p.rend());

    BinaryIndexedTree bit(n);
    long long ans = 0;
    for(int i=0; i<n; ++i){
        ans += bit.sum(p[i].second);
        bit.add(p[i].second, 1);
    }
    return ans;
}

int solve(const vector<int>& a)
{
    int n = a.size();
    int left = *min_element(a.begin(), a.end());
    int right = *max_element(a.begin(), a.end()) + 1;
    while(right - left > 1){
        int mid = (left + right) / 2;
        vector<int> b(n+1, 0);
        for(int i=0; i<n; ++i){
            b[i+1] = b[i];
            if(mid <= a[i])
                ++ b[i+1];
            else
                -- b[i+1];
        }

        if(inversionNumber(b) > n * (n + 1LL) / 4)
            right = mid;
        else
            left = mid;
    }
    return left;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    cout << solve(a) << endl;

    return 0;
}


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

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < s.length() / 2; i++) {
		if (s.at(i) != s.at(s.length() - 1 - i))ans++;
	}
	cout << ans << endl;
}

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 whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<int> num(n);
            num[0] = 0;
            int ans = 0;
            REP(i, n - 1) num[i + 1] += num[i] + (i + 1);
            REP(i, n){
                REP(j, i){
                    if(num[i] - num[j] == n) ans++;
                }
            }
            cout <<  ans << endl;
        }
    }    
}


Measured memory_bytes: 3116
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
ans=1
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+1 if t[-1]-x>k else ans)

Measured memory_bytes: 7384
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int kiyaku(int n) {
	int ans = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			if (n%i == 0) {
				ans /= i;
				ans *= (i - 1);
			}
		}
	}
	return ans;
}
/*Library End!*/
int n, a[100005], b[100005], c[100005],bb[100005],ans;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++)cin >> c[i];
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	bb[0] = n - (upper_bound(c, c + n, b[0]) - c);
	for (int i = 1; i < n; i++) {
		bb[i] = n - (upper_bound(c, c + n, b[i]) - c);
		bb[i] += bb[i - 1];
	}
	for (int i = 0; i < n; i++) {
		ans += bb[n - 1] - bb[upper_bound(b, b + n, a[i]) - b - 1];
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void)
{
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=1; i<=T; i++)
    {
        scanf("%lld ",&n);
        if(i==1)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    
    vector<pair<int,int>> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i].first >> arr[i].second;
    }

    sort(arr.begin(), arr.end());

    int ans = arr[n - 1].first + arr[n - 1].second;

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int i, j, H, W;

  while(1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) {
      break;
    }
    for ( i = 1; i <= H; i++) {
      for ( j = 1; j <= W; j++) {
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  };
  
  return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
using namespace std;
#define int long long
typedef pair<int,int> pii;

const int M = 10000;
vector<pii> a[M];
bool used[M]={};
int v,e;

main(){
	cin>>v>>e;
	for(int i=0;i<e;i++)
	{
		int s,t,w;
		cin>>s>>t>>w;
		a[s].push_back(pii(w,t));
		a[t].push_back(pii(w,s));
	}
	priority_queue< pii,vector<pii>,greater<pii> > que;
	que.push(pii(0,1));
	int ans=0;
	while(!que.empty())
	{
		pii now=que.top();que.pop();
		if(used[now.second])continue;
		ans+=now.first;
		used[now.second]=true;
		for(int i=0;i<a[now.second].size();i++)
		{
			que.push(a[now.second][i]);
		}
	}
	cout<<ans<<endl;
	
}

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

int main(void){
  int n,k,d;
  int i,j,sum=0,c[102]={0};
  int s[102];
  
  scanf("%d %d", &n,&k);
  
  for(i=1;i<=k;i++){
    scanf("%d", &d);
    for(j=1;j<=d;j++){
      scanf("%d", &s[j]);
      c[s[j]]++;
    }
//    for(j=1;j<=d;j++){
//      if(s[j]==j)c[j]++;
//    }

  }
  
  for(i=1;i<=n;i++){
    if(c[i]==0)sum++;
  }
  printf("%d", sum);
  
  return 0;
}

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

int r[105];
int c[105];
int cache[105][105];

int f(int a, int b) {
    if (a == b) return 0;
    if (cache[a][b] == -1) {
        cache[a][b] = 2000000000;
        for (int i = a; i < b; i++) {
            int res = f(a, i) + f(i + 1, b) + r[a] * c[i] * c[b];
            if (res < cache[a][b]) cache[a][b] = res;
        }
    }
    return cache[a][b];
}

int main(void) {
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) scanf("%d %d",&r[i], &c[i]);
    memset(cache, -1, sizeof(cache));
    printf("%d\n",f(0,n-1));
}



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

int main() {
    int h, w;
    cin >> h >> w;
    char A[100][100];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> A[i][j];
        }
    }

    set<int> R, C;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (A[i][j] == '#') {
                R.insert(i);
                C.insert(j);
            }
        }
    }

    for (set<int>::iterator it_i = R.begin(); it_i != R.end(); it_i++) {
        for (set<int>::iterator it_j = C.begin(); it_j != C.end(); it_j++) {
            cout << A[*it_i][*it_j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k,j;
    cin>>n>>k;
    double p=0;
    for(int i=1;i<=n;i++){
        int sum=i;
        for(j=0;;j++){
            if(sum>=k) break;
            sum*=2;
        }
        double q=1;
        for(int x=0;x<j;x++) q*=0.5;
        p+=q;
    }
    p/=n;
    printf("%.16f",p);
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
d=[]
t=[[0]*w for i in range(h)]
for i in range(h):
    d.append(list(input()))
c=0
for i in range(h):
    f=0
    for j in range(w):
        if f==1 and d[i][j]==".":
            t[i][j]+=c
        elif d[i][j]=="#":
            c+=1
            t[i][j]+=c
            f=1

for i in range(h):
    f=0
    for j in range(w-1,-1,-1):
        if t[i][j]!=0:
            f=1
            c=t[i][j]
        elif f and t[i][j]==0:
            t[i][j]+=c
for i in range(w):
    f=0
    for j in range(h):
        if t[j][i]!=0:
            f=1
            c=t[j][i]
        elif f and t[j][i]==0:
            t[j][i]+=c

for i in range(w):
    f=0
    for j in range(h-1,-1,-1):
        if t[j][i]!=0:
            f=1
            c=t[j][i]
        elif f and t[j][i]==0:
            t[j][i]+=c




for i in t:
    print(*i)


Measured memory_bytes: 51804
#include <stdio.h>

int main(){
    int r,c;
    int s;
    int i,j;
    scanf("%d %d",&r,&c);
    int list[r+1][c+1];
    for(i=0;i<r;i++)for(j=0;j<c;j++)scanf("%d",&list[i][j]);
    for(i=0;i<r;i++){
        s = 0;
        for(j=0;j<c;j++)s += list[i][j];
        list[i][c] = s;
    }
    for(j=0;j<c;j++){
        s = 0;
        for(i=0;i<r;i++)s += list[i][j];
        list[r][j] = s;
    }
    s = 0;
    for(j=0;j<c;j++)s += list[r][j];
    list[r][c] = s;
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            printf("%d",list[i][j]);
            printf(j-c? " ":"\n");
        }
    }
}

Measured memory_bytes: 1068
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n[999] = { 0 };
	n[0] = 1;
	for (int i = 2; i < 1000; i++) {
		n[i - 1] = n[i - 2] + i;
	}

	int a, b;
	cin >> a >> b;
	int sa = b - a;

	cout << n[sa - 2] - a << endl;


	return 0;
}

Measured memory_bytes: 256
s=list(str(input()))
if len(s)%2!=0:
  print("No")
else:
  for i in range(len(s)):
    if (i%2==0 and s[i]!="h") or (i%2!=0 and s[i]!="i"):
      print("No")
      break
  else:
    print("Yes")

Measured memory_bytes: 9004
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}  
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
    }

    let s = match n % 10 {
        2|4|5|7|9 => "hon",
        0|1|6|8 => "pon",
        _ => "bon",
    };

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


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

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

    int n[10],rec;
    for(int i=a;i<=b;++i){
        n[5] = i / 10000;
        n[4] = (i - n[5] * 10000) / 1000;
        n[3] = (i - n[5] * 10000 - n[4] * 1000) / 100;
        n[2] = (i - n[5] * 10000 - n[4] * 1000 - n[3] * 100) / 10;
        n[1] =  i - n[5] * 10000 - n[4] * 1000 - n[3] * 100 - n[2] * 10;
        if(n[5] == n[1] and n[4] == n[2]) ++rec;
    }

    cout<<rec<<endl;
}





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

ll dp[3005][3005];

// This problem is same as optimal strategy for game.

ll solve(ll a[], int start, int end){
	if(start > end)
		return 0;
		
	if(start==end)
		return a[start];
	
	if(start+1 == end) {
		return max(a[start], a[end]);		
	}
	
	if(dp[start][end] != -1)
		return dp[start][end];
	
	ll ans=0;	
	
	// choose from start.
	ll choose_start = a[start] + min( solve(a, start+2, end), solve(a, start+1, end-1) );
	
	// choose from end
	ll choose_end = a[end] + min( solve(a, start+1, end-1) , solve(a, start, end-2) );
	
	// take max dicision which is beneficial
	ans = max(choose_start, choose_end);
	
	return dp[start][end] = ans;
}

void iterative(ll a[], int n, ll tot){
	// our dp state
	// dp[L][R][P] -> (L...R) of Pth player
	
	// here we only focus on first player score we get second automatic.
	// so choose our dp accordingly.
	
	ll dp[n+1][n+1][3]={};
	
	// base case if player 1 turn and both same means we best get a[i]
	// if L==R but second player turn so he choose that and first get nothing so = 0.
	
	for(int i=0; i<n; i++){
		dp[i][i][1]=a[i];
		dp[i][i][2]=0;
	}
	
	// we do for L==R now slowly to move both ooposite side so (R-L) increasing i.e=len
	
	for(int len=1; len<n; len++){
		for(int L=0; L+len < n; L++){
			int R = L+len;
			
			// if player 1 choose first now he get second L+1....R
			// same for last pick
			dp[L][R][1]=max( a[L] + dp[L+1][R][2], a[R] + dp[L][R-1][2] );
			
			// player 2 turn so we not add a[L] or a[R] because we only focus on player 1.
			dp[L][R][2]=min( dp[L+1][R][1], dp[L][R-1][1] );
			
		}
	}
	
	ll x = dp[0][n-1][1];
	ll y = tot - x;
	
	cout << x-y << "\n";
	
}

void solve(){
	int n;
	cin >> n;
	
	ll a[n]={};
	long long int tot=0;
	
	for(int i=0; i<n; i++) {
		cin >> a[i];
		tot+=a[i];
	}
	
	// iterative version.
	iterative(a, n, tot);
	return;
	
	memset(dp, -1, sizeof dp);
	
	// [X-Y] maximize means max X, minimize means min X
	
	// play optimally and try to make sum as max as posible.
	// we get val of X.
	// then y = tot-x;
	// ans=x-y.
	
	ll x = solve(a, 0, n-1);
	ll y = tot-x;
	
	cout << x-y << "\n";
}

int main(){
	solve();
}


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

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

int main(){
   int n;   cin >> n;
   vector<ll> a(n);
   for(int i=0; i<n; i++)   cin >> a.at(i);
   
   vector<ll> lc(n+1, 0), rc(n+1, 0);

   for(int i=0; i<n; i++)  lc.at(i+1) = gcd(lc.at(i), a.at(i));
   for(int i=n-1; 0<=i; i--)   rc.at(i) = gcd(rc.at(i+1), a.at(i));
ll ans=0;
   for(int i=0; i<n; i++){
       ll l = lc.at(i);
       ll r = rc.at(i+1);

       ans = max(ans, gcd(l, r));
   }
   cout << ans << endl;

}

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

int main(){
  double a,b,v; cin>>a>>b>>v;
  cout<<fixed<<setprecision(10);
  if(2*v>=a*a*b){
    cout<<atan(2.0*(a*a*b-v)/(a*a*a))*180.0/M_PI<<"\n";
  }
  else{
    cout<<atan(a*b*b/(2.0*v))*180.0/M_PI<<"\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int H,W,bcnt=0;
  cin>>H>>W;
  vector<string> A(H+2);
  for(int i=0; i<W+2; i++){A[0].push_back('#');A[H+1].push_back('#');}
  for(int i=1; i<=H; i++){
    string a; cin>>a;
    A[i].push_back('#');
    A[i]+=a;
    A[i].push_back('#');
  }
  vector<vector<int>> memo(52,vector<int>(52,INF));
  vector<int> dy={1,-1,0,0}, dx={0,0,-1,1};
  queue<pair<int,int>> que;
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      if(A[i][j]=='#')bcnt++;
    }
  }
  que.push(make_pair(1,1));
  memo[1][1]=0;
  int ynow,xnow,ynext,xnext;
  while(que.size()){
    ynow=que.front().first; xnow=que.front().second;
    que.pop();
    for(int i=0; i<4; i++){
      ynext=ynow+dy[i]; xnext=xnow+dx[i];
      if(A[ynext][xnext]!='#'&&memo[ynext][xnext]==INF){
        memo[ynext][xnext]=memo[ynow][xnow]+1;
        if(ynext==H&&xnext==W)goto end;
        que.push(make_pair(ynext,xnext));
      }
    }
  }
  end : if(memo[H][W]==INF)cout<<-1<<endl;
  else cout<<H*W-bcnt-memo[H][W]-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    int gx,gy;cin>>gx>>gy;
    vector<int> v;
    char tmp=s[0];int now=0;
    rep(i,s.size()){
        if(s[i]!=tmp){
            v.push_back(now);
            tmp=s[i];
            now=1;
        }else{
            now++;
        }
    }
    if(now>0){
        v.push_back(now);
        now=0;
    }
    tmp=s[0];
    vector<vector<bool>> dpx(8010,vector<bool>(16010,false)),dpy(8010,vector<bool>(16010,false));
    dpx[0][8000]=dpy[0][8000]=true;
    int rx=0,ry=0,ur=0;
    //ur=0の時x遷移、1の時y遷移
    rep(i,v.size()){
        int k=v[i];
        if(tmp=='T'){
            tmp='F';
            k%=4;
            if(k==1||k==3){
                ur=1-ur;
                continue;
            }
        }else{
            tmp='T';
            if(i==0){
                dpx[rx+1][8000+k]=true;
                rx++;
            }else{
                if(ur==0){
                    rep(j,16000){
                        if(j+k>16000)dpx[rx+1][j]=dpx[rx][j-k];
                        else if(j-k<0)dpx[rx+1][j]=dpx[rx][j+k];
                        else dpx[rx+1][j]=dpx[rx][j+k]|dpx[rx][j-k];
                        //if(dpx[rx+1][j])cout<<"x"<<" "<<j<<endl;
                    }
                    rx++;
                }else{
                    rep(j,16000){
                        if(j+k>16000)dpy[ry+1][j]=dpy[ry][j-k];
                        else if(j-k<0)dpy[ry+1][j]=dpy[ry][j+k];
                        else dpy[ry+1][j]=dpy[ry][j+k]|dpy[ry][j-k];
                        //if(dpy[ry+1][j])cout<<"y"<<" "<<j<<endl;
                    }
                    ry++;
                }
            }
        }
    }
    if(dpx[rx][gx+8000]&&dpy[ry][gy+8000])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 32512
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivess
ll n, m, o, x=1, y=1, ans;
set <ll> s[MAXN];
set <pi> obst;
int main()
{
	cin >> n >> m >> o;

	FOR(i, 0, o)
	{
		ll a, b;
		cin >> a >> b;
		obst.ins(pi(a, b));
		s[b].ins(a);
	}
	FOR(i, 0+1, m+1) s[i].ins(n+1);
	ans = n;
	FOR(i, 0+1, m+1)
	{
		assert(i==y);
		ans = min(ans, *s[i].lower_bound(x) - 1); ll can = 0;
		while(x+1 < ans)
		{
			x += 1;
			if(obst.find(pi(x, y+1)) == obst.end())
			{
				y += 1, can = 1; break;
			}
		}
		if(can == 0) break;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 45568
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC092_A();
        }

        static void ABC092_A()
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var D = int.Parse(Console.ReadLine());
            Console.WriteLine((A > B ? B : A) + (C > D ? D : C));
        }
    }
}

Measured memory_bytes: 11092
S=input()
T=input()

flg=True

def dic(DIC,str):
    for num in range(len(str)):
        if str[num] not in DIC:
            DIC[str[num]]=[num]
        else:
            DIC[str[num]].append(num)
    return DIC

D_S={}
D_T={}

D_S=dic(D_S,S)
D_T=dic(D_T,T)

if len(D_S)==len(D_T):
    for lst in D_S.values():
        if lst not in D_T.values():
            flg=False
else:
    flg=False

if flg==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            int k = NextInt, x = NextInt;
            System.Console.WriteLine(string.Join(" ", Enumerable.Range(x - k + 1, 2 * k - 1)));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
use proconio::{input, fastout};

fn f(x: usize, a: usize, b: usize) -> usize {
    (a*x)/b - a*(x/b)
}

#[fastout]
fn main() {
    input! {
        a: usize, b: usize, n: usize,
    }

    if n < b {
        println!("{}", f(n,a,b))
    } else {
        println!("{}", f(b-1,a,b))
    }
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 100100

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

    vector<int> va(MAX_N), vb(MAX_N);
    for (int i = 0; i < n; i+=2) va[v[i]]++, vb[v[i+1]]++;

    int na1, ca1 = 0, nb1, cb1 = 0;
    for (int i = 0; i < MAX_N; i++) {
        if (ca1 < va[i]) {
            na1 = i;
            ca1 = va[i];
        }
        if (cb1 < vb[i]) {
            nb1 = i;
            cb1 = vb[i];
        }
    }
    int ans = n - ca1 - cb1;
    if (na1 == nb1) {
        int ca2 = 0, cb2 = 0;
        for (int i = 0; i < MAX_N; i++) {
            if (ca2 < va[i] && na1 != i) ca2 = va[i];
            if (cb2 < vb[i] && nb1 != i) cb2 = vb[i];
        }
        ans = min(n - ca1 - cb2, n - cb1 - ca2); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4544
Scanf.scanf "%d" (fun n ->
    let rec check a b =
        if b = 0 then 0, 0 else
            let ue = 4 * a * b - n * (a + b) in
            let shita = n * a * b in
            if ue <= 0 then 0, 0 else
                if shita mod ue <> 0 then check a (b - 1) else
                    b, shita / ue
    in

    let rec loop a =
        let b, c = check a a in
        if b <> 0 then Printf.printf "%d %d %d\n" a b c else loop (a - 1)
    in
    loop 3500
)

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;

public class Main
{
  static double x[] = new double[8];
  static double y[] = new double[8];
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      x[i] = Double.parseDouble(sl[0]);
      y[i] = Double.parseDouble(sl[1]);
    }

//    int v = 1;
//    double a = 0;
//    for(int i = 0; i < n; i++)
//    {
//      v *= i + 1;
//      ArrayList<Integer> arr = new ArrayList<>();
//      arr.add(i);
//      a += sum(n, i, 1 << i, arr);
//    }
//    System.out.println(v);
//
//    System.out.println(a / v);

    double a = 0;
    for(int i = 0; i < n; i++)
    {
      for(int j = i; j < n; j++)
      {
        a += Math.sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
      }
    }

    System.out.println(a * 2 / n);
  }


  public static double sum(int n, int start, int mask, List<Integer> v)
  {
    double a = 0;
    for(int i = 0; i < n; i++)
    {
      if((mask & (1 << i)) == 0)
      {
        v.add(i);
        a += sum(n, i, mask | (1 << i), v) +  Math.sqrt((x[start] - x[i]) * (x[start] - x[i]) + (y[start] - y[i]) * (y[start] - y[i]));
        v.remove(v.size() - 1);
      }
    }
    return a;
  }

}




class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}


Measured memory_bytes: 22740
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = reader.ni();
		int res = N * N;
		System.out.println(res);
		return;
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 23380
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
using namespace std;

#define int long long int
#define all(x) x.begin(),x.end()
#define endl '\n'

#ifndef ONLINE_JUDGE
template<typename T>		
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

void test_case(){
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int day=0;day<n;day++){
		vector<int> a(3),new_dp(3);
		for(int i=0;i<3;i++){
			cin>>a[i];
		}
		for(int now_act=0;now_act<3;now_act++){
			for(int prev_act=0;prev_act<3;prev_act++){
				if(now_act!=prev_act){
					new_dp[now_act]=max(new_dp[now_act],dp[prev_act]+a[now_act]);
				}
			}
		}
		dp=new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    int T=1;
    //cin>>T;
    for(int TT=1; TT<=T; TT++){
        test_case();
    }

    cerr<<endl<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

    return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
    ll S;
    cin >> S;

    int N = 1000000000;

    int y = (S + N - 1) / N;
    int x = (ll)y * N - S;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;
}

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

def func(ini):
    # さいころのめがiniのとき
    if ini >= K:
        per = 1 / N
        return per
    count = 0
    point = ini
    while point <= K - 1:
        point *= 2
        count += 1
    per = 1 / (N * 2**count)
    return per
ans = 0
for i in range(1, N+1):
    ans += func(i)
print(ans)

Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 18;

int n;
char s[100];
LL ans;
LL dp[100][100];

LL solve(vector<int> a, vector <int> b) {
	rep(i, 0, n) rep(j, 0, ss(a)) dp[i][j] = 0;
	dp[0][0] = 1;
	rep(i, 0, n - 1) 
		rep(j, 0, min(i, ss(a))) {
			if (!dp[i][j]) continue;
			int k = i - j;
			if (j < ss(a) && s[a[j]] == s[n + n - i - 1]) dp[i + 1][j + 1] += dp[i][j];
			if (k < ss(b) && s[b[k]] == s[n + n - i - 1]) dp[i + 1][j] += dp[i][j];
		}
	return dp[n][ss(a)];
}

int main() {
	scanf ("%d", &n);
	scanf ("%s", s);
	rep(mask, 0, (1 << n) - 1) {
		vector <int> a, b;
		rep(k, 0, n - 1)
			if (((mask >> k) & 1)) a.pb(k);
			else b.pb(k);
		ans += solve(a, b);
		//if (solve(a, b)) printf ("%d\n", mask);
	}
	printf ("%lld\n", ans);
	
    return 0;
}


Measured memory_bytes: 256