akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define pii pair<int,int>
#define mp make_pair
const int twx=1e6+100;
const int inf=0x7fffffff;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n,m;
struct LV
{
    int Next;
    int y;
    int v;
}a[twx<<1];
int Link[twx];
int len;
map<pii,int> p;
int cnt=0;
bool v[twx];
int d[twx];
void Insert(int x,int y,int z)
{
    a[++len].y=y;
    a[len].Next=Link[x];
    a[len].v=z;
    Link[x]=len;
}
int get(int x,int y)
{
    if(p.find(mp(x,y))!=p.end())
    {
        return p[mp(x,y)];     
    }
    else
    {
        return p[mp(x,y)]=++cnt;
    }
}
void spfa()
{
    memset(d,0x3f,sizeof d);
    queue<int> q;
    q.push(1);
    v[1]=1;
    d[1]=0;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        f3(Link[x],a[i].Next,i)
        {
            int y=a[i].y;
            int vs=a[i].v;
            if(d[y]>d[x]+vs)
            {
                d[y]=d[x]+vs;
                if(!v[y])
                {
                    v[y]=1;
                    q.push(y);
                }
            }
        }
        v[x]=0;
    }
}
void init()
{
	n=read();
    m=read();
    cnt=n;
    f1(1,m,i)
    {
        int x=read();
        int y=read();
        int z=read();
        int xz=get(x,z);
        int yz=get(y,z);
        Insert(xz,yz,0);
        Insert(yz,xz,0);
        Insert(x,xz,1);
        Insert(xz,x,1);
        Insert(y,yz,1);
        Insert(yz,y,1);
    }
    spfa();
    printf("%d\n",d[n]==0x3f3f3f3f?-1:d[n]/2);
}
void work()
{
	
}
void print()
{
	
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
	return 0;
}


Measured memory_bytes: 50304
import numpy as np
 
N,K=map(int, input().split())
A=np.sort(np.array(input().split(),np.int64))
z=A[A==0]
p=A[A>0]
n=A[A<0]
 
