akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<double, double> p;

#define MOD 1000000007

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

    int N;
    cin >> N;

    vector<ll> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    for(int i = 1; i < N; i++) A[i] += A[i - 1];

    ll ans = pow(10, 15);

    for(int i = 1; i < N - 2; i++) {
        ll ab = A[i] / 2LL;
        int x = upper_bound(A.begin(), A.begin() + i - 1, ab) - A.begin();

        ll a = A[x];
        ll b = A[i] - A[x];

        if(x > 0) {
            ll ka = A[x - 1];
            ll kb = A[i] - A[x - 1];
            if(abs(a - b) > abs(ka - kb)) {
                a = ka;
                b = kb;
            }
        }

        ll cd = (A[N - 1] - A[i]) / 2LL + A[i];
        int y = upper_bound(A.begin() + i + 1, A.end() - 1, cd) - A.begin();

        ll c = A[y] - A[i];
        ll d = A[N - 1] - A[y];

        if(y > i + 1) {
            ll kc = A[y - 1] - A[i];
            ll kd = A[N - 1] - A[y - 1];
            if(abs(c - d) > abs(kc - kd)) {
                c = kc;
                d = kd;
            }
        }

        ll f = max(max(a, b), max(c, d));
        ll s = min(min(a, b), min(c, d));

        ans = min(ans, f - s);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4788
from itertools import permutations

n, m = [int(i) for i in input().split()]
g = [[False] * n for i in range(n)]
for i in range(m):
    a, b = [int(i) - 1 for i in input().split()]
    g[a][b] = g[b][a] = True

ans = 0
for i in permutations(list(range(n)), n):
    if i[0] != 0:
        break

    for j in range(n):
        if j == n - 1:
            ans += 1
            break
        if not g[i[j]][i[j+1]]:
            break

print(ans)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        xys: [[(usize1, usize)]; n]
    }
    let mut answer = 0;
    for i in 0..(1<<n) {
        let mut p = vec![0; n];
        let mut count = 0;
        for k in 0..n {
            if i & (1<<k) == 0 { continue; }
            count += 1;
            p[k] = 1;
        }
        let mut flg = true;
        for k in 0..n {
            if p[k] == 0 {continue;}
            let a = &xys[k];
            for &(x, y) in a {
                if p[x] != y {flg = false};
            }
        }
        if flg {answer = cmp::max(answer, count)}
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
N,M = map(int, input().split())
A = [[] for _ in range(N)]
B = [[] for _ in range(N)]
lst = []
for i in range(N):
    A[i], B[i] = map(int, input().split())
    lst.append([A[i],B[i]])

lst.sort()

count = 0
cost = 0
for i in range(N):
    if count+lst[i][1] >= M:
        cost += lst[i][0]*(M-count)
        break
    else:
        cost += lst[i][0]*lst[i][1]
        count += lst[i][1]
        
print(cost)

Measured memory_bytes: 21676
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,p[200],u;
  string s[200];
  cin >> n;
  vector<tuple<string,ll,ll>>x(n);
  rep(i,n)cin >> s[i] >> p[i];
  rep(i,n){
    x[i]=make_tuple(s[i],100-p[i],i);
  }
  sort(all(x));
  rep(i,n){
    u=get<2>(x[i]);
    printf("%lld\n",u+1);
  }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class agcA {
public:
    void solve(istream& in, ostream& out) {
        long long A, B, C;
        in >> A >> B >> C;
        
        set<tuple<long long, long long, long long>> vis;
        
        int res = 0;
        while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            if (vis.find(make_tuple(A, B, C)) != vis.end()) {
                out << -1 << "\n";
                return;
            }
            vis.emplace(A, B, C);
            ++res;
            long long AA = A, BB = B, CC = C;
            A = BB / 2 + CC / 2;
            B = AA / 2 + CC / 2;
            C = AA / 2 + CC / 2;
        }
        
        out << res << "\n";
    }
};


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

	agcA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{ 
   
     
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
  
} 
  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        SieveOfEratosthenes(1000000);
    int n=0;
    cin>>n;
    int i=0;

    while(prime[n+i]!=true){
        i++;
    }
	if(n==1)
