akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int N, D, X, v = 1, c = 0;
    cin>>N;
    int A[N];
    cin>>D>>X;
    for(int i = 0; i<N; i++)
    {
        cin>>A[i];
    }
    //int c = 1;
    int k;
    for(int i = 0; i<N; i++)
    {
        //for(int j = 1;j<=1;j++)
        //{
            k = 1;
            v = 1;
            for(k = 1; ; k++)
            {
                v = k*A[i];
                if(v+1<=D){
                //v = v + k*A[i]+1;
                 c++;
                }
                else
                {
                    break;
                    //k = 1;
                    //v = 1;
                }
            }
            //k = 1;
            //v = 1;
        //}
    }
    cout<<c+N+X<<endl;
    return 0;
}


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

using namespace std;
long long x[10000010], y[10000010],z[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n) i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9+7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a,b,c,d,n,cnt=0,ans=0;
   string s,w;

   cin>>n>>a>>b;

   a=b-a;

   if(a<=0) cout<<"delicious"<<'\n';
   else if(a<=n) cout<<"safe"<<'\n';
   else cout<<"dangerous"<<'\n';
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
#define int ll

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

int32_t main() {

	const ll inf = 1ll<<60;
	const ll B = 1e5+100;

	int N, W;
	cin >> N >> W;

	vector<int> w(N+1), v(N+1);

	tik(i,0,N)
		cin >> w[i+1] >> v[i+1];

	vector<vector< ll > > dp(N+1,vector<ll>(B,inf)); //dp[i][j] = The mimimum weight we need to take among the first i items to obtain a value of j. dp[i][j] = min(dp[i-1][j-v[i]]+w[i], dp[i][j]);

	dp[0][0] = 0;

	tik(i,1,N+1) {
		tik(j,0,B) {
			if(j < v[i]) {
				dp[i][j] = dp[i-1][j];
				continue;
			}
			dp[i][j] = min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
		}
	}

	int res = 0;
	tik(i,0,B) {
		if(dp[N][i] <= W) {
			res = i;
		}
	}

	cout << res;

}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 2e5 + 5;
const int oo = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int a, int b){a += b; return a >= mod ? a - mod : a;}
inline int pop(int a, int b){a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b){return 1LL * a * b % mod;}

int N, cnt[MAXN];

struct edge {
	int y, next;
}e[MAXN];
int LINK[MAXN], len = 0, pw[MAXN], dep[MAXN];
inline void ins(int x, int y){
	e[++len].next = LINK[x]; LINK[x] = len;
	e[len].y = y;
}

struct Sta{
	int d[3];
	Sta(){d[0] = d[1] = d[2] = 0;}
};

Sta operator + (const Sta & a, const Sta & b) {
	Sta c;
	up (i, 0, 2) up (j, 0, 1) cadd(c.d[min(i + j, 2)], mul(a.d[i], b.d[j]));
	return c;
}

deque<Sta> f[MAXN], tmp;

void DFS(int node){
	int c = 0;
	cnt[dep[node]]++;
	Auto (i, node) {
		dep[e[i].y] = dep[node] + 1;
		DFS(e[i].y);
	}
	Auto (i, node) if (!c || SZ(f[e[i].y]) > SZ(f[c])) c = e[i].y;
	if (c) f[node].swap(f[c]);
	int n = 0;
	Auto (i, node) if (e[i].y != c) {
		cmax(n, SZ(f[e[i].y]));
		while (!f[e[i].y].empty()) {
			Sta cur = f[node].front() + f[e[i].y].front();
			f[node].pop_front(); f[e[i].y].pop_front();
			tmp.push_back(cur);
		}
		while (!tmp.empty()) {
			f[node].push_front(tmp.back());
			tmp.pop_back();
		}
	}
	Sta cur;
	cur.d[0] = 1; cur.d[1] = 1; cur.d[2] = 0;
	f[node].push_front(cur);
	up (i, 0, n) {
		cadd(f[node][i].d[0], f[node][i].d[2]);
		f[node][i].d[2] = 0;
	}
}