def f(x):
 cnt=0
 if x>=0:
  cnt+=len(z)*N
 cnt+=np.searchsorted(A,x//p,side='right').sum()
 cnt+=(N-np.searchsorted(A,(-x-1)//(-n),side='right')).sum()
 cnt-=np.count_nonzero(A*A<=x)
 assert cnt%2==0
 return cnt//2
 
l=-10**18
r=10**18
while l+1<r:
 x=(l+r)//2
 if f(x)>=K:
  r=x
 else:
  l=x
print(r)


Measured memory_bytes: 34616
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int dp[10001] = { 0 }, v[100], w[100];

int main()
{
	int N, W;

	cin >> N >> W;

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

	for (int i = 0; i < N; i++)
	{
		for (int j = W; j >= 0; j--)
		{
			if (j + w[i] <= W)
			{
				dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
			}
		}
	}

	cout << dp[W] << endl;

	return 0;
}


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

typedef long long ll;

int main(){
	ll X;
	cin >> X;

	ll i = 0;
	ll a = 100;
	while(a < X){
		a = a+0.01*a;
		i++;
	}

	cout << i << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
        char *str;
        str = (char *)malloc(sizeof(char)*22);
        int i=0, count = 0;

        scanf("%s",str);
        while(1)
        {
                if(str[count] == '\0')
                {
                        break;
                }
                count++;
        }

        for(i = count-1; 0 <= i; i--)
        {
                printf("%c",str[i]);
        }
        printf("\n");
        free(str);


        return 0;
}

Measured memory_bytes: 540
/*
 * Shell Sort
 *
 */
#include<stdio.h>
int A[1000000], G[100];
int cnt=0, m;

void InsertionSort(int, int);
void shellSort(int);

int main(void){
    int key=0, length, i, j;

    scanf("%d", &length);
    for(i=0; i<length; i++){
        scanf("%d",&A[i]);
    }

    shellSort(length);

    printf("%d\n", m);

    for(i=m-1;i>=0;i--){
        printf("%d ", G[i]);
    }
    printf("\n");

    printf("%d\n", cnt);

    for(i=0;i<length;i++){
        printf("%d\n", A[i]);
    }

    return 0;
}

void shellSort(int n) {
    cnt = 0;
    int i, h=1;

    m=0;
    while (h <= n)
    {
        G[m] = h;
        h = 3 * h + 1;
        m++;
    }

    for(i=m;i>=0;i--){
        InsertionSort(n, G[i]);
    }
}

void InsertionSort(int n, int g) {
    int j, i, key;
    //Insertion Sort Algo
    for(i=g; i<=n-1; i++){

        key = A[i];
        j = i - g;

        while(j>=0 && A[j]>key){
            A[j+g] = A[j];
            j = j - g;
            // j--;
            cnt++;
        }

        A[j+g] = key;
    }
}



Measured memory_bytes: 5732
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000009;
const ll MOD = 1000000007;

ll s[100005];
int ca[100005], cb[100005];
ll dpa[100005], dpb[100005];

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    s[0] = -INF;
    for(int i = 1; i <= n; i++) cin >> s[i];
    for(int i = 1; i <= n; i++){
        ca[i] = ca[i - 1];
        cb[i] = cb[i - 1];
        if(s[i] - s[i - 1] >= a) ca[i]++;
        if(s[i] - s[i - 1] >= b) cb[i]++;
    }
    dpa[0] = dpa[1] = dpb[0] = dpb[1] = 1;
    for(int i = 2; i <= n; i++){
        if(ca[i] - ca[i - 1]) dpa[i] = (dpa[i - 1] + dpb[i - 1]) % MOD;
        else{
            int j = upper_bound(s, s + n + 1, s[i] - a) - s;
            if(cb[i - 1] - cb[j] == (i - 1) - j) dpa[i] = dpb[j];
        }
        if(cb[i] - cb[i - 1]) dpb[i] = (dpa[i - 1] + dpb[i - 1]) % MOD;
        else{
            int j = upper_bound(s, s + n + 1, s[i] - b) - s;
            if(ca[i - 1] - ca[j] == (i - 1) - j) dpb[i] = dpa[j];
        }
    }
    cout << (dpa[n] + dpb[n]) % MOD << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<ll, ll> P;

ll N, M;

// n+x-1 C x
ll mod = 1000000007;
constexpr int len = 101010;

ll f[len], rf[len];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = y * y % mod;
        k /= 2;
    }
    return res;
}

void init() {
    f[0] = 1;
    rep (i, len - 1)
        f[i + 1] = f[i] * (i + 1) % mod;
    rep (i, len)
        rf[i] = inv(f[i]);
}

ll C(int n, int k) {
    ll a = f[n];
    ll b = rf[n - k];
    ll c = rf[k];
    ll bc = (b * c) % mod;
    return (a * bc) % mod;
}

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

    init();

    cin >> N >> M;

    ll orig_m = M;

    unordered_map<ll, ll> mp;

    while (true) {
        if (M % 2 != 0) break;
        mp[2]++;
        M /= 2;
    }

    int min = 3;
    bool find = true;
    while (find) {
        find = false;
        for (ll i = min; i <= sqrt(orig_m); i += 2) {
            if (M % i == 0) {
                mp[i]++;
                min = i;
                M /= i;
                find = true;
                break;
            }
        }
    }

    if (M != 1) mp[M]++;

    ll ans = 1;

    for (auto elem : mp) ans = ans * C(N + elem.second - 1, elem.second) % mod;

    print(ans);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int d[200001];
int a[200001];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,1,n,1)scanf("%d",a+i);
	d[0]=1;
	fup(i,0,n-1,1)
	{
		if(a[i]!=a[i+1])d[a[i+1]]=(d[a[i+1]]+d[a[i]])%MOD;
	}
	printf("%d",d[a[n]]);
}

Measured memory_bytes: 1792
// AtCoder Regular Contest 080
// E - Young Maids

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, pii> piii;


const int MAX_N = 200000;
const int INF = (int)1e8;

template <typename T>
class RMQ {
public:
    int n;
    vector<T> dat;
    void init(int _n);
    void update(int k, T a);
    T query(int a, int b);
private:
    T query(int a, int b, int k, int l, int r);
};

template <typename T>
void RMQ<T>::init(int _n) {
    n = 1;
    while (n < _n) {
        n <<= 1;
    }
    dat.reserve(2 * n - 1);
    for (int i = 0; i < 2 * n - 1; i++) {
        dat[i] = INF;
    }
    return;
}

template <typename T>
void RMQ<T>::update(int k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
    return;
}

template <typename T>
T RMQ<T>::query(int a, int b) {
    return query(a, b, 0, 0, n);
}

// [a, b), [l, r)
template <typename T>
T RMQ<T>::query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
        return INF;
    }
    if (a <= l && r <= b) {
        return dat[k];
    }
    return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
}


int N;
int p[MAX_N];
int at[MAX_N + 1];
RMQ<int> st[2];
priority_queue<piii, vector<piii>, greater<piii>> q;
vector<int> ans;

int main() {

    int l, r, a, b, av, bv;

    cin >> N;
    st[0].init(N / 2);
    st[1].init(N / 2);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        at[p[i]] = i;
        st[i % 2].update(i / 2, p[i]);
    }

    q.push(piii(st[0].query(0, N / 2), pii(0, N)));
    while (!q.empty()) {
        piii sec = q.top(); q.pop();
        l = sec.second.first;
        r = sec.second.second;
        if (l >= r) {
            continue;
        }
        av = sec.first;
        a = at[av];
        bv = st[(l + 1) % 2].query((a + 1) / 2, (r + 1) / 2);
        b = at[bv];
        ans.push_back(av); ans.push_back(bv);
        q.push(piii(st[l % 2].query(l / 2, a / 2), pii(l, a)));
        q.push(piii(st[(a + 1) % 2].query((a + 1) / 2, b / 2), pii(a + 1, b)));
        q.push(piii(st[(b + 1) % 2].query((b + 1) / 2, r / 2), pii(b + 1, r)));
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << (i == N - 1 ? '\n' : ' ');
    }

    return 0;

}





