akhauriyash/Code-Regression huggingface dataset:
n,m,c=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
cnt=0
for i in range(n):
    a=[int(i) for i in input().split()]
    result=c
    for j in range(m):
        result+=a[j]*b[j]
    if result>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[n-k]%MOD

def resolve():
    n,m,k=map(int,input().split())
    N=n*m
    ans=0
    mf=modfact(N)
    for d in range(1,n):
        ans+=d*(m**2)*(n-d)*mf.comb(N-2,k-2)
        ans%=MOD
    for d in range(1,m):
        ans+=d*(n**2)*(m-d)*mf.comb(N-2,k-2)
        ans%=MOD
    print(ans)
resolve()

Measured memory_bytes: 43884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string c;
  cin>>n>>c;
  int r=0;
  for(int i=0;i<n;i++)
    r+=(c.at(i)=='R'?1:0);
  int a=0;
  for(int i=0;i<r;i++)
    a+=(c.at(i)=='W'?1:0);
  cout<<a<<endl;
}

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var abc = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(abc);
        abc = abc.Select(v => abc[2] - v).ToArray();
        if (abc[0] % 2 == abc[1] % 2)
            WriteLine(abc[0] + (abc[1] - abc[0]) / 2);
        else
            WriteLine(1 + abc[0] + (abc[1] + 1 - abc[0]) / 2);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <stdio.h>
#define MAX 300000
int main(void) {
    int n, i, cnt=0, ans=MAX-1;
    char s[MAX];
    scanf("%d %s", &n, s);
    
    for(i=1; i<n; i++) {
        if(s[i]=='E')
            cnt++;
    }
    ans = cnt;
    for(i=1; i<n; i++) {
        if(s[i]=='E')
            cnt--;
        if(s[i-1]=='W')
            cnt++;
        if(cnt<ans)
            ans = cnt;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long line = in.nextInt();//文字列の入力受付
        String s = String.valueOf(line);
        int p = 0;
        String sl[]= s.split("");
        for (int i = 0;i < sl.length ;i++ ){
            p = p + Integer.parseInt(sl[i]);
        }
        if (line % p == 0){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	std::vector<std::string> ans(26);

	ans[25] = "Christmas";
	ans[24] = "Christmas Eve";
	ans[23] = "Christmas Eve Eve";
	ans[22] = "Christmas Eve Eve Eve";

	int a;

	std::cin >> a;

	std::cout << ans[a] << std::endl;
	return 0;
}

Measured memory_bytes: 384
N, W = list(map(int, input().split()))

values = []
weights = []

for i in range(N):
    v, w = list(map(int, input().split()))
    values.append(v)
    weights.append(w)

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1, N+1):
    for j in range(1, W+1):
        w = weights[i-1]
        v = values[i-1]

        if j >= w:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j- w] + v)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])


Measured memory_bytes: 25940
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

#define N 30000

