akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			long s = sc.scanLong();
			long x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
			//long limit = MOD - 7;
			long mx = (int) Math.sqrt(s);
			x2 = mx;
			y3 = mx;
			while (x2 * y3 < s) {
				++y3;
				++x2;
			}
			long diff = x2 * y3 - s;
			x3 = 1;
			y2 = diff;
			System.out.println(x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 37772
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];

  vector<vector<ll>> dp(n, vector<ll>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  repz(i, 1, n) {
    dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
    dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
    dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
  ret;
}


Measured memory_bytes: 11072
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL a,b,n;
    cin>>a>>b>>n;

    //LL ans = 0;
    //FOR(x,1,n+1){
    //    LL v = (a*x)/b - a*(x/b);
    //    ans = max(ans, v);
    //}
    //PUTS("-------");
    //PUTS(ans);
    LL x = min(n, b-1);
    PUTS((a*x)/b - a*(x/b));
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	int *h = new int[n];
	int *ans = new int[n];
	rep(i, 0, n) cin>>h[i];
	
	ans[1] = abs(h[1]-h[0]);
	if(n > 2) ans[2] = min(abs(h[2]-h[0]), abs(h[2] - h[1]) + ans[1]);
	
	rep(i, 3, n) ans[i] = min(abs(h[i]-h[i-2])+ans[i-2], abs(h[i]-h[i-1])+ans[i-1]);
	cout<<ans[n-1];
	delete [] h;
	delete [] ans;
}

Measured memory_bytes: 1792
#include<cstdio>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a + b == c || a + c == b || b + c == a )
	{
		printf("Yes\n");
		}
		else{
			printf("No\n");
			}
	return 0;
	}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)
        self.__rank = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x == y:
            return False

        if self.__rank[x] < self.__rank[y]:
            self.__table[x] = y
            self.__size[y] += self.__size[x]
        else:
            self.__table[y] = x
            self.__size[x] += self.__size[y]
            if self.__rank[x] == self.__rank[y]:
                self.__rank[x] += 1
        return True

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g

@mt
def slv(N, M, L):
    lo = 10**6
    uf = UnionFind()
    for i, l in enumerate(L):
        for j in l:
            uf.union(i, j+lo)


    return 'YES' if all(uf.same(0, i) for i in range(1, N)) else 'NO'








def main():
    N, M = read_int_n()
    L = [list(map(lambda x: x-1, read_int_n()[1:])) for _ in range(N)]
    print(slv(N, M, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 142068
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef pair<int,int> P;

int N;
int main(){
    cin >> N;
    vector<P> v(N);
    map<P,int> m;
    int x,y;
    for(int i=0;i<N;i++){
        cin >> x >> y;
        v[i] = {x,y};
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) continue;
            m[{v[j].first-v[i].first,v[j].second-v[i].second}]++;
        }
    }
    int ma = 0;
    for(auto x:m){
        ma = max(ma,x.second);
    }
    cout << N-ma << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k)cout<<s<<endl;
  else{
   for(int i=0;i<k;i++){
    cout<<s[i];
  }
  cout<<"..."<<endl;
}
 return 0;
}