int main(){
	scanf("%d", &N); N++;
	pw[0] = 1;
	up (i, 1, N) pw[i] = add(pw[i - 1], pw[i - 1]);
	up (i, 2, N) {
		int x, y = i;
		scanf("%d", &x);
		ins(x + 1, y);
	}
	DFS(1);
	int ans = 0, d = 0;
	while (!f[1].empty()) {
		Sta cur = f[1].front(); f[1].pop_front();
		cadd(ans, mul(cur.d[1], pw[N - cnt[d]]));
		d++;
	} 
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p,ll b)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,b);
	z=(z*z)%b;
	if(p%2) z=(z*a)%b;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2,MOD);
}


int main()
{
	int n;
	cin>>n;
	vector<vector<int>> V(n,vector<int> (n,-1));
	for(int j=0;j<n;j++)
	{
		int A;
		cin>>A;
		for(int i=0;i<A;i++)
		{
			int x,y;
			cin>>x>>y;
			V[j][x-1]=y;
		}
	}
	
	int ma=0;
	int TOT=pow(2,n);
	for(int i=0;i<TOT;i++)
	{
		set<int> S;
		int k=i;
		for(int j=0;j<n;j++)
		{
			if(k%2) S.insert(n-1-j);
			k/=2;
		}
		set<int> H;
		set<int> D;
		int f=1;
		for(auto s:S)
		{
			for(int j=0;j<n;j++)
			{
				if(V[s][j]==-1) continue;
				else
				{
					if(V[s][j]==1&&S.count(j)==1&&D.count(j)==0) H.insert(j);
					else if(V[s][j]==0&&S.count(j)==0&&H.count(j)==0) D.insert(j);
					else {f=0;break;}
				}
			}
			if(f==0) break;
		}

		if(f==1) ma=max(ma,(int)S.size());
		// cout<<"S ";
		// for(auto s:S) cout<<s<<" ";
		// cout<<endl;
		// cout<<"H ";
		// for(auto s:H) cout<<s<<" ";
		// cout<<endl;
		// cout<<"D ";
		// for(auto s:D) cout<<s<<" ";
		// cout<<endl;
		// cout<<ma<<endl;
		// cout<<endl;

	}
	cout<<ma<<endl;
}

Measured memory_bytes: 384
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int x,n;
	cin>>x>>n;
	vi v;
	si s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	for(int i=-1;i<=101;i++)
	{
		if(s.find(i)==s.end())
			v.pb(i);
	}
	if(binary_search(all(v),x))
		cout<<x;
	else
	{
		auto it=upper_bound(all(v),x);
		int tg=*it;
		it--;
		int tg1=*it;
		if(abs(x-tg1)==abs(x-tg))
			cout<<tg1;
		else
		{
			if(abs(x-tg)<abs(x-tg1))
				cout<<tg;
			else
				cout<<tg1;
		}
	}
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define INF 0X3f3f3f3f
#define ll long long
#define eps 1e-8
using namespace std;
typedef pair<ll,ll> node;
const ll maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
ll n,a,b,m,t,num[maxn],sum,ans = INF;
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> num[i];
    for(int i = 1; i <= 100; i++)
    {
        ll res = 0;
        for(int j = 1; j <= n; j++)
        {
            res += abs(i - num[j]) * abs(i - num[j]);

        }
        ans = min(res,ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
def Dijkstra(edge,r,i):
  d=[INF]*len(edge) 
  que=[]
  heappush(que,(0,r))
  d[r]=0
  while que:
    dist,node=heappop(que)
    for to,*cost in edge[node]:
      if d[to]>cost[i]+dist:
        d[to]=cost[i]+dist
        heappush(que,(d[to],to))
  return d
n,m,s,t=map(int,input().split())
e=[[] for _ in range(n+1)]
for _ in range(m):
  u,v,a,b=map(int,input().split())
  e[u]+=[(v,a,b)]
  e[v]+=[(u,a,b)]
INF=10**18
di=Dijkstra(e,s,0)
dj=Dijkstra(e,t,1)
d=sorted(enumerate([i+j for i,j in zip(di,dj)]),key=lambda x:x[1])[::-1]
for i in range(n):
  while d[-1][0]<=i:d.pop()
  print(10**15-d[-1][1])

Measured memory_bytes: 130964
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String s=br.readLine().trim();
	String t=br.readLine().trim();
	algo(s,t);	
	
	}

	public static void algo(String s,String t) {
		int res=0;
		for(int i=0;i<s.length();i++) {
			char c1=s.charAt(i);
			char c2=t.charAt(i);
			if(c1!=c2) {
				res++;
			}
		}
		System.out.println(res);
		
		
	}
	
	
	
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int d[200010];

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

	int n;cin>>n;

	for(int i=0; i<n-1; i++){
		int tmp;cin>>tmp;

		d[tmp]++;
	}
	for(int i=1; i<=n; i++){

			writeln(d[i]);
			cout<<endl;
	}


}




Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n , a=0 , b=0 , s ;
    cin>>n>>a;
    if (n+a<24)
    {
        cout<<n+a<<endl;
    }
    else
    {
        cout<<n+a-24<<endl;
    }
}


