akhauriyash/Code-Regression huggingface dataset:
#nowarn "25"

open System
open System.Collections.Generic

let MOD = 1000000007L

let rec gcd (x : int64) (y : int64) =
    if y = 0L then
        x
    else
        gcd y (x % y)

let pow b k =
    let mutable r = 1L
    for i in 1L .. k do
        r <- r * b % MOD
    r

let inc0 (dict : IDictionary<'a, int64 * int64>) k =
    let mutable v = ref (0L, 0L)
    if dict.TryGetValue(k, v) then
        dict.[k] <- (fst !v + 1L, snd !v)
    else
        dict.[k] <- (1L, 0L)

let inc1 (dict : IDictionary<'a, int64 * int64>) k =
    let mutable v = ref (0L, 0L)
    if dict.TryGetValue(k, v) then
        dict.[k] <- (fst !v, snd !v + 1L)
    else
        dict.[k] <- (0L, 1L)
 
let n = stdin.ReadLine() |> int
let d = new Dictionary<int64 * int64, int64 * int64>()
let mutable zeros = 0L

for i in 1 .. n do 
    let [| a; b |] = stdin.ReadLine().Split() |> Array.map int64
    
    if a = 0L && b = 0L then
        zeros <- zeros + 1L
    else if b = 0L then
        inc0 d (1L, 0L)
    else if a = 0L then
        inc1 d (1L, 0L)
    else 
        let g = gcd (Math.Abs a) (Math.Abs b)
        let mutable x = a / g
        let mutable y = b / g

        if x < 0L then
            x <- -x
            y <- -y
        
        if y > 0L then
            inc0 d (x, y)
        else
            inc1 d (-y, x)


let mutable comb = 1L
for kv in d do
    let (pos, neg) = kv.Value
    let c = (pow 2L pos + pow 2L neg - 1L + MOD) % MOD
//    printfn "%A %d" kv c
    comb <- comb * c % MOD

printfn "%d" ((zeros + comb - 1L + MOD) % MOD)
    

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(w, h);
    int2(x, y);
    cout << Decimal << (w * h) / 2.0 << " ";

    //if (x == 0 || y == 0 || x == w || y == h) {
    if (x * 2 == w && y * 2 == h) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
 
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
 
		if (n >= 10) {
			int ans = r;
			System.out.println(ans);
		} else {
			int ans = r + (100 * (10 - n));
			System.out.println(ans);
		}
 
		sc.close();
	}
 
}

Measured memory_bytes: 21844
N,K = map(int, input().split())

LR = list(tuple(map(int, input().split())) for _ in range(K))

S = [0]*(N+1)
S[1] = 1

for k in range(2, N+1):
    s = 0
    for l,r in LR:
        p0,p1 = max(k-r-1, 0), max(k-l, 0)
        s += S[p1] - S[p0]

    S[k] = (S[k-1] + s)%998244353

print((S[-1] - S[-2])%998244353)


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    string S;
    int K;
    cin >> S >> K;
    string ans = S;

    for (int i=0; i<S.size(); i++) {
        if (S[i] == 'a') continue;
        int cnt = 26 - (S[i] - 'a');
        if (cnt > K) continue;

        ans[i] = 'a';
        K -= cnt;
    }

    if (K > 0) {
        int last = ans.size() - 1;
        ans[last] = (((ans[last] - 'a') + K) % 26) + 'a';
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for j in range(h):
        for i in range(w):
            if i == 0 or j == 0 or i == w-1 or j == h-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

vector<vector<ll>> f(110000);
vector<ll> subsushi;
ll ksushi[110000];
main(){
  ll n,k,t,d,ks=0,kkind=0;
  cin>>n>>k;
  rep(i,0,n){cin>>t>>d;f[t-1].pb(d);}
  for(auto &i:f){
    sort(i.rbegin(),i.rend());
    if(i.empty())i.pb(0);
    else kkind++;
  }
  sort(f.begin(),f.end(),[&](vector<ll> a, vector<ll> b) {return a[0] > b[0];});
  kkind=min(kkind,k);
  rep(i,0,kkind){ks+=f[i][0];ksushi[i+1]=ks;}
  rep(i,kkind,f.size())subsushi.pb(f[i][0]);
  ks+=kkind*kkind;
  rep(i,0,f.size()){
    rep(j,1,f[i].size()){
      subsushi.pb(f[i][j]);
    }
  }
 
  sort(subsushi.rbegin(),subsushi.rend());
  irep(i,kkind,1){
    ll tmp=ksushi[i];
    rep(j,0,min(k-i,n-kkind))tmp+=subsushi[j];
    tmp+=i*i;
    if(ks<tmp)ks=tmp;
  }
  cout<<ks;
}


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

using namespace std;

int dp[100005], h[100005];

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &h[i]);

    dp[0] = 0;

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

    printf("%d\n", dp[n - 1]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<long long int, int> mp;
    for(int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        
        mp[a]++;
    }
    
    int ans=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        if(itr->first!=itr->second) {
            int dif=itr->second-itr->first;
            if(dif<0) {
                ans += itr->second;
            } else {
                ans += min(itr->second, dif);
            }
        }
    }
    cout << ans << endl;
    

    return 0;
    
}