Measured memory_bytes: 9904
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, Q = map(int, readline().split())
    S = list(readline().rstrip().decode())
    ac_check = [0] * (N)
    tsum = [0] * (N + 1)

    for i in range(N - 1):
        if S[i] == 'A' and S[i + 1] == 'C':
            tsum[i + 2] += 1
            ac_check[i] = 1
            ac_check[i + 1] = 2

    for i in range(N):
        tsum[i + 1] += tsum[i]

    ans = []
    for i in range(Q):
        l, r = map(int, readline().split())
        count = tsum[r] - tsum[l - 1]
        if ac_check[l - 1] == 2:
            count -= 1
        ans.append(count)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19540
#include<stdio.h>
#define NMAX 100100
int main(void){int n,m,a,b;int list[5*NMAX]={0};int last=NMAX;int node[5*NMAX]={0};int queue[5*NMAX]={0},qfirst=0,qlen=0;int room[NMAX]={0};int i;int now,tmp;scanf("%d%d",&n,&m);for(i=0;i<m;i++){scanf("%d%d",&a,&b);list[last]=list[a]; 		list[a]=last; 		node[last]=b; 		last++; 		list[last]=list[b]; 		list[b]=last; 		node[last]=a; 		last++; 	} 	queue[0]=1;qlen=1; 	room[1]=room[0]=-1; 	while(qlen){ 		now=queue[qfirst]; 		qlen--; 		qfirst++; 		tmp=now; 		 		while(tmp){ 			tmp=list[tmp]; 			if(room[node[tmp]]==0){ 				room[node[tmp]]=now; 				queue[(qfirst+qlen)%(5*NMAX)]=node[tmp]; 				qlen++; 			} 		} 	} 	puts("Yes"); 	for(i=2;i<=n;i++){ 		printf("%d\n",room[i]); 	} 	return 0; } 


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

int main() {
    string s;
    cin >> s;
    int mb = 0;
    int mw = 0;
    int eb = 0;
    int ew = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (s[i] == '0') {
                eb++;
            } else {
                ew++;
            }
        } else {
            if (s[i] == '0') {
                mb++;
            } else {
                mw++;
            }
        }
    }

    cout << min(eb + mw, ew + mb) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;

  int JPY = 0;
  float BTC = 0.;

  for(int i=0; i<N; i++) {
    float x; std::string u; std::cin >> x >> u;
    if ( u == "JPY" ) JPY += x;
    else BTC += x;
  }

  std::cout << std::setprecision(8);
  std::cout <<  380000. * BTC + JPY << std::endl;
  return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
print(math.ceil(N/2))

Measured memory_bytes: 67948
#include <stdio.h>
int main(){
	int H,W,i,e,r,x,y,z,j;
	for(;;){
		scanf("%d %d",&H,&W);
		if((H == 0) && (W == 0)) break;
		for(i=0;i < W;i++){
			printf("#");
		}
		printf("\n");
		e=H-2;
		for(y=0;y < e;y++){
			printf("#");
			z=W-2;
			for(x=0;x < z;x++){
				printf(".");
			}
			printf("#\n");
		}
		for(r=0;r < W;r++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	int n = s.size();
	if (s[0] == '0' || s[n - 1] == '1') {
		cout << "-1\n";
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - i - 2]) {
			cout << "-1\n";
			return 0;
		}
	}
	int p = 1;
	for (int i = 2; i <= n; i++) {
		cout << p << ' ' << i << endl;
		if (s[i - 2] == '1')p = i;
	}
	return 0;
}

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

namespace ABC130A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a;

            var word = Console.ReadLine().Split(' ');

            x = int.Parse(word[0]);
            a = int.Parse(word[1]);

            if (x < a)
                Console.WriteLine("0");
            else
                Console.WriteLine("10");

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		System.out.println((x >= a && x <= a+b) ? "YES" : "NO");
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string t;
    cin >> t;
    int len = t.size();
    for (int i = 0; i < len; i++) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
}


Measured memory_bytes: 3752
import math
import sys

S = sys.stdin.readline()[:-1]
T = sys.stdin.readline()[:-1]
sl = len(S)
tl = len(T)
dp = [[0 for _ in range(tl + 1)] for _ in range(sl + 1)]