cout<<"2";
else
    cout<<n+i;
        
    }

    return 0;
}


Measured memory_bytes: 1280
MAX = 300000

number = Array.new(MAX + 10, false)
i = 1
j = 6
while i <= MAX do
  number[i] = number[j] = true
  i += 7
  j += 7
end

isPrime = Array.new(MAX + 10, true)
isPrime[0] = isPrime[1] = false
for i in 2..MAX do
  next if !number[i]
  (i+i).step(MAX, i) do |j|
    isPrime[j] = false
  end
end

while (n = gets.to_i) != 1 do
  printf "%d:", n
  for i in 6..n do
    next if !number[i]
    next if !isPrime[i]
    next if n % i != 0
    printf " %d", i
  end
  puts
end

Measured memory_bytes: 10804
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int> engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n;
vector<string> ans[10];
void init(){
	ans[3]={
			"aa.",
			"..a",
			"..a"
	};
	ans[4]={
			"abaa",
			"abcc",
			"ccab",
			"bbab"
	};
	ans[5]={
			"aabba",
			"bcc.a",
			"b..ab",
			"a..ab",
			"abbcc"
	};
	ans[6]={
			"aabbaa",
			".b.a.b",
			".b.a.b",
			"aabbaa",
			"b.a.b.",
			"b.a.b."
	};
	ans[7]={
			"aabbaa.",
			"bb.cc.a",
			"..a..ba",
			"..a..bc",
			"aa.aa.c",
			"..a..ab",
			"..a..ab"
	};
	ans[11]={
			"aabba......",
			"bcc.a......",
			"b..ab......",
			"a..ab......",
			"abbcc......",
			".....aabbaa",
			"......b.a.b",
			"......b.a.b",
			".....aabbaa",
			".....b.a.b.",
			".....b.a.b."
	};
}
signed main() {
	cin>>n;
	init();
	if(n==2)cout<<-1<<endl;
	else if(n<=7){
		rep(i,n)cout<<ans[n][i]<<endl;
	}else {
		if(n==11){
			rep(i,11)cout<<ans[11][i]<<endl;
		}else {
			int cnt1;
			for(int i=0;;i++){
				if((n-4*i)%5==0){
					cnt1=4*i;
					break;
				}
			}
			rep(i,n){
				if(i<cnt1){
					rep(j,i/4*4)cout<<".";
					cout<<ans[4][i%4];
					for(int j=i/4*4+4;j<n;j++)cout<<".";
				}else {
					rep(j,cnt1+(i-cnt1)/5*5)cout<<".";
					cout<<ans[5][(i-cnt1)%5];
					for(int j=cnt1+(i-cnt1)/5*5+5;j<n;j++)cout<<".";
				}
				cout<<endl;
			}
		}
	}
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
  int n,a,b,c,i;
	bool flag;
	cin>>n;
	for(;n>0;n--){
		a = b = 0;
		flag = true;
		for(i=0;i<10;i++){
			cin>>c;
			if(a >= b && c > a)
				a = c;
			else if(c > b)
				b = c;
			else
				flag = false;
		}
		if(flag)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

string T;
void input() {
  ;
  ;
  cin >> N;
  cin >> S >> T;
}
void solve() {
  ;
  string ans = "";
  rep(i, 0, N - 1) {
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using P = pair<ll, ll>;

ll m[20][20];

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

ll comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

ll digit(ll num)
{
    if(num < 10)
    {
        return 1;
    }

    ll d = 1;
    ll k = 10;
    while(num >= k)
    {
        d++;
        k *= 10;
    }

    return d;
}

ll digitNum(ll num, ll count)
{
    ll a = (num % (ll) pow((double) 10, (double) count));
    return a / pow(10, count - 1);
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    rep(i,n)
    {
        ll x = a[i];
        if(x % 2 == 0 && x % 3 > 0 && x % 5 > 0)
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
from math import sqrt

n, m = map(int, input().split())


def fact(x):
	ret = []
	for i in range(1, int(sqrt(x)) + 1):
		if x % i == 0:
			ret.append(i)
			ret.append(x // i)

	return ret


fct = fact(m)
ans = 1
for e in fct:
	if e <= m / n:
		ans = max(ans, e)

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cctype>

using namespace std;

int main() {
	char ch;
	while (1) {
		scanf("%c",&ch);
		if (isalpha(ch)) {
			if (islower(ch)) {
				printf("%c", toupper(ch));
			}
			else{
				printf("%c", tolower(ch));
			}

		}
		else {
			printf("%c", ch);
		}

		if (ch == '\n') break;

	}

	return 0;
}

Measured memory_bytes: 2604
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>

#define ll long long
#define md  1000000007

using namespace std;
long long n,m;


int main(){
    cin>>n>>m;
    ll res=0;
    res = min(n, m/2);
    if(m-res*2>0){
	res+=(m-res*2)/4;
    }
    cout<<res<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    ll ans=0,n;
    cin >> n;
    vector<ll> v(n);
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
    }

    for(int i=0;i < n;i++)
    {
        while(v.at(i)%2==0){
            v.at(i)/=2;
            ans++;
        }
    }
    cout << ans << endl;
}
/*全て奇数になったら終わり 一つずつ2で割っていく 普通にカウント?*/

Measured memory_bytes: 384
import sys

input = sys.stdin.readline

dct = ['dream', 'dreamer', 'erase', 'eraser']
rdct = [''.join(reversed(x)) for x in dct]

def main():
    S = input()[:-1]
    rS = ''.join(reversed(S))

    fr = 0
    for _ in range(20005):
        flag = False
        for d in rdct:
            to = fr + len(d)
            if d == rS[fr:to]:
                fr = to
                flag = False
                break
            flag = True
        if flag:
            break
    
    if fr == len(S):
        print('YES')
    else:
        print('NO')
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3956
N = int(input())
p = [int(input()) for _ in range(N)]
q = [0] * (N + 1)
for i in range(N):
  q[p[i]] = i
res = 0
temp = 0
for i in range(2, N + 1):
  if q[i - 1]  < q[i]:
    temp += 1
  else:
    res = max(res, temp)
    temp = 0
res = max(res, temp)
print(N - res - 1)

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

int main(){
  int n;
  cin>>n;
  if(n%10==3)
    cout<<"bon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
LL n,k;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  n%=k;
  cout<<min(n,abs(n-k));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int main()
{
	int n,d,x;
	cin>>n>>d>>x;
	int a[n+1],i;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int ans;
	ans=x;
	for (i=1;i<=n;i++)
	{
		ans+=(d-1)/a[i]+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))

def check(x):
  b = a[: ]
  for i in range(N):
    b[i] += x
  c = 0
  for i in range(N):
    t = max(0, b[i] - (N - 1))
    c += -(-t // (N + 1))
  return c <= x

ok = sum(a)
ng = -1
while ok - ng > 1:
  m = (ok + ng) // 2
  isok = 0
  for i in range(N):
    if check(m + i):
      isok = 1
      break
  if isok: ok = m
  else: ng = m
for i in range(N):
  if check(ok + i):
    print(ok + i)
    break

Measured memory_bytes: 41324
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n;
		int roop=0;
		StringBuilder[] ans=new StringBuilder[1000];
		String tmpData;
		while((n=sc.nextInt())!=0){
			String[][] str=new String[n][2];
			for(int j=0;j<n;j++){	//変換表の入力
				str[j][0]=sc.next();
				str[j][1]=sc.next();
			}
			int dn=sc.nextInt();	//変換データ文字数
			for(int j=0;j<dn;j++){
				tmpData=sc.next();
				for(int k=0;k<n;k++){
					if(tmpData.equals(str[k][0])){
						tmpData=str[k][1];
						break;
					}
				}
				if(j==0){
					ans[roop]=new StringBuilder(tmpData);
				}else{
					ans[roop].append(tmpData);
				}
			}
			roop++;
		}
		sc.close();
		for(int i=0;i<roop;i++){
			System.out.println(ans[i].toString());
		}
	}
}

Measured memory_bytes: 69564
n = gets.chomp.to_i
ls = gets.chomp.split(' ').map(&:to_i)

if n < 3
  puts 0
  exit
end

ts = 0
(0..n-1).each do |i|
  
  ((i+1)..n-1).each do |j|
    break if j >= n
    next if ls[j] == ls[i]
    
    ((j+1)..n-1).each do |k|
      next if [ls[i], ls[j]].include?(ls[k])
     
      lls = [ls[i], ls[j], ls[k]].sort
      if lls[0] + lls[1] <= lls[2]
        next   # 三角形にならない
      end
      
      ts += 1
    end
  end
  
end

puts ts


Measured memory_bytes: 14376
import java.util.Scanner;

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

		while (true) {
			long a = scanner.nextInt();
			String op = scanner.next();
			long b = scanner.nextInt();

			switch (op) {
			case "+":
				System.out.println(a + b);
				break;

			case "-":
				System.out.println(a - b);
				break;

			case "*":
				System.out.println(a * b);
				break;

			case "/":
				System.out.println(a / b);
				break;

			case "?":
				scanner.close();
				return;
			}
		}
	}
}



Measured memory_bytes: 26252
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  string line;
  getline(cin, line);
  
  vector<string> vs(2);
  getline(cin, vs[0]);
  getline(cin, vs[1]);

  int index = 0;
  ll ans = 1;
  ll prev = 0;
	
  while (index < n)
  {
	if (vs[0][index] == vs[1][index]) // vert
	{
	  ans *= 3 - prev;
	  ans %= 1000000007ll;
	  prev = 1;
	  index++;
	}
	else // hor
	{
	  ans *= prev == 0 ? 6ll : prev == 1 ? 2ll : 3ll;
	  ans %= 1000000007ll;
	  prev = 2;
	  index += 2;
	}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from math import sqrt
eps = 10**-10
# eps = sys.float_info.epsilon
def crosscl(cx, cy, r, x1, y1, x2, y2):
    xd = x2 - x1; yd = y2 - y1
    X = x1 - cx; Y = y1 - cy
    a = xd**2 + yd**2
    b = xd * X + yd * Y
    c = X**2 + Y**2 - r**2
    # D = 0の時は1本で、D < 0の時は存在しない
    D = (b**2 - a*c)
    if D<0:
        return None, None
    s1 = (-b + sqrt(D)) / a
    s2 = (-b - sqrt(D)) / a
    return (x1 + xd*s1, y1 + yd*s1), (x1 + xd*s2, y1 + yd*s2)

def crosscc(x1,y1,r1,x2,y2,r2):
    k = -2*(x1-x2)
    l = -2*(y1-y2)
    m = x1**2 - x2**2 + y1**2 - y2**2 - r1**2 + r2**2
    if k==0:
        p1 = (0, -m/l)
        p2 = (100, -m/l)
    elif l==0:
        p1 = (-m/k, 0)
        p2 = (-m/k, 100)
    else:
        p1 = (0, -m/l)
        p2 = (1, -(m+k)/l)
    return crosscl(x1,y1,r1,*p1,*p2)

N = int(input())
xy = [None]*N
for i in range(N):
    x,y = map(int, input().split())
    xy[i] = (x,y)
def sub(r):
    kouho = xy[:]
    for i in range(N):
        for j in range(i+1, N):
            p1, p2 = crosscc(xy[i][0], xy[i][1], r, xy[j][0], xy[j][1], r)
            if p1 is not None:
                kouho.append(p1)
                kouho.append(p2)
    ans = False
#     print(kouho)
    for k in kouho:
        for x,y in xy:
            if (k[0]-x)**2 + (k[1]-y)**2 <= (r**2) * (1+eps):
                pass
            else:
                break
        else:
            ans = True
    return ans
lb = 0
ub = 2000
while abs(lb-ub)>10**-8:
    mm = (lb+ub)/2
    if sub(mm):
        ub = mm
    else:
        lb = mm
print(ub)

Measured memory_bytes: 78252
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int val[N<<1];
int a[N];
void pushUp(int u){
	val[u]=max(val[u<<1],val[u<<1|1]);
}
void update(int u,int l,int r,int x,int d){
	if(l==r){
		val[u]=max(d,val[u]);
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)update(u<<1,l,mid,x,d);
	else update(u<<1|1,mid+1,r,x,d);
	pushUp(u);
}
int query(int u,int l, int r,int x,int y){
	if(x<=l&&r<=y){
		return val[u];
	}
	int res=0;
	int mid=l+r>>1;
	if(x<=mid)res=max(res,query(u<<1,l,mid,x,y));
	if(y>mid)res=max(res,query(u<<1|1,mid+1,r,x,y));
	return res;
}
int maxDog;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		maxDog=max(maxDog,a[i]);
	}
	for(int i=1;i<=n;i++){
		int t=query(1,1,maxDog,max(1,a[i]-k),min(maxDog,a[i]+k))+1;
		update(1,1,maxDog,a[i],t);
	}
	printf("%d\n",query(1,1,maxDog,1,maxDog));
	return 0;
}


Measured memory_bytes: 9080
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K<=A){
        cout << K;
    }else if(K<=A+B){
        cout << A;
    }else{
        cout << A-(K-A-B);
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  int n, x;
  cin >> n >> x;

  vector<int> a(n);
  vector<int> dif(n);
  rep(i, n) cin >> a[i];
  if (n == 1) {
    cout << abs(x - a[0]) << endl;
    return 0;
  }
  rep(i, n) dif[i] = abs(a[i] - x);

  int ans = dif[0];
  rep(i, n) ans = gcd(ans, dif[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[2000];
int dp[2000][2000];
int main() {
    int i;
    int N,x;
    scanf("%d %d",&N,&x);
    for (i = 0; i < N; i++) scanf("%d",&a[i]);

    int j;
    LLI ans = 1e18;
    for (i = 0; i < N; i++) {
        dp[i][i] = a[i];
        for (j = i+1; j < N; j++) dp[i][j] = min(dp[i][j-1],a[j]);
    }
    for (i = 0; i < N; i++) {
        LLI sum = (LLI) i*x;
        for (j = 0; j < N; j++) {
            if (j-i < 0) sum += min(dp[0][j],dp[j-i+N][N-1]);
            else sum += dp[j-i][j];
        }
        ans = min(ans,sum);
    }
    printf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long, long long> pll;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());


    ll lb = -1, ub = 1e13;
    while(ub - lb > 1){
        ll m = (lb + ub) / 2;
        ll cnt = 0;
        bool flag = 1;
        rep(i, 0, N){
            if(m < A[i] * F[i]){
                cnt += (A[i] * F[i] - m + F[i] - 1) / F[i];
            }
            if(cnt > K){
                flag = 0;
                break;
            }
        }
        if(flag) ub = m;
        else lb = m;
    }
    cout << ub << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const long long INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
#define pb push_back
#define ll long long
int n;
int a[100000] , b[100000];
map<int , int> g;
int main()
{
	scanf("%d" , &n);
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		scanf("%d"  , &a[i]);
		g[a[i]] = i % 2;
		b[i] = a[i];
	}
	sort(b , b + n);
	for(int i = 0; i < n; i++)
	{
		if(g[b[i]] != i % 2)
		{
			ans++;
		}
	}
	cout << ans / 2;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

static const double pi = 3.141592653589793;
signed main(void)
{	
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double angle = abs(6 * m - (30 * h + m / 2));
	double cosx = cos(angle * pi / 180);
	double ans = pow(a*a + b * b - 2 * a*b*cosx,0.5);
	std::cout << std::fixed;
	std::cout << std::setprecision(10) << ans; 
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
B = set(A)
C = list(B)

if max(A)==0:
    print('Yes')
    exit()

if N%3!=0:
    print('No')
    exit()

if (len(B)==3 and
    C[0]^C[1]==C[2] and
    A.count(C[0])==N//3 and
    A.count(C[1])==N//3 and
    A.count(C[2])==N//3):
    print('Yes')
    exit()

if (len(B)==2 and
    min(C)==0 and
    A.count(0)==N//3 and
    A.count(max(C))==2*N//3):
    print('Yes')
    exit()

print('No')

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

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

void fastscan(ll &number)
{
	bool negative = false;
	register int c;
	number = 0;
	c = getchar();
	if (c=='-') 
	{
		negative = true;
		c = getchar();
	}
	for (; (c>47 && c<58); c=getchar())
		number = number *10 + c - 48;
	if (negative)
		number *= -1;
}

bool isprime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

bool checkisTree(ll degree[],ll n) 
{
    ll deg_sum = 0; 
    for (ll i = 0; i < n; i++) 
        deg_sum += degree[i]; 
    return (2*(n-1) == deg_sum);
}

ll gcd(ll a, ll b) 
{
    
    if (b == 0)  return a;
    return gcd(b, a % b);

}

int main()
{
	cin.sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		ll arr[n], arr1[n-1];
		for(ll i=0; i<n+1; i++)
			cin>>arr[i];
		for(ll i=0; i<n; i++)
			cin>>arr1[i];
		ll x=0;
		for(ll i=0; i<n; i++)
		{
			x += min(arr[i]+arr[i+1],arr1[i]);	
			if(arr[i]-arr1[i]<0)
				arr[i+1]=max((ll)0,arr[i+1]+(arr[i]-arr1[i]));
         	//cout<<arr1[i+1];
		}
		cout<<x;
	}	
}

Measured memory_bytes: 1792
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

bool check(int a, int b, int c) {
	int largest = max(a, max(b, c));
	int smallest = min(a, min(b, c));
	int x = a^b^c^largest^smallest;
	return (b == x);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];

	int ct = 0;
	for(int i = 1; i < n-1; i++) {
		if(check(a[i-1], a[i], a[i+1])) ++ct;
	}

	cout << ct;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<math.h>
using namespace std;

#define LL long long

char ma[603][603];
int mb[603][603];

int cd(int a,int b,int n){
        int ans=0;
        for(int i=0;i<n;i++){
                for(int j=i;j<n;j++){
                        if(ma[a+i][b+j]!=ma[a+j][b+i])ans++;
                }
        }
        return ans;
}

int next(int a,int b,int n){
        int ans=0;
        for(int i=0;i<n;i++){
                if(ma[a-1+i][b]!=ma[a][b-1+i])ans--;
        }
        for(int i=0;i<n;i++){
                if(ma[a+i][b+n]!=ma[a+n][b+i])ans++;
        }
        return ans;
}

int main()
{
        int n;
        while(cin>>n){
                for(int i=0;i<n;i++){
                        cin>>ma[i];
                }
                for(int i=0;i<n;i++){
                        for(int j=n;j<2*n;j++)ma[i][j]=ma[i][j-n];
                }
                for(int i=n;i<2*n;i++){
                        for(int j=0;j<2*n;j++)ma[i][j]=ma[i-n][j];
                }
//
//                for(int i=0;i<2*n;i++){
//                        for(int j=0;j<2*n;j++){
//                                cout<<ma[i][j];
//                        }
//                        cout<<endl;
//                }
                int ans=0;
                for(int i=0;i<n;i++){
                        mb[i][0]=cd(i,0,n);
                        for(int k=1;k+i<n&&k+0<n;k++){
                                mb[i+k][0+k]=mb[i+k-1][0+k-1]+next(i+k,0+k,n);
                        }
                }
                for(int j=1;j<n;j++){
                        mb[0][j]=cd(0,j,n);
                        for(int k=1;k+0<n&&k+j<n;k++){
                                mb[0+k][j+k]=mb[0+k-1][j+k-1]+next(0+k,j+k,n);
                        }
                }
                for(int i=0;i<n;i++){
                        for(int j=0;j<n;j++){
                                //cout<<mb[i][j]<<endl;
                                if(mb[i][j]==0)ans++;
                        }
                        //cout<<endl;
                }
                cout<<ans<<endl;
        }
        return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int X, t;
    std::cin >> X >> t;

    if (t > X) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << X - t << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

s64 N;
s64 L;


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

    cin >> N >> L;

    s64 sum = N * (2 * L + N - 1) / 2;

    s64 bite = -L >= N ? L + N - 1
            : -L >= 0 ? 0 : L;

    cout << sum - bite << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int i;
		char s[13];
		scanf("%s",s);
		for(i=0;i<4;i++)printf("%c",s[i]);
		printf(" ");
		for(i=4;i<12;i++)printf("%c",s[i]);
		puts("");
		return 0;
}


Measured memory_bytes: 128
N = int(input())
j = 0
c2 = 0
for i in range(1, N+1):
	a = i
	c = 0
	while a % 2 == 0:
		c = c + 1
		a = a / 2
		if c >= c2:
			c2 = c
			j = i
if N == 1:
	print(1)
else:
	print(j)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
string ans;
signed main() {
	int n = input(); n--;
	while (n >= 0) {
		ans = (char)(n % 26 + 'a') + ans;
		n /= 26; n--;
	}
	puts(ans);
}

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

const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  vector<pair<int, int>> ab(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;

  vector<int> dp(h + 1, INF);

  dp[0] = 0;
  rep(i, n) {
    rep(j, h) {
      int nj = min(j + ab[i].first, h);
      dp[nj] = min(dp[nj], dp[j] + ab[i].second);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)][::-1]
ans = 0
for i in range(N):
    if (arr[i][0]+ans) % arr[i][1] != 0:
        ans += arr[i][1] - ((arr[i][0]+ans) % arr[i][1])
print(ans)

Measured memory_bytes: 62168
xmoji=input()
ymoji=input()

x=len(xmoji)
y=len(ymoji)
tempmin = 0
for i in range(0,x-y+1):
    xmin=xmoji[i:i+y]
    samenum=0
    for j in range(0,y):
        if(xmin[j]==ymoji[j]):
            samenum+=1
    if(tempmin<samenum):
        tempmin = samenum
print(y-tempmin)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, c, cnt = 0; cin >> n >> m >> c;
    vi b(m, 0);

    rep(i, m) cin >> b[i];
    rep(i, n){
        ll ans = 0;
        rep(j, m){
            ll a; cin >> a;
            ans += a * b[j];
        }
        if(ans+c > 0) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  const char* result = "No";
  if ((S[0] != S[1]) || (S[1] != S[2])) {
    result = "Yes";
  }
  cout << result << endl;
  return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b!=c) cout << "Yes" << endl;
    else if(a==c && b!=c) cout << "Yes" << endl;
    else if(b==c && a!=c) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vec<ll> d(n); rep(i,n)cin >> d[i];
    sort(d);
    cout << d[n/2] - d[n/2-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		ll N,L;

		cin >> N >> L;

		string S[100]={};

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

		sort(S,S+N);

		for(int i=0;i<N;i++){
			cout << S[i];
		}

		cout << endl;
				
		return 0;
    }

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

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, K;
int num[26];

bool ok(int x)
{
	int s = 0;
	rep(i, 26) s += min(num[i], x);
	return s >= K * x;
}

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

	rep(i, N) {
		string s;
		cin >> s;
		++num[s[0] - 'A'];
	}

	if (!ok) {
		puts("0");
		return 0;
	}
	int lo = 0, hi = N + 1;
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) lo = m;
		else hi = m;
	}

	cout << lo << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

words = []
last_char = nil
n.times do
  word = gets.chomp

  if words.find { |w| w == word }
    puts 'No'
    exit
  elsif last_char && word[0] != last_char
    puts 'No'
    exit
  end

  words << word
  last_char = word[-1]
end

puts 'Yes'


Measured memory_bytes: 1916
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,x,pos[200005],ans,k;
int main()
{
    scanf("%d",&n);
    ans=n;
    for(int i=1;i<=n;i++)scanf("%d",&x),pos[x]=i;
    for(int i=1;i<=n;i++)
    {
        if(pos[i]<pos[i-1])k=1;
        else k++;
        ans=min(ans,n-k);
    }
    printf("%d",ans);
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<bool>> board(H, vector<bool>(W));
    string S;
    for (int i = 0; i < H; i++)
    {
        cin >> S;
        for (int j = 0; j < W; j++)
        {
            board[i][j] = (S[j] == '#');
        }
    }

    vector<vector<bool>> visited(H, vector<bool>(W, false));

    vector<pair<int, int>> diff{
        pair<int, int>(1, 0),
        pair<int, int>(0, 1),
        pair<int, int>(-1, 0),
        pair<int, int>(0, -1)};
    queue<pair<int, int>> q;
    long long ans = 0;
    long long bsum, wsum;
    int x, newx;
    int y, newy;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (!visited[i][j])
            {
                q.push(make_pair(i, j));
                bsum = 0;
                wsum = 0;
                while (!q.empty())
                {
                    x = q.front().first;
                    y = q.front().second;
                    q.pop();
                    if (visited[x][y])
                    {
                        continue;
                    }

                    if (board[x][y])
                    {
                        bsum++;
                    }
                    else
                    {
                        wsum++;
                    }
                    visited[x][y] = true;
                    for (pair<int, int> d : diff)
                    {
                        newx = x + d.first;
                        newy = y + d.second;
                        if (newx < 0 || newy < 0)
                        {
                            continue;
                        }
                        if (newx >= H || newy >= W)
                        {
                            continue;
                        }
                        if (visited[newx][newy])
                        {
                            continue;
                        }
                        if (board[x][y] != board[newx][newy])
                        {
                            q.push(make_pair(newx, newy));
                        }
                    }
                }
                ans += bsum * wsum;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    set<char> s;
    rep(i,n){
        char tmp; cin >> tmp;
        s.insert(tmp);
    }
    if(s.size() == 4){
        put("Four");
    }else if(s.size() == 3){
        put("Three");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t Nmod= 1000000007;

int64_t negmod(int64_t a, int64_t n= Nmod){
  int64_t ans= a%n;
  if(ans<0) ans+= n;

  return ans;
}

int64_t fac(int64_t a, int64_t p= Nmod){
  int64_t ans= 1;
  for(auto i=1; i<=a; i++){
    ans= (ans*i)% p;
  }

  return ans;
}

int64_t invmod(int64_t a, int64_t p= Nmod){ // a^{p-1} mod p =1 を利用してinv(a)= a^{p-2} を求める
  int64_t d= p-2;
  int64_t ans= 1;
  int64_t tmp= a;
  while(d > 0){
    if(d%2==1){
      ans= (ans*tmp)% p;
    }
    d/= 2;
    tmp= (tmp*tmp)% p;
  }

  return ans;
}

int64_t choose(int64_t n, int64_t k, int64_t p= Nmod){
  if(n < 0 || min(k,n-k) < 0){
    return 0;
  }
  else{
    return fac(n)*(invmod(fac(k))* invmod(fac(n-k))% p) % p;
  }
}

int main() { // S= f(r_2 +1, c_2 +1)- f(r_2 +1, c_1)- f(r_1, c_2 +1)+ f(r_1, c_1)
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;

  int64_t pos= (choose(r2 +c2 +2, c2 +1)+ choose(r1 +c1, c1))% Nmod;
  int64_t neg= (choose(r2 +c1 +1, c1)+ choose(r1 +c2 +1, r1))% Nmod;

  cout << negmod(pos- neg) << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,L;
ll i,ans;
int main(){
    scanf("%lld%lld", &N,&L);
    ans = N * L;
    fornum(i,1,N){
        ans += i;
    }
    if(L<0){
        if(-L>=N){
            ans -= (L + N - 1);
        }
    }else{
        ans -= L;
    }

    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256