Measured memory_bytes: 6272
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

string ans;
void out(int num){
    if(!num){
        // putchar('0');
        ans += '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        ans += buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) >> 1]);
    }
    // printd(accs[lim]);
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    ans.reserve(4 * q);
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        ans += '\n';
    }
    // cout << ss.str();
    cout << ans;
    // write(1, ans.data(), ans.size());
}


Measured memory_bytes: 1536
using System;
using System.Linq;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var items = Console.ReadLine().Split();
                
                var H = int.Parse(items[0]);
                var W = int.Parse(items[1]);

                if (H == 0 && W == 0)
                {
                    break;
                }

                var line = new string('#', W);
                line += "\n";

                var rect = string.Concat(Enumerable.Repeat(line, H));

                Console.WriteLine(rect);
            }
        }
    }
}



Measured memory_bytes: 16300
#include<iostream>
using namespace std;
int main(){
	int H,W,K,min,max;
	bool ex[302][302];
	bool row[302];
	int value[302][302]={0},v=1;
	char s;
	cin>>H>>W>>K;
	for(int i=0;i<=H+1;i++){
		row[i]=false;
		for(int j=0;j<W+1;j++){
			if(i==0||i==H+1||j==0||j==W+1)ex[i][j]=true;
			else{
				cin>>s;
				if(s=='#'){
					ex[i][j]=true;
					row[i]=true;
				}else ex[i][j]=false;
			}
		}
	}
	row[0]=true;
	row[H+1]=true;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(ex[i][j]){
				value[i][j]=v;
				min = 1;
				max = W;
				for(int k=j;k>=1;k--){
					if(ex[i][k-1]||value[i][k-1]!=0){
						min=k;
						break;
					}else{
						value[i][k-1]=v;
					}
				}
				for(int k=j;k<=W;k++){
					if(ex[i][k+1]||value[i][k+1]!=0){
						max=k;
						break;
					}else{
						value[i][k+1]=v;
					}
				}
				for(int k=i-1;k>=1;k--){
					if((!row[k])&&value[k][min]==0&&value[k][max]==0){
						for(int l=min;l<=max;l++)value[k][l]=v;
					}else break;
				}
				for(int k=i+1;k<=H;k++){
					if((!row[k])&&value[k][min]==0&&value[k][max]==0){
						for(int l=min;l<=max;l++)value[k][l]=v;
					}else break;
				}
				v++;
			}
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<value[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		if(n % 2 == 0) {
			double p =(double) 1/2;
			System.out.println(p);
		}
		else {
			double q = (double)(n + 1)/(n * 2);
			System.out.println(q);
		}

	}

}


Measured memory_bytes: 24276
def insertionSort(a,n,g)
  g.upto(n-1){|i|
    v=a[i]
    j=i-g
    cnt=0
    while j>=0 && a[j]>v do
      a[j+g]=a[j]
      j = j-g
      @cnt+=1
    end
    a[j+g]=v
  }
end

def shellsort(a,n)
  @cnt=0
  g=[]
  val=1
  flag=false
  while val<n do
    g<<val
    val=g.last*3+1
    flag=true
  end
  g<<1 if !flag
  g.reverse!
  m=g.length
  0.upto(m-1){|i|
    insertionSort(a,n,g[i])
  }
  puts m
  puts g.join(" ")
  puts @cnt
end
n=gets.to_i;
a=[]
n.times{
  a<<gets.to_i
}
shellsort(a,n)
puts a


Measured memory_bytes: 14816
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int x = n * 800;
        int y = (n/15) * 200;
        
        System.out.println(x - y);
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool ok[100];

