akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807ll
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        100000000000007ll
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  10005
ll dp[10001][1001];
ll h,n;
ll A[N],B[N];
ll dps(ll hel,ll ind)
{
    if(hel<0)
        return 0;
    if(ind==0&&hel!=0)
    {
        return hell;
    }
    if(dp[hel][ind]!=-1)
        return dp[hel][ind];
    if(hel==0)
    {
        return dp[hel][ind]=0;    
    }
    vi v;
    v.pb(dps(hel-A[ind-1],ind-1)+B[ind-1]);
    v.pb(dps(hel,ind-1));
    // v.pb(dps(hel,ind-1));
    v.pb(dps(hel-A[ind-1],ind)+B[ind-1]);
    sort(all(v));

    dp[hel][ind]=v[0];
    return dp[hel][ind];
}
void solve()
{
    cin>>h>>n;
    rep(i,0,n)
    {
        cin>>A[i]>>B[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<dps(h,n)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int64_t S;
  cin>>S;
  int64_t a;
  a=S/500;
  S=S-(a*500);
  cout<<a*1000+(S/5)*5;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func digit(n, k int) int {
	var dig float64 = math.Log10(float64(n)) / math.Log10(float64(k))
	return int(dig + 1.0)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	fmt.Println(digit(n, k))
}

Measured memory_bytes: 640
n,m = map(int,input().split())
s = list(map(int,input().split()))
check = 1/(4*m)*sum(s)
#print(check)
count = 0
for i in range(n):
  if s[i] >= check:
    count += 1
if count >= m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A + B >= C - 1)System.out.println(B + C);
        else System.out.println(B + (A + B + 1));
        sc.close();
    }

}


Measured memory_bytes: 22228
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47616
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] ary = new int[N][2];
		for(int i = 0;i < N;i++) {
			ary[i][0] = sc.nextInt();
			ary[i][1] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(ary, Comparator.comparingInt(i -> i[0]));
		long res = 0;
		int cnt = 0;
		Queue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
		for(int i = 0;i < M;i++) {
			while(cnt< N && ary[cnt][0]<=i+1) {
				pq.add(ary[cnt][1]);
				cnt++;
			}
			if(!pq.isEmpty())res += (long)pq.poll();
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 95868
#include <stdio.h>

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

    int p;
    if (n <= k) {
        p = n * x;
    } else {
        p = k * x + ((n-k) * y);
    }

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

    return 0;
}

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

using namespace std;

const int M = 1e9+7;
int n, m;
int s[2200];
int t[2200];
long long dp[2200][2200];
long long sum[2200][2200];

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = (sum[i-1][j-1] + 1) % M;
      }
      sum[i][j] += (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + M) % M;
    }
  }
  
  cout << (sum[n][m] + 1) % M << endl;
  return 0;
}