Measured memory_bytes: 3628
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

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

	int mx = 1000000;
	vector<int> D(mx+1, 0);
	rpd(i, 2, mx+1, 1)
		if(!D[i]) rpd(j, i, mx+1, i) D[j] = i;

	int N; cin>>N;
	int g = 0;
	bool not_pairwise = false;
	unordered_set<int> past;
	rpd(i, 0, N, 1){
		int a; cin>>a;
		g = gcd(g, a);
		if(not_pairwise) continue;
		unordered_set<int> now;
		while(a != 1){
			// 素数 D[a]: 今回は未済 & 過去は済
			if(( not_pairwise = !now.count(D[a]) && past.count(D[a]) )) break;
			now.insert(D[a]);
			past.insert(D[a]);
			a /= D[a];
		}
	}
	int t = not_pairwise + (g > 1);
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


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

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

    map<long long, long long> m;
    long long a;
    bool all_zero = true;
    for (long long i = 0; i < N; i++)
    {
        cin >> a;
        if (a != 0)
        {
            all_zero = false;
        }
        m[a]++;
    }

    if (all_zero)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (m.size() > 3 || m.size() == 1)
    {
        cout << "No" << endl;
        return 0;
    }

    vector<long long> x;
    vector<long long> n;

    for (auto itr = m.begin(); itr != m.end(); itr++)
    {
        x.push_back(itr->first);
        n.push_back(itr->second);
    }

    if (m.size() == 3)
    {
        if ((n[0] != n[1]) || (n[1] != n[2]))
        {
            cout << "No" << endl;
            return 0;
        }
        if (((x[0] ^ x[1]) == x[2]) && ((x[1] ^ x[2]) == x[0]) && ((x[2] ^ x[0]) == x[1]))
        {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
    }
    if (m.size() == 2)
    {
        if ((x[0] ^ x[1]) == x[0])
        {
            if (n[0] == 2 * n[1])
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        if ((x[0] ^ x[1]) == x[1])
        {
            if (n[1] == 2 * n[0])
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}


Measured memory_bytes: 5120
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 500

int compar(const int *val1, const int *val2);

int main() {
	char sInput[MAX_STRING+1]="";
	char* psInput;

	int i=0;
	int nX[3];
	int nA=0;
	int nB=0;
	int nC=0;
	int nHands=0;
	int nMax=0;

	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nX[0] = atoi(psInput);
	psInput = strtok(NULL," ");
	nX[1] = atoi(psInput);
	psInput = strtok(NULL," ");
	nX[2] = atoi(psInput);

	// sort
    qsort(nX, 3, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
//		printf("%d,%d,%d\n",nX[0],nX[1],nX[2]);

	while (nX[0]!=nX[2] || nX[1]!=nX[2]){
		if(nX[0]<nX[2]&&nX[1]<nX[2]){
			nX[0]=nX[0]+1;
			nX[1]=nX[1]+1;
			nHands++;
		} else if (nX[0]<nX[2]&&nX[1]==nX[2]) {
			nX[0]=nX[0]+2;
			nHands++;
		} else if (nX[0]>nX[2]&&nX[0]>nX[2]) {
			nX[1]=nX[1]+1;
			nX[2]=nX[2]+1;
			nHands++;
		}
	}


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

    return 0;
}
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 128
def roll(i):
    global u, s, e, w, n, d
    if i == 'N':
        u, s, n, d = s, d, u, n
    elif i == 'E':
        u, e, w, d = w, u, d, e
    elif i == 'S':
        u, s, n, d = n, u, d, s
    elif i == 'W':
        u, e, w, d = e, d, u, w

u, s, e, w, n, d = input().split()
q = int(input())
for i in range(q):
    u1, s1 = input().split()
    if u1 == s:
        roll('N')
    elif u1 == e:
        roll('W')
    elif u1 == w:
        roll('E')
    elif u1 == n:
        roll('S')
    elif u1 == d:
        roll('N')
        roll('N')
    if s1 == s:
        print(e)
    elif s1 == e:
        print(n)
    elif s1 == n:
        print(w)
    elif s1 == w:
        print(s)

Measured memory_bytes: 7784
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner keyboardScanner=new Scanner(System.in);
		int k=keyboardScanner.nextInt();
		int cc;
		if(k%2==0) {cc=(k/2)*(k/2);}
		else {cc=(k/2)*((k/2)+1);}
		System.out.println(cc);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int ans=INFI;
  for(int i=-100; i<=100; i++){
    int sum=0;
    for(int j=0; j<N; j++){
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(n) for (int i = 0; i < (n); ++i)
typedef long long ll;
int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> p(n, 0);
    rep(q)
    {
        ll a;
        cin >> a;
        a--;
        p[a]++;
    }
    rep(n)
    {
        if ((q - p[i]) < k)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#define x first
#define y second

const int N=1050;

typedef std::pair<int,int> pii;
typedef long long ll;

const ll INF=9023372036854775807ll;

ll A[N];
int n;

int stk[N],tot;

void fuck(int p)
{
	stk[++tot]=p;
	if(p>1&&p<n)
	{
		A[p-1]+=A[p+1];
		for(int i=p;i<=n;i++)
			A[i]=A[i+2];
		n-=2;
	}
	else
	{
		for(int i=p;i<=n;i++)
			A[i]=A[i+1];
		n--;
	}
}

void outputodd()
{
	for(int i=1;i<=n;i++)
		if(i&1 && A[i]<0)
		{
			fuck(i);
			i--;
			if(i==0 && n>1)fuck(1);
		}
	while(n%2==0)fuck(n);
	while(n>1)fuck(2);
}
void outputeven()
{
	fuck(1);outputodd();
}

void fuckyou()
{
	ll x=-INF;
	int pos=-1;
	for(int i=1;i<=n;i++)
		if(A[i]>x)x=A[i],pos=i;
	printf("%lld\n",x);
	printf("%d\n",n-1);
	
	int a=pos-1,b=n-pos;
	while(b--)printf("%d\n",n--);
	while(a--)printf("1\n");
}

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

	ll a=0,b=0;
	bool flag=0;

	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x),A[i]=x;

		flag|=(x>=0);

		if(i&1)a+=std::max(0,x);
		else b+=std::max(0,x);
	}

	if(!flag){fuckyou();return 0;}

	printf("%lld\n",std::max(a,b));

	if(a>b)outputodd();
	else outputeven();

	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)
		printf("%d\n",stk[i]);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
struct Node{
	int x,y,x1,y1;
};
int a[505][505];
int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&a[i][j]);
		}
	}
	vector<Node> V;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]%2==1){
				if(j+1<=w){
					Node p;
					p.x=i;p.y=j;p.x1=i;p.y1=j+1;
					V.push_back(p);
					a[i][j+1]++;
				}else if(i+1<=h){
					Node p;
					p.x=i;p.y=j;p.x1=i+1;p.y1=j;
					V.push_back(p);
					a[i+1][j]++;
				}
			}
		}
	}
	printf("%d\n",V.size());
	for(int i=0;i<V.size();i++){
		printf("%d %d %d %d\n",V[i].x,V[i].y,V[i].x1,V[i].y1);
	} 
	return 0;
} 