#dp[ s_ind][t_ind] → S の  s_ind文字目、Tの t_ind文字目までのLCS
ans = ""
for s_ind in range(sl):
    for t_ind in range(tl ):
        if S[s_ind]  == T[t_ind]:
            dp[s_ind + 1][t_ind + 1] = dp[s_ind ][t_ind ] + 1   # AB "C"    と DQ "C" → AB まで とDQまでが dp[s_ind - 1][t_ind -1] 、それに各+1文字してdp[s_ind ][t_ind ] 、共通列の長さも+1

        dp[s_ind + 1][t_ind + 1]  = max(dp[s_ind + 1][t_ind + 1],dp[s_ind + 1][t_ind  ],dp[s_ind][t_ind+ 1])

i = sl
j = tl
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j- 1]:
        j -=1
    elif dp[i][j] == dp[i - 1][j]:
        i -=1
    else:
        ans = S[i -1 ] + ans
        i -=1
        j -=1


print(ans)





Measured memory_bytes: 120412
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int map[2000][2000];
int l[2000][2000];

int main()
{
	int H, W;

	cin >> H >> W;

	char buff[2048];

	for (int i = 0; i < H; i++)
	{
		cin >> buff;

		for (int j = 0; j < W; j++)
		{
			if (buff[j] == '.')
			{
				map[i][j] = 0;
			}
			else
			{
				map[i][j] = 1;
			}
		}
	}

	memset(l, 0, 2000 * 2000 * sizeof(int));

	for (int i = 0; i < H; i++)
	{
		int num1 = 0;
		int num2 = 0;
		for (int j = 0; j < W; j++)
		{
			if (map[i][j] == 1)
			{
				num1 = 0;
			}
			else
			{
				l[i][j] += num1;
				num1++;
			}

			if (map[i][W - 1 - j] == 1)
			{
				num2 = 0;
			}
			else
			{
				l[i][W - 1 - j] += num2;
				num2++;
			}
		}
	}

	for (int j = 0; j < W; j++)
	{
		int num1 = 0;
		int num2 = 0;
		for (int i = 0; i < H; i++)
		{
			if (map[i][j] == 1)
			{
				num1 = 0;
			}
			else
			{
				l[i][j] += num1;
				num1++;
			}

			if (map[H-1-i][j] == 1)
			{
				num2 = 0;
			}
			else
			{
				l[H-1-i][j] += num2;
				num2++;
			}
		}
	}

	int maxd = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			maxd = max(maxd, l[i][j]);
		}
	}

	cout << maxd+1 << endl;

	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

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

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD7;
        a = a * a % MOD7;
        n >>= 1;
    }
    return res;
}

