akhauriyash/Code-Regression huggingface dataset:
#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;
    string s;
    cin >> s;
    int count=0;
    for(int i=0;i<N-1;i++){
        if(s[i]==s[i+1]) count++;
    }
    cout << N-count << endl;
}

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

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



Measured memory_bytes: 3888
from operator import mul
from functools import reduce
# from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(2000)


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


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N, P = inpl()
A = inpl()

odd = sum(a % 2 == 1 for a in A)
even = sum(a % 2 == 0 for a in A)

if P == 1 and odd == 0:
    print(0)
    exit()

print(
    sum(cmb(odd, i) for i in range(P, odd + 1, 2)) * sum(
        cmb(even, j) for j in range(even + 1)))


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

vector<vector<int> > v;

void init()
{
	int N;
	cin >> N;
	int t;
	cin >> t;
	if (t != 0) {
		cout << -1 << endl;
		exit(0);
	}
	v.PB(vector<int>(0));
	rep(i, N-1) {
		cin >> t;
		if (t == 0) {
			if (v.back().size()) {
				v.PB(vector<int>(0));
				continue;
			}
		} else if (t == 1) {
			if (v.back().size()) v.PB(vector<int>(1, 1));
			else v.back().PB(t);
		} else {
			v.back().PB(t);
		}
	}
}

ll culc(vector<int>& x)
{
	int l = x.size();
	ll res = 0;
	int i = l - 1;
	while (i >= 0) {
		res += x[i];
		i--;
		while (i >= 0 && x[i] + 1 == x[i+1]) i--;
	}
	return res;
}

void solve()
{
	if (v[0].size() == 0) {
		cout << 0 << endl;
		return;
	}
	if (v[0][0] != 1) {
		cout << -1 << endl;
		return;
	}
	for (auto& a : v) {
		reps(i, 1, a.size()) {
			if (a[i] > a[i-1] + 1) {
				cout << -1 << endl;
				return;
			}
		}
	}
	ll res = 0;
	for (auto& a : v) {
		res += culc(a);
	}
	cout << res << endl;
}





Measured memory_bytes: 1404
import java.util.*;
 
 
class Main {
    static int abc[];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i=0; i<A.length; i++){
            A[i] = sc.nextInt();
        }
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();

        for(int i=0; i<A.length; i++){
            map.put(A[i],0);
        }
        for(int i=0; i<A.length; i++){
            int n = map.get(A[i]) + 1;
            map.put(A[i],n);
        }
        int ans = 0;
        for(int i=0; i<N; i++){
            int m = map.get(A[i])%2;
            if(m == 1){
                ans++;
                map.put(A[i],0);
            }
        }
        System.out.println(ans);
    }

}

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

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

using ll = long long;
using P = pair<int,ll>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

struct edge
{
    int to, cost;
};

int N = 1e5+5;
vector<ll> sum(N, INF);

