akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 100005
using namespace std;
typedef long long ll;
char s[maxn];
int n,ans;
int main(){
  scanf("%s",s);
  n = strlen(s);
  for(int i = 0;i < n;i++){
    ans += ((s[i] - '0') ^ (i & 1));
  }
  printf("%d\n",min(ans,n - ans));
  return 0;
}


Measured memory_bytes: 384
from collections import deque


def main():
    n, m = map(int, input().split())
    route = [[] for _ in range(n)]  # 各ノードと隣接するノード
    INF = 10 ** 12

    for _ in range(m):
        a, b = map(int, input().split())
        route[a - 1].append(b - 1)
        route[b - 1].append(a - 1)

    d = deque()
    d.append(0)
    dist = [0] + [INF] * (n - 1)  # 根からの距離
    pre = [-1] * n  # 各ノードの親

    while d:
        u = d.popleft()
        for v in route[u]:
            if dist[v] != INF:
                continue
            dist[v] = dist[u] + 1
            pre[v] = u
            d.append(v)

    print("Yes")
    for i in range(1, n):
        print(pre[i] + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 94408
import queue
import sys

q = queue.Queue()
K = int(input())

for i in range(1,10):
    q.put(i)

n = 0
while True:
    n += 1
    val = q.get()
    if n == K:
        print(val)
        sys.exit()

    mod = val%10
    if mod != 0:
        q.put(val*10+mod-1)
    q.put(val*10+mod)
    if mod != 9:
        q.put(val*10+mod+1)

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

const int64_t mod = 1e9 + 7;

int64_t sum_mod (int64_t a, int64_t b) {
    return (a + b) % mod;
}

int64_t sub_mod (int64_t a, int64_t b) {
    return (a - b + mod) % mod;
}

int64_t mul_mod (int64_t a, int64_t b) {
    return (a * b) % mod;
}

int64_t pow_mod (int64_t a, int64_t b) {
    int64_t res = 1, t = a;
    while (b) {
        if (b & 1)
            res = mul_mod(res, t);
        t = mul_mod(t, t);
        b >>= 1;
    }
    return res;
}

int64_t div_mod (int64_t a, int64_t b) {
    return mul_mod(a, pow_mod(b, mod - 2));
}

signed main () {
    int n;
    string s;
    cin >> n >> s;
    int64_t ans = 0;
    map < char, int64_t > cnt;
    for (int i = 0; i < n; ++i) {
        int64_t pref = 1;
        for (auto pr: cnt) {
            if (pr.first != s[i])
                pref = mul_mod(pref, pr.second + 1);
        }
        ans = sum_mod(ans, pref);
        ++cnt[s[i]];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int i = 0, k, x, y;
    int data1[3000], data2[3000];
    while(1) {
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        data1[i] = x;
        data2[i] = y;
        i++;
    }
    for(k = 0; k < i; k++) {
        if(data1[k] > data2[k]) printf("%d %d\n", data2[k], data1[k]);
        else printf("%d %d\n", data1[k], data2[k]);
    }
    return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
constexpr int INF = 1LL<<60;

signed main() {
  string s; cin>>s;
  
  for(int bit=0;bit<(1<<3);++bit){
    int res = s[0]-'0';
    for(int i=0;i<3;++i){
      res += (((bit>>i)&1)?1:-1) * (s[i+1]-'0');
    }
    if (res == 7) {
       // 解ができた時は出力
       cout<<s[0];
       for(int i=0;i<3;++i){
         cout<<(bit&(1<<i)?"+":"-")<<s[i+1];
       }
       cout<<"=7"<<endl;
       return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>List.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>List.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N,K=R2 int64 int64
    let m = min (N%K) (K-(N%K))
    outl m
    0


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

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: 3576
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
b = []
b_sum = 0
mod = 10**9+7
for i in range(n):
    b_sum += (ans // a[i])

print(b_sum % mod)

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

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n;
vector<int> dat;

//inputします
void input() {
	cin >> n;
	dat.resize(n);
	ff(i, 0, n) {
		cin >> dat[i];
	}
	srt(dat);
}

//ライブラリ置き場


//main
int main() {
	input();
	int ans = inf;
	ff(x, 0, 100) {
		int pre = 0;
		ff(i, 0, n) {
			pre += (dat[i] - x) * (dat[i] - x);
		}
		if (pre < ans)ans = pre;
	}
	cout << ans << endl;
	return 0;
}

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

int SumDigit(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int total = 0;
    for (int i = 1; i <= n; i++) {
        int sum = SumDigit(i);
        if (a <= sum && sum <= b) {
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

int prefa[N];

void solve() {
	string s;
	ll cnt = 0;
	cin >> s;
	for (int i = 0; i + 2 < sz(s); ++i) {
		if (s[i] == 'A') prefa[i] += prefa[i-1] + 1;
		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
			++cnt;
			s[i] = 'B'; s[i+1] = 'C'; s[i+2] = 'A';
			if (0 < i) cnt += prefa[i-1];
			if (0 < i) prefa[i+1] = prefa[i-1];		
		}
	}	
	cout << cnt;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 1300
def dfs(ret, cur, f1, f2, f3):
    if N < cur:
        return ret

    ret += 1 if f1 and f2 and f3 else 0

    ret = dfs(ret, cur * 10 + 7, True, f2, f3)
    ret = dfs(ret, cur * 10 + 5, f1, True, f3)
    ret = dfs(ret, cur * 10 + 3, f1, f2, True)

    return ret


N = int(input())

print(dfs(0, 0, False, False, False))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

vector<lld> v;
lld l, k;

lld f(lld d, lld c, bool m) {
  if (l == d) {
    return c == 0;
  }
  lld s = f(d + 1, c, m && v[d] == 0);
  if (c == 0) {
    return s;
  }
  if (m) {
    if (v[d] == 0) {
      return s;
    }
    return s + (v[d] - 1) * f(d + 1, c - 1, false) + f(d + 1, c - 1, true);
  } else {
    return s + 9 * f(d + 1, c - 1, false);
  }
}

int main(void) {
  string n;
  cin >> n >> k;
  l = n.length();
  v = vector<lld>(l);
  for (lld i = 0; i < l; i++) {
    v[i] = n.c_str()[i] - '0';
  }
  cout << f(0, k, true) << "\n";
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par, w;
    
    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
 
    int wei(int x) {
        return w[root(x)];
    }
};

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    vector<P> c(n), d(n);
    rep(i, n) {
        cin >> a[i];
        c[i] = {a[i], i};
    }
    rep(i, n) {
        cin >> b[i];
        d[i] = {b[i], i};
    }
    sort(all(c));
    sort(all(d));
    rep(i, n) {
        if(c[i].fr > d[i].fr) {
            cout << "No" << endl;
            return;
        }
    }
    UnionFind uf(n);
    vector<int> p(n, -1);
    rep(i, n) {
        p[d[i].sc] = c[i].sc;
    }
    rep(i, n) {
        uf.merge(i, p[i]);
    }
    set<int> se;
    rep(i, n) {
        se.insert(uf.root(i));
    }
    if(se.size() >= 2) {
        cout << "Yes" << endl;
        return;
    }
    rep(i, n - 1) {
        if(c[i + 1].fr <= d[i].fr) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

long long n, m, d;
double ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m >> d;
	if(n <= 2*d || d == 0) ans = 1;
	else ans = (2*n-2*d)/(double)n;
	ans *= m-1;
	ans /= n;
	printf("%.10f\n", ans);
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);

    map<int, ll> imp, jmp;
    for(int i=0; i<n; i++)
    {
        imp[as.at(i)+i+1]++;
        jmp[-as.at(i)+i+1]++;
    }
    ll ans = 0;
    for(auto [k, v] : imp)
    {
        ans += jmp[k] * v;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 38204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] o = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        for (int i = 0 ; i < t.length ; i++) {
            System.out.print(o[i]);
            System.out.print(t[i]);
        }
        if (t.length  == o.length) {
            System.out.print("\n");
        } else {
            System.out.print(o[o.length - 1] + "\n");
        }
    }

}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 998244353
typedef pair<int,int> pii;
int N;
pii robot[200009];
int f[200009];
stack<pii>st;
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)cin>>robot[i].first>>robot[i].second;
    sort(robot+1,robot+N+1);
    f[N+1]=1;
    for(int i=N;i>=1;i--){
        int to=robot[i].first+robot[i].second,nxt=i+1;
        while(!st.empty()&&to>robot[st.top().first].first){
            nxt=st.top().second;
            st.pop();
        }
        st.push(make_pair(i,nxt));
        f[i]=(f[i+1]+f[nxt])%mod;
    }
    cout<<f[1]<<endl;
    return 0;
}

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

int main(){
    vector<int> n(3);
    for(int i=0; i<3; i++) cin >> n.at(i);
    sort(n.begin(), n.end());
    if(n[0] == 5 && n[1] == 5 && n[2] == 7) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 3600
s = input()
a = int(s[:2])
b = int(s[2:])

if a <= 12 and b <= 12:
    if a==0 and b!=0:
        print("YYMM")
    elif b==0 and a!=0:
        print("MMYY")
    elif a==0 and b==0:
        print("NA")
    else:
        print("AMBIGUOUS")
elif a<=12 and b>12:
    if a==0:
        print("NA")
    else:
        print("MMYY")
elif a>12 and b<=12:
    if b==0:
        print("NA")
    else:
        print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    string t = s;

    reverse(t.begin(), t.end());

    rep(i, t.size()) {
        if(t[i] == 'b') {
            t[i] = 'd';
        }
        else if(t[i] == 'd') {
            t[i] = 'b';
        }
        else if(t[i] == 'p') {
            t[i] = 'q';
        }
        else if(t[i] == 'q') {
            t[i] = 'p';
        }
    }

    if(t == s) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

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

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

    for (int i = n - 1; i > -1; i--) {
        cout << a[i];
        if (i > 0) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3040
def d_maximum_sum_of_minimum(N, Nodes, C):
    # 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
    import sys
    sys.setrecursionlimit(10**6)

    int_list = list(sorted(C))
    graph = [[] for _ in range(N)]
    for u, v in Nodes:  # 0-basedとする
        graph[u - 1].append(v - 1)
        graph[v - 1].append(u - 1)

    def traverse_tree(parent, current, ret=[0] * N):
        """各頂点にCの値が大きなもの順に書き込んでいく"""
        def dfs(p, c):
            ret[c] = int_list.pop()
            for next_edge in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge)
        dfs(parent, current)
        return ret
    tmp = traverse_tree(-1, 0)
    return str(sum(tmp[1:])) + '\n' + ' '.join(map(str, tmp))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
print(d_maximum_sum_of_minimum(N, Nodes, C))

Measured memory_bytes: 17816
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int h[] = new int[n];
    boolean ju[] = new boolean[n];

    for(int i = 0 ; i < n ; ++i){
      h[i] = sc.nextInt();
      ju[i] = true;
    }
    
    for(int i = 0 ; i < m ; ++i){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(h[a-1]>=h[b-1]) ju[b-1]=false;
      if(h[a-1]<=h[b-1]) ju[a-1]=false;
    }
    
    int count = 0;
    for(int i = 0 ; i < n ; ++i){
      if(ju[i]) count++;
    }
    System.out.println(count);

  }
}

Measured memory_bytes: 59760
#include <stdio.h>
#include <math.h>
int main(void)
{
	int N, D;
	int X[11][11];
	long long sum = 0;
	int count = 0;
	scanf("%d %d", &N, &D);
	for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= D; j++)
		{
			scanf("%d", &X[i][j]);
		}
	}
	for(int i = 1; i < N; i++)
	{
		for(int j = i + 1; j <= N; j++)
		{
			for(int k = 1; k <= D; k++)
			{		
				sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			if((int)(sqrt(sum)) * (int)(sqrt(sum)) == sum)
				count++;
			sum = 0;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int d, e;
    while(1){
        cin >> d >> e;
        if(d + e == 0) break;
        double ans = 10000000000;
        rep(i, 0, d){
            int dist = i * i + (d - i) * (d - i);
            double dt = sqrt((double)dist);
            ans = min(ans, fabs(dt - (double)e));
        }
        printf("%.15lf\n", ans);
    }
}

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

int main(){
  int n,m;
  int hoge,fuga,ans = 0;
  int count = 0;
  cin >> n >> m;
  int imosu[100001] = {0};
  for(int i = 0; i < m;i++){
    cin >> hoge >> fuga;
      imosu[hoge-1]++;
      imosu[fuga]--;
  }
  for(int i = 0;i < n;i++){
    count += imosu[i];
    if(count == m){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long ma = long.Parse(input[1]);
    long mb = long.Parse(input[2]);
    long[,] vertexes = new long[n,3];
    long answer = long.MaxValue-99999;
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
      vertexes[i,2] = nums[2];
    }

    long[][][] dp = new long[n+1][][];
    for(long i = 0; i <= n; i++)
    {
      dp[i] = new long[ma*n+1][];
      for(long j = 0; j <= ma*n; j++)
      {
        dp[i][j] = new long[mb*n+1];
      }
    }

    for(long nL = 0; nL <= n; nL++)
    {
      for(long maL = 0; maL <= ma*n; maL++)
      {
        for(long mbL = 0; mbL <= mb*n; mbL++)
        {
          if(nL + maL + mbL > 0) dp[nL][maL][mbL] = long.MaxValue-99999;
          if(nL-1>=0 && maL-vertexes[nL-1,0] >= 0 && mbL-vertexes[nL-1,1] >= 0)
          {
            dp[nL][maL][mbL] = Math.Min
              (dp[nL][maL][mbL], dp[nL-1][maL-vertexes[nL-1,0]][mbL-vertexes[nL-1,1]]+vertexes[nL-1,2]);
          }
          if(nL-1>=0)
          {
            dp[nL][maL][mbL] = Math.Min(dp[nL][maL][mbL], dp[nL-1][maL][mbL]);
          }
          if(ma*mbL == mb*maL && maL != 0) answer = Math.Min(answer, dp[nL][maL][mbL]);
          //Console.WriteLine(nL+" "+maL+" "+mbL+" "+dp[nL][maL][mbL]);
        }
      }
    }
    if(answer == long.MaxValue-99999) answer = -1;
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 81976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
int main(){
    ll n;
    cin >> n;


    ll ans = 0;
    ll cnt = 1;
    while(n>0){
        n /= 2;
        ans += cnt;
        cnt *= 2;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long INF = 1L << 60;
	static long[] h = new long [100010];
	static long[] dp = new long [100010];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for(int i=0;i<n;i++)h[i] = Long.parseLong(sc.next());
		sc.close();
		//初期化(INF)
		Arrays.fill(dp,INF);
		dp[0] = 0;

		for(int i=1;i<n;i++) {
			if(chmin(dp[i],dp[i-1]+Math.abs(h[i]-h[i-1]))) {
				dp[i]=dp[i-1]+Math.abs(h[i]-h[i-1]);
			}
			if(i>1) {
				if(chmin(dp[i], dp[i-2]+Math.abs(h[i]-h[i-2]))) {
					dp[i]=dp[i-2]+Math.abs(h[i]-h[i-2]);
				}
			}
		}
		System.out.println(dp[n-1]);

	}
	private static boolean chmin(long a, long b) {
		if (a > b) { return true; } return false;
	}

}


Measured memory_bytes: 48424
#include <stdio.h>
int main(){
  int	d;
  scanf("%d", &d);
  if	 (d==22){ printf("Christmas Eve Eve Eve"); }
  else if(d==23){ printf("Christmas Eve Eve"); }
  else if(d==24){ printf("Christmas Eve"); }
  else if(d==25){ printf("Christmas"); }
  return 0;
}

Measured memory_bytes: 1724
using System;
using System.Numerics; 

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str1=Console.ReadLine().Split(' ');
      string[] str2=Console.ReadLine().Split(' ');
      long T=long.Parse(Console.ReadLine());
      long A=long.Parse(str1[0]);
      long V=long.Parse(str1[1]);    
      long B=long.Parse(str2[0]); 
      long W=long.Parse(str2[1]); 
	long ans=Math.Abs(A-B);
      if(ans<=(T*(V-W))){
        Console.WriteLine("YES");
    }else{
        Console.WriteLine("NO");
    }
  }
  }
}


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

string s;

bool isPal(int b, int e){
    for(int i = b, j = e ; i < j; i++, j--)
        if(s[i] != s[j])
            return 0;
    return 1;
}

int main()
{
    cin >> s;

    int n = s.size();

    if(isPal(0, (n - 1) / 2 - (n  % 2 ? 1 : 0)) && isPal(n / 2 + (n % 2 ? 1 : 0), n - 1) && isPal(0, n - 1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int ans = gcd(a, b);
    int cnt = 0;
    while (ans >= 1)
    {
        if (a % ans == 0 && b % ans == 0)
            cnt++;
        if (cnt == k)
        {
            cout << ans << endl;
            return 0;
        }
        ans--;
    }
}


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

int main() {
  int n,ans = 0,preans= 0;string s;
  cin >> n >> s;
  for(int i = 0;i < n;i++){
    if(s.at(i) == 'I'){
      preans++;
    }
    else{
      preans--;
    }
    if(preans > ans){
      ans = preans;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    [a, b, c] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    c = String.to_integer(c)
    if a + b + c <= 21 do 
    IO.puts("win")
    else 
    IO.puts("bust") 
    end
  end
end


Measured memory_bytes: 30728
#include <cstdio>

#define MAX 150

char sp[MAX][MAX];
//u r d l
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};

bool range(int x,int y,int n){
  if(0 > x || x >= n || 0 > y || y >= n){
    return false;
  }
  return true;
}

void make(int n){
  int x = 0 , y = n-1 ,dir = 0;

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      sp[i][j] = '.';
    }
  }

  int end = 0;
  sp[y][x] = '#';
  while(true){
    int nx = x + dx[dir];
    int ny = y + dy[dir];  

    bool flg = true;
    if(!range(nx,ny,n)){
      flg = false;
    }

    for(int i = 0 ; i < 4 ; i++){
      int nnx = nx + dx[i];
      int nny = ny + dy[i];

      if((x == nnx && y == nny) 
	 || !range(nnx,nny,n)){
	continue;
      }

      if(sp[nny][nnx] == '#'){
	flg = false;
	break;
      }
    }

    if(!flg){
      dir++;
      dir = dir % 4;
      end++;
      if(end == 4) return;
    }else{
      end = 0;
    }

    if(flg){
      sp[ny][nx] = '#';
      x = nx;
      y = ny;
    }
  }
}

int main(){
  int d,n;
  bool ok = false;

  scanf("%d" ,&d);
  while(d--){
    scanf("%d" ,&n);

    if(ok){
      puts("");
    }
    ok = true;

    make(n);
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	if(sp[i][j] == '.'){
	  printf(" ");
	}else{
	  printf("%c" ,sp[i][j]);
	}
      }
      puts("");
    }   
  }

  return 0;
}

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

typedef pair<int, int> P;

int N;
vector<vector<long long>> dp;
vector<P> A;

long long dfs(int l, int r) {
    if (dp[l][r] != -1) return dp[l][r];
    if (l == 0 && r == 0) return dp[l][r] = 0;
    long long res = -1;
    long long activeness = A[l + r - 1].first, idx = A[l + r - 1].second;
    if (l >= 1) res = max(res, dfs(l - 1, r) + activeness * abs(idx - (l - 1)));
    if (r >= 1) res = max(res, dfs(l, r - 1) + activeness * abs(idx - (N - r)));
    return dp[l][r] = res;
}

int main() {
    cin >> N;
    dp.resize(N + 1, vector<long long>(N + 1));
    for (int i = 0; i < N + 1; ++i) for (int j = 0; j < N + 1; ++j) dp[i][j] = -1;
    for (int i = 0; i < N; ++i) {
        int a;  cin >> a;
        A.push_back(P(a, i));
    }
    sort(A.begin(), A.end(), greater<P>());

    long long ans = -1;
    for (int l = 0; l < N + 1; ++l) {
        int r = N - l;
        ans = max(ans, dfs(l, r));
    }
    cout << ans << endl;
}


Measured memory_bytes: 35172
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int W, H;
    while (1) {
        scanf("%d%d", &W, &H);
        if ((W == 0) && (H == 0))break;
        else {
            for (int i = 1; i <= W; i++) {
                for (int j = 1; j <= H; j++) {
                    printf("#");
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2116
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans, win = 0, {'r': 'P', 's': 'R', 'p': 'S'}
for i in range(K):
    prev = '-'
    for t in T[i::K]:
        if not prev == win[t]:
            ans += eval(win[t])
            prev = win[t]
        else:
            prev = '-'
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    int g[15][15];
    while(cin>>n){
        if(n==0) break;
        memset(g,0,sizeof(g));
        int x=n/2, y=n/2+1;
        rep(i,n*n){
            g[y][x]=i+1;
            y=(n+y+1)%n;
            x=(n+x+1)%n;
            if(g[y][x]){
                y=(n+y+1)%n;
                x=(n+x-1)%n;
            }
        }
        rep(i,n){
            rep(j,n)
                printf("%4d",g[i][j]);
            puts("");
        }
    }
}

Measured memory_bytes: 1144
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[0])
answer = 0
for ab in AB:
    if ab[1] <= M:
        answer += (ab[0]*ab[1])
        M -= ab[1]
    else:
        answer += (ab[0]*M)
        M = 0
        break
        
print(answer)

Measured memory_bytes: 29788
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >>s; 
    rep(i,3){
        if(s[i]=='1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s <<endl;
    return 0;
} 

Measured memory_bytes: 256
/*
Author: Xjrjyy
LANG: C++
PROG: agc021_a.cpp
Mail: admin@xjrjyy.com
Blog: https://blog.xjrjyy.cn/
*/

#include <cstdio>
#include <cctype>
#include <vector>
#include <iostream>

#define MAXN ()

long long n;
int ans, ans2;

int main()
{
    scanf("%lld", &n);
    while (n >= 10)
    {
        ans += n % 10;
        ans2 += 9;
        n /= 10;
    }
    ans += n;
    ans2 += n - 1;
    printf("%d\n", std::max(ans, ans2));
    return 0;
}


Measured memory_bytes: 3780
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
g = [[] for _ in range(n)]
for i in range(n):
    a = inp()
    for j in range(a):
        x,y = inpl()
        g[i].append([x-1,y])
res = 0
for fl in itertools.product(range(2), repeat=n):
    ch = [i for i in fl]
    ok = True
    for i,f in enumerate(fl):
        if not f: continue
        for x,y in g[i]:
            if ch[x] != y:
                ok = False
    if ok: res = max(res, sum(fl))
print(res)

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

int Prime(int x){
	if(x<2) return 0;
	else if( x==2 ) return 1;
	if( x%2==0 ) return 0;
	for(int i=3; i*i<=x; i++){
		if( x%i==0 ) return 0;
	}
	return 1;
}


int main(){
	int n,s=0,x[10000];
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> x[i];
		if( Prime(x[i]) ) s++;
	}

	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		sc.close();

		if (2 * n >= m) {
			System.out.println(m / 2);
		} else {
			System.out.println(n + (m - 2 * n) / 4);
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

ll N, K;

int main() {
    cin >> N >> K;
    N %= K;
    cout << min( N, abs(N - K)) << endl;
}


Measured memory_bytes: 3560
#include <stdio.h>

int main()
{
    unsigned short H, A, out;
    scanf("%hu %hu", &H, &A);
    if (H%A ==0)
    {
        out = H/A;
    }
    else
    {
        out = H/A +1;
    }
    
    printf("%hu", out);

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    cout << max(0, v[n/2]-v[n/2-1]) << endl;
    return 0;
}

Measured memory_bytes: 640
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  a = [nil] * 3
  3.times do |y|
    a[y] = InputLine.to_ia
  end

  n = InputLine.to_i
  n.times do |i|
    b = InputLine.to_i
    
    3.times do |y|
      3.times do |x|
        a[y][x] = 0 if a[y][x] == b
      end
    end
  end

  flag = false

  3.times do |y|
    _flag = true
    3.times do |x|
      _flag = false if a[y][x] > 0
    end
    flag = true if _flag
  end

  3.times do |x|
    _flag = true
    3.times do |y|
      _flag = false if a[y][x] > 0
    end
    flag = true if _flag
  end

  [
    [[0, 0], [1, 1], [2, 2]],
    [[0, 2], [1, 1], [2, 0]]
  ].each do |v|
    _flag = true
    v.each do |x|
      _flag = false if a[x[0]][x[1]] > 0
    end
    flag = true if _flag
  end

  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
main(i,m,h,t,a){
    char s[201];
    for(;scanf("%s%d",s,&m),*s!='-';puts("")){
    for(i=t=0,a=strlen(s);i<m;scanf("%d",&h),t+=h,i++);
    for(i=0;i<a;printf("%c",s[(t+i++)%a]));
    }
}

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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

set <char> s;
char c;
int n;

int main () {
    scanf("%d ", &n);
    for (int i = 0; i < n; i++) {
        scanf(" %c", &c);
        s.insert(c);
    }
    int ans = s.size();
    if (ans == 4) printf("Four\n");
    else if (ans == 3) printf("Three\n");
    else printf("%d\n", ans);
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AFiftyFifty {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        map<char, int> cnt;
        REP(i, s.size()) {
            cnt[s[i]]++;
        }

        if (cnt.size() != 2) {
            cout << "No" << endl;
            return;
        }

        bool ok = true;
        for (auto kv : cnt) {
            if (kv.second != 2) {
                ok = false;
            }
        }
        if (ok) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AFiftyFifty solver;
    solver.solve(in, out);
    return 0;
}



Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		//String s = "5 4 2 2 1";
		String[] str = s.split(" ");
		int w = Integer.parseInt(str[0]);
		int h = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		int y = Integer.parseInt(str[3]);
		int r = Integer.parseInt(str[4]);

		int a = x + r;
		int b = y + r;
		int c = x - r;
		int d = y - r;
		if (a <= w && b <= h && c >= 0 && d >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24480
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    bool being=false;
    string ans;
    for(int type=0;type<4;type++){
        vector<bool> sorw(n); // sheep=true; wolf=false;
        sorw[0]=type&1;
        sorw[1]=(type>>1)&1;
        for(int i=2;i<n;i++){
            if(sorw[i-1]){
                if(s[i-1]=='o'){
                    sorw[i]=sorw[i-2];
                }else{
                    sorw[i]=!sorw[i-2];
                }
            }else{
                if(s[i-1]=='x'){
                    sorw[i]=sorw[i-2];
                }else{
                    sorw[i]=!sorw[i-2];
                }
            }
        }
        bool f=true;
        if(sorw[0]){
            if(s[0]=='o' && sorw[1]!=sorw[n-1]) f=false;
            if(s[0]=='x' && sorw[1]==sorw[n-1]) f=false;
        }else{
            if(s[0]=='x' && sorw[1]!=sorw[n-1]) f=false;
            if(s[0]=='o' && sorw[1]==sorw[n-1]) f=false;
        }

        if(sorw[n-1]){
            if(s[n-1]=='o' && sorw[0]!=sorw[n-2]) f=false;
            if(s[n-1]=='x' && sorw[0]==sorw[n-2]) f=false;
        }else{
            if(s[n-1]=='x' && sorw[0]!=sorw[n-2]) f=false;
            if(s[n-1]=='o' && sorw[0]==sorw[n-2]) f=false;
        }

        if(f){
            being=true;
            for(int i=0;i<n;i++){
                if(sorw[i]){
                    ans+='S';
                }else{
                    ans+='W';
                }
            }
            break;
        }
    }
    if(!being){
        cout<<-1<<endl;
        return 0;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3864
#include <stdio.h>
int main(void){
    
    int N,x;
    int i,j,count = 0,big,ct = 0;
    
    scanf("%d %d",&N,&x);
    
    int okasi[N];
    
    for(i = 0; i < N; i++){
        scanf("%d",&okasi[i]);
    }
    for(i = 0; i < N; i++){
        for(j = i; j < N; j++){
            if(okasi[i] > okasi[j]){
                big = okasi[i];
                okasi[i] = okasi[j];
                okasi[j] = big;
            }
        }
    }
    
    for(i = 0; i < N; i++){
        ct += 1;
        if(ct == N && x != okasi[ct - 1])break;
        x -= okasi[i];
        if(x < 0 )break;
        count += 1;
    }
    
    printf("%d",count);
    
    return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstring>
#include<string.h>
using namespace std;
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define T int t;cin>>t;while(t--)
#define MOD 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define S second n
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<int>
#define vecl vector<long long int> 
#define vec1 vector<string>
#define vec2 vector<vector<int>>
#define all(n) (n).begin(), (n).end()
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
//Author:-Avinash//
    
#define MAX 1000
 
int main()
{

    FAST
    ll n;
    double d;
    cin>>n>>d;
    double x1,y1;
    ll res;
    ll count  = 0;
    fo(i,n){
      cin>>x1>>y1;\
      res = (x1*x1) + (y1*y1);
      if(res <= d*d){
        count++;
      }
    }
    cout<<count;
    return 0;

 }

Measured memory_bytes: 3792
#include <iostream>
using namespace std;
// A * n = B * k + C
int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 0; i < B; i++) {
    if (C == (A * i % B)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[11];
    int i,C_count=0,flag=0;
    
    scanf("%s",s);
    int len = strlen(s);
    
    if(s[0] != 'A'){
        printf("WA\n");
        return 0;
    }
    if(s[1] == 'C' || s[1] < 97 || s[1] > 122){
        printf("WA\n");
        return 0;
    }
    
    for(i = 2; i < len-1; i++){
        if(s[i] == 'C'){
            C_count++;
        }else{
            if(s[i] < 97 || s[i] > 122){
                flag++;
//                printf("s[%d] is not small\n",i);
            }
        }
    }
    if(s[len-1] < 97 || s[len-1] > 122) {
        flag++;
//        printf("s[%d] is not small\n",len-1);
    }
    
    if(flag == 0 && C_count == 1) printf("AC\n");
    else printf("WA\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c>> d;
    
    while(a > 0 and c > 0){
        c -= b;
        a -= d;
    }
    if(a <= 0 and c <= 0){
        cout << "Yes" << endl;
    }else if(a <= 0){
        cout << "No" << endl;
    }else{
        cout <<"Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int N;
int A[301][301];
bool B[301][301];
int main()
{
  int N; scanf("%d", &N);
  for(int i=0; i<N; ++i) for(int j=0; j<N; ++j)
  {
    scanf("%d", &A[i][j]);
    B[i][j] = true;
  }
  for(int i=0; i<N; ++i)
    for(int j=0; j<N; ++j)
      for(int k=0; k<N; ++k)
      {
        if(i != j && j != k && k != i)
        {
          if(A[i][j]+A[j][k] < A[i][k])
          {
            puts("-1"); return 0;
          }
          else if(A[i][j] + A[j][k] == A[i][k])
            B[i][k] = false;
        }
      }
  long long ans = 0;
  for(int i=0; i<N; ++i)
    for(int j=0; j<i; ++j)
      if(B[i][j]) ans += A[i][j];
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include <cmath>
#include<vector>
#include<cstdlib>
using namespace std;

int main() {
	char n[4]; int i, ans;
	cin >> n;
	for (i = 0; i < 3; i++) {
		if (n[i] == '1')n[i] = '9';
		else n[i] = '1';
	}
	ans = atoi(n);
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;


int main() {
    
    while (1) {
        double n = 0;
        double sum = 0, sum2 = 0;
        double average = 0.0;
        double output = 0.0;
        cin >> n;
        
        if (n == 0) break;
        
        vector<double> array, array2;
        
        for (int i = 0; i < n; ++i) {
            int score;
            cin >> score;
            array.push_back(score);
            sum += array[i];
        }
        
        average = sum / n;
        
        for (int i = 0; i < n; ++i) {
            double diff = array[i] - average;
            array2.push_back(pow(diff, 2.0));
            sum2 += array2[i];
        }
        
        output = sqrt(sum2 / n);
        
        cout << output << "\n";
        //printf("%f\n", output);
    }
    return 0;
}

Measured memory_bytes: 3296
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for x in (-1, 0, 1):
    for y in (-1, 0, 1):
        test_case.append((x, y))
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((x1, y1))
    test_case.append((-x1, -y1))
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
        else:
            tx += x2
            ty += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    if(s[0]==s[2])cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256