Measured memory_bytes: 5232
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define pf push_front

using namespace std;
using ll=long long;
using ld=long double;

const int maxn = 1e6 +2;
const int base = 31;
const int mod = 1e9 +7;

template<class T>
void read(T &x)
{
    register ll c;
    T neg = 1;
    x = (T)0;
    while ((c = getchar()) <= 47 || c >= 58)
        if(c == '-') neg = -1;
    for (; (c > 47 && c < 58); c = getchar())
    {
        x = (x << 3) + (x << 1) + (T)(c - 48);
    }
    x *= neg;
}

ll nhan(ll x,ll y)
{
    if (y == 0)
        return 0;
    ll t;
    t = nhan(x, y/2) % mod;
    t = t % mod + t % mod;
    if (y % 2 == 0)
        return t % mod;
    else
        return (t % mod + x % mod) % mod;
}

ll mu(ll x, ll y)
{
    if (y == 0)
        return 1;
    ll t;
    t = mu(x, y/2) % mod;
    t = nhan(t, t) % mod;
    if (y % 2 == 0)
        return t % mod;
    else
        return nhan(t,x) % mod;
}

ll n, k, ans = 0;
int main()
{
    cin >> n >> k;
    for(ll i = k; i <= n + 1; i++) ans = (ans + nhan(i, n-i+1) + 1) % mod;
    cout << ans % mod;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void) {
	int n, x;
	int l[100],d[100];
	scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	d[0] = 0;
	int c = 1;
	for (int i = 1; i < n + 1; i++) {
		d[i] = d[i - 1] + l[i-1];
		if (d[i] <= x) {
			c++;
		}
		else {
			break;
		}
	}
	printf("%d\n", c);
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
int c,e,d;
double a,b,result=0;
cin>>a>>b;
c=a/b;
d=fmod(a,b);
result=a/b;
cout<<c<<" "<<d<<" ";
printf("%5f",result);
cout<<endl;
}



Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x,y=0,n;
  cin>>a>>b>>x;
  if(a!=b)
    y++;
  if(a!=x)
    y++;
  if(b!=x)
    y++;
  if(y==0)
    y=1;
  cout<<y<<endl;
  return(0);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        String str = sc.nextLine();

        String ans = "Good";
        for (int i = 0; i < 3; i++) {
            if (str.charAt(i) == str.charAt(i + 1)) {
                ans = "Bad";
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        x = x - a; 
        for(;;){
          if(x-b<0) break;
          x = x-b;
          
        }
        System.out.print(x);
        
}
}


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