Measured memory_bytes: 71936
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    int n;
    vector<int> A;
    void input(){
        cin >> n;
        A.resize(n);
        rep(i,0,n) cin >> A[i];

    }
    void solve(){
        input();
        sort(all(A));
        cout << A.back() - A.front() << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 512
from operator import itemgetter

n,m= map(int, input().split())
py = [list(map(int, input().split())) for i in range(m)]


for i in range(m):
    py[i].append(i)

py.sort(key = itemgetter(1))
py.sort(key = itemgetter(0))

py[0].append(str(py[0][0]).zfill(6)+str(1).zfill(6))

if m == 0:
    print(py[0][3])
    exit()

for i in range(1,m):
    if py[i][0]!=py[i-1][0]:
        py[i].append(str(py[i][0]).zfill(6)+str(1).zfill(6))
    else:
        py[i].append(str(int(py[i-1][3])+1).zfill(12))

py.sort(key = itemgetter(2))

for i in range(m):
    print(py[i][3])

Measured memory_bytes: 38476
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;

int main(){
    cin >> N;
    ll ans=0;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = list(map(str, input().split()))
# print(b)

# print(b[1][1])
# print(type(int(b[1][1])))

# for k in range(len(b)):
#     c.append(b[k][1])
# print(c)

c = b[:] #リストで参照渡しをせずに、値のみを渡す方法。
d = b[:]

# print(id(b))
# print(id(c))
# print(id(d))

def BubleSort(c):
    for i in range(len(c)):
        for j in range(len(c)-1,i,-1):
            if int(c[j][1])<int(c[j-1][1]):
                c[j],c[j-1]= c[j-1],c[j]
    return c

def isStable(In, Out):
    for m in range(0,len(Out)):
        for n in range(m+1,len(Out)):
            for x in range(0,len(Out)):
                for y in range(x+1,len(Out)):
                    if int(In[m][1])==int(In[n][1]) and In[m] == Out[y] and In[n] == Out[x]:
                        return print('Not stable')
    return print('Stable')

def SelectSort(d):
    for i in range(len(d)-1):
        mini = i
        for j in range(i+1,len(d)):
            if int(d[mini][1])>int(d[j][1]):
                mini=j
        if int(d[mini][1])!=int(d[i][1]):
            d[i],d[mini]=d[mini],d[i]
    return d


print(*BubleSort(c))
isStable(c,b)
# print(d)
# print(b)
print(*SelectSort(d))
isStable(d,b)


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

int main() {
    char c;
    cin >> c;

    if(c == 'a' || c == 'e' || c=='i' || c=='o' || c=='u'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 3596
import java.util.Scanner;
 
public class Main{
    public static void main( String[] args ) throws Exception {
        Scanner in = new Scanner( System.in );
        char a = in.next().charAt( 0 );
        char b = in.next().charAt( 0 );
        char c = in.next().charAt( 0 );
        System.out.println( a + "" + b + "" + c );
    }
}

Measured memory_bytes: 9676
#include<stdio.h>
#define M 2000000
int n,A[M];

void maxH(int);
void swap(int *,int *);


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

  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  for(i=n/2;i>=1;i--) maxH(i);
  for(i=1;i<=n;i++){
    
    printf(" %d",A[i]);
  }

  printf("\n");
  
  return 0;
}

void maxH(int i){
  int l,r,b;
  l=2*i;
  r=2*i+1;
    if(l<=n&&A[l] >A[i]) b =l;
    else b = i;

    if(r<=n&&A[r]>A[b]) b =r;
  if(b!=i){
    swap(&A[i],&A[b]);
    maxH(b);
    
  }
}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
  return;
}




Measured memory_bytes: 3736
x, y = map(int, input().split())
count = 0
for c in range(x + 1):
    for t in range(x + 1):
        if c + t == x and c * 4 + t * 2 == y:
            count += 1

if count > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#include <stdio.h>
#include <math.h>

int main()
{
    int a, b;
    double C, S, L, h;
    
    scanf("%d%d%lf", &a, &b, &C);
    C = C * M_PI/180;
    S = 0.5*a*b*sin(C);
    L = a + b + sqrt((a*a) + (b*b) - 2*a*b*cos(C));
    h = 2*S/a;
    
    printf("%f %f %f\n", S, L, h);
    
    return 0;
}

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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    ll a=rr,b=rr,x=rr;

    ll aa = (a+x-1)/x;
    ll bb = b/x;

    ll ans = bb-aa+1;
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
n,c,k = gets.split.map(&:to_i)
ts = n.times.map {gets.to_i}.sort
d_time = ts.shift
cnt = 1
ans_cnt = 1

ts.each do |t|
  if t <= d_time+k && cnt+1 <= c
    cnt += 1
  else
    cnt = 1
    d_time = t
    ans_cnt += 1
  end
end
puts ans_cnt

Measured memory_bytes: 6576
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)

#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define siz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__)
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

// #define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(string,s);
  int ss=siz(s);
  int ans=0,c=0;
  fou(i,0,ss){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      c++;
    }else{
      maxi(ans,c);
      c=0;
    }
  }
  maxi(ans,c);
  out(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

struct Point {
  double x, y;

  void print() {
    printf("%.8f %.8f\n", x, y);
  }
};

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2 * a.x + 1 * b.x) / 3;
  s.y = (2 * a.y + 1 * b.y) / 3;
  t.x = (1 * a.x + 2 * b.x) / 3;
  t.y = (1 * a.y + 2 * b.y) / 3;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  s.print();
  koch(n - 1, s, u);
  u.print();
  koch(n - 1, u, t);
  t.print();
  koch(n - 1, t, b);
}

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

  a.x = 0;
  a.y = 0;
  b.x = 100.0;
  b.y = 0;

  a.print();
  koch(n, a, b);
  b.print();

  return 0;
}



