akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-3;
const int INF=0x3f3f3f3f;
const int MOD=1e8+7;
const int N=1e4+5;
const ll maxn=1e6+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        ll ans=0;
        if(!k) ans-=n;
        rep(p,k+1,n+1)
        {
            ans=ans+(n/p)*(p-k);
            int t=n%p+1-k;
            if(t>0) ans+=t;///样例1
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
const long long mo =  998244353;
vector<int> v[maxi];
long long a[maxi];
string s;
int n;
long long cnt[maxi];
long long rez[maxi];
long long sum[maxi];
long long fi[maxi];
long long f[maxi];
vector<int> divisors[maxi];

long long step(long long x, long long y)
{
    if (!y) return 1;

    long long p = step(x,y/2);
    if (y&1) return p*p%mo*x%mo; else
        return p*p%mo;
}
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    for (int i=1;i<maxi;i++)
        for (int j=i;j<maxi;j+=i)
         divisors[j].pb(i);

    for (int i=1;i<=n;i++)
    {
        for (int j:divisors[a[i]]){
          cnt[j]+=a[i];
          if (cnt[j]>=mo) cnt[j]-=mo;
        }
    }

    long long ans =0 ;
    for (int i=maxi-1;i>0;i--)
    {
        sum[i] = cnt[i]*cnt[i]%mo;
        for (int j = 2*i;j<maxi;j+=i){
          sum[i]-=sum[j];
          if (sum[i]<0) sum[i]+=mo;
        }

        rez[i] = sum[i]*step(i,mo-2)%mo;
        ans+=rez[i];
        ans%=mo;
    }

   for (int i=1;i<=n;i++)
   {
       ans-=a[i];
       if (ans<0) ans+=mo;
   }

   ans = ans * step(2, mo-2);
   ans%=mo;
   cout<<ans<<endl;
    return 0;
}
//sanjao sam ruke njene
//da je sada pored mene


Measured memory_bytes: 166656
import java.lang.Math
import kotlin.comparisons.*

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

fun main(args: Array<String>)
{
    val (n, z, w) = read().split().toInt()
    val a = read().split().toInt()
    if (n >= 2) {
        val score1 = Math.abs(w - a[n-1])
        val score2 = Math.abs(a[n-2] - a[n-1])

        println(Math.max(score1, score2))
    } else {
        println(Math.abs(w - a[0]))
    }

}

fun read(): String = readLine()!!
fun CharSequence.split(): List<String> = this.split(" ")
fun Iterable<String>.toInt(): List<Int> = this.map{it.toInt()}


Measured memory_bytes: 38712
from collections import deque
K=int(input())
reached=[0 for i in range(K)]
reached[1]=1
dist=[0 for i in range(K)]
q=deque([])
q.append(1)
while(len(q)>0):
    r=q.popleft()
    v=(r+1)%K
    reached[r]=1
    if (reached[v]==0):
        q.append(v)
        dist[v]=dist[r]+1
    v=(r*10)%K
    if (reached[v]==0):
        q.appendleft(v)
        dist[v]=dist[r]
    if (reached[0]==1):
        break
print(dist[0]+1)


Measured memory_bytes: 48816
#include<bits/stdc++.h>
using namespace std;
int a,b,c,cnt1=0,cnt2=0;
char ch;
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>a>>ch>>b>>ch>>c){
		if(a==b)
			cnt2++;
		if(a*a+b*b==c*c)
			cnt1++;	
	}
	cout<<cnt1<<endl
		<<cnt2<<endl;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
ll a[N], mx=1e18;

ll solve(){
    rep(i,1,n) if(a[i]==0) return 0;
    ll sum=a[1];
    rep(i,2,n){
        if(mx/sum<a[i]) return -1;
        sum*=a[i];
    }
    return sum;
}