Measured memory_bytes: 3552
H,W=map(int,input().split());S=[input() for _ in range(H)];G=[[-1]*W for _ in range(H)];G[0][0]=1;q=[(0,0)]
while q:
 i,j=q[0];q=q[1:]
 for x,y in[(1,0),(0,1),(-1,0),(0,-1)]:
  t,u=i+x,j+y
  if 0<=t<H and 0<=u<W and G[t][u]<0 and S[t][u]==".":
   G[t][u]=1+G[i][j];q+=[(t,u)]
print(-1*(G[-1][-1]<0)or sum(s.count(".")for s in S)-G[-1][-1])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f  = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5, P = 1e9+7;
int n;
pair<int, int> p[N], h[N];
int f[N], ans;
int t[N], _[N];
void add(int x, int d) { for( ; x <= n; x += x&-x) t[x] = (t[x]+d)%P; }
int ask(int x) { int ret = 0; for( ; x > 0; x -= x&-x) ret = (ret+t[x])%P; return ret; }
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) 
    {
        int x = read(), v = read();
        p[i] = make_pair(x, v);
        _[i] = v;
    }
    sort(_+1, _+1+n), sort(p+1, p+1+n);
    for(int i = 1; i <= n; ++i) p[i].second = lower_bound(_+1, _+1+n, p[i].second)-_+1;
    for(int i = 1, f = 0; i <= n; ++i) f = max(f, p[i].second), h[i].first = f;
    for(int i = n, f = p[n].second; i; --i) f = min(f, p[i].second), h[i].second = f;
    h[++n] = make_pair(1, 1), sort(h+1, h+1+n), f[1] = 1, add(h[1].second, 1);
    for(int i = 2; i <= n; ++i) f[i] = (ask(h[i].first)-ask(h[i].second-2)+P)%P, add(h[i].first, f[i]);
    for(int i = n; i&&h[i].first == h[n].first; --i) ans = (ans+f[i])%P;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ac(0),pn(0);
  
  cin >> n >> m;
  
  vector<int>p(m),cnt(n),sum(n);
  vector<string>s(m);
  
  for(int i = 0;i<m;i++){
    cin >> p.at(i) >> s.at(i);
  }
  for(int i = 0;i<m;i++){
    if(cnt.at(p.at(i)-1) == 0){
      if(s.at(i) == "AC"){
        ac++;
        cnt.at(p.at(i)-1) = 1;
      }else{
        sum.at(p.at(i)-1)++;
      }
    }
  }
  for(int i = 0;i<n;i++){
    if(cnt.at(i) == 1)pn += sum.at(i);
  }
  cout << ac << " " << pn << endl;
}