Measured memory_bytes: 2760
# -*- 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 functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


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

INF = 2**62-1


def read_int():
    return int(buff_readline())


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


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_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.time()
        ret = f(*args, **kwargs)
        e = time.time()

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

    return wrap


@mt
def slv(N, A):
    ans = 0
    for i, a in enumerate(A, start=1):
        if i % 2 == 1 and a % 2 == 1:
            ans += 1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76828
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;
int main(){
    int n; cin >> n;
    int maxV = -1000000000;
    
    vector<int> v;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }
    int minV = v[0];
    for(int i = 1; i < n; i++){
        maxV = max(maxV, v[i] - minV);
        minV = min(minV, v[i]);
        
    }
    cout << maxV  << endl;
    return 0;
}   

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

struct BBox
{
	int BN;
	bool red;
};

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

	BBox box[N+3];
	int x,y;

	for(int i=1;i<N+1;i++)
	{
		box[i].BN = 1;
		box[i].red=false;
	}
	box[1].red = true;


	for(int i=0;i<M;i++)
	{
		cin >> x >> y; 

		if(box[x].red == true && box[x].BN ==1)
		{
			box[x].red = false;
			box[y].red = true;
		}else if(box[x].red == true && box[x].BN >1){
			box[y].red = true;
		}

		box[x].BN = box[x].BN -1;
		box[y].BN = box[y].BN +1;

	}

	int possible=0;
	for(int i=1;i<N+1; i++ )
	{
		if(box[i].red == true )
		{
			possible++;
		}
	}

	cout << possible << endl; 

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t x;
    cin >> x;

    int64_t price = 100;
    int64_t ans = 0;
    while(price < x) {
        price = (int64_t)((double)price * 1.01);
        ans++;
    }

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

Measured memory_bytes: 3676
import sys
input = sys.stdin.readline

#+++++
		
def main():
	n, m = map(int, input().split())
	
	nn=[ [] for _ in range(n+1)]
	
	for _ in range(m):
		u, v = map(int, input().split())
		nn[u].append(v)
		
	start, goal = map(int, input().split())
	
	arrived = set()
	opened = [start]
	cc=1
	while len(opened) > 0:
		#print(arrived)
		#print(opened)
		for i in opened:
			arrived.add(i)
		tt =opened.copy()
		opened=[]
		
		
		for i in range(3):
			temp=set()
			for p in tt:
				for i in nn[p]:
					temp.add(i)
			tt=list(temp)
			#print('tt:'+str(tt))
		#print('ccccc'+str(goal)+':'+str(tt))
		if goal in tt:
			return cc
		cc+=1
		
		for ttt in tt:
			if ttt not in arrived:
				opened.append(ttt)
	return -1
		
		

	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 24104
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
vi adj[maxn];
int vis[maxn];
int n,m;
int ans;
void dfs(int curr,int c)
{
    vis[curr]=1;
    if(c==n)ans++;
    for(int child:adj[curr])
    {
        if(vis[child]==0)dfs(child,c+1);
    }
    vis[curr]=0;
}
void solve()
{
    cin>>n>>m;
    while(m--)
    {
        int a,b;cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1,1);
    cout<<ans<<endl;


}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}



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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            //var s = Console.ReadLine().Split(' ');
            var s = Console.ReadLine();
            var ww = Console.ReadLine();

            int w = int.Parse(ww);
            //int n, m;
            //n = int.Parse(s[0]);
            //m = int.Parse(s[1]);
            string result = "";
            for(int i = 0; i<s.Length;i += w)
            {
                result += s[i];
            }

            Console.WriteLine(result);

        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    b++;
    for(int i=a;i<min(a+c,b);i++) cout<<i<<endl;
    for(int i=max(a+c,b-c);i<b;i++) cout<<i<<endl;
}



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