int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%lld",&a[i]);
    ll ans = solve();
    cout<<ans<<endl;
    return 0;
}
/*


*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 4488
import numba
import numpy as np
N = int(input())
P = np.array([int(c)-1 for c in input().split()])

#from random import shuffle
#N = 500
#P = list(range(N*N))
#shuffle(P)
#P = np.array(P)

@numba.njit("void(i8,i8[:])")
def proc(N, P):
    ans = 0
    Removed = np.zeros((500, 500), dtype=np.int8)
    Mat = np.zeros((500, 500), dtype=np.int16)
    Dy, Dx = [1,0,-1,0], [0,1,0,-1]

    for y in range(N):
        for x in range(N):
            Mat[y, x] = min(y, N-1-y, x, N-1-x)
    #print(Mat)
    for i in range(N*N):
        p = P[i]
        y, x = divmod(p, N)
        ans += Mat[y,x]
        Removed[y,x] = 1
        st = [(y, x)]
        while st:
            vy, vx = st.pop()
            vr = Removed[vy,vx]
            val = Mat[vy,vx]
            #for dy, dx in zip(Dy, Dx):
            for j in range(4):
                dy = Dy[j]
                dx = Dx[j]
                uy = vy + dy
                ux = vx + dx
                if not (0<=uy<N and 0<=ux<N):
                    continue
                ur = Removed[uy,ux]
                if vr:
                    if Mat[uy,ux] >= val+1:
                        Mat[uy,ux] = val
                        st.append((uy, ux))
                else:
                    if Mat[uy,ux] >= val+2:
                        Mat[uy,ux] = val+1
                        st.append((uy, ux))
    # for m in Mat:
    #     print(m)
    print(ans)
proc(N, P)



Measured memory_bytes: 122032
#include<bits/stdc++.h>
#define ll long long
#define testfor(T) ll T; cin>>T; while(T--)
using namespace std;
int main(){
	string s1,s2;
	cin>>s1;
	cin>>s2;
	int cnt=0;
	for(int i=0;i<s1.size();i++){
		if(s1[i]!=s2[i]){
			cnt++;
		}
	}
	cout<<cnt<<"\n";
}

Measured memory_bytes: 3904
import java.util.Scanner;

public class Main {
	

	public static boolean check(String k,int i,int j) {
		
		while(i<j) {
			if(k.charAt(i)!=k.charAt(j))
				return false;
			i++;
			j--;
			
		}
		return true;
	}
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String s1 = s.next();
		int n = s1.length();
		
		if(check(s1,0,n-1) && check(s1,0,(n-1)/2-1) && check(s1,(n+1)/2,n-1)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	ll n;
	cin >> n;

	cout << (n * (n - 1)) / 2 << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    ll ans = 1;
    map<int, int> mp;
    reps(i, 2, N + 1){
        int k = i;
        for(int j = 2; j * j <= k; ++j){
            while(k%j == 0){
                ++mp[j];
                k /= j;
            }
        }
        if(k != 1) ++mp[k];
    }
    for(auto a : mp) (ans *= a.se + 1)%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> II;

vector<LL> dist;
vector<vector<II>> edges;

void dfs(int n, LL d) {
	if (dist[n] < 0) {
		dist[n] = d;
		for (auto next : edges[n]) {
			dfs(next.first, d + next.second);
		}
	}
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, a, b, c, q, k, x, y;
		cin >> n;
		if (n <= 0) return 0;
		edges = vector<vector<II>>(n);
		for (int i = 0; i < n - 1; ++i) {
			cin >> a >> b >> c;
			--a, --b;
			edges[a].push_back({ b, c });
			edges[b].push_back({ a, c });
		}
		dist = vector<LL>(n, -1);
		cin >> q >> k;
		--k;
		dfs(k, 0);
		for (int i = 0; i < q; ++i) {
			cin >> x >> y;
			--x, --y;
			cout << (dist[x] + dist[y]) << endl;
		}
	}
	return 0;
}


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

using namespace std;

void trace(int* A, int n)
{
    cout << A[0];
    for(int i=1; i < n; i++)
    {
        cout << " " << A[i];
    }
    cout << endl;

    return;
}

void bubbleSort(int* A, int n)
{
    int flag = 1;
    int count = 0;

    while(flag)
    {
        flag = 0;
        for(int i = n-1; i > 0; i--)
        {
            if(A[i] < A[i-1])
            {
                int temp = A[i];
                A[i] = A[i-1];
                A[i-1] = temp;
                flag = 1;
                count++;
            }
        }
    }

    trace(A, n);
    cout << count << endl;

    return;
}

int main(void)
{
    int n;
    int A[100];

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

    bubbleSort(A, n);
    
    return 0;
}

Measured memory_bytes: 1160
from collections import deque

S = deque(input())
Q = int(input())
is_reversed = False
for _ in range(Q):
    q = input().split()
    if q[0] == "1":
        is_reversed = not is_reversed
    else:
        f = int(q[1]) - 1
        if is_reversed:
            f ^= 1
        c = q[2]
        if f:
            S.append(c)
        else:
            S.appendleft(c)
if is_reversed:
    S = reversed(S)
print(*S, sep="")


Measured memory_bytes: 12272
s = input()
n = len(s)
ans_list = [0] * n

cnt_odd = 0
cnt_even = 0

for i in range(n):
    if i == n-1:
        break
    if s[i] ==  'R' and s[i+1]=='R' and i%2==1:
        cnt_odd +=1
    elif s[i] ==  'R' and s[i+1]=='R' and i%2==0:
        cnt_even +=1
    elif s[i] =='R' and i%2==0:
        ans_list[i] += cnt_even +1
        ans_list[i+1] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[i] =='R' and i%2==1:
        ans_list[i] += cnt_odd +1
        ans_list[i+1] += cnt_even
        cnt_even = 0
        cnt_odd = 0

cnt_odd = 0
cnt_even = 0
for i in range(n):
    if i ==n-1:
        break
    if s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==1:
        cnt_odd +=1
    elif s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==0:
        cnt_even +=1
    elif s[-i-1] =='L' and i%2==0:
        ans_list[-i-1] += cnt_even +1
        ans_list[-i-2] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[-i-1] =='L' and i%2==1:
        ans_list[-i-1] += cnt_odd +1 
        ans_list[-i-2] += cnt_even
        cnt_even = 0
        cnt_odd = 0

print(' '.join(map(str,ans_list)))

Measured memory_bytes: 10612
import sys

def factorial(n, mod):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
        fact %= mod
    return fact

mod = 10 ** 9 + 7
N, M = map(int,input().split())
if abs(N - M) >= 2:
    print(0)
    sys.exit()
ans = factorial(N, mod) * factorial(M, mod)
if N == M:
    ans *= 2
print(ans % mod)

Measured memory_bytes: 3064
class Main{
    
    public static void main(String[] args){
        java.util.Scanner in = new java.util.Scanner(System.in);
        int t = in.nextInt();
        System.out.println(getFormattedTime(t));
    }
    
    public static String getFormattedTime(int sec){
        int h = sec / 3600;
        int rest_h = sec - h * 3600;
        int m = rest_h / 60;
        int s = rest_h - m * 60; 
        return String.format("%d:%d:%d", h, m, s);
    }
    
}

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

int check(string str) 
{ 

	int n = str.length(); 
	int digitSum = 0; 
	for (int i=0; i<n; i++) 
		digitSum += (str[i]-'0'); 

	return (digitSum % 9 == 0); 
} 

int main() 
{ 
	string str;
  	cin>>str;
	check(str)? cout << "Yes" : cout << "No "; 
	return 0; 
} 


Measured memory_bytes: 3908
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;

void main()
{
  int n = readln.chomp.to!int;
  long[] t = new long[](n);
  foreach (ref v; t) {
    v = readln.chomp.to!long;
  }
  long ite = 1;
  foreach (v; t) {
    ite = lcm(ite, v);
  }
  writeln = ite;
}

long lcm(long a, long b)
{
  return a / gcd(a, b) * b;
}

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


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

int main(){
	int n,i;
	cin >> n >> i;
	cout << n-i+1 << endl;

	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int	main(void)
{
  	char	s[101];
  	int		num;
  	int		i;
  	int		len;
  
  	num = scanf("%s", s);
  	if(num != 1)
      	return (0);
  
  	len = strlen(s);
  
  	for(i=0; i<len; i++)
    {
      	if(i % 2 == 0)
        {
          	if(s[i] == 'L')
            {
              	printf("No");
              	return (0);
            }
        }
      	else
        {
          	if(s[i] == 'R')
            {
              	printf("No");
              	return (0);
            }
        }
    }
  	printf("Yes");
  	return (0);
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  ll t[2];
  ll a[2];
  ll b[2];
  rep(i, 2) cin >> t[i];
  rep(i, 2) cin >> a[i];
  rep(i, 2) cin >> b[i];
  ll p, q;
  p = t[0] * (b[0] - a[0]);
  q = p + t[1] * (b[1] - a[1]);
  if (p > 0) {
    q = -q;
    p = -p;
  }
  if (q < 0) {
    cout << 0 << endl;
    return;
  }
  if (q == 0) {
    cout << "infinity" << endl;
    return;
  }
  ll ans = abs(p) / q * 2;
  if (abs(p) % q != 0) ans++;
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

namespace ConsoleApplication11 {
    class Program {
        const int digit = 4;

        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            int num_input = int.Parse(Console.ReadLine());
            int[] pack = new int[11];
            for (int i = 0; i < num_input; i++) {
                pack[0] = int.Parse(Console.ReadLine());
                for (int c = 1; c < pack.Length; c++) {
                    int pow = pack[c - 1] * pack[c - 1];
                    string a = pow.ToString();
                    for (int j = 0; j < digit * 2 - pow.ToString().Length; j++) {
                        a = "0" + a;
                    }
                    string rand = "";
                    for (int j = digit - 2; j < digit + 2 ; j++) {
                        rand += a.Substring(j, 1);
                    }
                    pack[c] = int.Parse(rand);
                }
                Console.WriteLine("Case "+ (i+1)+":");
                for (int c = 1; c < pack.Length; c++) {
                    Console.WriteLine(pack[c]);
                }
            }
        }
    }
}

Measured memory_bytes: 9220
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		long water_sum = 0L;
		long odd_sum = 0L;
		long ans[] = new long[N];
		for (int i=0;i<N;i++) {
			A[i] = Integer.parseInt(sc.next());
			water_sum += A[i];
			if (i%2==0 && i!=N-1) {
				odd_sum += A[i];
			}
		}
		ans[N-1] = (water_sum-odd_sum*2);
		for (int i=N-2;i>=0;i--) {
			ans[i] = (A[i]-ans[i+1]/2)*2;
		}
		for (int i=0;i<N;i++) {
			System.out.print(ans[i] + " ");
		}
	}
}

Measured memory_bytes: 52144
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int W,H,N;
    cin >> W >> H >> N;
    vector<vector<int>> m(W, vector<int>(H, 0));
    REP(i, N){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            Rep(xi, 0, x) REP(yi, H) {
                m[xi][yi] = 1;
            } 
        }else if(a==2){
            Rep(xi, x, W) REP(yi, H) {
                m[xi][yi] = 1;
            } 
        }else if(a==3){
            REP(xi, W) Rep(yi, 0, y) {
                m[xi][yi] = 1;
            } 
        }else if(a==4){
            REP(xi, W) Rep(yi, y, H) {
                m[xi][yi] = 1;
            } 
        }
    }

    int ans = 0;
    REP(i, W) REP(j, H){
        if(m[i][j]==0) ans++;
    }

    pr(ans);
}

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

using namespace std;

int main()
{
    string S, T;
    cin>>S>>T;
    int ans = 1001;
    int l1 = S.length(), l2 = T.length();
    for (int i=0; i<=(l1-l2); i++) {
        int c = 0;
        for (int j=0; j<l2; j++) {
            if (S[i+j] != T[j]) c++;
        }
        ans = min(ans, c);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
city = []
for i in range(N):
  x,y,p = map(int,input().split())
  city.append((x,y,p))

xx = [ [ abs(city[j][0]) for j in range(N) ] for i in range(2**N) ]
yy = [ [ abs(city[j][1]) for j in range(N) ] for i in range(2**N) ]

for i in range(2**N):
  X = [0]
  rest = []
  for j in range(N):
    if (i>>j)&1:
      X.append(city[j][0])
      xx[i][j] = 0
    else:
      rest.append(j)

  for j in rest:
    res = 10**15
    for k in X:
      res = min(res, abs(city[j][0]-k))
    xx[i][j] = res

for i in range(2**N):
  Y = [0]
  rest = []
  for j in range(N):
    if (i>>j)&1:
      Y.append(city[j][1])
      yy[i][j] = 0
    else:
      rest.append(j)

  for j in rest:
    res = 10**15
    for k in Y:
      res = min(res, abs(city[j][1]-k))
    yy[i][j] = res


ans = [10**15 for _ in range(N+1)]
for i in range(2**N):
  cond = i
  rest = [j for j in range(N) if (i>>j)&1==0]
  count = N-len(rest)

  while True:
    X = cond
    Y = i-cond
    temp = 0
    for j in rest:
      temp += min(xx[X][j], yy[Y][j])*city[j][2]
    ans[count] = min(ans[count], temp)
    if cond == 0:
      break
    else:
      cond = (cond-1)&i

for i in range(N+1):
  print(ans[i])


Measured memory_bytes: 83112
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int n,i,lr[2],flag=0,count;
  string data;
  lr[0]=1;
  lr[1]=1;
  while(1){
    count=0;
    flag=0;
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> data;
      if(data=="lu") lr[0]=2;
      if(data=="ld") lr[0]=1;
      if(data=="ru") lr[1]=2;
      if(data=="rd") lr[1]=1;
      if(flag==0&&lr[0]==2&&lr[1]==2){
    flag=1;
    count++;
      }
      if(flag==1&&lr[0]==1&&lr[1]==1){
        flag=0;
    count++;
      }
    }
    lr[0]=1;
    lr[1]=1;
    cout << count << endl;
  }
  return 0;
}

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

int main()
{
    long int X, K, D;
    cin >> X >> K >> D;

    long int ans = 0;
    long int k = abs(X) / abs(D);

    if (k >= K)
        ans = abs(X) - abs(D * K);
    else
    {
        if ((K - k) % 2 == 0)
            ans = abs(X) - abs(D * k);
        else
            ans = - (abs(X) - abs(D * (k + 1)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
from collections import deque

N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    E[u-1].append((v-1, w))
    E[v-1].append((u-1, w))
ans = [-1]*N
ans[0] = 0

q = deque([0])
while q:
    next = q.popleft()
    for (u, w) in E[next]:
        if ans[u] < 0:
            q.append(u)
            ans[u] = int(ans[next]) if w % 2 == 0 else int(not ans[next])
print(*ans)

Measured memory_bytes: 40724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string a, b, c;
    int n;
    cin >> n >> a >> b >> c;
    int result = 0;
    REP(i,n){
        if(a[i]==b[i]&&b[i]==c[i]){
            continue;
        }else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]){
            result++;
        }else{
            result += 2;
        }
    }
    cout << result << endl;
    return 0;
}


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

typedef long long int LLI;

int N;
int M;
int col[114514];
LLI cnt[2];
vector<int> es[114514];
typedef pair<int, int> Pair;
queue<Pair> q;

int main() {
  scanf("%d%d", &N, &M);
  for (int i=0; i<M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }

  fill(col, col+N, -1);
  col[0] = 0;
  cnt[col[0]]++;
  q.push(Pair(0, 0));
  bool biparate = true;
  while (!q.empty()) {
    Pair p = q.front(); q.pop();
    int v = p.first;
    int c = p.second;
    for (int u : es[v]) {
      if (col[u] == -1) {
        col[u] = col[v]^1;
        cnt[col[u]]++;
        q.push(Pair(u, col[u]));
      } else {
        if (col[u] != col[v]^1) {
          biparate = false;
          break;
        }
      }
    }

    if (!biparate) break;
  }

  if (!biparate) {
    printf("%lld\n", LLI(N)*LLI(N-1)/2-M);
  } else {
    printf("%lld\n", cnt[0]*cnt[1]-M);
  }
}


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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if ((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

int dp[3005][6005];

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> A(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        A[i] = P(a, b);
    }
    sort(A.begin(), A.end());
    rep(i, n) rep(j, t) {
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        dp[i+1][j+A[i].first] = max(dp[i][j+A[i].first], dp[i][j]+A[i].second); 
    }
    int ans = 0;
    rep(i, n+1) rep(j, 6005){
        ans = max(ans, dp[i][j]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
n, m = map(int, input().split())
h = list(map(int, input().split()))
bridge = []

isgood = [1 for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] < h[b]:
        isgood[a] = 0

    elif h[b] < h[a]:
        isgood[b] = 0

    else:
        isgood[a] = 0
        isgood[b] = 0

print(sum(isgood))



Measured memory_bytes: 84924
N = int(input())
H = list(map(int,input().split()))

tmp = -1
flag = True
for i in range(N-1,0,-1):
    if H[i] - H[i-1] < -1:
        flag = False
        break
    elif H[i] - H[i-1] == -1:
        H[i-1] -= 1
if flag: print('Yes')
else: print('No')

Measured memory_bytes: 15020
a = int(input())
count = 0
input_list = []
patterns = ['S', 'H', 'C', 'D']
total_list = []

for i in patterns:
    for n in range(1,14):
        total_list.append('{} {}'.format(i, n))

while count < a:
    b = input()
    count += 1
    input_list.append(b)

remain_list = []

for b in input_list:
    if b in total_list:
        total_list.remove(b)

for a in total_list:
    print(a)


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

#define MOD 1000000007
typedef unsigned long long ull;


int main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy";
    } else if (s == "Cloudy") {
        cout << "Rainy";
    } else {
        cout << "Sunny";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, K; 
double X[64], Y[64], C[64]; 
vector<pair<double, double>> P;
double eps = 1e-10; 
void add1(double x1, double x2, double y1, double y2, double r1, double r2){
	double a = x2-x1; double b = y2-y1; 
	double k = (r1*r1-r2*r2+a*a+b*b)*0.5; 
	double dis = (a*a+b*b)*r1*r1-k*k; 
	if(dis < -eps) return; 
	else if(abs(dis) <= eps){
		double x = k*a / (a*a + b*b); double y = k*b / (a*a + b*b); 
		P.push_back(make_pair(x+x1, y+y1)); 
	}
	else{
		double xp = (k*a + b * pow(dis, 0.5)) / (a*a + b*b); 
		double yp = (k*b - a * pow(dis, 0.5)) / (a*a + b*b); 
		double xm = (k*a - b * pow(dis, 0.5)) / (a*a + b*b); 
		double ym = (k*b + a * pow(dis, 0.5)) / (a*a + b*b); 
		P.push_back(make_pair(xp+x1, yp+y1)); P.push_back(make_pair(xm+x1, ym+y1)); 
	}
}
void add2(double a, double b){
	P.push_back(make_pair(a, b)); 
}
bool check(double t, vector<pair<double, double>> &P){
	int mx = 0; 
	for(auto p : P){
		int cnt = 0; 
		for(int i = 0; i < N; i++){
			double dx = p.first - X[i]; 
			double dy = p.second - Y[i]; 
			if(pow(dx*dx + dy*dy, 0.5) <= t/C[i] + eps) cnt ++; 
		}
		mx = max(mx, cnt); 
	}
	return mx >= K; 
}
int main(){
	cin >> N >> K; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i] >> C[i]; 
	}
	if(K == 1){
		cout << 0 << endl; return 0; 
	}
	double ok = 314514.1919; double ng = 0; 
	for(int t = 0; t < 100; t++){
		double mid = (ok + ng) * 0.5; 
		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				add1(X[i], X[j], Y[i], Y[j], mid/C[i], mid/C[j]); 
			}
		}
		for(int i = 0; i < N; i++) add2(X[i], Y[i]); 
		if(check(mid, P)) ok = mid; 
		else ng = mid; 
		P.clear(); 
	}
	cout.precision(15);
	cout << ok << endl;  
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        if (b - a == c - b) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int x,y;
	cin>>x>>y;
	int ans = 0;
	if(x == 1)
		ans+=300000;
	if(y == 1)
		ans+=300000;
	if(x == 2)
		ans+=200000;
	if(y==2)
		ans+=200000;
	if(x == 3)
		ans+=100000;
	if(y == 3)
		ans+=100000;
	if(x == 1 && y==1)
		ans+=400000;
	cout<<ans;
    return 0;
}
//.........

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int dp[1 << 17];
signed main(void) {
  while (true) {
    int n, t[20][20];
    cin >> n;
    if(!n) break;
    REP(i, n) REP(j, n + 1) cin >> t[i][j];

    FOR(i, 1, 1 << n) {
      int tmptime = INF;
      //??????i???????´?j??????????????????????????????
      REP(j, n) {
        //??????i???????´?j????????¨??????????????°
        if (!(i >> j & 1))
          continue;
        int tmps = i & ~(1 << j), mint = t[j][0];
        // cout << i << " " << j << " " << tmps << endl;
        //????¨??????????????????????????´????k t[k][j]???min
        REP(k, n) {
          if (tmps >> k & 1) {
            mint = min(mint, t[j][k + 1]);
          }
        }
        tmptime = min(tmptime, dp[tmps] + mint);
      }
      dp[i] = tmptime;
    }

    /*REP(i, 1<<n) {
      cout << i << " " << dp[i] << endl;
    }*/

    cout << dp[(1 << n) - 1] << endl;
  }
  return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;