Measured memory_bytes: 6912
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        WriteLine(N * 800 - 200 * (N / 15));
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] zahyo = new int[n][2];

		for(int i=0;i < n; i++) {
			zahyo[i][0] = sc.nextInt();
			zahyo[i][1] = sc.nextInt();
		}
		double distanceSum = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j) {
					continue;
				}
				distanceSum += getDistance(zahyo[i],zahyo[j]);
			}
		}

		System.out.println(distanceSum/n);

	}

	private static double getDistance(int[] i,int[] z) {
		double distance = 0;
		return Math.sqrt(Math.pow(i[0] -z[0],2) + Math.pow(i[1] -z[1],2));
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) { cin >> h[i]; }
  int count = 0;
  rep(i, n) {
    if (h[i] >= k) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a,b,c = LI()
    if c-b == b-a:
        return 'YES'
    return 'NO'



print(main())


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

int main(){
  int N;
  cin >> N;
  char C;
  
  for(int i = 0; i <N ; i++){
    cin >> C;
      if(i == N-1){
          cout << "Three" << endl;
      }
    if(C == 'Y'){
        cout << "Four" << endl;
        break;
    }
    
    else {
        continue;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L;
  for (int i = 0; i < N; i++) {
  	int X;
    cin >> X;
    L.push_back(X);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] < L[j] + L[k] && L[j] < L[i] + L[k] && L[k] < L[i] + L[j]) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> t = {0};
  int mini = 0;
  int now = 0;
  vector<int> c;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == '>'){
      now--;
    }
    else now++;
    mini = min(now, mini);
    t.push_back(now);
  }
  for(int i = 0; i <= s.length(); i++){
    if(i == 0){
      if(s[i] == '<') c.push_back(i);
    }
    else if(i == s.length()){
      if(s[i-1] == '>') c.push_back(i);
    }
    else if(i > 0 && s[i-1] == '>' && s[i] == '<') c.push_back(i);
  }
  t = vector<int>(s.length()+1, mini+1);
  for(int i = 0; i < c.size(); i++){
    t[c[i]] = mini;
  }
  for(int i = c[0]+1; i < t.size(); i++){
    if(t[i] != mini){
      if(s[i-1] == '<') t[i] = t[i-1] + 1;
    }
  }
  for(int i = 0; i < c.size(); i++){
    t[c[i]] = mini;
  }
  for(int i = c[c.size()-1]-1; i >= 0; i--){
    if(t[i] != mini){
      if(s[i] == '>') t[i] = max(t[i], t[i+1] + 1);
    }
  }
  long long ans= 0;
  for(int i = 0; i < t.size() ; i++){
    ans += t[i] - mini;
  }
  cout << ans << endl;
}


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

class saikoro
{
	private:
		int up, down, right, left, before, behind;
	public:
		saikoro(int a, int b, int c, int d, int e, int f);
		void W(void);
		void S(void);
		void E(void);
		void N(void);
		void turnrl(void);
		void turnud(void);
		int which_up(void);
		int which_right(void);
		int which_before(void);
		int which_down(void);
		int which_left(void);
		int which_behind(void);
};