using namespace std;

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

    int res = 32;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        int r = 0;
        for (int j = a; j % 2 == 0; j /= 2) {
            r++;
        }

        res = min(res, r);
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

signed main(){
	IOS;
	ll n;
	cin >> n;
	string l,r,m;
	ll left = 0,right = n - 1;
	ll mid;
	dump(left);
	cin >> l;
	if(l == "Vacant"){
		return 0;
	}
	dump(right);
	cin >> r;
	if(l == "Vacant"){
		return 0;
	}
	REP(i,20){
		ll mid = (right + left) / 2;
		dump(mid);
		cin >> m;
		if(m == "Vacant"){
			return 0;
		}
		if(((right - mid) % 2 == 0 && m != r) || ((right - mid) % 2 == 1 && m == r)){
			left = mid;
			l = m;
		}
		else if(((mid - left) % 2 == 0 && l != m) || ((mid - left) % 2 == 1 && l == m)){
			right = mid;
			r = m;
		}
	}
}

Measured memory_bytes: 852
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, d = list(map(int, input().rstrip('\n').split()))
    if b <= c or d <= a:
        print(0)
    else:
        print(abs(min(d, b) - max(c, a)))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;
int lst[Max];

int main()
{
	ll n, t;
	cin >> n >> t;
	ll sum = 0, f;
	cin >> f;
	for (int i = 2;i <= n;i++)
	{
		ll r;
		scanf("%lld", &r);
		sum += min(t, r - f);
		f = r;
	}
	cout << sum + t;
}

Measured memory_bytes: 3196
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    n,x,t = readInt()
    print((n+x-1)//x*t)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9156
#include<cstdio>
#include<algorithm>
using namespace std;
int k,n;
int main(){
	scanf("%d",&k);
	if(k==1)return puts("1\n1"),0;
	while(n+n<k)n+=2;
	printf("%d\n",n);
	for(int i=0;i<n;++i,puts(""))
		for(int j=0;j<n;++j){
			int x=(i+j)%n+(i&1?0:n);
			if(x>=k)x-=n;
			printf("%d ",x+1);
		}
	return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace ABC92_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string[] s = ReadLine().Split(' ');
            int[] a = new int[N+2];
            for (int i = 1; i < N + 1; i++)
            {
                a[i] = int.Parse(s[i-1]);
            }
            a[0] = 0;
            a[N+1] = 0;
            int[] sum = new int[N+2];
            sum[0] = 0;
            for (int i = 0; i < N + 1; i++)
            {
                sum[i + 1] = sum[i] + Math.Abs(a[i + 1] - a[i]);
            }
            int f;
            int x;
            for (int i = 0; i < N + 1; i++)
            {
                if (i > 0)
                {
                    f = sum[i-1];
                    x = a[i-1];
                    f += Math.Abs(a[i+1] - x) + sum[N + 1] - sum[i+1];   
                    WriteLine(f);
                }
            }
        }
    }
}


Measured memory_bytes: 25180
use std::io::*;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let t: usize = read();

    println!("{}", (t / a) * b);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
from statistics import mean

N = int(input())
A = list(map(int, input().split()))

S = [A[0]]
for i in range(1, N):
    S.append(S[i - 1] + A[i])   

left_middle = 0
right_middle = 2

ans = float('inf')

for middle in range(1, N - 2):
    left_sum = S[left_middle]
    right_sum = S[middle] - left_sum
    diff = abs(left_sum - right_sum)

    for i in range(left_middle+1, middle):
        left_sum = S[i]
        right_sum = S[middle] - left_sum
        if diff > abs(left_sum - right_sum):
            left_middle = i
            diff = abs(left_sum - right_sum)
        else:
            break
    
    left_sum = S[right_middle] - S[middle]
    right_sum = S[-1] - S[right_middle]
    diff = abs(left_sum - right_sum)

    for i in range(right_middle + 1, N):
        left_sum = S[i] - S[middle]
        right_sum = S[-1] - S[i]
        if diff > abs(left_sum - right_sum):
            right_middle = i
            diff = abs(left_sum - right_sum)
        else:
            break
    
    s1 = S[left_middle]
    s2 = S[middle] - s1
    s3 = S[right_middle] - s1 - s2
    s4 = S[-1] - s1 - s2 - s3

    score = max(s1, s2, s3, s4) - min(s1, s2, s3, s4)
    ans = min(ans, score)