int N;
int A[22][22];
ll dp[1 << 21];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cin >> A[i][j];
    for(int mask = (1 << N) - 1; mask >= 0; mask--){
        ll res = 0;
        int num = __builtin_popcount(mask);
        if(num == N) res = 1;
        else{
            for(int i = 0; i < N; i++){
                if((mask >> i)&1) continue;
                if(!A[num][i]) continue;
                int nmask = mask | (1 << i);
                (res += dp[nmask]) %= mod;
            }
        }
        dp[mask] = res;
    }

    cout << dp[0] << endl;

    return 0;
}


Measured memory_bytes: 16640
import java.util.ArrayList;
import java.util.List;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	static final int MAX = 10000;

	public static void main(String[] args) {

		int primecount = 0;
		Input stdIn = new Input();

		int n = stdIn.getValue();

		List<Integer> values = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			values.add(stdIn.getValue());
		}

//		List<Integer> primeList = createPrimeList(MAX);
//		System.out.println(primeList);
//		System.out.println(primeList.size());

		for(int i = 0; i < n; i++) {
//			System.out.println("values[i] :" + values.get(i));
			if(checkPrime(values.get(i))) {
				primecount++;
			}
		}

		System.out.println(primecount);

		stdIn.close();
	}

	public static boolean checkPrime(int n) {
		boolean b = true;
		if(n == 1) {
			return b;
		} else if(n == 2) {
			return b;
		} else if(n % 2 ==0) {
			return false;
		}

		for(int i = 3; i <= Math.sqrt(n); i += 2) {
			if(n % i == 0) {
				b = false;
			}
		}
		return b;
	}

	public static List<Integer> createPrimeList(int max) {

		List<Integer> primeList = new ArrayList<>();
		primeList.add(2);

		for(int i = 3; i < max; i += 2) {
			boolean b = true;
			for(int j = 3; j <= Math.sqrt(i); j += 2) {
				if(i % j == 0) {
					b = false;
				}
			}
			if(b) {
				primeList.add(i);
			}
		}
		return primeList;
	}
}
class Input{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;                          

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') {
    cout << b << endl;
  } else {
    if (b == 'H') {
      cout << 'D' << '\n';
    } else {
      cout << 'H' << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

const ll MXV=2e5;
vl G[MXV];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll ans=0;
    vl d(n);
    rep(i,n-1){
        ll u,v;
        cin >> u >> v;
        if(u>v){
            swap(v,u);
        }
        ans-=(u)*(n-v+1);
    }
    rep(i,n){
        ans+=(i+1)*(n-i);
    }
    cout << ans << '\n';
}

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

int totalcost(int n, vector<int> &a){
  int min = 0;
  int cost;
  
  for (int rewrite = -100; rewrite <= 100; rewrite++){
    for (int i = 1; i <= n; i++) cost += (a[i-1] - rewrite)*(a[i-1] - rewrite);  
    if (rewrite == -100 || cost < min) min = cost;
    cost = 0;
  }
  
  return min;
}

int main(){
  int N; 
  int same = 1;
  vector<int> a(100);
  
  cin >> N;
  
  for (int i = 0; i < N; i++) cin >> a[i];
  
  for (int i = 1; i < N; i++) if (a[0] != a[i]) same = 0;
  if (same) cout << 0;
  else cout << totalcost(N, a);
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <climits>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
const int INF = 987654321;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int num[100001];

int main(){
    int n,q;
    scanf("%d",&n);
    ll ans = 0;
    int a,b;
    for(int i = 0;i<n;i++){
        scanf("%d",&a);
        num[a]++;
        ans += a;
    }
    scanf("%d",&q);
    for(int i = 0;i<q;i++){
        scanf("%d %d",&a,&b);
        ans -= (ll)num[a]*a;
        ans += (ll)num[a]*b;
        num[b] += num[a];
        num[a] = 0;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[100],i,j,x,y=0,n,m=1,ch=0,d;
	scanf("%d",&n);
	scanf("%d %d",&d,&x);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		m=1; 
		for(j=1;j<=d;j++)
		{
			y=j*a[i]+1;
			if(y<=d)
			{
				ch++;
			}
			else
			{
				break;
			}
		}
	}
	ch+=n+x;
	printf("%d",ch);

}

Measured memory_bytes: 256
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        int sum = 0;
        int a[n];
        loop(0, n) {
            cin >> a[i];
            sum += a[i];
        }
        int x = ceil(sum / (4.0 * k));
        int c = 0;
        loop(0, n) {
            if (a[i] >= x)
                c++;
        }
        if (c >= k)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3664
N = int(input())
a = list(map(int, input().split()))

a = [0] + a
b = [0 for i in range(N+1)]
i = N
while i > 0:
    s = sum(b[i::i])
    if a[i] != s % 2:
        b[i] = 1
    i -= 1

print(sum(b))
for i, j in enumerate(b):
    if j == 1:
        print(i, end=' ')

Measured memory_bytes: 8352
a, b = input().split()

mine = [list(input()) for i in range(int(a))]

for i in range(int(a)):
    for j in range(int(b)):
        if mine[i][j] != '#':
            count = 0
            for k in range(-1, 2):
                for l in range(-1, 2):
                    if -1 < i + k and i + k < int(a) and -1  < j + l and j + l < int(b) :
                        if mine[i+k][j+l] == '#':
                            count += 1
            mine[i][j] = count

for i in range(int(a)):
    for j in range(int(b)):
        print(mine[i][j], end='')
    print()

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

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

  return 0;
}


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

int main()
{
  int n, a, min, max;
  long long int sum = 0;
  bool first = true;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &a);
    sum = sum + a;
    if (first)
    {
      min = a;
      max = a;
      first = false;
    }
    if (a < min)
    {
      min = a;
    }
    if (a > max)
    {
      max = a;
    }
  }
  cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3236