bool zeronai(ll kkk){
    while(kkk > 0){
        if(kkk % 10 == 0){
            return false;
        }else{
            kkk /= 10;
        }
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    ll n = s.length();
    ll mmmod = 2019;
    vector<vector<ll>> dp(2, vector<ll>(mmmod, 0));

    dp[0][0] = 1;
    ll imano = 0;

    REP(i, n){
        imano = (imano * 10 + (s[i] - '0')) % mmmod;
        REP(j, mmmod){
            dp[(i + 1) % 2][(j * 10) % mmmod] = dp[i % 2][j];
        }
        dp[(i + 1) % 2][imano] += 1;
    }

    ll ans = 0;
    REP(i, mmmod){
        if(dp[n%2][i] >= 2){
            ans += dp[n%2][i] * (dp[n%2][i]-1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
// D - Insertion

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int unpaired_r = 0;
	int l = 0;
	for (int i=0; i<N; i++) {
		if (S[i] == ')') {
			if (l == 0) {
				unpaired_r++;
			} else {
				l--;
			}
		} else {
			l++;
		}
	}

	int unpaired_l = 0;
	int r = 0;
	for (int i=N-1; i>=0; i--) {
		if (S[i] == '(') {
			if (r == 0) {
				unpaired_l++;
			} else {
				r--;
			}
		} else {
			r++;
		}
	}

	string ans = S;
	for (int i=0; i< unpaired_r; i++) {
		ans = '(' + ans;
	}
	for (int i=0; i< unpaired_l; i++) {
		ans = ans + ')';
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

int a[200001];
set <int> s;
int main(void){
    int n; cin >> n; ll ans = 0;
    for(int i = 0;i < n;i++){
        int A; cin >> A; a[A] = i+1; 
    }
    s.insert(0); s.insert(n+1);
    for(int i = 1;i <= n;i++){
        auto r = s.insert(a[i]);
        auto ite = r.first;
        auto stite = --ite; ++ite;
        auto goite = ++ite;
        int st = *stite; int go = *goite;
        ans += (ll)i*(a[i]-st)*(go-a[i]);
    }
    cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define INF (2100)
int main(){
  int r=0,h,w;
  cin>>h>>w;
  vector<string> a(h);
  vector<vector<int>> b(h,vector<int>(w,INF));
  for(int i=0;i<h;++i){
    cin>>a[i];
    for(int j=0;j<w;++j){
      if(a[i][j]=='#')b[i][j]=0;
    }
  }
  bool ch=true;
  while(ch){
    ch=false;
    // ->
    for(int i=0;i<h;++i){
      int nw=INF;
      for(int j=0;j<w;++j){
        if(a[i][j]=='.'){
          nw++;
          if(nw<b[i][j]){
            ch=true;
            b[i][j]=nw;
          }
          else nw=b[i][j];
        }
        else nw=0;
      }
    }
    // <-
    for(int i=h-1;i>=0;--i){
      int nw=INF;
      for(int j=w-1;j>=0;--j){
        if(a[i][j]=='.'){
          nw++;
          if(nw<b[i][j]){
            ch=true;
            b[i][j]=nw;
          }
          else nw=b[i][j];
        }
        else nw=0;
      }
    }
    // down
    for(int i=w-1;i>=0;--i){
      int nw=INF;
      for(int j=h-1;j>=0;--j){
        if(a[j][i]=='.'){
          nw++;
          if(nw<b[j][i]){
            ch=true;
            b[j][i]=nw;
          }
          else nw=b[j][i];
        }
        else nw=0;
      }
    }
    // up
    for(int i=0;i<w;++i){
      int nw=INF;
      for(int j=0;j<h;++j){
        if(a[j][i]=='.'){
          nw++;
          if(nw<b[j][i]){
            ch=true;
            b[j][i]=nw;
          }
          else nw=b[j][i];
        }
        else nw=0;
      }
    }
  }
  for(int i=0;i<h;++i)for(int j=0;j<w;++j){
    if(a[i][j]=='.'&&b[i][j]<INF)r=max(r,b[i][j]);
  }
  cout<<r;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    map<int,int> cnt0;
    map<int,int> cnt1;
    for(int i=0;i<n;i+=2){
        cnt0[v[i]]++;
    }
    for(int i=1;i<n;i+=2){
        cnt1[v[i]]++;
    }
    vector<pair<int,int>> v0;
    v0.push_back(make_pair(0,(int)(1e5+1)));
    for(auto &e:cnt0){
        v0.push_back(make_pair(e.second,e.first));
    }
    vector<pair<int,int>> v1;
    v1.push_back(make_pair(0,(int)(1e5+2)));
    for(auto &e:cnt1){
        v1.push_back(make_pair(e.second,e.first));
    }
    sort(v0.begin(),v0.end(),greater<>());
    sort(v1.begin(),v1.end(),greater<>());
    int res=n;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if(v0[i].second!=v1[j].second){
                res=min(res,n-(v0[i].first+v1[j].first));
            }
        }
    }
    cout<<res<<endl;


    return 0;
}

Measured memory_bytes: 6520
#include<iostream>
using namespace std;
int n;
long long int a[55];
int main(){
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	long long int res = 0;
	while(true){
		int p = -1;
		for(int i=0; i<n; i++)
			if(p == -1 || a[i] > a[p])
				p = i;
		if(a[p] >= n){
			long long int w = a[p] / n;
			a[p] -= w*n;
			for(int j=0; j<n; j++)if(j!=p)
				a[j] += w;
			res += w;

		}else
			break;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	FOR{
		for(int j=i+1;j<=n;j++){
			int bas=1;
			int son=n;
			while(bas<=son){
				if(a[ort]+a[j]<=a[i])bas=ort+1;
				else if(a[ort]+a[i]<=a[j])bas=ort+1;
				else if(a[i]+a[j]<=a[ort])son=ort-1;
				else bas=ort+1;
			}
			//~ cout<<son<<endl;
			if(son>j)
				cev+=son-j;
		}
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int a, n, c[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a;
    if(a%4 == 0){
      c[2]++;
    }else if(a%2 == 0){
      c[1]++;
    }else{
      c[0]++;
    }
  }
  cout << ((c[2] + (c[1] > 0 ? 0 : 1) >= c[0]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);

    REP(i, M)
    {
        cin >> B.at(i);
    }

    int cnt = 0;
    int a;
    REP(i, N)
    {
        int ans = C;
        REP(j, M)
        {
            cin >> a;
            ans += a * B.at(j);
        }

        if (ans > 0)
            cnt++;
    }
    cout << cnt << endl;
    ;
}

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

typedef long long int int64;

typedef struct directedGraph{
  int *vertex;
  int *next;
  int *start;
  int v,e;
  int pointer;
} graph;

graph* newGraph(const int v,const int e){
  graph *g=(graph *)malloc(sizeof(graph));
  g->vertex=(int *)calloc(e,sizeof(int));
  g->next=(int *)calloc(e,sizeof(int));
  g->start=(int *)calloc(v,sizeof(int));
  for(int i=0;i<v;i++) g->start[i]=-1;
  g->v=v;
  g->e=e;
  g->pointer=0;
  return g;
}

void freeGraph(graph *g){
  free(g->vertex);
  free(g->next);
  free(g->start);
  free(g);
  return;
}

void addEdge(graph *g,const int from,const int to){
  const int p=g->pointer;
  g->vertex[p]=to;
  g->next[p]=g->start[from];
  g->start[from]=p;
  g->pointer++;
  return;
}

const int mod=1000000000+7;

int calc(int v,int c,graph *g,int *dp,int *used,int n){
  if(dp[c*n+v]>=0) return dp[c*n+v];
  used[v]=1;
  int ans=1;
  for(int p=g->start[v];p!=-1;p=g->next[p]){
    int u=g->vertex[p];
    if(used[u]) continue;
    int t=calc(u,0,g,dp,used,n);
    if(c==0) t+=calc(u,1,g,dp,used,n);
    ans=(int64)ans*t%mod;
  }
  used[v]=0;
  dp[c*n+v]=ans;
  return ans;
}

void run(void){
  int n;
  scanf("%d",&n);
  graph *g=newGraph(n,2*n);
  int i;
  for(i=0;i<n-1;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    x--;y--;
    addEdge(g,x,y);
    addEdge(g,y,x);
  }
  int *dp=(int *)calloc(2*n,sizeof(int));
  int *used=(int *)calloc(n,sizeof(int));
  for(i=0;i<2*n;i++) dp[i]=-1;
  int ans=calc(0,0,g,dp,used,n)+calc(0,1,g,dp,used,n);
  printf("%d\n",ans%mod);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 11648
import sys
input = sys.stdin.readline
def main():
  h,w=map(int,input().split())
  a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
  ans=[]
  for i in range(h):
    for j in range(w):
      if j<w-1 and a[i][j]==1:
        a[i][j]-=1
        a[i][j+1]+=1
        a[i][j+1]%=2
        ans.append([i,j,i,j+1])
      elif i<h-1 and a[i][j]==1:
        a[i][j]-=1
        a[i+1][j]+=1
        a[i+1][j]%=2
        ans.append([i,j,i+1,j])
  print(len(ans))
  for x1,y1,x2,y2 in ans:
    print(x1+1,y1+1,x2+1,y2+1)
if __name__=='__main__':
  main()


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

int main(){
	int n,W;
	int v[1000],w[1000];
	for(int cnt = 0;;cnt++){
		cin >> W >> n;
		if(!W) break;
		int dp[1001][1001] = {},ma = 0,mi = 1e+9;
		for(int i = 0;i < n;i++){
			scanf("%d,%d",&v[i],&w[i]);
		}
		dp[0][0] = 0;
		for(int i = 1;i <= n;i++){
			for(int j = 0;j <= W;j++){
				if(j - w[i - 1] >= 0) dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
				else dp[i][j] = dp[i - 1][j];
				if(ma < dp[i][j]){
					ma = dp[i][j];
					mi = j;
				}else if(ma == dp[i][j]) mi = min(mi,j);
			}
		}
		printf("Case %d:\n%d\n%d\n",cnt + 1,ma,mi);
	}
	
	return 0;
}

Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int dfs(const vector<vector<pair<int, int> > > &v, int idx, vector<int> &used, int needs) {
    int ans = 0;

    for(int i = idx; i < v.size(); ++i) {
        int used_cnt = 0;
        for(int j = 0; j < v[i].size(); ++j) {
            if(used[v[i][j].first]) {
                ++used_cnt;
            }
        }
        if(used_cnt != needs) continue;

        used[i] = 1;
        int score = 0;
        for(int k = 0; k < used.size(); ++k) {
            if(!used[k]) continue;
            int sat = 10000000;
            for(int l = 0; l < v[k].size(); ++l) {
                if(used[v[k][l].first]) sat = min(sat, v[k][l].second);
            }
            if(sat == 10000000) sat = 0;
            score += sat;
            //cout << k << ' ';
        }
        //cout << ':' << score << endl;
        ans = max(ans, score);
        ans = max(ans, dfs(v, i+1, used, needs+1));
        used[i] = 0;
    }

    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int> > > friends(N);
    for(int i = 0; i < M; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        --u; --v;
        friends[u].push_back(make_pair(v, f));
        friends[v].push_back(make_pair(u, f));
    }

    vector<int> tmp(N, 0);
    cout << dfs(friends, 0, tmp, 0) << endl;

    return 0;
}

Measured memory_bytes: 0
open System
open System.Collections.Generic

[<EntryPoint>]
let main argv =
    let [|N; K|] = stdin.ReadLine().Split() |> Array.map int

    let mutable check = new List<bool>()
    for i in [1..N] do
        check.Add false

    for i in [1..K] do
        let d = stdin.ReadLine() |> int
        let a = stdin.ReadLine().Split() |> Array.map int

        for j in [0..(d - 1)] do
            let no = a.[j]
            check.[no - 1] <- true
    
    check
    |> Seq.filter (fun x -> x = false)
    |> Seq.length
    |> printfn "%d"
    

    0

Measured memory_bytes: 30772
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define int long long

int ord2(int n){
    int ret =0;
    while(n%2==0){
        n/=2;
        ret++;
    }
    return ret;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,ans=0,L=1,ord,d;
    cin>>n>>m;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ord=ord2(a[0]);
    d=(1<<ord);
    for(int i=0;i<n;i++){
        if((a[i]/d)%2==0){cout<<0<<endl;return 0;}
        a[i]/=d;
        int tmp =(L/__gcd(L,a[i]))*a[i];
        if(tmp<0||L>tmp){cout<<0<<endl;return 0;}
        else{L = tmp;}
    }
    L*=d/2;
    if((L>m)||(L<=0)){cout<<0;return 0;}
    cout<<(m+L)/(2*L)<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	vector<ll> a(5);
	for (ll i = 0; i < 5; ++i)
	{
		cin >> a[i];
	}

	ll k;
	cin >> k;

	ll ans = 0;

	if (a[0] + k < a[1]) ans++;
	if (a[0] + k < a[2]) ans++;
	if (a[0] + k < a[3]) ans++;
	if (a[0] + k < a[4]) ans++;
	if (a[1] + k < a[2]) ans++;
	if (a[1] + k < a[3]) ans++;
	if (a[1] + k < a[4]) ans++;
	if (a[2] + k < a[3]) ans++;
	if (a[2] + k < a[4]) ans++;
	if (a[3] + k < a[4]) ans++;

	if (ans != 0)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}

	//system("pause");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int dp[100002];
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    IOS;
    int n; cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++) cin>>h[i];
    dp[1] = 0;
    dp[2] = fabs(h[2] - h[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(fabs(h[i]-h[i-2]) + dp[i-2] , fabs(h[i]-h[i-1]) + dp[i-1]);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    long int a;
    long total =0;
  cin >> a;
  for(int i=1; i<=a; i++){
    if(i % 3 != 0 && i % 5 != 0){
        total += i;
    }
  }
 cout << total << endl;
     return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3e5+5,M=1e5+5;
struct node{
	int l,r,len;
}good[N];
int n,m,d,cnt,ans[M],tree[N];

inline bool cmp(node x,node y){
	return x.len<y.len;
}

inline int lowbit(int x){
	return x&(-x);
}

inline void add(int x,int w){
	while(x<=m){
		tree[x]+=w;
		x+=lowbit(x);
	}
}

inline int query(int x){
	int res=0;
	while(x){
		res+=tree[x];
		x-=lowbit(x);
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&good[i].l,&good[i].r);
		good[i].len=good[i].r-good[i].l+1;
	}
	sort(good+1,good+n+1,cmp);
	for(d=1;d<=m;d++){
		for(int i=cnt+1;i<=n;i++)
			if(good[i].len>d){
				cnt=i-1;
				break;
			}else{
				add(good[i].l,1);
				add(good[i].r+1,-1);
				cnt++;
			}
		int res=0;
		for(int i=1;i*d<=m;i++)	res+=query(i*d);
		ans[d]=n-cnt+res;
	}
	for(int i=1;i<=m;i++)	printf("%d\n",ans[i]);
	return 0;
}

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

int main() {

  std::string s;
  std::cin >> s;

  int sum = 0;

  for (char c : s) {
    sum += c - '0';
  }

  std::cout << (sum % 9 == 0 ? "Yes" : "No") << std::endl;

  return 0;

}


Measured memory_bytes: 3684
import sys
input = sys.stdin.readline

import numpy as np

def main():
  n, W = map(int, input().split())
  dp = np.zeros(W+1, dtype=np.int64)
  for _ in range(n):
    w, v = map(int, input().split())
    np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])
  print(dp[-1])
  
if __name__ == "__main__":
  main()


Measured memory_bytes: 14628
using System;

namespace _088c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] c = new int[4,4];
            for(int i = 1; i <= 3; i++){
                int[] read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
                for(int j = 1; j <= 3; j++){
                    c[i,j] = read[j-1];
                }
            }
            bool res = false;
            if(c[1,1]-c[2,1]==c[1,2]-c[2,2] && c[1,1]-c[2,1]==c[1,3]-c[2,3]){
                if(c[1,1]-c[3,1]==c[1,2]-c[3,2]&&c[1,1]-c[3,1]==c[1,3]-c[3,3]){
                    if(c[1,1]-c[1,2]==c[2,1]-c[2,2]&&c[1,1]-c[1,2]==c[3,1]-c[3,2]){
                        if(c[1,1]-c[1,3]==c[2,1]-c[2,3]&&c[1,1]-c[1,3]==c[3,1]-c[3,3]){
                            res = true;
                        }
                    }
                }
            }
            Console.WriteLine(res?"Yes":"No");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 3e3 + 5;

string A, B;
int n, m;
int dp[N][N];
string S;

void go (int x, int y){
    if (dp[x][y] == 0)
        return;
    if (dp[x][y] == dp[x - 1][y]){
        go (x - 1, y);
        return;
    }
    if (dp[x][y] == dp[x][y - 1]){
        go (x, y - 1);
        return;
    }
    S += A[x];
    go (x - 1, y - 1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>A>>B;
    n = (int)A.size();
    m = (int)B.size();
    A = "#" + A;
    B = "#" + B;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
            if (A[i] == B[j])
                dp[i][j] = max (dp[i][j], dp[i - 1][j - 1] + 1);
        }
    go (n, m);
    for (int i = dp[n][m] - 1; i >= 0; i--)
        cout<<S[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, a[105];
    float sum = 0.0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += 1.0 / a[i];
    }

    cout << setprecision(12) << 1.0 / sum << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int d,t,s;
  double a;
  scanf("%d %d %d", &d,&t,&s);
  a=(double)d/s;
  if ( a <= t) {
   printf("Yes"); 
  } else {
   printf("No");
  }
  return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int n; cin >> n;
    vector<int> b(n - 1);
    vector<int> a(n);
    rep(i, n-1) cin >> b[i];
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for (int i = 1; i < n - 1; i++) {
        a[i] = min(b[i - 1], b[i]); 
    }
    int ans = 0;
    rep(i, n) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> jr;
    REP(i, n-1){
        if(s[i] == 'R' && s[i+1] == 'L'){
            jr.push_back(i);
        }
    }
    vector<int> num(n, 0);

    FOR(i, 0, jr.size()){
        int r = jr[i];
        int l = r + 1;
        int x = r, y = l;
        while(x >= 0 && s[x] == 'R') 
            x--;
        while(y < n && s[y] == 'L')
            y++;
        int rnum = r - x;
        int lnum = y - l;
        num[r] = (rnum+1)/2 + lnum/2;
        num[l] = (lnum+1)/2 + rnum/2;
    }

    print_container(num);
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<iomanip>
#include<cctype>
#include<climits>
#include<queue>
#include<utility>
#include<functional>
#include<memory>
using namespace std;
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

int N, K;
set< int > d;

int a[9], tot, ret, len;

void dfs(int pos, int num, bool unlim) {
  if (pos > len) {
    if (num >= N) {
      ret = min(ret, num);
      return;
    }
  }

  for (int i = (pos == 1); i <= 9; ++i) {
    if (d.find(i) != d.end()) {
      continue;
    }
    dfs(pos + 1, num * 10 + i, unlim | (i < a[pos]));
  }

}

void solve(int x) {
  // memset(f, 0x3f, sizeof(f));

  len = 0;
  int nn = N;
  while (nn) {
    nn /= 10;
    ++len;
  }

  tot = 0;
  while (x) {
    a[++tot] = x % 10;
    x /= 10;  
  }
  reverse(a + 1, a + tot + 1);

  ret = INF;
  dfs(1, 0, 0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> N >> K;
  for (int k = 0; k < K; ++k) {
    int x; 
    cin >> x;
    d.insert(x);
  }
  
  solve(99999);
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())

v = a * a * b

if x > v / 2:
    rad = math.atan(2*(v-x)/(a*a*a))
    print(math.degrees(rad))

elif x < v / 2:
    rad = math.atan(a * b * b / (2 * x))
    print(math.degrees(rad))


else:
    print(45)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int X;

    cin >> X;

    cout << (X >= 30 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int64_t d[55][2510] = {1};

int main()
{
    int n, a;
    cin >> n >> a;

    for (int x, i = 1; i <= n; ++i) {
        cin >> x;
        for (int j = i; j; --j)
            for (int k = 0; k <= (j - 1) * 50; ++k)
                d[j][k+x] += d[j-1][k];
    }

    int64_t res = 0;

    for (int i = 1; i <= n; ++i)
        res += d[i][a * i];

    cout << res;
    return 0;
}


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

int main(){
    string S,T;
    cin>>S>>T;
    int a,b;
    cin>>a>>b;
    string U;
    cin>>U;
    if(S == U){
        cout<<(a-1)<<" "<<b<<endl;
    }else{
        cout<<a<<" "<<(b-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double i[5001];
	int x, y, n;
	double sum, max;
	
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (x = 0; x < n; x++) {
			scanf("%lf", &i[x]);
		}
		max = -500000001;
		for (x = 0; x < n; x++) {
			sum = 0;
			for (y = x; y < n; y++) {
				sum += i[y];
				if (max < sum) {
					max = sum;
				}
			}
		}
		printf("%.f\n", max);
	}
	
	return (0);
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int n,k;
		cin >> n >> k;
		int ans = n%k;
		ans = min(ans,abs(ans-k));
		cout << ans;
	}
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      Map<Integer,Integer> map = new HashMap<Integer,Integer>();
      for(int i = 0;i < n;i++){
      	a[i]=sc.nextInt();
        if(map.containsKey(a[i]))map.put(a[i],map.get(a[i])+1);
        else map.put(a[i],1);
      }
      int sum = 0;
      for(Map.Entry<Integer,Integer> entry : map.entrySet()){
      	int x = entry.getKey();
        int y = entry.getValue();
        if(x>y)sum+=y;
        else if(x==y){}
        else sum+=y-x;
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 65212