int main()
{
	int n;cin >> n;
	ll now = 0;
	REP(i,n)
	{
		ll tmp;cin >> tmp;
		now ^= tmp;
		REP(j,60)
		{
			if(tmp & (1LL<<j))
			{
				ok[j] = true;
				break;
			}
		}
	}
	
	//SHOW1d(ok,10);
	
	int ans = 0;
	for(int i = 60; i >= 0;i--)
	{
		if(now & (1LL<<i))
		{
			if(!ok[i])
			{
				cout << -1 << endl;
				return 0;
			}
			else
			{
				ans++;
				now ^= ((1LL<<i)-1);
			}
			
		}
	//	cout << now << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a | b | c) {
		int d[101]{};
		for (int e = 1; e < a+1; e++)d[e] = e;
		multimap<int, vector<int>>f;
		for (int g = 0; g < b; g++) {
			int h; vector<int>i(2);
			cin >> h >> i[0] >> i[1];
			f.insert(pair<int, vector<int>>(h, i));
		}
		for (auto k = f.begin(); k != f.end(); k++) {
			int l = d[(*k).second[0]];
			d[(*k).second[0]] = d[(*k).second[1]];
			d[(*k).second[1]] = l;
		}
		cout << d[c] << endl;
	}
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string s; int w; cin >> s >> w;
    string ans;
    for(int i=0;i<s.size();i+=w) {
        ans += s[i];
    }
    cout << ans;
}


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

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
   
int N=Integer.parseInt(nyuA);

String[] data=nyuA.split("");

int count=0;
for(String temp:data)count+=Integer.parseInt(temp);

if(N%count==0)System.out.println("Yes");
else System.out.println("No");

}

}



Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int now = 0;
	for (;;) {
		if (s[now].empty()) {
			char ans = now + 'A';
			cout << ans << endl;
			return 0;
		}
		char c = s[now][0];
		s[now].erase(0, 1);
		now = int(c - 'a');
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}
const int M=1e3;
const int N=14;
int n,m;
int a[M];
vi c[M];
vi abiertax[N];
int sol[(1<<15)];

void solve(int mask){
    if (sol[mask]==-1){
        sol[mask]=INF;
        for(int i=0;i<n;++i){
            if ((mask &(1<<i) )==0){
                for(int j:abiertax[i]){
                    int mask2= mask;
                    for(int k:c[j]){
                        mask2 |= (1<<k);
                    }
                    solve(mask2);
                    sol[mask] = min(sol[mask],sol[mask2]+a[j]);
                }
                break;
            }
        }
    }
}