#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;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int H, W;
char A[1010][1010];
int d[1010][1010];
int main() {
	cin >> H >> W;
	queue<P> Q;
	rep(i,H)rep(j,W){
		cin >> A[i][j];
		if (A[i][j] == '#') {
			Q.push({ i,j });
			d[i][j] = 0;
		}
		else d[i][j] = INF;
	}
	
	while (!Q.empty()) {
		int y = Q.front().first;
		int x = Q.front().second;
		Q.pop();
		for (int k=0; k<4; k++){
			int ny = y + dy[k];
			int nx = x + dx[k];
			if (0 <= ny && ny < H && 0 <= nx && nx < W&&A[ny][nx] == '.'&&d[ny][nx]==INF) {
				Q.push({ ny,nx });
				d[ny][nx] = d[y][x] + 1;
			}
		}
	}
	int ans = 0;
	rep(i,H)rep(j,W){
		if (d[i][j] == 0)continue;
		ans = max(ans, d[i][j]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MAT(h): return [list(map(int, input().split())) for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    N, M = MAP()
    S = LIST()
    T = LIST()
    dp = [[0 for i in range(N + 1)] for j in range(M + 1)]
    for j in range(M):
        for i in range(N):
            if S[i] == T[j]:
                dp[j+1][i+1] = (dp[j][i+1] + dp[j+1][i] + 1) % mod
            else:
                dp[j+1][i+1] = (dp[j][i+1] + dp[j+1][i] - dp[j][i]) % mod
    print((dp[M][N] + 1) % mod)

if __name__ == '__main__':
    main()


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

int main() {
    int N,M;
    cin >> N >> M;
    int a[M], b[M];
    int num[N] ={};
    for(int i = 0; i < M; ++i) cin >> a[i] >> b[i];

    for(int i = 0; i < M; ++i){
        num[a[i]-1]++;
        num[b[i]-1]++;
    }
    for(int i = 0; i < N; ++i) cout << num[i] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,n;
    scanf("%d %d",&n,&a);

    while(n-500>=0){
        n=n-500;
    }
    
    if(a>=n){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> b(n+1),c(n+1);
	rep(i,n) b.at(i+1)=b.at(i)+a.at(i);
	rep(i,n) c.at(i+1)=c.at(i)+max(a.at(i),0);
	ll ans=-1000000000000000000;
	rep(i,n-k+1){
		ans=max(ans,max(b.at(i+k)-b.at(i)+c.at(n)-c.at(i+k)+c.at(i),c.at(n)-c.at(i+k)+c.at(i)));
	}
	cout << ans << endl;
}


Measured memory_bytes: 2176
///BISMILLAH'IR  RO'HMANIR  ROH'IM
///RIFAT SHARIAR SAKIL
///SOFTWARE ENGINEERING(SUST)

#include<stdio.h>
#include<string.h>
int main()
{
  char S[100];
  gets(S);
  if(strcmp(S,"Sunny")==0) {printf("Cloudy");}
   if(strcmp(S,"Cloudy")==0) {printf("Rainy");}
    if(strcmp(S,"Rainy")==0) {printf("Sunny");}
  return 0;
}

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


Measured memory_bytes: 1024
a,b,c,d = map(int, raw_input().split())

x = abs(c-a)
y = abs(d-b)

if x == 0 or y == 0:
	print 0
	import sys
	sys.exit(0)

def gcd(a,b):
	return a if b == 0 else gcd(b, a % b)

e = gcd(x,y)
x /= e
y /= e

print (x+y-1) * e

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

int main(){
  int n,sum,i,k;
  cin >> n;
  sum=0;

  vector<int> d;

  for(i=0;i<n;i++){
    int a;
    cin >> a;
    d.push_back(a);
  }

  for(i=0;i<n-1;i++){
    for(k=i+1;k<n;k++){
      sum=sum+d[i]*d[k];
    }
  }

  cout << sum << endl;


  return 0;

}


Measured memory_bytes: 256