X=[0]   #X[0]はダミー #X[i]はi日めの活動の情報
for x in range(N):
    x=tuple(map(int,input().split()))
    X.append(x)

inf=float('inf')
DP=[[0,0,0]]
for i in range(N):
    DP.append([-inf,-inf,-inf])

#DPの初期値
DP[1][0]=X[1][0]
DP[1][1]=X[1][1]
DP[1][2]=X[1][2]

for i in range(2,N+1):
    for j in range(3):
        for k in range(3):
            if j!=k:
                DP[i][j]=max(DP[i][j],DP[i-1][k]+X[i][j])

#for index in range(N+1):
    #print(DP[index])

print(max(DP[N]))




Measured memory_bytes: 85336
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	p := make([]int, n)
	q := make([]int, n)

	for i := range p {
		p[i] = nextInt()
		q[i] = p[i]
	}
	sort.Ints(q)
	count := 0
	for i := range p {
		if p[i] != q[i] {
			count++
		}
	}

	if count <= 2 {
		_, _ = fmt.Fprint(writer, "YES")
	} else {
		_, _ = fmt.Fprint(writer, "NO")
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    if(n%2!=0) n++;
    cout << n/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

int main(void)
{
  int N,M;
  int A,B,X;

  cin >> N >> M;

  //vector<vector<int> > pos(N + 3,vector<int>(N + 3));

  vector< vector<int> > pos(N + 5);
  rep(i, N + 5) pos[i].assign(i + 5, 0);

  rep(i,M)
    {
      cin >> A >> B >> X;

      pos[A][B]++;
      pos[A][B+1]--;
      pos[A+X+2][B+1]++;
      pos[A+X+1][B]--;
      pos[A+X+1][B+X+2]++;
      pos[A+X+2][B+X+2]--;

    }

  rec(y,1,N+1)
    rep(x,y+2)
    if(x > 1)
      pos[y][x] += pos[y][x-1];

  rec(x,1,N+2)
    rec(y,x,N+2)
      if(y != x)
        pos[y][x] += pos[y-1][x];

  rep(i,N+2)
    for(int j=0; i+j < N+2;++j)
      if(j > 1 && j + i > 1)
        pos[i+j][j] += pos[i+j-1][j-1];

  int ans = 0;

  rep(i,N+1)
    rep(j,i+1)
      if(pos[i][j] > 0)
        ans++;

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 50376
# -*- coding: utf-8 -*-

s = input()
h = int((len(s)-1)/2)
s1 = s[:h]
s2 = s[h+1:]

def cal(h, s):
    for i in range(h):
        j = (i*-1)-1

        if s[i] != s[j]:
            print('No')
            exit()


cal(h, s)
cal(len(s1), s1)
cal(len(s2), s2)


print('Yes')

Measured memory_bytes: 3064
k,*a = map(int,open(0).read().split())
a = a[::-1]
nmax = 2
nmin = 2
for i in range(k):
  if nmax//a[i]-(nmin-1)//a[i]<=0:
    print(-1)
    exit()
  nmin = ((nmin-1)//a[i]+1)*a[i]
  nmax = (nmax//a[i])*a[i]+a[i]-1
print(nmin,nmax)

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

int num[200010] ;
int b[200010] ;
int a[200010] ;

main()
{
	int n,m,q,c,d,pos=0 ;
	cin >> n >> m >> q ;
	
	for( int i=0 ; i<n ; i++ )
	{
		num[i] = 1 ;
		b[i] = i-1 ;
		a[i] = i+1 ;
	}
	b[0] = n-1 ;
	a[n-1] = 0 ;
	
	for( int i=0 ; i<m ; i++ )
	{
		cin >> c ;
		if( c%2 )
			while(c--) pos = b[pos] ;
		else
			while(c--) pos = a[pos] ;
		
		num[pos] = 0 ;
		b[a[pos]] = b[pos] ;
		a[b[pos]] = a[pos] ;
		pos = a[pos] ;
	}
	
	for( int i=0 ; i<q ; i++ )
	{
		cin >> d ;
		cout << num[d] << endl ;
	}
}

Measured memory_bytes: 3504
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;
 
int n;
int a[105];
int ave;
int min = INF;
int ans;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		ave += a[i];
	}
	for(int i = 0; i < n; i++){
		if(abs(a[i] * n - ave) < min){
			min = abs(a[i] * n - ave);
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
	long long N;
	cin >> N;
	vector<pair<long long, long long> > ANS;
	for (int i = 1; i < N; i += 2) {
		ANS.push_back({ 0, i });
	}
	for (int i = 1; i < N; i += 3) {
		if (i % 2 == 0) {
			for (int j = 1; j < N; j += 2) ANS.push_back({ j, i });
		}
		else {
			for (int j = 2; j < N; j += 2) ANS.push_back({ j, i });
		}
	}
	if (N % 3 == 1) {
		if (N % 2 == 0) {
			for (int i = 2; i < N; i += 2) ANS.push_back({ i, N - 1 });
		}
		else {
			for (int i = 1; i < N; i += 2) ANS.push_back({ i, N - 1 });
		}
	}
	cout << ANS.size() << endl;
	for (pair<long long, long long > P : ANS) cout << P.first << " " << P.second << endl;
}

Measured memory_bytes: 6384
N,A=map(int,input().split())
x=[int(i) for i in input().split()]
NX=N*max([max(x),A])
dp=[[[0 for s in range(NX+1)] for k in range(N+1)] for j in range(N+1)]
dp[0][0][0]=1
for j in range(N+1):
    for k in range(N+1):
        for s in range(NX+1):
            if j==0 and k==0 and s==0:
                dp[j][k][s]=1
            elif j>=1 and s<x[j-1]:
                dp[j][k][s]=dp[j-1][k][s]
            elif j>=1 and k>=1 and s>=x[j-1]:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s]=0
#(dp)
ans=0
for k in range(1,N+1):
    ans+=dp[N][k][k*A]
print(ans)


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

int main(){
  int n,a[100010]={},b[100010]={};
  cin>>n;
  int x,y;
  for(int i=0;i<n/2;++i){
    cin>>x>>y;
    a[x]++;
    b[y]++;
  }
  int ans=0,ans2=0,x2=x,y2=y;
  for(int i=1;i<=1e5;++i){
    if(a[i]>ans){
        ans2=ans;
        x2=x;
        ans=a[i];
        x=i;
    }else if(a[i]>ans2){
        ans2=a[i];
        x2=i;
    }
  }
  int ans1=0,ans3=0;
  for(int i=1;i<=1e5;++i){
    if(b[i]>ans1){
        ans3=ans1;
        y2=y;
        ans1=b[i];
        y=i;
    }else if(b[i]>ans3){
        ans3=b[i];
        y2=i;
    }
  }
  if(x!=y){
    cout << n-ans-ans1 << endl;
  }else{
    cout << min(n-ans-ans3,n-ans2-ans1) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
// ALDS1_2_D: Shell Sort

fn insertion_sort(
    a: &mut Vec<i64>, 
    n: usize, 
    g: usize
) -> usize {
    let mut cnt = 0;
    for i in g..n {
        let v = a[i];
        let mut j = i;
        while j >= g && a[j-g] > v {
            a[j] = a[j-g];
            j -= g;
            cnt += 1;
        }
        a[j] = v;
    }
    cnt
}

fn shell_sort(
    a: &mut Vec<i64>, 
    n: usize
) -> (Vec<usize>, usize) {
    let mut g = Vec::new();
    let mut h = 1;
    while h <= n {
        g.push(h);
        h = 3*h + 1;
    }
    g.reverse();
    let mut cnt = 0;
    for g in &g {
        cnt += insertion_sort(a, n, *g);
    }
    (g, cnt)
}

fn print_vec<T: std::fmt::Display>(a: &Vec<T>){
    let s = a.iter()
        .map(|v| v.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", s);
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse::<usize>().unwrap();

    let mut a = Vec::new();
    for _ in 0..n {
        s.clear();
        std::io::stdin().read_line(&mut s).unwrap();
        let i = s.trim().parse::<i64>().unwrap();
        a.push(i);
    }

    let (g, cnt) = shell_sort(&mut a, n);

    println!("{}", g.len());
    print_vec(&g);
    println!("{}", cnt);

    for i in 0..n {
        println!("{}", a[i]);
    }
}


Measured memory_bytes: 14212
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	int H, N; cin >> H >> N;
	int sum = 0;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		sum += tmp;
	}
	if (sum >= H)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N, K; cin >> N >> K;
  string S; cin >> S;
  ll slen = S.length(); 
  ll R_shima=0;
  ll L_shima=0;
  ll point=0;
  
  // Sの両端も他同様に扱えるようにする
  if(S[slen-1]=='R'){S+='L';}else{S+='R';}
  if(S[0]=='R'){S='L'+S;}else{S='R'+S;}
  
  char edge1=S[0];
  char prev=S[0];
  ll index=1;
  while(index<=slen+1){
    char c=S[index];
    if(c==prev){
      point++;
    }
    if(c!=prev&&c==edge1){
      if(prev=='R'){R_shima++;}else{L_shima++;}
      edge1=prev;
    }
    //cout << index << ':' << " L_shima="<< L_shima << " R_shima=" << R_shima <<" point="<<  point << endl;
    prev=c;
    index++;
  }
  //cout << point << endl;
  point=min(slen-1,  point+2*min(K, max(R_shima, L_shima)));
  cout << point;
}


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

int main(){
  double ans=0;
  double N;
  cin>>N;
  vector<double>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    ans+=1/A[i];
  }
  cout<<1/ans<<endl;
}


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

int main()
{
    double a, b;
    int d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = int(a) % int(b);
    f = a / b;
    cout << d << " ";
    cout << r << " ";
    cout << fixed << f << "\n";

    return 0;
}

Measured memory_bytes: 1288
#include <iostream>

using namespace std;

int main () {


    string s;
    cin >> s;

    int a = -1;
    int z = -1;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A' && a == -1){
            a = i;
        }

        if (s[i] == 'Z'){
            z = i;
        }   
    }


    cout << z  - a + 1 << endl;



    return 0;
}

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

using namespace std;


int main() {
	int n;
	cin >> n;
	string s;
	vector<int64_t> vals(5,0);
	for (int i = 0; i < n; ++i) {
		cin >> s;
		if (s[0] == 'M') vals[0]++;
		if (s[0] == 'A') vals[1]++;
		if (s[0] == 'R') vals[2]++;
		if (s[0] == 'C') vals[3]++;
		if (s[0] == 'H') vals[4]++;
	}
	int64_t res = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = i+1; j < 5; ++j) {
			for (int k = j + 1; k < 5; ++k) {
				res += vals[i] * vals[j] * vals[k];
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

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

    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    double u = 1.0;
    exrep(i, 1, n) {
        u *= i;
    }

    vl perm(n);
    rep(i, n) {
        perm[i] = i;
    }

    double ans = 0;
    do {
        rep(i, n-1) {
            ans += dist(x[perm[i]], y[perm[i]], x[perm[i+1]], y[perm[i+1]]);
        }
    } while(next_permutation(all(perm)));

    ans /= u;
    
    exout(ans);
    re0;
}

Measured memory_bytes: 256
import Data.Char(isUpper)

main = do
    s <- getLine
    if accept s then putStrLn "AC"
                else putStrLn "WA"

accept :: String -> Bool
accept (s:xs) = s == 'A' && filter isUpper xs == "C" && (findC $ take (length xs-2) (tail xs))

findC :: String -> Bool
findC [] = False
findC (x:xs)
    | x == 'C'  = True
    | otherwise = findC xs


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
ll dp[1<<17];
ll cost[1<<17];
int a[17][17];
bool visdp[1<<17];
bool viscost[1<<17];

ll totcost(int mask){
    ll &ans = cost[mask];
    if(viscost[mask]){
        viscost[mask] = false;
        ans = 0;
        int i = __builtin_ffs(mask) - 1;
        for(int j=i+1;j<n;++j){
            if(mask & (1<<j))
                ans += a[i][j];
        }
        ans += totcost(mask ^ (1<<i));
    }
    return ans;
}

ll solve(int mask){
    ll &ans = dp[mask];
    if(visdp[mask]){
        visdp[mask] = false;
        ans = -1e18;
        for(int sub = mask;sub;sub=(sub-1)&mask){
            ans = max(ans, totcost(sub) + solve(mask ^ sub));
        }
    }
    return ans;
}

int main(){
    memset(dp, 0, sizeof dp);
    memset(visdp, true, sizeof visdp);
    memset(viscost, true, sizeof viscost);
    memset(cost, 0, sizeof cost);
    scanf("%d", &n);
    for(i=0;i<n;++i){
        for(j=0;j<n;++j){
            scanf("%d", a[i]+j);
        }
    }
    
    visdp[0] = viscost[0] = 0;
    for(i=0;i<n;++i)
        visdp[1<<i] = viscost[1<<i] = 0;
    ll ans = solve((1<<n)-1);
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())

cnt = [0]*30
for i in range(n):
    l = list(map(int, input().split()))
    for j in range(1, l[0]+1):
        cnt[l[j]-1] += 1

ans = 0
for i in cnt:
    if i == n:
        ans += 1

print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll fact[n];
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=fact[i-1]*i;
    }
    vector<pair<ll,ll>>v;
    f(i,0,n){
        ll x,y;cin>>x>>y;
        v.pb(mp(x,y));
    }
    sort(v.begin(),v.end());
    ld sum=0;
    do{
        ld dist=0;
        f(i,1,v.size()){
            ll x1=v[i-1].F;ll x2=v[i].F;
            ll y1=v[i-1].S;ll y2=v[i].S;
            dist+=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        }
        sum+=dist;  
    }while(next_permutation(v.begin(),v.end()));
    ld ans=sum/fact[n];
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int X,Y,Z,tmp;
    cin >>X>>Y>>Z;
    tmp = X;
    X=Y;
    Y=tmp;
    tmp=X;
    X=Z;
    Z=tmp;
    cout << X << ' ' <<  Y << ' ' << Z << endl;
    return 0;    
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
char str[N];

int main() {
    scanf("%s", str + 1);
    int len = strlen(str + 1);
    int sum = 0;
    for (int i = 1; i <= len; i++)sum += str[i] - '0';
    if (sum % 9)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int n;
    string w[100];
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    
    for (int i = 0; i < n; i++) {
        if ((i < (n - 1)) && (w[i][w[i].length() - 1] != w[i + 1][0])) {
            cout << "No" << endl;
            return 0;
        }
        
        for (int ii = 0; ii < i; ii++) {
            if (w[i] == w[ii]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    a = int(input())

    print(a + pow(a, 2) + pow(a, 3))


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """2"""
        output = """14"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10"""
        output = """1110"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

void Main() {
    ll N; cin >> N;
    map<ll, ll> x = prime_factorize(N);
    // 2^{1}, 2^{2}, .. , 2^{N}と割り切って行って限界を見つける
    ll cnt_total = 0;
    for (auto a: x){
        ll tmp = a.second;
        rep2(i, 1, 100){ // 2^{40}で10^{12}なのでかなり余裕があるはず
            if (tmp >= i){
                tmp -= i;
            } else {
                cnt_total += (i - 1);
                break;
            }
        }
    }
    cout << cnt_total << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;
	 
	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	cout << maxv <<endl;
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 1;
  for ( int i = 1; i <n; i++ ){
    if ( s[i] != s[i-1] ){
      ans++;
    }
  }

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

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import numpy as np
import math
 
N, M = map(int, input().split())
 
def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
print(comb(N, 2)+comb(M, 2))

Measured memory_bytes: 13076
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n, m, q;

vector<int> vec[501];
vector<int> evec[501];
int co[501][501];

bool comp(const P &a, const P &b){
		if(a.first != b.first)return a.first < b.first;
		else return a.second < b.second;
}

int main(int argc, char const* argv[])
{
	cin >> n >> m >> q;
	for(int i = 0; i < m; i++){
			int x, y;
			cin >> x >> y;
			x--; y--;
			vec[x].pb(y);
			evec[y].pb(x);
	}
	for(int i = 0; i < n; i++){
			sort(vec[i].begin(), vec[i].end());
			sort(evec[i].begin(), evec[i].end());
	}
	for(int i = 0; i < n; i++){
			for(int j = n - 1; j >= i; j--){
					if(j == n - 1){
							if(i == 0)co[i][j] = m;
							else {
									co[i][j] = co[i-1][j] - vec[i-1].size();
							}
					} else {
							co[i][j] = co[i][j+1] - evec[j+1].size();
							co[i][j] = co[i][j+1] - (evec[j+1].size() - (lower_bound(evec[j+1].begin(), evec[j+1].end(), i) - evec[j+1].begin()));
					}
			}
	}
	for(int i = 0; i < q; i++){
			int x, y;
			cin >> x >> y;
			x--; y--;
			cout << co[x][y] << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;

  bool found = false;
  if (s.length() < 2) {
    cout << "-1 -1";
  } else if (s.length() == 2) {
    if (s[0] == s[1]) {
      cout << "1 2";
    } else {
      cout << "-1 -1";
    }
  } else {
    for (size_t i = 0; i < s.length() - 2; i++) {
      if (s[i] == s[i+1]) {
        cout << i + 1 << " " << i + 2;
        found = true;
        break;
      } else if (s[i] == s[i+2]) {
        cout << i + 1 << " " << i + 3;
        found = true;
        break;
      }
    }
    if (!found) {
      cout << "-1 -1";
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N, A, B = map(int, input().split())

    all_sum = 0
    for i in range(1,N+1):
        keta_sum = sum(list(map(int, str(i))))
        if keta_sum >= A and keta_sum <= B:
            all_sum += i
    print(all_sum)

main()


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

vector<int> primes;
vector<bool> isPrime(maxn, true);
int ans[maxn];

void sieve(int n = maxn - 10) {
    isPrime[0] = isPrime[1] = false;
    isPrime[2] = true;
    for (int i = 3; i * i <= n; i += 2)
        if (isPrime[i])
            for (int j = i * i; j <= n; j += 2 * i)
                isPrime[j] = false;
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
        if (isPrime[i])primes.push_back(i);
}

void solve() {
    int q;
    cin >> q;

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

        cout << ans[b] - ans[a - 1] << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    sieve();
    for (int i = 1; i <= maxn - 10; i++) {
        if (i & 1) {
            if (isPrime[i] and isPrime[(i + 1) / 2] and (((i + 1) / 2) % 2 != 0 or (i + 1) / 2 == 2))
                ans[i] = 1;
        }
        ans[i] += ans[i - 1];
    }

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    long long N, K, ans, i;
  	cin >> N >> K;
    ans = 0;
    
    for(i=K; i<=N+1; i++){
        ans = (ans - i*i +(N+1)*i + 1)%1000000007;
    }
    cout << ans;
}

Measured memory_bytes: 3612
(let* ((n (read))
       (a-lst (loop repeat n collect (read))))
  (labels ((f (elm result)
             (if (evenp elm)
                 (f (/ elm 2) (1+ result))
                 result)))
    (princ (apply #'+
             (mapcar #'(lambda (elm) (f elm 0))
                     a-lst)))))

Measured memory_bytes: 53604
module Main where
import qualified Data.Map as M
import Data.Function
main = do
  n:k:_ <- map read . words <$> getLine :: IO [Int]
  xs <- flip fix (M.empty, n) $ \loop (ints, cnt) -> do
    if cnt == 0 then return ints
    else do
    a:b:_ <- map read . words <$> getLine :: IO [Int]
    let n = b + M.findWithDefault 0 a ints
    let ints' = M.insert a n $ ints
    loop (ints', cnt-1)

  flip fix (xs, 0) $ \loop (ints, num) -> do
    if M.null ints then return ()
    else do
    let ((i,n),ints') = M.deleteFindMin ints
        newNum = num + n
    if newNum >= k
    then print i
    else loop (ints', newNum)
  return ()


Measured memory_bytes: 214396