int main() {
    READ(0);
    cin>>n>>m;
    FOR(i,m){
        cin>>a[i];
        int b;cin>>b;
        c[i].resize(b);
        FOR(j,b) {
            cin>>c[i][j];
            abiertax[--c[i][j]].push_back(i);
        }
    }
    fill(sol,sol+(1<<n),-1);
    sol[(1<<n)-1]=0;
    solve(0);
    if (sol[0]==INF) cout << -1;
    else cout << sol[0];
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include<iostream>
#include<queue>
using namespace std;

char s[13][1];
int D[106][106];
int A[106],f[106],w,h,n,sx,sy,gx,gy,e,g[106];
int   kensa(int ,int);
int main(){
	queue<int> P;
	int i,j,a,b,c,d;
	for(i=1;i<=100;i++){
		for(j=1;j<=100;j++){
			D[i][j]=-1;		
		}					
	}						
	for(i=1;i<=100;i++){		
		A[i]=0;				
		f[i]=-1;
		g[i]=0;
	}							
	scanf("%d" ,&a);//     a=4
	for(i=1;i<=a;i++){
        scanf("%d",&b);		//
		scanf("%d",&b);			//b=2					//
		for(j=1;j<=b;j++){		//
		scanf("%d",&c);			//					//
		D[i][c]=1;
//
		}						//D[???][???]
	}				
	for(i=1;i<=a;i++){
		for(j=1;j<=a;j++){
	//		printf("%d %d %d\n",i,j,D[i][j]);
		}	
	}//
	P.push(1);
	//P???1
	f[1]=0;
	while(!P.empty()){			//
		d=P.front();
		//
		A[d]=1;
		//
		P.pop();				//
		for(i=1;i<=a;i++){
			//printf("%d %d %d\n",d,i,D[d][i]);//
			if(D[d][i]==-1){		//
			continue;			//
			}					//
			if(A[i]==1){		//
			continue;			//
			}					//
			P.push(i);			//
			
			g[i]=g[d]+1;
			f[i]=g[d]+1;
			A[i]=1;
			//printf("%d\n",P.back());
		}	
	}							//
	for(i=1;i<=a;i++){			//
	printf("%d %d\n",i, f[i]);	//
	}
	return 0;
}

Measured memory_bytes: 1236
def main():
    N, M = [int(_) for _ in input().split()]
    slist = list(map(int, input().split()))
    sort_list = sorted(slist)
    thr = sum(sort_list) / (4 * M)
    
    cnt = 0
    for i in sort_list:
        if i >= thr:
            cnt += 1

    if cnt >= M:
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


int main() {

	int N;
	cin >> N;
	
	
	cout << N*N*N << endl;




    return 0;
}


/*

for(int i = 0; i < N; i++){
	
}

for(int i = 0; i < N; i++){
	for(int j = 0; j < N; j++){
		
	}
}


*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string> 
using namespace std;
string a ,b;
int main()
{  
	cin>>a>>b;
		if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
		cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
   
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#define ll long long
#define mp make_pair
using namespace std;
int n,m,bg,ed;
vector<int> v[100005];
int dp[100005][3];
inline void bfs(){
	memset(dp,63,sizeof(dp));
	dp[bg][0]=0;
	queue<pair<int,int> >q;
	pair<int,int> p;
	q.push(mp(bg,0));
	while(!q.empty()){
		p=q.front();
		q.pop();
		int u=p.first,x=p.second,y=(x+1)%3;
		if(u==ed and x%3==0){
			cout<<x/3<<endl;
			return;
		}
		for(int i=0;i<v[u].size();++i){
			int t=v[u][i];
			if(dp[t][y]>x+1){
				dp[t][y]=x+1;
				q.push(mp(t,x+1));
			}
		}
	}
	cout<<-1<<endl;
}
int main(){
	int i,j,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;++i) scanf("%d%d",&x,&y),v[x].push_back(y);
	scanf("%d%d",&bg,&ed);
	bfs();
}

Measured memory_bytes: 7416
#include <iostream>

using namespace std;

bool ch(int a, string A, string B) {

    string r = "";
    r.resize(a);

    for(int i = 0; i < A.size(); i++) {
        if(i >= r.size())
            return false;
        r[i] = A[i];
    }

    int C = r.size()-1;

    for(int i = B.size()-1; i >= 0; i--, C--) {
        if(C < 0)
            return false;
        //cout << B[i] << " " << a << " " << r[C] << '\n';
        if((r[C] >= 'a' && r[C] <= 'z') && r[C] != B[i])
            return false;
        r[C] = B[i];
    }

    return true;

}

int main() {

    ios::sync_with_stdio(false);

    int n;
    string a,b;
    cin >> n >> a >> b;

    if(n >= a.size()+b.size()) {
        cout << n;
        return 0;
    }

    for(int i = n; i < a.size()+b.size(); i++) {
        if(ch(i, a, b)) {
            cout << i;
            return 0;
        }
    }

    cout << a.size()+b.size() << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> adj(n, vector<int>(n, 0));
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        adj[a-1][b-1] = adj[b-1][a-1] = 1;
    }
    vector<vector<int>> ans(1<<n, vector<int>(n, 0));
    ans[1][0] = 1;
    for(int state = 2; state < (1<<n); state++) {
        for(int i = 0; i < n; i++) {
            if ((state >> i) & 1) {
                int src = state ^ (1<<i);
                for(int j = 0; j < n; j++) {
                    if (((src >> j) & 1) && adj[j][i]) {
                        ans[state][i] += ans[src][j];
                    }
                }
            }
        }
    }
    int last = (1 << n) - 1;
    int ret = accumulate(ans[last].begin(), ans[last].end(), 0);
    cout << ret << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int sum = 0;
  rep(i,n){
    sum += (s.at(i) - '0');
  }
  if(sum % 9 == 0) YES;
  else NO;
}

Measured memory_bytes: 3716
n = int(input())
a = sorted(list(map(int, input().split())))

a_max = a[-1]
ans_list = [0] * a_max

ans = 0

for i in range(n-1):

    p = a[i]

    if ans_list[p-1] == 0:
        for q in range(1, (a_max//p)+1):
            ans_list[p*q-1] = 1
            
        if a[i] != a[i+1]:
            ans += 1

if ans_list[a_max-1] == 0:
    ans += 1

print(ans)

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

int main () {
  int n;
  cin >> n;
  int a[n];
  int two[3];
  two[0] = 0;
  two[1] = 0;
  two[2] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 != 0) {
      two[0]++;  
    }  
    if (a[i] % 2 == 0) {
      if (a[i] % 4 == 0) {
        two[2]++;  
      }  
      else {
        two[1]++;
      }
    }
  }  
  int x = (two[1] >= 1) ? 1 : 0;
    if (two[2] + 1 - x >= two[0]) {
      cout << "Yes"  << endl;  
    }  
    else {
      cout << "No" << endl;  
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define replb(i,a,b) for(ll i=a;i>=b;i--)
#define repl(i,a,b) for(ll i=a;i<b;i++)
#define repit(arr)  for(auto it=arr.begin();it!=arr.end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set <int>
#define setl set <ll>
#define dseti set <int, greater <int> >
#define dsetl set <ll, greater <ll> >
#define mseti multiset <int>
#define msetl multiset <ll>
#define dmseti multiset <int, greater <int> >
#define dmsetl multiset <ll, greater <ll> >
#define sortA(arr)   sort(arr.begin(),arr.end())
#define ssort(arr) stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int gcd(int a,int b){
    if (a < b) swap(a, b);
    if (b == 0) return a;
    else return gcd(b, a % b);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t,n;char c;
    cin>>c;
    //cout<<int(c-'A');
    if((int(c-'A')>=0)&&(int(c-'A')<=25))cout<<'A';
    else cout<<'a';
    
    return 0;
}

Measured memory_bytes: 3648
def ryuka():
    N = int(input())
    
    if N==0:
        return 2
    elif N==1:
        return 1

    L = 1
    L_2 = 0
    L_1 = 2
    for i in range(2,N+1):
        L_2 = L_1
        L_1 = L
        L = L_1 + L_2
    return L
        
print(ryuka())

Measured memory_bytes: 3060
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true) {
            String[] cut = br.readLine().split(" ");
            int H = Integer.parseInt(cut[0]);
            int W = Integer.parseInt(cut[1]);
            if (H == 0 && W == 0)
                break;
 
            for (int i = 0; i < H; i++) {
 
                if (i % 2 == 1) {
                    for (int j = 0; j < W; j++) {
                        if (j % 2 == 1) {
                            sb.append("#");
                        }
                        if (j % 2 == 0) {
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
 
                if (i % 2 == 0) {
                    for (int k = 0; k < W; k++) {
                        if (k % 2 == 1) {
                            sb.append(".");
                        }
                        if (k % 2 == 0) {
                            sb.append("#");
                        }
                    }
                    sb.append("\n");
                }
 
            }
 
            sb.append("\n");
        }
 
        System.out.print(sb);
 
    }
}

Measured memory_bytes: 25712
import java.util.*;

public class Main {
    Integer result = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n1 = sc.nextLine();
        String n2 = sc.nextLine();
        String n3 = sc.nextLine();
        int num = sc.nextInt();
        int[] numbers = new int[num];
        for(int i=0; i<num; i++) {
            numbers[i] = sc.nextInt();
        }
        check(n1, n2, n3, numbers);
    }

    public static void check(String n1, String n2, String n3, int[] numbers) {
        int[] b1 = new int[3];
        int[] b2 = new int[3];
        int[] b3 = new int[3];
        String[] s1 = n1.split(" ");
        String[] s2 = n2.split(" ");
        String[] s3 = n3.split(" ");

        for(int i=0; i<3; i++) {
            b1[i] = Integer.parseInt(s1[i]);
            b2[i] = Integer.parseInt(s2[i]);
            b3[i] = Integer.parseInt(s3[i]);
        }
        List<String> checkList = new ArrayList<String>();
        for(int number: numbers) {
            for(int i=0; i<3; i++) {
                if(b1[i] == number) {
                    checkList.add("b1" + i);
                }
                if(b2[i] == number) {
                    checkList.add("b2" + i);
                }
                if(b3[i] == number) {
                    checkList.add("b3" + i);
                }
            }
        }
        if(checkList.contains("b10") && checkList.contains("b20") & checkList.contains("b30")
        || checkList.contains("b11") && checkList.contains("b21") & checkList.contains("b31")
                ||checkList.contains("b12") && checkList.contains("b22") & checkList.contains("b32")
            ||checkList.contains("b10") && checkList.contains("b11") & checkList.contains("b12")
        ||checkList.contains("b20") && checkList.contains("b21") & checkList.contains("b22")
        ||checkList.contains("b30") && checkList.contains("b31") & checkList.contains("b32")
            ||checkList.contains("b10") && checkList.contains("b21") & checkList.contains("b32")
            ||checkList.contains("b12") && checkList.contains("b21") & checkList.contains("b30")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 21844
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    if not((p[i-1] > p[i] and p[i] < p[i+1]) or (p[i-1] < p[i] and p[i] > p[i+1]) or (p[i-1] == p[i] and p[i] < p[i+1])  or (p[i-1] == p[i] and p[i] == p[i+1])):
        count += 1
print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<string>
using namespace std;
int X,Y;
int fie[20][20];
int dp[20][20];
int dx[]={-1,0,1};
int solve(int x,int y){
  if(dp[x][y]!=-1) return dp[x][y];
  if(y>=Y-1) return dp[x][y]=1;
  if(fie[x][y]==2){
    if(fie[x][y+2]!=1)
      return dp[x][y]=solve(x,y+2);
    return dp[x][y]=0;
  }
  int ret=0;
  for(int i=0;i<3;i++){
    int nx=x+dx[i];
    if(nx < 0 || nx >= X) continue;
    if(fie[nx][y+1]==1) continue;	 
    if(i==1){
      ret += solve(nx,y+1);
    }else{
      if(fie[nx][y+1]==2) continue;
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y]=ret;
}
main(){
  while(1){
    cin >> X >> Y;
    if(X==0 && Y==0) break;
    memset(fie,0,sizeof(fie));
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> fie[j][i];
    memset(dp,-1,sizeof(dp));
    int res=0;
    for(int i=0;i<X;i++){
      if(fie[i][0]==0)
	res += solve(i,0);
    }
    cout << res << endl;
  }
  
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
    int a,b;
    cin >> a >> b;
    if (a*b%2){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
}

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

#define ll long long

int main() {
  int n;
  ll a, min, max, sum;
  min = 100000000;
  max = -min;
  sum = 0;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    cin >> a;
    if (a < min) min = a;
    if (a > max) max = a;
    sum += a;
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
  

Measured memory_bytes: 1168
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := strings.Split(sc.Text(), " ")
    a, _ := strconv.Atoi(s[0])
    b, _ := strconv.Atoi(s[1])
    
    fmt.Println(float64(a) / float64(b))
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 3e3 + 4;
const int MOD = 998244353;
int memo[N][N] , a[N] , n , S , en;

int mul(int a , int b){
   return (1ll * a * b) % MOD;
}
int add(int a , int b){
   a += b;
   while (a > MOD) a -= MOD;
   while (a < 0) a += MOD;
   return a;
}

int solve(int indx , int sum){
   if(!sum)
      return n - indx + 1;
   if(indx == n)
      return 0;
   int &ret = memo[indx][sum];
   if(~ret)
      return ret;
   ret = 0;
   if(sum >= a[indx])ret = add(ret , solve(indx + 1 , sum - a[indx]));
   ret = add(ret , solve(indx + 1 , sum));
   return ret;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n >> S;
   for(int i = 0 ; i < n ; ++i)
      cin >> a[i];
   memset(memo , -1, sizeof(memo));

   int ans = 0;
   for(int i = 0 ; i < n ; ++i){
      int cur = solve(i , S);
      ans = add(ans , cur);
   }
   cout << ans << "\n";
}

Measured memory_bytes: 35840
n = gets.to_i

p = []
isprime = Array.new(10000,true)
isprime[0] = isprime[1] = false
for i in 2..100
    if isprime[i]
        for j in 2..10000/i
            isprime[i*j] = false
        end
    end
end

for i in 2..10000
    p << i if isprime[i] && i%5 == 1
end

puts p[0..n-1].join(" ")

Measured memory_bytes: 1916
n = input()
nums = list(map(int, input().split()))

if (nums[0] % 2 == 1):
  print('0')
else:
  tmp = nums[0] / 2
  tmp_ans = 1
  while(tmp % 2 == 0 and tmp > 1):
    tmp_ans += 1
    tmp = tmp / 2

  min_ans = tmp_ans
  
  for num in nums[1:]:
    if (num % 2 == 1):
      min_ans = 0
      break
    tmp = num / 2
    tmp_ans = 1
    while (tmp % 2 == 0 and tmp_ans <= min_ans):
      tmp_ans += 1
      tmp = tmp / 2

    if (tmp_ans < min_ans):
      min_ans = tmp_ans
      
  print(min_ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int waru(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
        //sum++;
    }
    return sum;
}
   


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

    int n,k;
    vector<int>l(101);
    cin>>n>>k;
    rep(i,n)cin>>l.at(i);

    sort(ALL(l));
    reverse(ALL(l));
    int sum=0;
   

    for(int i=0;i<k;i++){
        sum+=l.at(i);
    }
    cout<<sum<<endl;
    
}


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

const int dx[]={1,-1,0,0},
		  dy[]={0,0,1,-1};

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt;

char s[N];

int main(){

	scanf("%d",&n);
	printf("%d\n",(n+1)/2);
}


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

int main(void){
  int N,i;
  long a[10005],count;
  char str[10000005],*p;
  
  
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atol(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
  	a[i]=atol(p);
  }
  
  for(count=0;;){
    for(i=0;i<N;i++){
      if(a[i]%2==0){
        a[i]/=2;
        count++;
        break;
      }
    }
    if(i==N){
        break;
    }
    
  }
  
  printf("%ld\n",count);
  
  
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    int N, tmp, ans = 0;
    cin >> N;

    vector<int> K(N);
    vector<bool> A(N);

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

    for (int i = 0; i < N; i++) {
        if (A[i] == true) {
            continue;
        }
        if (i + 1 == K[K[i] - 1]) {
            ans ++;
            A[K[i] -1] = true;
        }
    }

    cout << ans;

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	long long ans = 0;
	long long before;
	cin >> before;
	for (int i = 1; i < N; i++) {
		long long now;
		cin >> now;
		ans += max(0ll, before - now);
		before = max(before, now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3616
a=int(input())
b=list(map(int,input().split()))
c=min(b)
d=0
b.pop(b.index(min(b)))
while True:
    if b==[]:
        break
    c+=min(b)
    b.pop(b.index(min(b)))
    d=c/2+d/2
    c=0
print(d)

Measured memory_bytes: 9180
#include<bits/stdc++.h> 
using namespace std;
long long mat[52][3000]={0};

int main(){
	int n, a;cin>>n>>a;
	mat[0][0] = 1;
	for(int i=1; i<=n; i++){
		int temp;cin>>temp;
		for(int j=i; j>=0; j--){
			for(int k=0; k<=2500; k++)
			mat[j+1][k+temp]+=mat[j][k];
		}
	}
	long long ans = 0;
	for(int i=1; i<=n; i++)
		ans+=mat[i][i*a];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define MAX 1000006
#define INF 2e9
using namespace std;
int ara[MAX] , dp[MAX];

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

	for(int i =1 ; i < n ; i++ ) {

        int val = INF;
        if( i-1 >=0 ) val = min(val ,abs(ara[i] - ara[i-1]) + dp[i-1]);
        if( i-2 >=0 ) val = min(val ,abs(ara[i] - ara[i-2]) +dp[i-2]);
        dp[i] = val;
	}
	cout<<dp[n-1]<<endl;
	return 0;

}


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

using namespace std;
using ll = long long;
#define MOD 1e9+7

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

std::vector<bool> sieve(size_t N){
    std::vector<bool> IsPrime(N+1);
    for (int i = 2; i <= N; i++)
            IsPrime[i] = true;

        for (int i = 2; i <= N; i++) {
            if (!IsPrime[i]) continue;
            for (int j = 2 * i; j <= N; j += i)
                IsPrime[j] = false;
        }
        return IsPrime;
}
bool is_prime(int64_t x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
    ll A,B;cin >> A >> B;
    set<ll> A_;
    vector<int64_t> a = divisor(A);
    vector<int64_t> b = divisor(B);
    for(auto w : a)A_.insert(w);
    ll ans = 0;
    for(auto q : b){
        if(A_.find(q) != A_.end()){
            if(is_prime(q)){
              //  cout<<q<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(){

 int N; cin >> N;
  string S; cin >> S;
  
  int head = 0; int tail = 0;
  int cnt = 0;
  
  while( head < N && tail < N){
    if( S[head] != S[tail] && tail < N){ head++; continue;}
    
    while(tail < N && S[head] == S[tail]){
      tail++;}
    
    cnt++;
    head = tail;
  }
  
  cout << cnt << endl; return 0;
}

Measured memory_bytes: 512
//CLMN
//Every cloud has a silver lining
//Hakuna matata

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

const char *fin = "";
const char *fon = "";

#define oo (int) (1e9+7)
#define maxn (int) ()

void inp() {
    int n, m;
    cin >> n >> m;
    if (abs(n - m) <= 1) {
        if (n > m) swap(n, m);
        long long tmp = 1, res;

        for(int i = 1; i <= m; ++i) {
            tmp *= i;
            tmp %= oo;
            if (i == n) res = tmp;
        }

        res = (res * tmp) % oo;
        if (m == n) res = (res * 2) % oo;
        cout << res;
    } else cout << 0;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //freopen(fin, "r", stdin); freopen(fon, "w", stdout);
    inp();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define p_q priority_queue
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    fast_io;

    int n;
    cin>>n;
    bool flag = 0;

    int a[n+1], b[n+1];

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

    int i=0;

    while(i < n-2)
    {
        if(a[i] != b[i])
        {
            i++;
        }

        else if(a[i] == b[i])
        {
            if(a[i+1] == b[i+1] && a[i+2] == b[i+2])
            {
                flag = 1;
                break;
            }

            else 
            {
                i++;
            }
        }
    }

    if(flag == 1)
    cout<<"Yes"<<endl;

    else 
    cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3604
from collections import deque

n = int(input())
a_L = list(map(int,input().split()))

ans = deque()

if n %2 == 0:
    for i in range(0,n):
        if i %2 != 0:
            ans.appendleft(a_L[i])
        else:
            ans.append(a_L[i])
else:
    for i in range(0,n):
        if i %2 == 0:
            ans.appendleft(a_L[i])
        else:
            ans.append(a_L[i])

print(*ans)

Measured memory_bytes: 98872
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int c1,c2,c3,ssr,sr;
	while(cin>>c1>>c2>>c3){
		ssr=0;
		sr=c1+c2;
		fu(1,11){
			if(i!=c1&&i!=c2&&i!=c3){
				if(sr+i<=20) ssr++;
			}
		}
		if(ssr>=4) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int N;
int A[109];
int minA,maxA;
int main() {  
  minA=1000000009;
  maxA=0;
  cin >> N;             //入力
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]<minA)minA=A[i];
    if(A[i]>maxA)maxA=A[i];
  }
  cout << (maxA-minA) << "\n";    //出力
}

Measured memory_bytes: 256
n = int(input())
k = int(input())
m = len(list(str(n)))
n0 = list(str(n))
for i in range(m):
    n0[i] = int(n0[i])
ans = 0
comb = 1
if k < m:
    for j in range(k):
        comb *= (m-1-j)
        comb //= (j+1)
    ans += comb*(9**k)
#print(ans,k,m)
if k == 1:
    ans += n0[0]
elif k == 2:
    if m >= 2:
        ans += (n0[0]-1)*9*(m-1)
        c = 1
        while n0[c] == 0 and c < m-1:
            c += 1
        if n0[c] > 0:
            ans += n0[c]
            ans += 9*(m-c-1)
    else:
        ans = 0
else:
    if m >= 3:
        ans += (n0[0]-1)*9*9*(m-1)*(m-2)//2
        c = 1
        while n0[c] == 0 and c <= m-2:
            c += 1
        if c < m-1:
            ans += (n0[c]-1)*9*(m-c-1)
            ans += 9*9*(m-c-1)*(m-c-2)//2
            c1 = c+1
            while n0[c1] == 0 and c1 < m-1:
                c1 += 1
            if n0[c1] > 0:
                ans += n0[c1]
                ans += 9*(m-c1-1)
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n, a, b;
    cin >> n;
    if (n == 1) puts("Hello World");
    else {
        cin >> a >> b;
        cout << a + b << endl;
    }
}


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


int main(){
  int n;
  cin >> n;
  int mi,ma;
  mi=1000000001;
  ma=0;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    mi=min(mi,a);
    ma=max(ma,a);
  }
  int ans=ma-mi;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define loop(i,a,b) for (int i=a; i<b; ++i)
    #define ld long double
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
     
        ll N, K;
        cin >> N >> K;
        ld ans=0;
        ld sum=0;
        vector <ll> X(N);
        loop(i,0,N) cin >> X[i]; 
        loop(i,0,K)
        {
            sum += ((1+X[i])/(ld)2);
        }
        ans = sum;
        loop(i, K, N)
        {
            sum-= ((1+X[i-K])/(ld)2);
            sum+= ((1+X[i])/(ld)2);
            ans=max(ans, sum);
        }
        cout << fixed << setprecision(10) << ans << "\n";
        return 0;
    }

Measured memory_bytes: 1792