akhauriyash/Code-Regression huggingface dataset:
//一様分布ゆえの嘘解法。(サンプルとって目星つける感じ)
#include<iostream>
#include<algorithm>
#define B 100000
using namespace std;

long long sample[B], per_l, per_r;
long long num_l, num_r;
long long koho[5000000], koho_size = 0;
int koho0IndexOfAll;

int n, k;
long long x0;

void solve1() {
	static long long X[B];
	unsigned long long x = x0;
	for(int i = 0; i < n; i++ ) {
		X[i] = x;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	sort(X, X+n);
	cout << X[k] << endl;
}
void solve2(long long maxi) {
	unsigned long long x = x0;
	int i, N = n;
	static long long X[1000000];
	int Xsize = 0;
	
	while(N--) {
		if ( x < maxi ) {
			X[Xsize++] = x;
		}
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	sort(X, X + Xsize);
	cout << X[k] << endl;
}

int main() {
	int i, j;
	cin >> n >> k >> x0;
	k--;
	
	if ( x0 == 0 ) {
		cout << 0 << endl;
		return 0;
	}
	
	if ( n < B ) {
		solve1();
		return 0;
	}
	
	per_l = max( (long long)0, (long long)B * (long long)k/(long long)n - 1000 );
	per_r = min( (long long)B-1, (long long)B * (long long)k/(long long)n + 1000 );
	
	unsigned long long x = x0;
	for( i = 0; i < B; i++ ) {
		sample[i] = (long long)x;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
  	}
  	
  	sort(sample, sample+B);
  	
  	num_l = sample[per_l];
  	num_r = sample[per_r];
	
  	//cout << per_l << " " << per_r << endl;
  	//cout << num_l << " " << num_r << endl;
  	
  	for( i = per_l; i <= per_r; i++ ) {
  		koho[koho_size++] = sample[i];
  	}
  	
  	for( i = B; i < n; i++ ) {
  		if ( num_l <= (long long)x && (long long)x <= num_r ) {
  			koho[koho_size++] = (long long)x;
  		}
  		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
  	}
  	
  	sort(koho, koho + koho_size);
  	koho0IndexOfAll = 0;
  	
  	x = x0;
  	for( i = 0; i < n; i++ ) {
  		if ( (long long)x < koho[0] )
  			koho0IndexOfAll++;
  		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	
	if ( k < koho0IndexOfAll ) {
		//cout << "solve2" << endl;
		solve2(num_l);
		return 0;
	}
	
	//cout << "koho_size = " << koho_size << endl;
	//cout << "koho_min = " << koho[0] << " koho_max = " << koho[koho_size-1] << endl;
	//cout << "koho0IndexOfAll = " << koho0IndexOfAll << endl;
	
	cout << koho[k - koho0IndexOfAll] << endl;
  	return 0;
  }

Measured memory_bytes: 19604
N, M = map(int, input().split())
graph = [list() for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
for g1 in graph[0]:
    if N-1 in graph[g1]:
        print("POSSIBLE")
        break
        
else:
    print("IMPOSSIBLE")

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,M,T;
int sum[100000];

signed main(){
    cin>>N>>M>>T;
    rep(i,N){
        int a;
        cin>>a;
        sum[a-M]++;
        sum[a+M]--;
    }
    int ans=0;
    rep(i,T){
        sum[i+1]+=sum[i];
        if(!sum[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける

int main(){
  int N, sum=0;
  cin >> N;
  vi d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  for (int i = 0; i < (N-1); i++)
  {
    for (int j = 1; j < N; j++)
    {
      if (i!=j && i<j)
      {
        sum += d.at(i)*d.at(j);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin>>x; in(move(xs)...); };
template <typename T> void _out(const char *sep, const char *end, T &&x) { cout<<x<<end; };
template <typename T, typename...TS> void _out(const char *sep, const char *end, T &&x, TS &&...xs) { cout<<x<<sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i <  (n); ++i)
#define range(a, b, i) for (i32 i = (a); i <  (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n;

i32 main()
{
    in(n);
    i64 mina = LLONG_MAX, maxa = 0;
    times(n, _) {
        indef(i64, a);
        mina = min(mina, a);
        maxa = max(maxa, a);
    }
    out(maxa - mina);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(p.rbegin(), p.rend());

	int ans = x;
	rep(i, n) {
		if (p[i] == ans) {
			ans--;
		}
	}
	int anss = x;
	sort(p.begin(), p.end());
	rep(i, n) {
		if (p[i] == anss) {
			anss++;
		}
	}
	if (x - ans <= anss - x) {
		cout << ans << endl;
	}
	else {
		cout << anss << endl;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,k,A[200001],B[200001];
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    rep(i,n) A[i]+=k-1,A[i]=A[i]%k;
    B[0]=0;
    rep(i,n) B[i+1]=(B[i]+A[i])%k;
  if(n<k){
    sort(B,B+n+1);
    ll ans=0,a=0,b=B[0];
    rep(i,n+1){
        if(b==B[i]) a++;
        else b=B[i],ans+=a*(a-1)/2,a=1;
    }
    ans+=a*(a-1)/2;
    cout<<ans;
  }
  else{
    ll num[200001]={0},ans=0;
    rep(i,k) num[B[i]]++;
    rep(i,n+1){
        ans+=num[B[i]]-1;
        if(i<n-k+1) num[B[i]]--,num[B[i+k]]++;
        else num[B[i]]--;
    }
    cout<<ans;
  }
}

Measured memory_bytes: 4992
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n, t := sc.getInt2()
	type pair struct{ a, b int }
	ps := make([]pair, n)
	for i := range ps {
		ps[i].a, ps[i].b = sc.getInt2()
	}
	sort.Slice(ps, func(i, j int) bool {
		return ps[i].a < ps[j].a
	})

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, t+1)
		for j := range dp[i] {
			dp[i][j] = -1
		}
	}
	dp[0][0] = 0

	for i, p := range ps {
		for j := range dp[i] {
			if dp[i][j] == -1 {
				continue
			}

			dp[i+1][j] = max(dp[i+1][j], dp[i][j])
			if j != t {
				k := min(t, j+p.a)
				dp[i+1][k] = max(dp[i+1][k], dp[i][j]+p.b)
			}
		}
	}

	ans := max(dp[n]...)
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

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

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

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 76932
/// @file

#include <iostream>
#include <vector>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  int n;
  int h;
  int w;
  is >> n >> h >> w;

  std::vector<std::pair<int, int>> ab(n);
  for (int i = 0; i < n; ++i) is >> ab[i].first >> ab[i].second;

  int count(0);
  for (const auto& v: ab) {
    if (v.first < h) continue;
    if (v.second < w) continue;
    ++count;
  }

  os << count << "\n";

  return true;
}
}  // unnamed namespace


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

int main()
{
    vector<char> numc(4);
    vector <int> num(4);

    for (int i=0;i<4;++i){
        cin>>numc.at(i);
        num.at(i) = numc.at(i)-'0';
    }
    
    vector <string> sumc = {{numc.at(0)}};
    vector <int> sum = {num.at(0)};
    for(int i=1;i<4;++i){
        vector <string> sumsumc;
        vector <int> sumsum;
        for (string x:sumc){
            sumsumc.push_back(x+'+'+numc.at(i));
            sumsumc.push_back(x+'-'+numc.at(i));
        }
        for (int x:sum){
            sumsum.push_back(x+num.at(i));
            sumsum.push_back(x-num.at(i));
        }
        sum = sumsum;
        sumc = sumsumc;
    }
    for (int i =0;i<sum.size();++i){
        if (sum.at(i) == 7){
            cout<<sumc.at(i)+"=7"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
	int n,k;
	long sum=0;
	cin >> n >> k;

	vector<int> h(n);
	rep(i,n) cin >> h[i] ;
	sort(h.begin(), h.end());
	reverse(h.begin(), h.end());
	
	for (int i=k; i < n; i++) sum += h[i];
	
	cout << sum << endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

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

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    map<int,int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    LL ans = 0;
    for (auto&& var : mp) {
        if (var.first < var.second) {
            ans += var.second - var.first;
        }
        else if (var.first > var.second) {
            ans += var.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
n = int(input())
ac =0
wa =0
tle = 0
re = 0

for i in range(n):
    case = input()
    if case == "AC":
        ac += 1
    elif case == "WA":
        wa += 1
    elif case == "TLE":
        tle += 1
    else:
        re += 1
print("AC x"+" "+str(ac),sep=" ")
print("WA x"+" "+str(wa),sep=" ")
print("TLE x"+" "+str(tle),sep=" ")
print("RE x"+" "+str(re),sep=" ")

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = input[0];
            int b = input[1];
            int c = input[2];
            int max_n = Math.Max(Math.Max(a, b), c);
            Console.WriteLine(max_n * 10 + a + b + c - max_n);
        }
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,a[N],b[N];
char s[N];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        a[i]=a[i-1]+(s[i]=='W');
    for(int i=n;i>=1;i--)
        b[i]=b[i+1]+(s[i]=='E');
    int ans=n;
    for(int i=1;i<=n;i++)
        ans=min(ans,a[i-1]+b[i+1]);
    printf("%d\n",ans);
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	string a; cin >> a;
	string b; cin >> b;
	if (b.size() <= a.size()) {
		cout << "No\n";
	}
	else {
		string x = "";
		for (int i = 0; i < b.size()-1; i ++) {
			x += b[i];
		}
		cout << (x == a ? "Yes\n" : "No\n");
	}
	
	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main()
  { 
    int n,x,i,sum=0,count=1,a;
    scanf("%d %d",&n,&x);
    int arr[n];
    for(i=0;i<n;i++)
      { 
       scanf("%d",&arr[i]);
      } 
  for(a=0;a<n;a++)
  { 
    sum=sum+arr[a];
    if(sum<=x)
      { 
        count++;
      }
    } 
  printf("%d",count);
  return 0;
  }
  
    
  


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

using namespace std;

int main(){
  int N,K; cin >> N >> K;
  
  vector<int> vec; 
  for(int i = 0; i < K; i++){
    int d; cin >> d;  vec.push_back(d);}
  
  for(int i = N; i < 100000; i++){
    
    bool flag = true;
    
    int tmp = i;
    set<int> s;
    while( tmp > 0){
      s.insert( tmp% 10); tmp /= 10;}
    //　s中にあって、vecにもある数があればfalse
    for(int j = 0; j < K; j++){
      if(s.count( vec[j])){ flag = false;} }
    
    if( flag){ cout << i << endl; break;}
  }
  
  return 0;}
    
    

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
s = list(sorted([a, b, c, d, e]))
d_min = s[0]
d_max = s[-1]
if d_max - d_min > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 9088
open String;;let rec p=function|[]->false|"the"::_->true|"this"::_->true|"that"::_->true|_::t->p t and g l=if p l then print_endline(concat" "l)else g(List.map(fun s->map(fun c->if c>'`'&&c<'{'then Char.chr(((Char.code c-97+1)mod 26)+97)else c)s)l)and f()=f(g(Str.split(Str.regexp" ")(read_line())));;try f()with _->()

Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    ll ans = (a*x)/b - a *(x/b);
    cout << ans << endl;
}

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

int main() {
	string S;

	cin >> S;

	int cnt = 0;
	for( int i = 0; i < S.size(); i++ ) {
		if( S[i] == 'o' ) {
			cnt++;
		}
	}
	string ans = "NO";
	if( cnt + 15 - S.size() >= 8 ) {
		ans = "YES";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int power(int n,int t){
      int x=1;
      for(int i=0;i<t;i++){
        x*=n;
      }
      return x;
    }
    int main() {
      int n,k;
      cin >> n;
      cin >> k;
      int x=1;
      for(int i=0;i<n;i++){
        if(x<=k){
          x*=2;
        }else{
          x+=k;
        }
      }
      cout << x <<endl;
      
    }

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

using namespace std;

#define FOR(i, a, n) for(ll int i = a; i < n; ++i)
#define ll long long


ll int comb2(ll int m){
	return (m * (m - 1)) / 2;
}

int main() {


    ll int n, total = 0, ans; cin >> n;

    vector<ll int> v(n);
    vector<ll int> count(n);

    FOR(i, 0, n) 
    	cin >> v[i];

    FOR(i, 0, n) 
    	v[i]--;	

    FOR(i, 0, n)
    	count[v[i]]++;

	FOR(i, 0, n)
		total += comb2(count[i]);

	FOR(i, 0, n) {
		ans = total;
		ans -= comb2(count[v[i]]);
		ans += comb2(count[v[i]] - 1);
		cout << ans << endl;
	}
    

	return 0;
}


// g++ -std=c++11 -o solve solve.cpp
// ./solve < input.txt


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e2+7;
char s[MAXN],t[MAXN];
bool cmp(char x,char y){
    return x>y;
}
int main(){
    gets(s);
    gets(t);
    int lens=strlen(s);
    int lent=strlen(t);
    sort(s,s+lens);
    sort(t,t+lent,cmp);
    for(int i=0;i<max(lens,lent);i++){
        
        if(s[i]<t[i]){
            cout<<"Yes"<<endl;
            return 0;
        }
        else if(s[i]>t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int A,B,m,ans,id1,id2,c;
int a[N],b[N]; 

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int main(){
	ans=2e9;
	A=read(),B=read(),m=read();
	for (register int i=1; i<=A; ++i) a[i]=read();
	for (register int i=1; i<=B; ++i) b[i]=read();

	for (register int i=1; i<=m; ++i)
	{
		id1=read();
		id2=read();
		c=read();
		ans=min(ans,a[id1]+b[id2]-c);
	}	
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
	ans=min(ans,a[1]+b[1]);
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-5;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


typedef complex<double> P;
const double r = 1.0;


vector<P> GetCrossPoint(P a, P b)
{
	vector<P> res;
	
	// ツ堕スツ閉ェツつャツづィツつャツづィツ静堋触ツつオツづつ「ツづゥ
	if(abs(abs(b - a) - r * 2) < EPS)
	{
		P c = a + b;
		res.push_back( P(c.real() / 2,c.imag() / 2) );
	}
	// ツ閉津環づ可古ーツづュツづづつ「ツづゥ
	else if(abs(b - a) < r * 2)
	{
		P ab = b - a;
		P center = a + P(ab.real() / 2, ab.imag() / 2);
		
		P u1 = (ab * P(0, +1)) / abs(ab);
		P u2 = (ab * P(0, -1)) / abs(ab);
		
		double dist = sqrt(1 - pow(abs(ab) / 2, 2));
		P c1 = center + u1 * dist;
		P c2 = center + u2 * dist;
		
		res.push_back(c1);
		res.push_back(c2);
	}
	
	return res;
}


int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<P> c(n);
		
		char del;
		double x, y;
		
		rep(i, n)
		{
			cin >> x >> del >> y;
			
			c[i] = P(x, y);
		}
		
		
		int res = 1;
		
		rep(i, n) REP(j, i + 1, n)
		{
			vector<P> crs(GetCrossPoint(c[i], c[j]));
			
			rep(k, crs.size())
			{
				int cover = 2;
				
				rep(l, n) if(l != i && l != j && abs(crs[k] - c[l]) - 1.0 < EPS)
				{
					cover++;
				}
				
				chmax(res, cover);
			}
		}
		
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    ll k;cin>>k;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]=='1')cnt++;
        else{break;}
    }
    co((k>cnt)?s[cnt]:'1');
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
vector<vector<int> > dp;
vector<vector<int> > back;
void createString(int m,int n, string &ans, string &s, string &t) {
	if(m == 0 || n == 0) return;
	if(back[m][n] == 0) {
		ans.push_back(s[m-1]);
		createString(m-1,n-1,ans,s,t);
		return;
	}
	if(back[m][n] == 1) {
		createString(m-1,n,ans,s,t);
		return;
	}
	createString(m,n-1,ans,s,t);
}
int main() {
	string s, t;
	cin>>s>>t;
	int m = s.size(), n = t.size();
	// dp[i][j] 
	dp.resize(m+1);
	back.resize(m+1);
	for(auto &vec : dp) vec.resize(n+1);
	for(auto &vec : back) vec.resize(n+1, -1);

	for(int i=0;i<=m;i++) {
		for(int j=0; j<=n; j++) {
			if(i==0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if(s[i-1] == t[j-1]) {
				dp[i][j] =  dp[i-1][j-1] + 1;
				back[i][j] = 0;
			}
			if(dp[i][j] < dp[i-1][j]) {
				dp[i][j] = dp[i-1][j];
				back[i][j] = 1;
			}
			if(dp[i][j] < dp[i][j-1]) {
				dp[i][j] = dp[i][j-1];
				back[i][j] = 2;
			}
		}
	}
	string ans;
	createString(m,n,ans,s,t);
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70784
import re
while True:
    n,t=map(str,input().split())
    if t == 'X':
        break
    if '_' in n :
        if t == 'D':
            print(n)
        else:
            m = n.title()
            l= re.sub('_', '',m)
            
            if t == 'U':
                print(l)
            elif t == 'L':
                p = l[0].lower() + l[1:]
                print(p)
    else:
        q = n[0].upper() + n[1:]
        r = re.findall('[A-Z][a-z]*',q)
        
        if t == 'D':
            s = '_'.join(r)
            print(s.lower())
        elif t == 'U':
            print("".join(r))
        elif t == 'L':
            u = "".join(r)
            v = u[0].lower() + u[1:]
            print(v)


Measured memory_bytes: 6512
n,k=map(int, input().split())
a=sorted([list(map(int, input().split())) for i in range(n)], key=lambda x:-x[1])
q=[]
ans=0
s=set()
for i in range(k):
    ans+=a[i][1]
    if a[i][0] in s:
        q.append(a[i][1])
    s.add(a[i][0])
ans+=len(s)**2
k1=k
ans1=ans
while k1<n and q:
    if a[k1][0] not in s:
        ans1=ans1+a[k1][1]-q.pop()-len(s)**2+(len(s)+1)**2
        ans=max(ans,ans1)
        s.add(a[k1][0])
    k1+=1
print(ans)

Measured memory_bytes: 33024
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x)write(x/10),putchar(x%10+'0');}
void writeln(int x){if (x<0)putchar('-'),x=-x;write(x);if (x==0)putchar('0');puts("");}
int x,y,ans;
signed main(){
	x=read();y=read();while (x<=y)x*=2,ans++;
	cout<<ans<<endl; 
}


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

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String[] input = br.readLine().split(" ");
        
        int A = Integer.parseInt(input[0]);
        int B = Integer.parseInt(input[1]);
        int C = Integer.parseInt(input[2]);

        int result = 0;

        if(A == B){
          result += 1;
        }

        if(A == C){
          result += 1;
        }
        
        if(B == C){
          result += 1;
        }

        if(result == 1){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }
    }
}

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

li = list(map(int,input().split()))
ans=[];count=[]
#li.sort(reverse=True)

#print(abs(li[0]-li[-1]))
mx=li[0];mn=li[0]
for i in range(1,n) :
  cr=li[i]
  if cr>mx :
    mx=cr
  if cr< mn :
    mn=cr
    
print(abs(mx-mn))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

int main(){

      ll w,h,x,y;cin >>w >> h >> x >> y;
      int flag=0;
      if(x+x == w && y+y == h){
            flag = 1;
      }
      double a = double(w) * double(h);
      printf("%lf %d\n",a/2,flag);
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

const int MID = 65;
const int INF = 1 << 28;
int dx[] = { 0, 1, 1, 0, -1, -1 }, dy[] = { 1, 1, 0, -1, -1, 0 };

void dfs ( int x, int y, int t, VVI& m )
{
	if ( !t || m[y][x] == -1 ) {
		return;
	}
	for ( int d = 0; d < 6 ; ++d ) {
		int nx = x + dx[d],
			ny = y + dy[d];
		if ( m[ny][nx] > m[y][x] + 1 ) {
			m[ny][nx] = m[y][x] + 1;
			dfs( nx, ny, t - 1, m );
		}
	}
}

int main() {
	int t, n;
	while ( cin >> t >> n, t | n ) {
		VVI m( 2 * MID, VI( 2 * MID, INF ) );
		for ( int i = 0; i < n; ++i ) {
			int x, y;
			cin >> x >> y;
			m[y + MID][x + MID] = -1;
		}
		int sx, sy;
		cin >> sx >> sy;
		
		m[sy + MID][sx + MID] = 0;
		dfs( sx + MID, sy + MID, t, m );
		
		int ans = 0;
		for ( int y = 0; y < 2 * MID; ++y ) {
			for ( int x = 0; x < 2 * MID; ++x ) {
				int val = m[y][x];
				ans += 0 <= val && val <= t;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    vec<int> cnt(26);
    for(auto& c:S) cnt[c-'a']++;
    int ans = 1e9;

    auto check = [&](string T){
        int n = T.size();
        bool ok = true;
        for(int i=0;i+1<n;i++) ok &= T[i]==T[i+1];
        return ok;
    };

    for(int i=0;i<26;i++) if(cnt[i]){
        int now = 0;
        char c = 'a'+i;
        string T = S;
        while(!check(T)){
            int n = T.size();
            string A = "";
            for(int i=0;i+1<n;i++){
                if(c==T[i] || c==T[i+1]) A += c;
                else A += T[i];
            }
            T = A;
            now++;
        }
        ans = min(ans,now);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
class RangeMinimumQuery:
    def __init__(self, n, F=min, e=float("inf"), fill=None):
        self.n0 = 2**(n-1).bit_length()
        self.F = F
        self.e = e
        if fill is None:
            fill = e
        self.data = [fill]*(2*self.n0)

    def construct(self, a):
        for i, x in enumerate(a):
            self.data[i+self.n0-1] = x
        for i in range(self.n0-2, -1, -1):
            self.data[i] = self.F(self.data[2*i+1], self.data[2*i+2])

    def query(self, l,r):
        l += self.n0
        r += self.n0
        res = self.e
        while l < r:
            if r&1:
                r -= 1
                res = self.F(res, self.data[r-1])
            if l&1:
                res = self.F(res, self.data[l-1])
                l += 1
            l >>=1
            r >>=1
        return res

    def update(self, i, x):
        i += self.n0-1
        self.data[i] = x
        while i:
            i = ~-i//2
            self.data[i] = self.F(self.data[2*i+1], self.data[2*i+2])


n,k,c = map(int, input().split())
s = input()
f = [1]*n
for i in range(n):
    if s[i] == "x":
        f[i] = 0

foward = RangeMinimumQuery(n, max, 0)
for i in range(n):
    if f[i]:
        j = i-(c+1)
        s = foward.query(0,j+1)
        foward.update(i, s+1)

backward = RangeMinimumQuery(n, max, 0)
for i in reversed(range(n)):
    if f[i]:
        j = i+(c+1)
        s = backward.query(j,n)
        backward.update(i, s+1)

first = [-1]*(n+10)

ans = []
for i in range(n):
    if f[i] == 0:
        continue
    left = foward.query(0, i)
    if left == 0:
        l = i+1
    else:
        l = max(i+1, first[left]+c+1)
    if l >= n:
        right = 0
    else:
        right = backward.query(l,n)
    if left + right < k:
        ans.append(i+1)
    cur = foward.query(i,i+1)

    if first[cur] == -1:
        first[cur] = i

if len(ans):
    print(*ans, sep="\n")


Measured memory_bytes: 83476
for e in iter(input,'0'):
 n=int(e);m,f=[[0]*n for _ in[0]*n],'{:4}'*n
 s=lambda x:-~x%n
 j=n//2;i=j+1
 m[i][j]=1
 for k in range(2,n*n+1):
  i,j,t=s(i),s(j),j
  if m[i][j]:i,j=s(i),t
  m[i][j]=k
 for r in m:print(f.format(*r))


Measured memory_bytes: 5612
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	int a,b,c,d,sum=0;
	cin>>a>>b;
	int num=b;
	while(num)
	{
		num/=10;
		sum++;
	}
	c=a*pow(10,sum)+b;
	d=sqrt(c);
	if(d*d==c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
	
}

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

int main(void) {
    int N;
    string c;
    cin >> N;
    cin >> c;
    int sr = 0;
    for (int i = 0; i < N; i++) {
        if (c[i] == 'R') {
            ++sr;
        }
    }
    int tr = 0;
    if (sr != N) {
        for (int i = sr; i < N; i++) {
            if (c[i] == 'R') {
                ++tr;
            }
        }
    }
    printf("%d\n", tr);
    return 0;
}


Measured memory_bytes: 3848
l, r = [int(i) for i in input().split()]
ans = 2019
for i in range(l, r+1):
    if ans == 0:
        break
    for j in range(i+1, r+1):
        ans = min(ans, (i*j) % 2019)
        if ans == 0:
            break
print(ans)


Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	map<int,int> mp;
	stack<int> q;
	for(int i=1;i<=n;i++){
		int x; cin >> x;
		if(x>0){
			if(mp[x]>0){
				cout << i << endl;
				return 0;
			}
			q.push(x);
			mp[x]++;
		}
		else{
			if(mp[-x]==1&&q.top()==-x){
				q.pop();
				mp[-x]--;
			}
			else{
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << "OK" << endl;
}



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

int heights[100000];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> heights[i];
    }
    sort(heights, heights + n);
    int result = 1e9;
    for (int i = k - 1; i < n; i++)
    {
        result = min(result, heights[i] - heights[i - (k - 1)]);
    }
    cout << result << endl;
}


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

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  i32 H, A;
  cin >> H >> A;
  i32 a = H/A;
  i32 mod = H%A;
  if(mod == 0.0f)
  	cout << H/A << endl;
  else
    cout << H/A + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def common_divisors(k,j):
  c = make_divisors(k) + make_divisors(j)
  return [x for x in set(c) if c.count(x) > 1]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
  
kouyakusuu = common_divisors(a,b)

aa=factorize(a)
bb=factorize(b)
l = list(set(aa))+list(set(bb))
ll = [x for x in set(l) if l.count(x) > 1]

print(len(ll)+1)

Measured memory_bytes: 4268
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES


#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列
#include <list>           //双方向連結リスト

using namespace std;

class Point{
    public:
        Point(double _x, double _y) : x(_x), y(_y){}
        Point operator+(const Point& p) const{
            return Point(this->x + p.x, this->y + p.y);
        }
        Point operator-(const Point& p) const{
            return Point(this->x - p.x, this->y - p.y);
        }
        Point operator/(const double& i) const{
            return Point(this->x / i, this->y / i);
        }
        Point operator*(const double& i) const{
            return Point(this->x * i, this->y * i);
        }
        Point rotate(const double& r) const{
            return Point(x * cos(r) - y * sin(r), x * sin(r) + y * cos(r));
        }
        friend ostream& operator<<(ostream& os, const Point& p){
            os << fixed << setprecision(8) << p.x << " " << p.y;
            return os;
        }
    private:
        double x;
        double y;
};
Point p1 = Point(0, 0);
Point p2 = Point(100, 0);

void kock(Point p1, Point p2, int n){
    Point diff = p2 - p1;
    Point s = p1 + diff / 3.0;
    Point t = p1 + diff * 2 / 3;
    Point u = s + (t - s).rotate(M_PI / 3);
    if(n < 1){
        return;
    }
    kock(p1, s, n - 1);
    cout << fixed << setprecision(8) << s << "\n";
    kock(s, u, n - 1);
    cout << fixed << setprecision(8) << u << "\n";
    kock(u, t, n - 1);
    cout << fixed << setprecision(8) << t << "\n";
    kock(t, p2, n - 1);
}

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

    int n;
    cin >> n;

    cout << fixed << setprecision(8) << p1 << "\n";
    kock(p1, p2, n);
    cout << fixed << setprecision(8) << p2 << "\n";

	return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
using namespace std;
int main()
{
	ll int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b &&k>=a)
	cout<<a<<endl;
	else if (k<a)
	cout<<k<<endl;
	else 
	{
		ll int ans=2*a+b-k;
		cout<<ans<<endl;
	}
	
	
}
		


 







Measured memory_bytes: 3584
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if a[i - 1] < a[i] < a[i + 1] or a[i - 1] > a[i] > a[i + 1]:
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(string& s) {
        int n = s.length();

        auto calc = [&](const string& t) {
            int n = t.length();
            vector<int> next(n + 1, -1);
            for (int i = 0, j = -1; i < n; ++i) {
                while (j != -1 && t[j] != t[i]) {
                    j = next[j];
                }
                next[i + 1] = ++j;
            }

            int res = 0;
            for (int i = 1; i <= n; ++i) {
                int j = i - next[i];
                if (j < next[i]) {
                    int l = j;
                    if (i % l == 0) {
                        int len = i / l / 2 * l;
                        res = max(res, len);
                    } else {
                        res = max(res, l);
                    }
                } else {
                    res = max(res, next[i]);
                }
            }
            return res;
        };

        int res = 0;
        for (int i = 0; i + 2 < n; ++i) {
            string t = s.substr(i);
            res = max(res, calc(t));
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int main() 
{
	int X , A;
	cin >> X >> A;
	if (X < A)
	{
		cout << "0" << endl;
	}
	else cout << "10" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> B(m);

    for (int i = 0; i < m; i++) {
        cin >> B[i];
    }

    vector<vector<int>> A(n, vector<int>(m));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        int sum = c;
        for (int j = 0; j < m; j++) {
            sum += A[i][j] * B[j];
        }

        if (sum > 0) {
            count++;
        }
    }

    cout << count;

    return 0;
}

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

const int NMAX = 5005;
int n, k, vis[NMAX], per[NMAX], a[NMAX], p[NMAX];
long long scor, sum[NMAX][NMAX];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    scor = p[a[1]];
    for(int i = 1; i <= n; i++) {
        int pas = 1;
        int pos = i;
        for(int j = 1; j <= n; j++) {
            vis[j] = 0;
        }
        while(pas <= min(k, n) && !vis[a[pos]]) {
            sum[i][pas] = sum[i][pas - 1] + 1LL * p[a[pos]];
            vis[a[pos]] = 1;
            scor = max(scor, sum[i][pas]);
            pos = a[pos];
            pas++;
        }
        per[i] = pas - 1;
        for(int j = 0; j <= k % per[i]; j++) {
            scor = max(scor, 1LL * (k / per[i]) * sum[i][per[i]] + sum[i][j]);
        }
        for(int j = 1; j < per[i]; j++) {
            scor = max(scor, 1LL * (k / per[i] - 1) * sum[i][per[i]] + sum[i][j]);
        }
    }
    cout << scor;
    return 0;
}

Measured memory_bytes: 199232
/**
 * At Boss's Expense
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

public class Main {

	static boolean[] primes = new boolean[1000001];

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

		//
		Arrays.fill(primes, true);
		for (int i = 2; i < 1000000 / 2 + 1; i++) {
			if (primes[i]) {
				for (int j = 2; j < 1000000 / i + 1; j++) {
					primes[i * j] = false;
				}
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int x = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | x) == 0) break;

			int max = 0;
			int[] dp = new int[x + 1];
			int[] c = new int[n];

			for (int i = 0; i < n; i++) c[i] = parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				for (int j = c[i]; j < x + 1; j++) {
					dp[j] = Math.max(dp[j], dp[j - c[i]] + c[i]);
					if (primes[dp[j]]) max = Math.max(max, dp[j]);
				}
			}
			System.out.println(max != 0 ? max : "NA");
		}//end while
	}//end main
}

Measured memory_bytes: 88884
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#define MAXN 0x7fffffff
typedef long long LL;
const int N=100005;
using namespace std;
inline int Getint(){register int x=0,f=1;register char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}return x*f;}
char sr[N];
int main(){
	scanf("%s",sr+1);
	int n=strlen(sr+1);
	if(sr[1]=='0'||sr[n]=='1')cout<<-1,exit(0);
	for(int i=1;i<n;i++)if(sr[i]^sr[n-i])cout<<-1,exit(0);
	int tp=2;cout<<1<<' '<<2<<'\n';
	for(int i=2;i<n;i++){
		cout<<tp<<' '<<i+1<<'\n';
		if(sr[i]=='1')tp=i+1;
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	--k;
	s.at(k)='a'+s.at(k)-'A';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcount(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;
const ll MOD = 1e9 + 7;

void solve(){
    ll n,k; cin >> n >> k;
    
    ll sum = 0,temp,mx,mn;
    vll pre(n+2,0);
    
    rep(i,2,n+2){
        pre[i] = (pre[i-1] + (i-1)) % MOD;
    }
    // D2(pre);
    rep(i,k,n+2){
        mx = (pre[n+1] - pre[n-i+1] + MOD) % MOD;
        mn = pre[i];
        temp = (mx - mn + MOD) % MOD;
        sum = (sum + temp + 1)%MOD;
    }
    cout << sum%MOD;
}

int main() {
    IOS;
    // int t; cin >> t;
    int t = 1;
    while(t--) solve();
}

Measured memory_bytes: 4756
defmodule Main do
  def main do
    [x,y]=IO.gets("") |> String.trim |> String.split(" ") |>Enum.map(fn x->String.to_integer(x)end)
    0..x
    |>Enum.map(fn z-> Integer.mod(y-2*(x-z), 4)==0 && div(y-2*(x-z), 4)==z end)
    |>Enum.any?(fn x-> x==true end)
    |>(fn x -> if x==true do
      IO.puts("Yes")
    else
      IO.puts("No")
    end
    end).()
  end
end


Measured memory_bytes: 30700
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1.1e18; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int a,b,m;
    cin >> a >> b >> m;
    int aa[a],bb[b];
    rep(i,a) cin >> aa[i];
    rep(i,b) cin >> bb[i];
    int ans = INF_int;
    rep(i,m){
        int x,y,c;
        cin >> x >> y >> c;
        ans = min(ans,aa[x-1]+bb[y-1]-c);
    }
    sort(aa,aa+a);
    sort(bb,bb+b);
    ans = min(ans,aa[0]+bb[0]);
    cout << ans << endl;
}

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

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(v) begin(v), end(v)

int sign(int x) {
	return x > 0 ? 1 : (x < 0 ? -1 : 0);
}

int dist(int x1, int y1, int x2, int y2) {
	const int dx = x2 - x1;
	const int dy = y2 - y1;
	if(sign(dx) == sign(dy)) {
		return abs(dx) + abs(dy) - min(abs(dx), abs(dy));
	}
	return abs(dx) + abs(dy);
}

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

	int w, h, n;
	cin >> w >> h >> n;

	int x, y;
	cin >> x >> y;

	int ans = 0;
	rep(i, n - 1) {
		int nx, ny;
		cin >> nx >> ny;

		ans += dist(x, y, nx, ny);
		x = nx;
		y = ny;
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196