int main(void)
{
	using namespace std;
	int a1, b1, c1, d1, e1, f1;
	int a2, b2, c2, d2, e2, f2;
	int flag = 0, count = 0;
	cin >> a1 >> b1 >> c1 >> d1 >> e1 >> f1;
	cin >> a2 >> b2 >> c2 >> d2 >> e2 >> f2;
	saikoro sai1(a1, b1, c1, d1, e1, f1);
	saikoro sai2(a2, b2, c2, d2, e2, f2);
	for(int i = 0; i < 3; i++)
			{
				sai1.turnud();
				if(sai1.which_up() == sai2.which_up())
				{
					while(sai1.which_before() != sai2.which_before())
					{
						sai1.turnrl();
						count++;
						if(count > 3)
							break;
					}
					break;
				}
			}
			if(sai1.which_up() != sai2.which_up())
			{
				sai1.E();
				count = 0;
				while(sai1.which_up() != sai2.which_up())
				{
					sai1.turnud();
					count++;
					if(count > 3)
						break;
				}
				count = 0;
				while(sai1.which_before() != sai2.which_before())
				{
					sai1.turnrl();
					count++;
					if(count > 3)
						break;
				}
			}
	if(sai1.which_right() == sai2.which_right() && sai1.which_left() == sai2.which_left() && sai1.which_down() == sai2.which_down() && sai1.which_behind() == sai2.which_behind())
		flag = 1;
	if(flag == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

saikoro::saikoro(int a, int b, int c, int d, int e, int f)
{
	up = a;
	before = b;
	behind = e;
	right = c;
	left = d;
	down = f;
}

void saikoro::W(void)
{
	int temp = left;
	left = up;
	up = right;
	right = down;
	down = temp;
}

void saikoro::S(void)
{
	int temp = before;
	before = up;
	up = behind;
	behind = down;
	down = temp;
}

void saikoro::E(void)
{
	int temp = right;
	right = up;
	up = left;
	left = down;
	down = temp;
}

void saikoro::N(void)
{
	int temp = behind;
	behind = up;
	up = before;
	before = down;
	down = temp;
}

void saikoro::turnrl(void)
{
	int temp = left;
	left = before;
	before = right;
	right = behind;
	behind = temp;
}

void saikoro::turnud(void)
{
	int temp = up;
	up = before;
	before = down;
	down = behind;
	behind = temp;
}

int saikoro::which_up(void)
{
	return up;
}

int saikoro::which_right(void)
{
	return right;
}

int saikoro::which_before(void)
{
	return before;
}

int saikoro::which_down(void)
{
	return down;
}


int saikoro::which_left(void)
{
	return left;
}


int saikoro::which_behind(void)
{
	return behind;
}


Measured memory_bytes: 3136
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while (true) {
        int a, b;
        cin >> a >> b;
        if (a == b && a == 0) {
            break;
        } else if (a < b) {
            cout << a << " " << b << endl;
        } else if (a >= b) {
            cout << b << " " << a << endl;
        }
    }
}



Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m,a[301][301],ans=2e9,sum[301],now[301],mx,b[301];
int main(void){
	register int i,j;
	n=read(),m=read();
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j)
			a[i][j]=read();
		++sum[a[i][1]],now[i]=1;
	}
	for(i=1;i<=n;++i)
		if(sum[a[i][1]]>sum[mx])
			mx=a[i][1];	
	ans=min(ans,sum[mx]);
	for(i=1;i<m;++i){
		b[mx]=1,mx=0;
		for(j=1;j<=n;++j){
			int s=0;
			if(b[a[j][now[j]]])
				--sum[a[j][now[j]]];
			while(b[a[j][now[j]]])
				++now[j],s=1;
			sum[a[j][now[j]]]+=s;
			if(sum[a[j][now[j]]]>sum[mx])
				mx=a[j][now[j]];
		}
		ans=min(ans,sum[mx]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
A,B,K=map(int,input().split())
C=min(A,B)
D=[0]*C

for i in range(C):
  if A%(i+1) == 0 and B%(i+1) == 0:
    D[i]=i+1
  else:
    D[i]=0

D=sorted(D,reverse=True)
print(D[K-1])

Measured memory_bytes: 3064
n,m,*a=map(int,open(0).read().split())
d=[0]*-~n
for i in range(1,n+1):
 for j,k in zip((1,2,3,4,5,6,7,8,9),(2,5,5,4,5,6,3,7,6)):
  if j in a and i-k>=0and(i-k<1or d[i-k]):d[i]=max(d[i],d[i-k]*10+j)
print(d[n])

Measured memory_bytes: 14388
main(){double a,b,c,d,e,f,g,h;for(;~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f,&g,&h);)puts((a-c)*(e-g)+(b-d)*(f-h)?"NO":"YES");exit(0);}

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7) cout << "YES" << endl;
    else cout << "NO" << endl;   
}

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

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

using namespace std;

int main(){
    int A, B;
    int sum, sub, product;
    int temp;
    cin >> A >> B;
    sum = A + B;
    sub = A - B;
    product = A * B;

    temp = max(sum, sub);
    cout << max(temp, product) << endl;

    return 0;
}



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

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << ":" << x << endl

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
    
    
}

using namespace atcoder;