print(ans)
        


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

char buf[10];
int main() {
	int a[4], b[4];
	while (gets(buf), strcmp(buf, "0 0")) {
		char*s = buf;
		rep(i, 4) { sscanf(s, "%1d", &a[i]); s += 1; }s += 1;
		rep(i, 4) { sscanf(s, "%1d", &b[i]); s += 1; }
		int hit = 0, blow = 0;
		rep(i, 4)if (a[i] == b[i])hit++;
		rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
		cout << hit << ' ' << blow - hit << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		v[i] = t;
	}
	int minj = 0;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		minj = i;
		bool flag = false;
		for (int j = i; j < n; j++)
		{
			if (v[j] < v[minj])
			{
				minj = j;
				flag = true;
			}
		}
		swap(v[i], v[minj]);
		if(flag)ans++;
	}
	for (int i = 0; i < n; i++)
	{
		cout << v[i];
		if (i == n - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	cout << ans << endl;
	return 0;
}

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

char s[110];

int main() {
    int len;
    scanf("%d%s", &len, s);
    int cnt1 = 0;
    for (int i = 0; i < len; i++) 
        if (s[i] == 'R') 
            cnt1++;
    if (cnt1 > len / 2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 128
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	string s; cin >> s;
	ll sum = 0;
	REP(i, s.size()){
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

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

using namespace std;

int upcmp(const void *p,const void *q){
    return *(int*)p-*(int*)q;
}

int downcmp(const void *p,const void *q){
  return *(int*)q-*(int*)p;
}

int main(void){
  int A,B,C;
  cin >> A >> B >> C;
  int ans=C-(A-B);
  if(ans<0){
    cout << "0" << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;




ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

int firstDigit(ll a) {
    auto l = to_string(a);
    return int(l[0]) - 48;
}

void oneCase () {
    ll n;
    cin >> n;
    ll count = 0;
    vector<int> table(100);
    for (ll a = 1; a <= n; ++a) {
        auto last = a % 10;
        auto first = firstDigit(a);
        ++table[10 * first + last];
    }
    for (ll a = 1; a <= n; ++a) {
        auto last = a % 10;
        auto first = firstDigit(a);
        count += table[10 * last + first];
    }
    cout << count << "\n";
}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
#define endl "\n"
#define max_ll 2e18

// std::vector<int> ad[100005];

// int vis[100005]={},intime[100005],low[100005],timer=0;
// int flag=0;
// vector<pair<int,int>> ans;

// void dfs(int node, int par){
//     vis[node]=1;
//     intime[node]=low[node]=timer++;
//     for(auto child:ad[node]){
//         if(child==par) continue;
//         if(vis[child]){
//             low[node] = min(low[node],low[child]);
//             if(intime[child]<intime[node]) ans.pb({node,child});
//         }
//         else{
//             dfs(child,node);
//             if(low[child]>intime[node]){
//                 flag=1;
//                 return;
//             }
//             low[node] = min(low[child],low[node]);
//             ans.pb({node,child});
//         }
//     }
// }

ll check(ll t,ll m,ll i){
    ll ans=0,n=t;
    while(n>0){
        ans+=n%i;
        n=n/i;
    }
    return m==ans;
}

void answer(){
    ll n,m,x,y,ans=max_ll;
    cin>>n>>m;
    x = n;
    if(n<m){
        cout<<-1;
        return;
    }
    if(n==m){
        cout<<n+1;
        return;
    }
    ll s = sqrt(n)+1;
    for(int i=2;i<=s;i++){
        x=n;
        y=0;
        while(x>0){
            y+=x%i;
            x = x/i;
        }
        if(m==y){
            ans=i;
            break;
        }
    }
    ll t;
    
        t = n-m;
        //cout<<t<<endl;
        for(ll i=1;i*i<=t;i++){
            if(t%i!=0){
                continue;
            }
            if(check(n,m,i+1)){
                ans=min(ans,i+1);
            }
            if(check(n,m,t/i+1)){
                ans=min(ans,1+t/i);
            }
            //cout<<i<<" "<<t/i+1<<" "<<n<<endl;
            //cout<<ans<<" \n";
        }
    
    cout<<((ans==max_ll)?-1:ans)<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0] * n 
asum = 0
for i in range(n):
  a[i] = (p[i]+1)/2 + asum
  asum = a[i]
ans = a[k-1]
for f in range(1, n-k+1):
  ans = max([ans, a[f+k-1] - a[f-1]])
print(ans)  

Measured memory_bytes: 32048
import scala.collection.JavaConverters._

object Main extends App {
  val scanner = new java.util.Scanner(System.in).asScala

  val data = scanner.map(_.toInt).takeWhile(_ != 0).zipWithIndex.toList
  data.foreach {
    case (x, i) =>
      println(s"Case ${i+1}: ${x}")
  }
}

Measured memory_bytes: 69936
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int dp[n+1]={0};
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
	}
	cout << dp[n-1];
}


Measured memory_bytes: 1792
#include<iostream>
#include<stack>
#include<algorithm>
//#include<math.h>
using namespace std;
int n;
long long h[100010];

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
//	sort(h,h+n);
	long long ma=__gcd(h[0],h[1]);
	
	
	
	for(int i=2;i<n;i++){
		ma=__gcd(ma,h[i]);
	}
	
	
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String N;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = "No";
        String[] list = N.split("");
        
        for (int i=0; i<N.length(); i++) {
        	if (list[i].equals("7")) {
        		answer = "Yes";
        		break;
        	}
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<60;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
ll dp[410][410];
int a[410];
ll sums[410];

ll rec(int l,int r) {
    if (dp[l][r] > 0) return dp[l][r];
    dp[l][r] = INF;
    for (int i = l;i < r;++i) dp[l][r] = min(dp[l][r],rec(l,i)+rec(i+1,r));
    if (l == r) dp[l][r] = -a[l];
    dp[l][r] += sums[r+1]-sums[l];
    return dp[l][r];
}

int main() {
    cin >> n;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n+1;++i) for (int j = 0;j < n+1;++j) dp[i][j] = 0;
    sums[0] = 0;
    for (int i = 0;i < n;++i) sums[i+1] = sums[i]+a[i];
    cout << rec(0,n-1) << endl;
    return 0;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].Decimal();
            var b = r[1].Decimal();
            var c = r[2].Decimal();
            var d = r[3].Decimal();
            var s1 = Math.Floor((a - 1) / c);
            var s2 = Math.Floor((a - 1) / d);
            var e1 = Math.Floor(b / c);
            var e2 = Math.Floor(b / d);
            var lcm = Lcm((long)c, (long)d);
            var s3 = Math.Floor((a - 1) / lcm);
            var e3 = Math.Floor(b / lcm);
            var ans = b - a + 1 + s1 + s2 - e1 - e2 - s3 + e3;
            WriteRead(ans);
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
        public static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
int main(){
	int a,b,ans,i;
	char op;
	while(1){
		std::cin >> a >> op >> b ;	
		if(op=='+') 
			ans = a + b;
		if(op=='-') 
			ans = a - b;
		if(op=='*') 
			ans = a * b;
		if(op=='/') 
			ans = a / b;
		if(op=='?') 
			break;
		std::cout << ans <<std::endl;
			}
	return 0;
}

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

int judge(int size, int w){
	if(size <= 120 && w <= 15){
		if(size <= 80 && w <= 5){
			if(size <= 60 && w <= 2) return 600;
			else return 800;
		} else if(size <= 100 && w <= 10) return 1000;
		else return 1200;
	} else if(size <= 160 && w <= 25){
		if(size <= 140 && w <= 20) return 1400;
		else return 1600;
	} else return 0;
}

int main(){
	int n, x, y, h, w, charge, sum;
	while(1){
		cin >>n;
		if(n == 0) break;
		
		sum = 0;
		for(int i = 0; i < n; i++){
			cin >>x >>y >>h >>w;
			sum += judge((x + y + h), w);
		}
		cout <<sum <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}
int main(){
  ll N; cin>>N;
  ll d[N+10];
  ll a[N+10];
  rep(i,N){
    ll b; cin>>b;
    d[i]=b;
  }
  a[0]=0;
  rep1(i,N){
    a[i]=a[i-1]+d[i-1];
  }
  
  ll count=0;
  rep(i,N){
    count+=d[i]*(a[N]-a[i+1]);
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

class Solver extends Main{
	Solver(){
		
	}
}//Solver_end

@SuppressWarnings("unchecked")
class Main{
	static int imax=Integer.MAX_VALUE;
	static long lmax=Long.MAX_VALUE;
	
	public static void main(String[] args) throws FileNotFoundException{
		
		Scanner sc=new Scanner(System.in);
		
		int mn=imax;
		int[] num=readlnI(sc," ");
		int a=num[0], b=num[1], c=num[2];
		
		if(mn>a+b)mn=a+b;
		if(mn>a+c)mn=a+c;
		if(mn>b+c)mn=b+c;
		puts(mn);
		
	}//main_end
	
//---------------------------------------------------------------------------
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static long readL(Scanner sc){
		return Long.parseLong(sc.nextLine().trim());
	}
	static String readS(Scanner sc){
		return sc.nextLine().trim();
	}
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static String[] readlnS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void bs(){
		System.out.println("");
	}
	static int sum(int[] ary){
		int sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static long sum(long[] ary){
		long sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}


Measured memory_bytes: 28492
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;


int main(){
	ll n, m; cin >> n >> m;
	vl x(m);
	for (int i = 0; i < m; ++i) cin >> x[i];
	sort(all(x));
	if (n >= m){
		cout << 0 << endl;
		return 0;
	}
	vl ngo(m - 1); 
	for (int i = 0; i < m - 1; ++i) ngo[i] = x[i + 1] - x[i];
	sort(all(ngo));
	ll ans = x[m - 1] - x[0];
	for (int i = 0; i < n - 1; ++i){
		ans -= ngo[m - 2 - i];
	}cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

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


const int MOD = 1e9 + 7;
int dp[110000][13];// 桁数,余り

int main(){
  string S;
  cin >> S;
  int len = S.size();//桁数
  reverse(All(S));//1桁目から見る
  if(S[0] == '?') {
    for(int i=0;i<10;i++){
      dp[0][i] = 1;//余りの値のパターンは0-9まである
    }
  }else{//1桁目が決まっている
    int index = S[0] - '0';//文字をint型に変換
    dp[0][index] = 1;
  }
  int num = 1;//桁数
  for(int i=1;i<len;i++){
    num*=10;
    num%=13;//毎回13で割った余りにしておく
    if(S[i] == '?'){
      for(int j=0;j<10;j++){
        for(int k=0;k<13;k++){
          int index = (k+j*num) % 13;//余り
          dp[i][index] += dp[i-1][k];//更新式
          dp[i][index] %= MOD;//剰余に変換
        }
      }
    }else{
      //数が決まっている
      for(int k=0;k<13;k++){
        int j=(S[i] - '0');
        int index = (k+j * num) % 13;
        dp[i][index] += dp[i-1][k];
        dp[i][index] %= MOD;
      }
    }
  }
  cout << dp[len-1][5] << endl;
  return 0;
}

Measured memory_bytes: 8804
# from math import factorial
from sys import exit
n,m,k = map(int, input().split())
if m == 1:
    if k == n-1:
        print(1)
    else:
        print(0)
    exit()
MOD = 998244353

ans = tmp = (m * (m-1) ** (n-1)) % MOD

for i in range(k):
    tmp *= (n-1-i)
    tmp %= MOD
    tmp *= pow((m-1) * (i+1), -1, MOD)
    ans += tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 10780