void dijkstra(int x, vector<edge> G[]){
    priority_queue<int> q; 
    sum[x] = 0;
    q.push(x);
    while(!q.empty()){
        int v = q.top(); q.pop();


        for (auto& pp : G[v]) {
            if(sum[pp.to] > sum[v] + pp.cost) {
                sum[pp.to] = sum[v] + pp.cost;
            }else{
                continue;
            }
            q.push(pp.to);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int v, e, r;
    cin >> v >> e >> r;

    vector<edge> G[v];

    rep(i, e){
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(edge{t, d});
        //rG[t].push_back(edge{s, d});
    }

    dijkstra(r, G);
    //dijkstra(r, rG);

    for (int i = 0; i < v; ++i) {
        if(sum[i] == INF){
            cout << "INF" << "\n";
        }else{
            cout << sum[i] << "\n";
        }
    }


    return 0;
}



Measured memory_bytes: 16476
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    int s = 0;
    for(int n; cin >> n; s += n);
    cout << s / 60 << endl;
    cout << s % 60 << endl;

    return 0;
}

Measured memory_bytes: 1160
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
A = 1
B = 1
for i in range(N):
  k = max(-(-A//L[i][0]),-(-B//L[i][1]))
  A = L[i][0]*k
  B = L[i][1]*k
print(A+B)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;
    vector<int> d(N);
    for (auto &x : d) {
        cin >> x;
    }
    sort(d.begin(), d.end());
    cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;

    return 0;
}

Measured memory_bytes: 640
c0=list(map(int, input().split()))
c1=list(map(int, input().split()))
c2=list(map(int, input().split()))

c=[c0,c1,c2]

judge = 0

if c[0][0]-c[0][1]==c[1][0]-c[1][1] and c[1][0]-c[1][1]==c[2][0]-c[2][1]:
  judge +=1
if c[0][2]-c[0][1]==c[1][2]-c[1][1] and c[1][2]-c[1][1]==c[2][2]-c[2][1]:
  judge +=1
if c[0][0]-c[1][0]==c[0][1]-c[1][1] and c[0][1]-c[1][1]==c[0][2]-c[1][2]:
  judge +=1
if c[2][0]-c[1][0]==c[2][1]-c[1][1] and c[2][1]-c[1][1]==c[2][2]-c[1][2]:
  judge +=1

if judge == 4:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <set>
#include <vector>
#include <utility>
using namespace std;

using int64 = long long;

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

    vector<int64> x(N), y(N);
    int64 rmax = 0,
          rmin = (1LL << 40),
          bmax = 0,
          bmin = (1LL << 40);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        rmax = max(rmax, max(x[i], y[i]));
        rmin = min(rmin, max(x[i], y[i]));
        bmax = max(bmax, min(x[i], y[i]));
        bmin = min(bmin, min(x[i], y[i]));
    }

    int64 ans = (rmax - rmin) * (bmax - bmin);

    rmin = min(rmin, bmin);

    set<pair<int64, int>> st;
    for (int i = 0; i < N; i++) st.insert({min(x[i], y[i]), i});
    while (!st.empty()) {
        int64 diff = st.rbegin()->first - st.begin()->first;
        ans = min(ans, (rmax - rmin) * diff);

        auto elt = *st.begin();
        if (elt.second >= 364364) break;
        st.insert({max(x[elt.second], y[elt.second]), 364364});

        st.erase(elt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long x,k,d;
	cin>>x>>k>>d;
	x=llabs(x);
	long long need=x/d;
	if(need>=k){
		cout<<x-k*d<<endl;
		return 0;
	}
	x-=d*need;
	k-=need;
	if(k%2==0)
		cout<<x<<endl;
	else
		cout<<min(x+d,llabs(x-d))<<endl;
	return 0;
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func SubInclude(x string, y string) bool {
	i := 0
	j := 0
	for {
		if j >= len(y) {
			return true
		}
		if i >= len(x) {
			return false
		}

		if x[i] == y[j] {
			i++
			j++
			continue
		}

		i++
	}
}

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	total := 0
	for i := 0; i<1000; i++ {
		x := fmt.Sprintf("%03d", i)
		if SubInclude(s, x) {
			total++
		}
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

const int MAX_N = 22;
int dp[MAX_N][(1 << MAX_N)];

int main() {
    int N; cin >> N;
    bool a[N][N];
    rep(h, N)
        rep(w, N)
            cin >> a[h][w];
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i) {
        for(int bit = 0; bit < (1 << N); ++bit) {
            if(i + 1 != __builtin_popcount(bit))continue;
            for(int j = 0; j < N; ++j) {
                if(a[i][j] && (bit & (1 << j))) {
                    dp[i + 1][bit] += dp[i][bit - (1 << j)];
                    dp[i + 1][bit] %= MOD;
                }
            }
        }
    }
    cout << dp[N][(1 << N) - 1] << endl;
}


Measured memory_bytes: 180480
#include<iostream>

using namespace std;

typedef long long ll;

ll N, K;
ll W[100000];
 
int check(ll P) {
  int i = 0;
  for (int j = 0; j < K; j++) {
    ll s = 0;
    while(s + W[i] <= P) {
      s += W[i];
      i++;
      if (i == N) {
        return N;
      }
    }
  }
  return i;
}

int solve() {
  ll left = 0;
  ll right = 100000 * 100000;
  ll mid;
  while (right - left > 1) {
    mid = (right + left) / 2;
    int v = check(mid);
    if (v >= N) {
      right = mid;
    } else {
      left = mid;
    }
  }

  return right;
}

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

  cin >> N >> K;
  for(ll i = 0; i < N; i++) {
    cin >> W[i];
  }

  ll ans = solve();
  cout << ans << endl;

  return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> G(N, vector<bool>(N));
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a][b] = 1;
    G[b][a] = 1;
  }

  vector<int> v(N);
  iota(v.begin(), v.end(), 0);
  int num = 1;
  for (int i = 1; i <= N; i++)
    num *= i;
  vector<vector<int>> b(num);
  int l = 0;
  do
  {
    for (auto x : v)
      b[l].push_back(x);
    l++;
  } while (next_permutation(v.begin(), v.end()));

  int ans = 0;
  for (int i = 0; i < b.size(); i++)
  {
    if (b[i][0] != 0)
      continue;
    bool can = true;
    for (int j = 1; j < b[i].size(); j++)
    {
      if (!G[b[i][j - 1]][b[i][j]])
      {
        can = false;
        break;
      }
    }
    if (can)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3072
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ab=[[a-1,b-1] for a,b in ab]
# Union FInd
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
ans=[]
ans.append((n*(n-1))//2)
uf=UnionFind(n)
ab.reverse()
for a,b in ab:
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    x1=uf.size(a)
    x2=uf.size(b)
    ans.append(ans[-1]-x1*x2)
    uf.union(a,b)
ans.reverse()
for ai in ans[1:]:
  print(ai)

Measured memory_bytes: 106772
package main

import (
	"fmt"
	"math"
	"math/big"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := make([]int64, n)

	max := big.NewInt(int64(math.Pow(10, 18)))

	res := big.NewInt(1)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if (a[i] == 0) {
			fmt.Printf("0")
			return
		}
	}

	for i := 0; i < n; i++ {
		ai := big.NewInt(a[i])
		res = res.Mul(res, ai)
		if (res.Cmp(max) == 1) {
			fmt.Printf("-1")
			return
		}
	}

	if (res.Cmp(max) == 1) {
		fmt.Printf("-1")
	} else{
		fmt.Printf("%d", res)
	}
}


Measured memory_bytes: 6480
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , ans;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    cin >> n;
    for(ll i = 1 ; i <= n ; i++)    if(i % 3 != 0 && i % 5 != 0)    ans += i;
    cout << ans << endl;
    
    return 0;
}
/*

*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll x;
  	ci(x);
  ll ans=1;
  FOR(i,1,101){
    FOR(j,2,101){
      ll a=pow(i,j);
      if(a<=x){
      ans=max(ans,a);
      }
    }
  }
  co(ans)
}

Measured memory_bytes: 256
package main

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

func main() {
	s := reads()
	yesOrNo(!(s == "AAA" || s == "BBB"))
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll x, t;
  cin >> x >> t;
  cout << max(0LL, x - t) << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, c = gets.chomp.split.map(&:to_i)

b = gets.chomp.split.map(&:to_i)
ans = 0

n.times do
  a = gets.chomp.split.map(&:to_i)
  ab = 0
  
  i = 0
  m.times do
    ab += a[i] * b[i]
    i += 1
  end
  
  if ab + c > 0
    ans += 1
  end
end

puts ans

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

int main()
{
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  if (a + b > c + d)
    cout << "Left" << endl;
  else if(a + b < c + d)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;

    vector<int> H;
    REP(i, N) {
        int a;
        cin >> a;
        H.push_back(a);
    }

    int count = 1;
    int max_h = H[0];
    REP(i, N - 1) {
        if (max_h <= H[i + 1]) {
            count++;
            max_h = max(H[i + 1], max_h);
        }
    }

    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],sum[n];
    map<int,int>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[i]=i+a[i];
    }
    sort(sum,sum+n);
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=upper_bound(sum,sum+n,i-a[i])-lower_bound(sum,sum+n,i-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5184
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    cnt=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    cnt+=1
    print(cnt)


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

int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    cout<<d.at(N/2)-d.at(N/2-1)<<endl;
}


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

int main() {
	string s; cin >> s;
	int gx, gy; cin >> gx >> gy;

	int xx, mode = 0, cnt = 0, spe = 1;
	vector<int>idx, idy;
	for (int i = 0; i <= s.size(); i++) {
		if (s[i] == 'T' || i == s.size()) {
			if (spe)xx = cnt, spe = 0;
			else if (mode == 0)idx.push_back(cnt);
			else idy.push_back(cnt);
			mode ^= 1; cnt = 0;
		}
		else cnt++;
	}

	set<int>canX = { 0 }, canY = { 0 };
	for (auto&& sX : idx) {
		set<int>res(canX);
		canX.clear();
		for (auto&& x : res) {
			canX.insert(x + sX);
			canX.insert(x - sX);
		}
	}
	for (auto&& sY : idy) {
		set<int>res(canY);
		canY.clear();
		for (auto&& y : res) {
			canY.insert(y + sY);
			canY.insert(y - sY);
		}
	}
	if (canX.count(gx - xx) && canY.count(gy))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 768
import math
S = input()

odds = ["R","U","D"]
evens = ["L","U","D"]
ans = "Yes"
for i,c in enumerate(S):
    if (i + 1) % 2 == 1:
        if c not in odds:
            ans = "No"
    else:
        if c not in evens:
            ans = "No"

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N,Q;
    cin>>N>>Q;
    string str1;
    cin>>str1;
    vector<int> vec(N+1,0);
    for(int i=0;i<N;i++){
        if(i>0){
            vec.at(i+1)=vec.at(i);
        }
        else if(i==N-1){
            continue;
        }
        if(str1.substr(i,2)=="AC"){
            vec.at(i+1)+=1;
        }
    }
    for(int i=0;i<Q;i++){
        int k,j;
        cin>>k>>j;
        cout<<(vec.at(j-1)-vec.at(k-1))<<endl;
    }

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;


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

  vector<int> dp(n, INF);
  dp[0] = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i < n - j) 
      dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j]);
    }
  }

  cout << dp[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int>che;
    vector<int>d,dd;
    for(int i=0;i<a;i++){
        int z;
        cin >> z;
        d.push_back(z);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    for(int i=0;i<x;i++)che.push_back(d.at(i));
    for(int i=0;i<b;i++){
        int z;
        cin >> z;
        dd.push_back(z);
    }
    sort(dd.begin(),dd.end());
    reverse(dd.begin(),dd.end());
    for(int i=0;i<y;i++)che.push_back(dd.at(i));

    for(int i=0;i<c;i++){
        int z;
        cin >> z;
        che.push_back(z);
    }
    sort(che.begin(),che.end());
    reverse(che.begin(),che.end());
    ll ans = 0;
    for(int i=0;i<x+y;i++){
        ans+=che.at(i);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3188
n=int(input())
a=list(map(int,input().split()))
# q=int(input())
L=[0]*(100001)
s=sum(a)

for i in a:
    L[i] +=1

q= int(input())
for _ in range(q):
    b, c = map(int,input().split())
    L[c] += L[b]
    s+= L[b]*(c-b)
    L[b]=0
    print(s)
# b=[]
# c=[]
# for i in range(q):
#     d,e=input().split()
#     b.append(int(d))
#     c.append(int(e))


# if q >= len(b):
#     for j in range(q):
#         for i in range(len(b)):
#             if q < len(b):
#                 if a[j]==b[i]:
#                     a[j]=c[i]
# else:
#     for i in range(len(b)):
#         for j in range(q):
#             if a[i] == b[j]:
#                 a[i]=c[j]
#         # elif q < len(b):
#         #     if a[i] == b[i]:
#         #         a[i]=c[j]
#         #         if a[-1] ==b[j]:
#         #             a[-1]=c[i]
#         print(sum(a))



# # print(a)
# # print(a)
# # print(b)
# # print(c)

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

int main()
{
    int a,b,c; cin >> a >> b >>c;
    int per_week = 7*a + b;
    int week = c/per_week;
    int remain = c - week*per_week;
    
    int ans= 0;
    
    ans = (remain + a -1 )/a;
    if(ans >7) ans=7;
    ans += 7*week;
    
    

    cout << ans << endl;
    


    return 0;
}


Measured memory_bytes: 3104
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=500;

int n;
int val[N+3][N+3];

void Solve(int l,int r,int dep){
	if(l==r) return;
	int m=(l+r)>>1;
	for(int i=l;i<=m;i++)
		for(int j=m+1;j<=r;j++)
			val[i][j]=val[j][i]=dep;
	Solve(l,m,dep+1);
	Solve(m+1,r,dep+1);
}
int main(){
	scanf("%d",&n);
	Solve(1,n,1);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			printf("%d",val[i][j]);
			if(j==n) printf("\n");
			else printf(" ");
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M, K, R;
int F[50000][4];
vector<int> G[50000];
int deg[50000];
int ord[50000][4];
vector<int> vect(vector<int> ord, int i) {
  vector<int> ret;
  rep(j, K) ret.pb(F[i][ord[j]]);
  ret.pb(i);
  return ret;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  rep(i, N) rep(j, K) cin >> F[i][j], F[i][j] = -F[i][j];
  cin >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    deg[b]++;
  }
  int last = 0;
  rep(j, K) cin >> ord[0][j], ord[0][j]--;
  cin >> R;
  rep(_, R) {
    int m;
    cin >> m;
    for (int p=last+1; p<m; p++) {
      rep(j, K) ord[p][j] = ord[p-1][j];
    }
    rep(j, K) cin >> ord[m][j], ord[m][j]--;
    last = m;
  }
  for (int p=last+1; p<N; p++) {
    rep(j, K) ord[p][j] = ord[p-1][j];
  }

  map<vector<int>, set<vector<int> > > mp;
  vector<int> r(K);
  rep(i, K) r[i] = i;
  do {
    set<vector<int> > vs;
    mp[r] = vs;
  }
  while (next_permutation(all(r)));

  rep(i, N) {
    if (deg[i] == 0) {
      for (auto &p : mp) p._2.insert(vect(p._1, i));
    }
  }

  rep(p, N) {
    vector<int> r(K); rep(i, K) r[i] = ord[p][i];
    assert(!mp[r].empty());
    auto &vs = *mp[r].begin();
    int x = vs.back();
    for (int t : G[x]) {
      deg[t]--;
      if (deg[t] == 0) {
        for (auto &p : mp) {
          p._2.insert(vect(p._1, t));
        }
      }
    }
    for (auto &p : mp) {
      p._2.erase(vect(p._1, x));
    }
    cout << x+1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 137272
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

constexpr int log2_uint64(u64 x)
{
    int ret = 0;
    x = (x & 0xFFFFFFFF00000000) ? (ret |= 0x20, x & 0xFFFFFFFF00000000) : x;
    x = (x & 0xFFFF0000FFFF0000) ? (ret |= 0x10, x & 0xFFFF0000FFFF0000) : x;
    x = (x & 0xFF00FF00FF00FF00) ? (ret |= 0x08, x & 0xFF00FF00FF00FF00) : x;
    x = (x & 0xF0F0F0F0F0F0F0F0) ? (ret |= 0x04, x & 0xF0F0F0F0F0F0F0F0) : x;
    x = (x & 0xCCCCCCCCCCCCCCCC) ? (ret |= 0x02, x & 0xCCCCCCCCCCCCCCCC) : x;
    x = (x & 0xAAAAAAAAAAAAAAAA) ? (ret |= 0x01, x & 0xAAAAAAAAAAAAAAAA) : x;
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    u64 h;
    cin >> h;
    cout << (1uL << (log2_uint64(h) + 1)) - 1 << endl;

    return 0;
}


Measured memory_bytes: 3648
from itertools import combinations
from math import sqrt


N, D = map(int, input().split())
X_list = []
for i in range(N):
    X = list(map(int, input().split()))
    X_list.append(X)

comb_list = list(combinations(X_list, 2))
res = 0

for i in range(len(comb_list)):
    x1 = comb_list[i][0]
    x2 = comb_list[i][1]

    dst_elements = [(x1[i] - x2[i])**2 for i in range(len(x1))]
    dst = sqrt(sum(dst_elements))
    if dst.is_integer():
        res += 1

print(res)


Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	if(n%3==0)
		{
			printf("Possible\n");
		}
	else if (m%3==0)
		{
		printf("Possible\n");
		}
	else if ((m+n)%3==0)
		{
			printf("Possible\n");
		}
	else
	{
		printf("Impossible\n");
	}
	return 0; 
}

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

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  map<char,int> mp;
  for (int i = 0; i < H; i++) {
    cin >> a[i];
    for (int j=0;j<W;j++)
      mp[a[i][j]]++;
  }

  int n4=0,n2=0,n1=0;
  n4 = (H/2) * (W/2);
  if (H%2 == 1) n2 += W / 2;
  if (W%2 == 1) n2 += H / 2;
  n1 = (H%2) * (W%2);


  while(n4) {
    bool in = false;
    for (int i = 0; i < 26; i++) {
      char c = 'a' + i;
      if (mp[c] >= 4) {
        mp[c] -= 4;
        n4--;
        in = true;
      }
    }
    if (!in && n4 > 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  while(n2) {
    bool in = false;
    for (int i = 0; i < 26; i++) {
      char c = 'a' + i;
      if (mp[c] >= 2) {
        mp[c] -= 2;
        n2--;
        in = true;
      }
    }
    if (!in && n2 > 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  while(n1) {
    bool in = false;
    for (int i = 0; i < 26; i++) {
      char c = 'a' + i;
      if (mp[c] >= 1) {
        mp[c] -= 1;
        n1--;
        in = true;
      }
    }
    if (!in && n1 > 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        long number = Long.parseLong(br.readLine());
        long temp = 0;
        long cnt = 1;
        String name = "";
        while(true){
            temp = number;
            number -= Math.pow(26, cnt);

            if(number <= 0){

                number = temp-1;
                cnt--;

                if(cnt == 0){
                    long alphabat = number%26;
                    char part = (char) (alphabat+97);
                    name += part;
                    break;
                }

                while(cnt > 0){


                    long tempNum = (long)Math.pow(26, cnt);
                    long alphabat = number/tempNum; // 0이라면 그냥 a
                    char part = (char) (alphabat+97);
                    number -= (tempNum)*alphabat;


                    name += part;

                    if(cnt ==1){
                        alphabat = number%26;
                        part = (char) (alphabat+97);
                        name += part;
                    }

                    cnt--;
                }

                break;
            }
            cnt++;
        }
        System.out.println(name);
    }
}


Measured memory_bytes: 36904
#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>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct uf {
private:
    vector<int> par, ran;
public:
    void init(int n) {
        par.resize(n, 0);
        ran.resize(n, 0);
        rep(i, n) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (ran[x] < ran[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (ran[x] == ran[y])ran[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

typedef pair<ll,P> PP;

int n;
vector<PP> E;
ll d,a[300000];

ll Kruskal(){
    ll ans=0;
    sort(E.begin(),E.end());
    uf u;u.init(n);
    rep(i,E.size()){
        if (!u.same(E[i].second.first,E[i].second.second)) {
            ans+=E[i].first;
            u.unite(E[i].second.first,E[i].second.second);
        }
    }
    return ans;
}

void rec(int l,int r){
    if (r-l<=1) return;
    int mid=(l+r)/2;
    ll minl=INF,minr=INF;
    int minlp=-1,minrp=-1;
    Rep(i,l,mid){
        if (minl>a[i]-d*i) {
            minl=min(minl,a[i]-d*i);
            minlp=i;
        }
    }
    Rep(i,mid,r){
        if (minr>a[i]+d*i) {
            minr=min(minr,a[i]+d*i);
            minrp=i;
        }
    }
    Rep(i,l,mid){
        E.push_back(PP(minr+a[i]-d*i,P(minrp,i)));
    }
    Rep(i,mid,r){
        E.push_back(PP(minl+a[i]+d*i,P(minlp,i)));
    }
    rec(l,mid);
    rec(mid,r);
}


void solve(){
    cin >> n >> d;
    rep(i,n){
        cin >> a[i];
    }
    rec(0,n);
    // rep(i,E.size()){
    //     cout << E[i].first << " " << E[i].second.first << " " << E[i].second.second << endl;
    // }
    cout << Kruskal() << endl;

}

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

Measured memory_bytes: 69344
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 50+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, v[N];

int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	sort(v, v+n);
	double ans = 1.0*(v[0]+v[1])/2.0;
	for(int i=2; i<n; i++){
		ans = (ans + v[i])/2.0;
	}
	cout << fixed << setprecision(9);
	cout << ans << endl;
	return 0;
}


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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
            var A = GetInt();
            var B = GetInt();
            var C = GetInt();
            var D = GetInt();
            var ans = Math.Min(A , B) + Math.Min(C , D);

            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.OptionalInt;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int K = sc.nextInt(),N =sc.nextInt();
	ArrayList<Integer> list = new ArrayList<>();
	for(int i=0;i<N;i++) {
		list.add(sc.nextInt());
	}
	ArrayList<Integer> sa = new ArrayList<>();
	for(int i=1;i<N;i++) {
		sa.add(list.get(i)-list.get(i-1));
	}
	sa.add(list.get(0)+K-list.get(N-1));
	OptionalInt max = sa.stream().mapToInt(v -> v).max();
	int ans = K-max.getAsInt();
	System.out.println(ans);
}
}


Measured memory_bytes: 88828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 510000;
const int MOD = 1000000007;

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;
}

int main() {
    COMinit();
    // 計算例
    ll n,k,ch[100010];
    cin>>n>>k;
    vector<ll>a;
    for(ll i=0;i<n;i++){
    	ll x;
    	cin>>x;
    	a.push_back(x);
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for(ll i=0;i<n-1;i++){
    	ll now=COM(n-1-i,k-1);
    	now*=-1*a[i];
    	ans+=now;
    	ans%=inf;
    	if(ans<0){
    		ans+=inf;
    	}
    }
 //   cout << COM(2,5)<<endl;
    reverse(a.begin(),a.end());
    for(ll i=0;i<n-1;i++){
    	ll now=COM(n-1-i,k-1);
    	now*=a[i];
    	ans+=now;
    	ans%=inf;
    	if(ans<0){
    		ans+=inf;
    	}
    }    
    cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 13304
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
string v[103];
int main(){
	fastIO;
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v,v+n);
	for(int i=0;i<n;i++){
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int n,a,b;
        cin >> n >> a >> b;
        int sum=0;
        for(int i=1; i<=n; i++) {
                int ans=0;
                int l=i;
                while(l>=10) {
                        ans+=(l%10);
                        l=l/10;
                }
                ans+=l;
                if((ans>=a)&&(ans<=b)) sum+=i;
        }
        cout << sum << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;
int n, W, w[109], v[109];
long long dp[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> W;
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	dp[w[0]] = v[0];
	for (int i = 1; i < n; i++) {
		for (int j = W; j > 0; j--) {
			if (j >= w[i])
				dp[j] = max(dp[j - w[i]] + v[i], dp[j]);
		}
	}
	long long ans = 0;
	for (int j = W; j > 0; j--) ans = max(ans, dp[j]);
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    // (R + P) / 2 = G
    // R + P = 2 * G
    // P = 2 * G - R;

    int R, G; cin >> R >> G;
    cout << 2*G - R << endl;
    return 0;
}

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

#define int long long

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int c1 = a * c;
    int c2 = a * d;
    int c3 = b * c;
    int c4 = b * d;

    int ans = max(c1, max(c2, max(c3, c4)));

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

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
//int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,t;
int m[200][200],fast[200][200];
int dx[6]={0,1,0,-1,1,-1},dy[6]={1,0,-1,0,1,-1};
void DFS(int y,int x,int len){
	m[y][x]=1;
	if(len<t&&len<fast[y][x]){
		fast[y][x]=len;
		for(int i=0;i<6;i++){
			if(m[y+dy[i]][x+dx[i]]!=-1)
				DFS(y+dy[i],x+dx[i],len+1);
		}
	}
}
int main(){
	while(true){
		cin>>t>>n;
		if(t==0&&n==0)
			break;
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				m[i][j]=0;
				fast[i][j]=100;
			}
		}
		int x,y;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			m[100+y][100+x]=-1;
		}
		cin>>x>>y;
		DFS(y+100,x+100,0);
		int ans=0;
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				if(m[i][j]==1)
					ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3380