int main(void) {
    int N;
    cin >> N;
    string ans;
    if(N == 0){
        cout << "0" << endl;
        return 0;
    }
    while(N != 0){
        if(N%2 == 0){
            ans = "0" + ans;
        }else{
            ans = "1" + ans;
            N-=1;
        }
        N/=-2;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/*

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String[] b = a.split("");

        int count = 0;
        if (a.equals("RRR")) {
            count = 3;
        } else if (a.contains("RR")) {
            count = 2;
        } else if (a.contains("R")) {
            count = 1;
        }
        // for (int i = 0; i < b.length; i++) {
        //     if (b[i].equals("R")) {
        //         count++;
        //     }
        // }
            System.out.println(count);
        // }

    }
}

Measured memory_bytes: 35588
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    n = len(s) - 1

    # bit全探索
    for i in r(1 << n):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if (i >> j & 1) > 0:
                p += "+"
            if j == n:
                break
        # p += s[-1]
        ans += eval(p)
    print(ans)


main()


Measured memory_bytes: 3192
#include <stdio.h>
#include<math.h>
#define MAX 2000005

int i,j,n;
int A[MAX], B[MAX], C[10000];

void countSort(int a[], int b[], int k){
	for (i = 0; i <= k; i++)
		C[i] = 0;
	for (j = 1; j < n+1; j++)
        C[a[j]]++;
    for (i = 1; i <= k; i++)
    	C[i] = C[i] + C[i-1];
    for (j = n; j >= 1; j--){ 
       b[C[a[j]]] = a[j];
       C[a[j]]--;
    }
}


int main(void){
	scanf("%d ", &n);
	for(i=1; i<=n; i++)
		scanf("%d ", &A[i]);
	
	int max = A[1];
	for (i=2; i<=n; i++){
		if (A[i]>max)
			max = A[i];
	}
	
	countSort(A,B,max);
	
	for (i=1; i<=n; i++){
		if (i<n)
			printf("%d ", B[i]);
		else printf("%d\n", B[i]);
	}
	return 0;
}





Measured memory_bytes: 17352
//ABC166 C

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n,m;
lint h[200001];
lint a[200001],b[200001];
lint score[200001];
lint res = 0;


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

  rep(i,n){
    scanf("%lld",&h[i+1]);
  }
  rep(i,m){
    scanf("%lld %lld",&a[i],&b[i]);
  }
  
  
  rep(i,m){
    score[a[i]] = max(score[a[i]],h[b[i]]);
    score[b[i]] = max(score[b[i]],h[a[i]]);
  }
  reps(i,1,n+1){
    if(score[i] < h[i]) ans++;
  }
  
  printf("%lld\n",ans);
}


Measured memory_bytes: 6960
N, K = map(int, input().split())
d = list(map(int, input().split()))
left = [0]
left_m = []
right = [0]
right_m = []
for i, l, r in zip(range(K), d, d[::-1]):
    left.append(left[i] + l)
    left_m.append(l if l < 0 else 0)
    right.append(right[i] + r)
    right_m.append(r if r < 0 else 0)
point = 0
m = min(N, K)
for i in range(m + 1):
    for j in range(m - i + 1):
        p = K - i - j
        minus = list(sorted(left_m[:i] + right_m[:j]))
        point = max(point, left[i] + right[j] - sum(minus[:p]))
print(point)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a,b;
string sa , sb;
int main(){
	char ca , cb;
	cin>>a>>b;
	ca = '0'+a;
	cb = '0'+b;
	for(int i=1;i<=b;i++)sa = sa + ca;
	for(int i=1;i<=a;i++)sb = sb + cb;
	if(sa < sb) cout << sa<<endl;
	else cout<<sb<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b, n := nextInt(), nextInt(), nextInt()

	x := min(b-1, n)
	puts((a * x) / b)
}


Measured memory_bytes: 1764
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n,m,k,a;
map<int,int> ma;
void input(){
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k){
            cin>>a;
            ma[a]++;
        }
    }
}
void src(){
    int ans=0;
    for(auto s:ma){
        if(s.second==n) ans++;
    }
    cout<<ans;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
double per[3000];
double dp[3000][3000];
int main() {
	cin >> N;
	REP(i, N) {
		cin >> per[i];
	}
	dp[0][0] = 1;
	REP(i, N) {
		REP(j, N) {
			dp[i + 1][j + 1] += dp[i][j] * per[i];
			dp[i + 1][j] += dp[i][j] * (1 - per[i]);
		}
	}
	double per_sum = 0;
	REP(i, N + 1) {
		if (i > N - i) per_sum += dp[N][i];
	}
	cout << setprecision(14) << per_sum << endl;
}


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

using namespace std;

struct Process {
  string name;
  int time;
};

const int LEN = 100005;
Process p_queue[LEN];
int head, tail, n;

void enqueue(Process p) {
  p_queue[tail] = p;
  tail = (tail + 1 ) % LEN;
}

Process dequeue() {
  Process p = p_queue[head];
  head = (head + 1) % LEN;
  return p;
}

int min(int a, int b) {
  return a < b ? a : b;
}

int main() {
  int q;
  int total_time = 0, c;
  Process u;

  cin >> n;
  cin >> q;

  for (int i = 1; i <= n; i++) {
    string name;
    cin >> name;
    int time;
    cin >> time;

    p_queue[i].name = name;
    p_queue[i].time = time;
  }
  head = 1;
  tail = n + 1;

  while (head != tail) {
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    total_time += c;
    if (u.time > 0) {
      enqueue(u);
    } else {
      cout << u.name << " " << total_time << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 5116
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
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 mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main() {
	COMinit();

	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	int a[100005];
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	int sum[100005];
	sum[0] = 0;
	rep(i, n) {
		sum[i + 1] = sum[i] + a[i];
		sum[i + 1] %= MOD;
	}

/*	rep(i, n + 1) {
		cout << sum[i] << " ";
	}
	cout << endl;*/

	int ans = 0;
	for (int i = k; i <= n; i++) {
		int now = ((sum[n] - sum[i - 1]) - (sum[n - i + 1] - sum[0]) )% MOD;
		//cout << now << endl;
		ans += (now * COM(i - 2, k - 2)) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13696
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a;
    cin >> a;
    if (a == 7 || a == 5 || a == 3) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans=1.0*w*h/2;
    int flag=0;
    if (2*x==w && 2*y==h) flag=1;
    cout << ans << ' ' << flag << endl;

    return 0;   
}

Measured memory_bytes: 3776
$a=[]
class Tree
    attr_accessor :id, :parent, :sibling, :degree, :depth, :height, :children, :type
    def initialize(id, children, degree)
        @id = id
        @parent = -1
        @sibling = -1
        @degree = degree
        @height = 0
        @children = children
        @type = (children == [-1, -1] ? 'leaf' : 'internal node')
    end

    def setDepth
        children.each {|c|
            unless c == -1
                $a[c].depth = depth + 1
                $a[c].setDepth
            end
        }
    end

    def setHeight
        unless parent == -1
            $a[parent].height = height + 1 if $a[parent].height < height + 1
            $a[parent].setHeight
        end
    end

    def print
        puts "node #{id}: parent = #{parent}, sibling = #{sibling}, degree = #{degree}, depth = #{depth}, height = #{height}, #{type}"
    end
end

N = gets.to_i

N.times {
    id, *children = gets.split.map(&:to_i)
    degree = 2
    children.each {|e| degree -= 1 if e == -1}
    $a << Tree.new(id, children, degree)
}
$a.sort_by! {|e| e.id}
$a.each {|ele|
    ele.children.each {|e|
        unless e == -1
            $a[e].parent = ele.id
            $a[e].sibling = (e == ele.children[0] ? ele.children[1] : ele.children[0])
        end
    }
}
$a.each {|e|
    if e.parent == -1
        e.type = 'root'
        e.depth = 0
        e.setDepth
    end

    e.setHeight if e.type == 'leaf'
}
$a.each {|e| e.print}

Measured memory_bytes: 6128
#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;
 
vvl G;
vl dp(MAX_N);  // dp[v] : 人vに対応する頂点を根とした部分木のトーナメントの深さの最小値
 
void dfs(ll v) {
    vl a;
    dp[v] = G[v].size();
    for(auto u : G[v]) {
        dfs(u);
        a.pb(dp[u]);
    }
    sort(rall(a));
    rep(i, G[v].size()) {
        chmax(dp[v], a[i] + i+1);
    }
}
 
int main() {
    ll n;
    cin >> n;
    
    G.resize(n);
    exrep(i, 1, n-1) {
        ll v;
        cin >> v;
        v--;
        G[v].pb(i);
    }

    dfs(0);
    
    out(dp[0]);
    re0;
}

Measured memory_bytes: 17408
#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++)
typedef long long ll;
using namespace std;
int main(){
    int n;cin>>n;
    rep(i,n){
        int a;cin>>a;
        if(a%2!=0)continue;
        if(!(a%5==0||a%3==0)){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>


using namespace std;


int main() {

	int x, a[10009], n;
	int cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;

	

}



Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s1 = ins()
s2 = ins()
if s1[0]==s2[0]:
    p = 3
    i = 1
else:
    p = 6
    i = 2
while i<n:
    if s1[i-1]==s2[i-1]:
        if s1[i]==s2[i]:
            p = (p*2)%R
            i += 1
        else:
            p = (p*2)%R
            i += 2
    else:
        if s1[i]==s2[i]:
            i += 1
        else:
            p = (p*3)%R
            i += 2
print(p)


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

ll findSumOfDigits(ll n) {
  ll sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  // ll n;
  // cin >> n;
  // ll sum = findSumOfDigits(n);
  // string ans = "No";
  // if (sum % 9 == 0) ans = "Yes";
  // cout << ans << endl;
  string n;
  cin >> n;
  string ans = "No";
  ll sum = 0;
  rep(i, n.size()) {
    char c = n[i];
    sum += c - '0';
  }
  if (sum % 9 == 0) ans = "Yes";
  cout << ans << endl;
  return 0;
}

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

int main(){
    string S;
    cin>>S;
    vector<string> v;
    int x[4];
    for(int i=0;i<4;i++)
        x[i]=S[i]-'0';

    for(int bit=0;bit<1<<3;++bit){
         int sum=x[0];
         v.clear();
         for(int i=0;i<3;++i){   
             if(bit&(1<<i)){
                 sum+=x[i+1];
                 v.push_back("+");
             }
             else {
                sum-=x[i+1];
                v.push_back("-");
             }
         }
         if(sum==7) {
             cout<<x[0]<<v[0]<<x[1]<<v[1]<<x[2]<<v[2]<<x[3]<<"=7"<<endl;
             goto lol;}     
        }
  lol:
  return 0;
}

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

int main(void) {
    int len;
    cin >> len;
    for (int i = 0; i<len;i++) {
        int a;
        cin >> a;
        if( a % 2 == 0) {
            if(! (a % 3 == 0 || a % 5 == 0) ){
                cout << "DENIED" << endl;
                    return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll t,i,j,n,d,x,y;
	cin>>n>>d;
	ll ans=0;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		ll val = (x*x) + (y*y);
		double check=(double)(sqrt(val));
		if(check <= (d*1.0)) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3692
a, b, c, d = map(int, input().split())
ans = 0
if a <= c <= b <= d:
    ans = b-c
if c <= a <= d <= b:
    ans = d-a
if a <= c <= d <= b:
    ans = d-c
if c <= a <= b <= d:
    ans = b-a
print(ans)

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

dic = {}

for _ in range(N):
    A,B = map(int,input().split())
    if B in dic:
        dic[B] += A
    else:
        dic[B] = A

cum = 0    
flag = True
dic_sort = sorted(dic.items(), key=lambda x:x[0])

for bb,aa in dic_sort:
    cum += aa
    if bb < cum:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;

bool is_prime(int x)
{
	if (x < 2) return false;
	if (x == 2) return true;
	for (int i = 2; i <= x / i; i ++ )
		if (x % i == 0)
			return false;
	return true;
}

int main()
{
	cin >> n;
	for (int i = 2; i <= 55555; i ++ )
		if (is_prime(i) && i % 5 == 1)
		{
			cout << i << ' ';
			if ( -- n == 0) return 0;
		}
	return 0;
}

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

int main() {
  int n,m;
  while(cin >> n >> m && (n && m)) {
    vector<int> a;
    for(int i=0; i<n; i++) a.push_back(i+1);
    int k=-1;
    while(a.size()>1) {
      k+=m;
      if(k>=a.size()) k%=a.size();
      a.erase(a.begin()+k);
      k--;
    }
    cout << a[0] << endl;
  }
}


Measured memory_bytes: 1228