int main(){fastio
    ll h,n;cin>>h>>n;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i]>>b[i];
    ll dp[n+1][N];rep(i,0,n)rep(j,0,N-1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,0,n-1){
        rep(j,0,N-1){
            Min(dp[i+1][j],dp[i][j]);
            if(j-a[i]>=0)Min(dp[i+1][j],dp[i][j-a[i]]+b[i]);
            if(j-a[i]>=0)Min(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
        }
    }
    ll ans=inf;
    rep(j,h,N-1)Min(ans,dp[n][j]);
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr long double pi = 3.141592653589793;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  long double a, b, h, m;
  cin>>a>>b>>h>>m;
  long double A=(h+m/60)/12*2*pi, B=m/60*2*pi;
  long double C=abs(A-B);
  if(C>pi){
    C=2*pi-C;
  }
  cout<<sqrt(a*a+b*b-2*a*b*cos(C))<<'\n';
  return 0;
}


Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli INF  = 1e9+5;
int main(){
    lli n;
    cin >> n;
    vector <lli> h(n);
    for(int i =0;i<h.size();i++)cin >> h[i];
    vector <lli> dp(n,INF);
    dp[0] = 0;
    for(int i =0;i<n;i++){
        if(i+1<n)
            dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2<n)
            dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[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()));
        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! {
        s: [chars]
    }
    let mut h = ['M', 'A', 'R', 'C', 'H']
        .iter()
        .map(|c| (*c, 0))
        .collect::<std::collections::HashMap<char, u64>>();
    for s in s {
        match s[0] {
            'M' | 'A' | 'R' | 'C' | 'H' => *h.get_mut(&s[0]).unwrap() += 1,
            _ => {}
        }
    }
    let v = h.values().collect::<Vec<_>>();
    let mut count = 0u64;
    for i in 0..v.len() {
        for j in 0..i {
            for k in 0..j {
                count += v[i] * v[j] * v[k];
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a[105];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a +n,greater<int>());

  int alice=0,bob=0;
  for(int i=0;i<n;i+=2){
    alice+=a[i];
  }
  for(int i=1;i<n;i+=2){
    bob+=a[i];
  }

  cout<<abs(bob-alice)<<'\n';
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=["." + input() + "." for _ in range(h)]
s.insert(0,"."*(w+2))
s.append("."*(w+2))
ans=""
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==".":
            ans+=str((sum([s[i-1][j-1]=="#",s[i-1][j]=="#",s[i-1][j+1]=="#",s[i][j-1]=="#",s[i][j+1]=="#",s[i+1][j-1]=="#",s[i+1][j]=="#",s[i+1][j+1]=="#"])))
        else:
            ans+="#"
    print(ans)
    ans=""


Measured memory_bytes: 3064
// 解説を読んだ　面白い
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<numeric>
using namespace std;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<int> v[n];
        while(m-- > 0){
            int a, b;
            cin >> a >> b;
            a--, b--;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        bool ok = true;
        vector<int> col(n, -1);
        queue<int> q;
        q.push(0);
        col[0] = 0;
        for(int x : v[0])   col[x] = 1, q.push(x);
        while(!q.empty()){
            int x = q.front();  q.pop();
            for(int next : v[x]){
                ok &= col[next]==-1 || col[next]!=col[x];
                if(col[next] == -1)   col[next] = 1-col[x], q.push(next);
            }
        }
        if(!ok){
            cout << 0 << endl;
            continue;
        }
        int one = accumulate(col.begin(),col.end(), 0);
        set<int> res;
        if(one%2 == 0)  res.insert(one/2);
        if((n-one)%2 == 0)  res.insert((n-one)/2);
        cout << res.size() << endl;
        for(int x : res)    cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

lint func(lint x){
    if(x%2) return (x+1) / 2 % 2;
    return x / 2 % 2 ^ x;
}

int main(){
    lint A, B; cin >> A >> B;
    cout << (func(A-1)^func(B)) << endl;
    return 0;
}

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		string s = "ACL";
		int n;
		cin>>n;
		string ans = "";
		while(n--)
		{
			ans+=s;
		}
		cout<<ans;
    }
    return 0;
}


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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N, sz[100001];
vector<pii> adj[100001];
ll ans = 0;
pii mn = {1,MOD};

void dfs(int par, int node, ll wei) {
    sz[node] = 1;
    for (pii x: adj[node]) if (x.f != par) {
        dfs(node,x.f,x.s);
        sz[node] += sz[x.f];
    }
    //cout << "HI " << node << " " << 2LL*wei*min(sz[node],N-sz[node]) << "\n";
    ans += 2LL*wei*min(sz[node],N-sz[node]);
}

void dfs1(int par, int node, ll wei) {
    if (2*sz[node] == N) mn = min(mn,{0,wei});
    
    int mx = 0, minedge = wei;
    for (pii x: adj[node]) if (x.f != par) {
        dfs1(node,x.f,x.s);
        mx = max(mx,sz[x.f]);
        minedge = min(minedge,x.s);
    }
    mx = max(mx,N-sz[node]);
    if (mx <= N/2) mn = min(mn,{1,minedge}); 
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N;
	F0R(i,N-1) {
	    int A,B,C; cin >> A >> B >> C;
	    adj[A].pb({B,C});
	    adj[B].pb({A,C});
	}
	dfs(0,1,0);
	dfs1(0,1,MOD);
	ans -= mn.s;
	cout << ans;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
 
const int N=2e4+10;
const ll MOD2=998244353;
const ll MOD=1e9+7;

int main(){
    fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int a;
    string s;
    cin>>a>>s;
    if (a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
   cin >> L.at(i);
  }
  int sum = 0;
  int num = 0;
  for(int i = 0; sum <= X; i++){
    sum += L.at(i);
    num++;
    if(i == N-1){
      if(sum <= X){
        num++;
      }
      break;
    }
  }
  cout << num;
}


Measured memory_bytes: 256
#include<stdio.h>

#define big(a,b) ((a)<(b)?(a):(b))

int main(){
	int n,i,ashu[2][100001]={{0}},tmp,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&tmp);
		ashu[i%2][tmp]++;
	}
	int max[2][2]={{0,0},{0,0}};
	for(i=0;i<=100000;i++){
		if(ashu[0][max[0][0]]<ashu[0][i]){
			max[0][1]=max[0][0];
			max[0][0]=i;
		}else if(ashu[0][max[0][1]]<ashu[0][i]){
			max[0][1]=i;
		}
		if(ashu[1][max[1][0]]<ashu[1][i]){
			max[1][1]=max[1][0];
			max[1][0]=i;
		}else if(ashu[1][max[1][1]]<ashu[1][i]){
			max[1][1]=i;
		}
	}
	if(max[0][0]!=max[1][0])ans=n-ashu[0][max[0][0]]-ashu[1][max[1][0]];
	else {
		ans=big(n-ashu[0][max[0][0]]-ashu[1][max[1][1]],n-ashu[0][max[0][1]]-ashu[1][max[1][0]]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
import java.util.*;

class Main {

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

    long n = sc.nextLong();
    sc.close();

    long n2 = n % 1000;
    if (n2 == 0) {
      System.out.println(0);
    } else {
      System.out.println(1000 - n2);
    }


  }
}


Measured memory_bytes: 35644
from enum import Enum
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2
 
def comp_str(A,B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.EVEN
 
N = int(input())
 
point_Taro = 0
point_Hanako = 0
 
for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0],line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1
 
print("%d %d"%(point_Taro,point_Hanako))


Measured memory_bytes: 6344
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e+5;
const double EPS = 1e-9;
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, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main() {
    vint v;
    int d, n;
    cin >> n;
    rep(i, n) {
        cin >> d;
        v.push_back(d);
    }
    sort(ALL(v));

    int maxval = 0;
    int count = 0;
    rep(i, n) {
        if (v[i] > maxval) {
            maxval = v[i];
            ++count;
        }
    }
    cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll H,W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W)), b(H, vector<int>(W));
    rep(i,H){
        rep(j,W){
            cin >> a[i][j];
        }
    }
    ll cnt =0;
    rep(i,H){
        rep(j,W){
            if(a[i][j] & 1){
                if(j+1 == W){
                    if(i+1 != H){
                        cnt++;//cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
                        a[i+1][j]++;
                        b[i][j] = 2;
                    }
                }else{
                    cnt++;//cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                    a[i][j+1]++;
                    b[i][j] = 1;

                }
            }
        }
    }
    cout << cnt << endl;
    rep(i,H){
        rep(j,W){
            if(b[i][j] == 1){
                cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
            }else if(b[i][j] == 2){
                cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
            }
        }
    }

}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int main(){
  int W;
  int H;
  int x;
  int y;
  int r;
  cin >> W >> H >> x >> y >> r;
  int X=x+r;
  int Y=y+r;
  if((x>=r && X<=W) && (y>=r && Y<=H)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1156
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    result = 0

    for i in range(n):
        for j in range(n):
            if i == j or i > j:
                continue
            result += num_list[i] * num_list[j]

    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  int n,p;
  cin >> n >> p;
  vector<int> a(n);
  rep(i,n){//50まで
    cin >> a[i];
  }
  int odd=0,even=0;//1,2
  rep(i,n){
    if(a[i]%2==0){
      even++;
    }
    else{
      odd++;
    }
  }
  if(odd==0){
    if(p==1){
      cout << "0" <<endl;
      return 0;
    }
    if (p==0){
      ll ans=0;
      ans = powl(2,n);
      cout << ans <<endl;
      return 0;
    }
  }
  ll ans=0;
  ans = powl(2,n-1);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 処理
void Solve()
{
	ll H1, M1;
	ll H2, M2;
	ll K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	ll sum1 = 60 * H1 + M1;
	ll sum2 = 60 * H2 + M2;
	ll diff;
	if (sum1 <= sum2) {
		diff = sum2 - sum1;
	} else {
		diff = sum2 + 60 * 24 - sum1;
	}

	ll ans = max((ll)0, diff - K);
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

int main() {
    int n; cin >> n;
    int v[n], c[n];

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

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

    int sum;

    for (int i=0;i<n;i++) {
        int sub = v[i] - c[i];

        if (sub > 0) {
            sum += sub;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 200007
#define MAXT 1100007
using namespace std;
int c[MAXT][26],br[MAXT],cnt=1;
long long t[MAXT],rez[MAXT][26],sol=0;
string s;
void ubaci(int ind,int d)
{
	if(d==s.size())
	{
		br[ind]++;
		return;
	}
	if(!c[ind][s[d]-'a']) c[ind][s[d]-'a']=++cnt;
	ubaci(c[ind][s[d]-'a'],d+1);
}
void dfs(int ind,int p)
{
	for(int i=0;i<26;i++) if(c[ind][i]) dfs(c[ind][i],ind);
	t[ind]+=br[ind];
	for(int i=0;i<26;i++) 
	{
		if(c[p][i]==ind) rez[p][i]+=t[ind];
		else rez[p][i]+=rez[ind][i];
	}
	t[p]+=t[ind];
	for(int i=0;i<26;i++) sol+=(rez[ind][i]-1)*br[c[ind][i]];
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		reverse(s.begin(),s.end());
		ubaci(1,0);
	}
	dfs(1,0);
	cout<<sol;
}

Measured memory_bytes: 388936
def vp(va, vb, i, m):
    return sum([
        va[i][j] * vb[j]
        for j in range(m)
    ])


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

A = []
b = []

for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    b.append(int(input()))

for i in range(n):
    print(vp(A, b, i, m))

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

int main() {
  int n;
  cin>>n;
  map<string,int> ma;
  rep(i,n) {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    ma[s]++;
  }
  ll ans=0;
  for (auto x: ma) {
    int se;
    se=x.second;
    ans+=(ll)se*(se-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 11136
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	memo := make(map[int]int)
	n, _ := strconv.Atoi(nextLine())
	for i := 0; i < n; i++ {
		a, _ := strconv.Atoi(nextLine())
		memo[a] = (memo[a] + 1) % 2
	}
	ret := 0
	for _, v := range memo {
		ret += v
	}
	fmt.Println(ret)
}


Measured memory_bytes: 7424
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i, n) reps(i,0,n)
#define fr first
#define sc second
#define SQR(x) ((x)*(x))
#define INF (1 << 28)
typedef pair< int , int > Pt;

int main(){
  int Q;
  int N,X,Y;
  Pt Natume;
  int x[1000],y[1000];
  vector< vector<int> > set;

  cin >> Q;
  while(Q--){
    //Input
    cin >> N >> X >> Y;
    cin >> Natume.sc >> Natume.fr;
    set.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) rep(j,N){
      if(SQR(x[i] - x[j]) + SQR(y[i] - y[j]) <= 2500){
        set[i].push_back(j);
      }
    }
    //end

    queue< Pt > que;
    int Say[1000],cnt = 0,flg = 1,END = 2*N*N,ans = 0;
    fill_n(Say,1000,-INF);
    rep(i,N){
      if(SQR(x[i] - Natume.sc) + SQR(y[i] - Natume.fr) <= 100){
        Say[i] = X;
        que.push(Pt(X,i));
      }
    }
    while(!que.empty()){
      Pt p = que.front(); que.pop();
      int now = p.sc , time = p.fr;
      cnt++;
      if(cnt > END){ flg--; break; }
      rep(i,set[now].size()){
        int e = set[now][i];
        if(time - Say[e] > Y){
          Say[e] = X + time;
          que.push(Pt(Say[e],e));
        }
      }
    }
    rep(i,N) ans = max(ans,Say[i]);

    //Output
    if(!flg) cout << "You're always welcome!" << endl;
    else cout << ans << endl;
    //end

    set.clear();
    }
}

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

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

  for (int i=1; i<=1000; i++) {
    int t = x - i*100;
    if (0 <= t && t <= 5*i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;

  return 0;
}


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

int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    double x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    sort(x,x+n);
    for(int i=n-1;i>=0;i--)
    {
        if(4*m*x[i]>=s)c++;
        else break;
    }

    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


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

namespace abc167_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine(). Split(' ');

            int a = int.Parse(input[0]); //1が書かれたカードa
            int b = int.Parse(input[1]); //0が書かれたカードｂ
            int c = int.Parse(input[2]); //-１が書かれたカードｃ
            int k = int.Parse(input[3]); //選ぶ枚数ｋ

        　　if(k<=a) 
            {
                Console.WriteLine(k);
            }
          else if(a<k && (k-a)<=b)
            {
                Console.WriteLine(a);
            }
          else
            {
                Console.WriteLine(a*2-k+b);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27356
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1001001001001;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    rep(i,n){
        ll a; cin >> a;
        ans += a;
    }
    ans-=n;
    cout << ans << endl;
}



Measured memory_bytes: 256
class Megalomania:
    def __init__(self):
        N = int(input())
        self.T = []
        for i in range(N):
            self.T.append([int(n) for n in input().split()])

    def main(self):
        sum_time = 0

        for task in sorted(self.T, key=lambda x: x[1]):
            sum_time += task[0]
            if sum_time > task[1]:
                print("No")
                return

        print("Yes")


megalomania = Megalomania()
megalomania.main()


Measured memory_bytes: 42836
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
const int INF = 100000000;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};

char S[20][21];
ll H,W;
int sx,sy;
int gx,gy;

int d[20][20];

int bfs(int sx, int sy, int gx, int gy){
	queue<P> que;
	REP(i,H){
		REP(j,W){
			d[i][j] = INF;
		}
	}
	que.push(P(sx,sy));
	d[sx][sy] = 0;
	while (que.size()){
		P p = que.front(); que.pop();
		if(p.first == gx && p.second == gy) break;
		REP(i,4){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if(0 <= nx && nx < H && ny < W && S[nx][ny] != '#' && d[nx][ny] == INF){
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

int main(){
	cin>>H>>W;
	REP(i,20){
		REP(j,21){
			S[i][j]='#';
		}
	}
	REP(i,H){
		REP(j,W){
			cin>>S[i][j];
		}
	}
	ll ans=0;
	
	REP(i,H){
		REP(j,H){
			REP(k,W){
				REP(l,W){
					if(S[i][j]!='#'&&S[k][l]!='#'&&((i!=k)||(j!=l))){
					    ll a=bfs(i,j,k,l);
						ans=max(a,ans);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int main( void ) {
	int n, x;
	scanf("%i %i", &n, &x);
	
	vector<int> S(n);
	for( int i = 0; i < n; i++ ) {
		scanf("%i", &S[i]);
	}
	
	const long long inf = 1LL << 60;
	
	vector<long long> f(n, inf);
	
	long long ans = inf;
	for( int k = 0; k < n; k++ ) {
		long long cost = (long long) k * x;
		for( int i = 0; i < n; i++ ) {
			f[i] = min(f[i], (long long) S[(i-k+n) % n]);
			cost += f[i];
		}
				
		ans = min(cost, ans);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import sys

alphabets = 'abcdefghijklmnopqrstuvwxyz'

cnt = {}
for c in alphabets:
    cnt[c] = 0

for line in sys.stdin:
    for c in line:
        if 'a' <= c.lower() <= 'z':
            cnt[c.lower()] += 1

for c in alphabets:
    print('%s : %d' % (c, cnt[c]) )

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    rep(i, s.size()) {
        std::cout << s[i];
        i++;
    }
    std::cout << "\n";
}


Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

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

        int r = sc.nextInt();
        int c = sc.nextInt();

        int ary[][] = new int[r + 1][c + 1];

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                ary[i][j] = Integer.valueOf(sc.next());
            }
        }

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                ary[i][c] += ary[i][j];
            }
        }
        for (int i = 0; i <= c; i++) {
            for (int j = 0; j < r; j++) {
                ary[r][i] += ary[j][i];
            }
        }

        for (int i = 0; i <= r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print(ary[i][j]+" ");
                
            }
            System.out.println(ary[i][c]);
        }
    }
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    int ans = min(count(c.begin(), c.end(), 'R'), count(c.begin(), c.end(), 'W'));

    // 赤白
    int cnt = 0, count_R = count(c.begin(), c.end(), 'R');
    REP(i, count_R){
        if(c[i] == 'W') ++cnt;
    }

    cout << min(ans, cnt) << endl;

    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, pre = "XXX";
	int ans = 0;

	cin >> S;

	rep(i, (int)S.length()) {
		ans++;
		if (S.substr(i, 1) != pre) {
			pre = S.substr(i, 1);
			if (i == (int)S.length() - 2 && S[i] == S[i + 1]) {
				pre = S.substr(i, 2);
				i++;
			}
		}
		else {
			pre = S.substr(i, 2);
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int W, H;
bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
int dx[2] = {1, 0};
int dy[2] = {0, 1};
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while ( cin >> W >> H, W || H ) {
		int N; cin >> N;
		ll dp[20][20] = {0}; dp[0][0] = 1;
		REP(i, N) {
			int x, y; cin >> x >> y; --x, --y;
			if ( inRange(x, y) ) {
				dp[y][x] = -1;
			}
		}
		REP(i, W+H) {
			REP(j, i+1) {
				int x = j, y = i-j;
				if ( !inRange(x, y) ) continue;
				if ( !dp[y][x] ) continue;
				if ( dp[y][x] < 0 ) continue;
				REP(d, 2) {
					int nx = x + dx[d], ny = y + dy[d];
					if ( !inRange(nx, ny) ) continue;
					if ( dp[ny][nx] < 0 ) continue;
					dp[ny][nx] += dp[y][x];
				}
			}
		}
/*
		REP(i, H) {
			REP(j, W) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
*/
		cout << dp[H-1][W-1] << endl;
	}
}

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

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

    string N;
    cin >> N;
    int first_digit = N[0] - 48;
    int second_digit = N[1] - 48;
    int third_digit = N[2] - 48;

    if (first_digit > second_digit || (first_digit == second_digit && second_digit >= third_digit)) {
        cout << first_digit * 111 << endl;
    } else if (first_digit < second_digit || (first_digit == second_digit && second_digit < third_digit)) {
        cout << (first_digit + 1) * 111 << endl;
    }

    return 0;
}


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

Measured memory_bytes: 256
using System;

namespace ABC071C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] bufs = Console.ReadLine().Split(' ');
            int[] A = new int[N];

            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(bufs[i]);
            }

            Array.Sort(A);

            int cnt = 0;
            int width = 0;
            int height = 0;
            int idx = N - 1;
            int seq = 0;
            int cur = 0;

            while (cnt < 2 && idx >= 0)
            {
                if (seq > 0 && A[idx] == A[cur])
                {
                    if (cnt == 0)
                    {
                        width = A[idx];
                    }
                    else if (cnt == 1)
                    {
                        height = A[idx];
                    }
                    seq = 0;
                    cnt++;
                }
                else
                {
                    seq = 1;
                    cur = idx;
                }

                idx--;
            }

            Console.WriteLine((long)width * height);
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  bool b=false;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if((i*j)==n) b=true;
    }
  }
  if(b) cout << "Yes" << endl;
  else cout <<"No" << endl;
}

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

const int INF = 2e9;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n,vector<int>(m+1));
    rep(i,n){
        rep(j,m+1){
            cin >> a[i][j];
        }
    }
    ll ans = INF;
    for(int i = 0; i < (1 << n);i++){
        vector<ll> s(m+1);
        rep(j,n){
            if(i>>j & 1){
                rep(k,m+1){
                    s[k] += a[j][k];
                }
            }
        }
        bool ok = true;
        for(int h = 1;h <= m;h++){
            if(s[h] < x)ok = false;
        }
        if(ok) ans = min(ans,s[0]);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main()
{
  long c[3],k,ans = 0,i;
  scanf("%ld %ld %ld %ld",&c[0], &c[1], &c[2], &k);
  for(i = 0 ; i < 3 ; i++)
  {
    int t = k - c[i];
    if(t<=0)
    {
      switch(i)
      {
        case 0 : ans += k;
          		break;
        case 2 : ans -= k;
          		break;
      }
      break;
    }
    else
    {
      switch(i)
      {
        case 0 : ans += c[i];
          		break;
        case 2 : ans -= c[i];
          	break;
      }
      k -= c[i];
    }
  }
  printf("%ld",ans);
  return 0;
  
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+10);
    int ma = 0,mi = 1000;
    for(int  i = 0; i < n; i++){
        cin >> a[i];
        ma = max(ma,a[i]);
        mi = min(mi,a[i]);
    }
    cout << ma-mi << endl;
}

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

string s;

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

int main() {
	while (cin >> s) {
		if (s == "#") break;
		
		string t;
		for (int i = s.length() - 1; i >= 0; i--) {
			if (s[i] == 'n' || s[i] == 'w') {
				t += s[i];
			}
		}
		
		int bo = (1 << 21);
		int si = 90 * bo;
		int sumSi = (t[0] == 'n') ? 0 : si;
		si /= 2;
		
		for (int i = 1; i < t.length(); i++) {
			if (t[i] == 'n') sumSi -= si;
			else sumSi += si;
			si /= 2;
		}
		
		int g = gcd(sumSi, bo);
		sumSi /= g;
		bo /= g;
		if (bo == 1) { cout << sumSi << endl; }
		else { cout << sumSi << "/" << bo << endl; }
	}
	return 0;
}

Measured memory_bytes: 3156
import sys
from itertools import accumulate
N, M, Q = map(int, sys.stdin.readline().split())
LR = [[0 for _ in range(N-i)] for i in range(N)]
for L, R in (map(int, sys.stdin.readline().split()) for _ in range(M)):
  LR[L-1][R-L] += 1
for i in range(N-2,-1,-1):
  acc = accumulate(LR[i])
  next(acc)
  for j in range(1, N-i):
    LR[i][j] = next(acc) + LR[i+1][j-1]
for p, q in (map(int, sys.stdin.readline().split()) for i in range(Q)):
  sys.stdout.write(str(LR[p-1][q-p])+"\n")


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

namespace Abc086A
{
    class Program
    {
        static void Main(string[] args) {
            var a_b = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
            Console.WriteLine(a_b[0] * a_b[1] % 2 == 0 ? "Even" : "Odd");
        }
    }
}


Measured memory_bytes: 11220
<?php
fscanf(STDIN,"%d %d",$n,$l);
for($i=0; $i<$n; $i++)
{
    $s[$i] = rtrim(fgets(STDIN));
}
sort($s);
 
$result = "";
for($i=0; $i<$n; $i++)
{
    $result .= $s[$i];
}
 
echo($result);

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n, m;
	cin >> n >> m;
	int sum = 0;
	int x;
	while(m--) {
		cin >> x;
		sum += x;
	}
	if(n - sum < 0) {
		cout << -1 << "\n";
	}
	else {
		cout << n - sum << "\n";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
N, Q = [int(_) for _ in input().split()]
STX = [[int(_) for _ in input().split()] for _ in range(N)]
D = [int(input()) for _ in range(Q)]
events = []
for stx in STX:
    s, t, x = stx
    events += [[s - x, 1, x], [t - x, 0, x]]
for i in range(Q):
    events += [[D[i], 2, i]]
events.sort()
block = set()
ans = [-1] * Q
m = float('inf')
for e in events:
    if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m
print(*ans, sep='\n')


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

long long n, p[200001], pmin[200001], ans = 0;

int main()
{
    cin >> n;
    for (int i = 0; i <= 200000; i++) pmin[i] = 200000;
    //for (int i = 1; i <= n; i++) cout << "i: " << pmin[i] << endl;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
        pmin[i] = min(pmin[i - 1], p[i]);
    }
    //for (int i = 1; i <= n; i++) cout << "i: " << pmin[i] << endl;
    for (int i = 1; i <= n; i++)
    {
        if (p[i] <= pmin[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6692
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
    int n[4];
    for (int i = 0; i < 4;i++){
        cin >> n[i];
    } 
    if(n[2]-n[0]==1){
        cout << 1;
    }else
        cout << 0;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
    int n; cin >> n;
    vector< vector<int> > g(n, vector<int>());
    for (int i = 0; i < n; i++)
    {
        int u, k; cin >> u >> k; u--;
        for (int j = 0; j < k; j++)
        {
            int v; cin >> v; v--;
            g[i].push_back(v);
        } 
    }
    vector<bool> seen(n, false);
    vector<int> d(n, -1); d[0] = 0;
    queue<int> q;
    q.push(0);
    int depth = 0;
    while (!q.empty())
    {
        depth++;
        queue<int> qt;
        while (!q.empty())
        {
            qt.push(q.front()); 
            q.pop();
        }
        while (!qt.empty())
        {
            int x = qt.front(); qt.pop();
            seen[x] = true;
            for (int i = 0; i < g[x].size(); i++)
            {
                if(d[g[x][i]] == -1) d[g[x][i]] = depth;
                if (seen[g[x][i]] == false) q.push(g[x][i]);
            }
        }
    }
    for (int i = 0; i < n; i++)
        cout << i + 1 << " " << d[i] << endl;
}


Measured memory_bytes: 3284
#include <iostream>

using namespace std ;

int main () {
  int a[3], b[3];
  int i;
  for(i=0;i<3;i++){
    cin >> a[i] >> b[i];
    a[i] -= 1;
    b[i] -= 1;
  }

  int endpoint[4];
  for(i=0;i<4;i++){
    endpoint[i]=0;
  }

  for(i=0;i<3;i++){
    endpoint[a[i]] += 1;
    endpoint[b[i]] += 1;
  }

  // for(i=0;i<4;i++){
  //   cout << endpoint[i] << "\n";
  // }

  for(i=0;i<4;i++){
    if(endpoint[i] > 2 || endpoint[i] == 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int main(){

  ll N=0;
  cin>>N;
  
  ll count=0;
  rep(i,N){

    int j=i+1;
    if(j%3!=0 && j%5!=0)count+=j;

  }
  
  cout<<count<<endl;
}



Measured memory_bytes: 3676
import math
n,k = map(int,input().split())
sum_prob = 0

for i in range(1, n+1):
    count = math.ceil(math.log2(k/i))
    if i <= k:
        sum_prob += (1/n) * (1/2)**count
    else:
        sum_prob += (1/n)
print(sum_prob)


Measured memory_bytes: 2940