akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
map<int,vector<pair<int,int>>>a;
signed main()
{
	int n,x,d;
	cin>>n>>x>>d;
	if(d==0)
	{
		cout<<(x?n+1:1)<<endl;
		return 0;
	}
	if(d<0)
		x=-x,d=-d;
	for(int i=0;i<=n;i++)
	{
		int b=i*x,mn=i*(i-1)/2,mx=(2*n-i-1)*i/2;
		a[b%d].emplace_back(mn+b/d,mx+b/d);
	}
	int ans=0;
	for(auto &zh:a)
	{
		vector<pair<int,int>> &v=zh.second;
		sort(v.begin(),v.end());
		long long r=-1e18;
		for(auto i:v)
		{
			ans+=max(i.second-max(i.first,r)+1,0LL);
			r=max(r,i.second+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 22144
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if ( s.equals("hi") ) {
			System.out.println("Yes");
		} else if ( s.equals("hihi") ) {
			System.out.println("Yes");
		} else if ( s.equals("hihihi") ) {
			System.out.println("Yes");
		} else if ( s.equals("hihihihi") ) {
			System.out.println("Yes");
		} else if ( s.equals("hihihihihi") ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}			
	}
}

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

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

// 再帰関数による全探索
bool search(int n, vector<int> &A, int i, int m)
{
  if (m == 0)
    return true;
  else if (i >= n)
    return false;

  return (search(n, A, i + 1, m) || search(n, A, i + 1, m - A[i]));
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  int q;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int m;
    cin >> m;
    search(n, A, 0, m) ? cout << "yes" << endl : cout << "no" << endl;
  }
  return 0;
}

// bit全探索だと少し遅いので再帰の方が良さげ
// i番目を使う場合と使わない場合　iの値を1進めてi+1の場合を更新したmで考える．mがちょうど0になった場合にtrueを返し，iがnを超えた場合にfalseを返す



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

using namespace std;

typedef long long ll;

void pv(vector <int> &v) {
    for(int i = 0; i < v.size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve() {
	
}

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

    ll n;
    cin >> n;
    vector <int> a(n, 0);
    vector <int> b(n, 0);
    
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    
    reverse(b.begin(),b.end());
    // pv(b);
    int prob = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] == b[i]) prob++;
    }
    int c = -1;
    int l = INT_MAX;
    int r = INT_MIN;
    for(int i = 0; i < n; i++) {
        if(a[i] == b[i]) {
            c = a[i];
            l = i;
            break;
        }
    }
    for(int i = n-1; i >= 0; i--) {
        if(a[i] == b[i]) {
            r = i;
            break;
        }
    }

    int toSwap = (r-l+1);
    if(toSwap == 0 || prob == 0) {
        cout << "Yes" << endl;
        pv(b);
        return 0;
    }
    int l0 = l;
    int r0 = r;
    int avail = 0;
    for(int i = 0; i < l; i++) {
        if(a[i] != c && b[i] != c) avail++;
    }
    for(int i = r+1; i < n; i++) {
        if(a[i] != c && b[i] != c) avail++;
    }
    if(avail < toSwap) {
        cout << "No" << endl;
        return 0;
    }
    else cout << "Yes" << endl;

    int i = 0;
    int j = r0+1;

    while(l <= r) {
        if(i < l0 && i < n) {
            if(a[i] != c && b[i] != c) {
                swap(b[i], b[l]);
                l++;
            }
        }
        i++;
        if(i == n) break;
    }
    // if(j < n) {
        while(l <= r) {
            if(j < n && a[j] != c && b[j] != c) {
                swap(b[j], b[l]);
                l++;
            }
            j++;
            // if(j == n) break;
        }
    // }


    // while(l <= r) {
    //     if(i < l0 && a[i] != c && b[i] != c) {
    //         swap(b[i], b[l]);
    //         l++;
    //         i++;
    //         continue;
    //     }
    //     else if(i == l0 && a[j] != c && b[j] != c && j < n) {
    //         swap(b[j], b[l]);
    //         l++;
    //         j++;
    //         continue;
    //     }
    //     i++;
    //     if(i == l0) j++;
    // }
    pv(b);
    


    
    return 0;
}

Measured memory_bytes: 4768
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

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

    int max_a = 0;
    int min_a = INT_MAX;
    map <int, int> a_count;
    for(int i = 0; i < N; i++){
        max_a = max(max_a, a[i]);
        min_a = min(min_a, a[i]);
        if(a_count.find(a[i]) != a_count.end()){
            a_count[a[i]] += 1;
        } else {
            a_count[a[i]] = 1;
        }
    }


    if(min_a < max_a / 2){
        cout << "Impossible" << endl;
        return 0;
    }

    int lowest;
    if(max_a % 2 == 0){
        lowest = max_a / 2;
    } else {
        lowest = max_a / 2 + 1;
    }

    if(max_a % 2 == 0 && a_count[lowest] != 1){
        cout << "Impossible" << endl;
        return 0;
    }
    if(max_a % 2 == 1 && a_count[lowest] != 2){
        cout << "Impossible" << endl;
        return 0;
    }
    
    if(a_count[max_a] == 1){
        cout << "Impossible" << endl;
        return 0;
    }

    for(int i = lowest; i < max_a; i++){
        if(a_count.find(i) == a_count.end()){
            cout << "Impossible" << endl;
            return 0;
        }
    }

    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll n,a,b,ans;
ll pow(ll a,ll n)
{
	ll res=1ll;
	while(n)
	{
		if (n&1)
            res=res*a%MOD;
		a=a*a%MOD;
		n>>=1;
	}
	return res%MOD;
}
ll C(ll n,ll m)
{
	if(n<m)
        return 0;
	if(n==m||!m)
	return 1;
	if(m<n-m)
	m=n-m;
	ll a=1;
	for(ll i=m+1;i<=n;++i)
	a=a*i%MOD;
	ll b=1;
	for(ll i=1;i<=n-m;++i)
	b=b*i%MOD;
	return a*pow(b,MOD-2)%MOD;
}
int main()
{
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	ans=((pow(2ll,n)-C(n,a)-C(n,b)-1)%MOD+MOD)%MOD;
	cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int a[100005];
int dp[100005];

int main() {
	int n;
	cin >>n;
	for (int i=0 ; i<n ; i++) {
		cin >>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for (int i=2 ; i<n ; i++) {
		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
	}
	cout <<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int s, w;
  cin >> s >> w;
  if (s <= w)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;

  int64_t S = 0;
  for(int i = 0; i <= N ;i++){
    if (i % 3 != 0 && i % 5 != 0){

    S += i;
  }
  else{
 
    S += 0;
    
  }
  
  }
      cout << S << endl;
}

Measured memory_bytes: 3624
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
ret = n
for s in range(n+1):
    c = 0
    v = s
    while 0 < v:
        c += v % 6
        v //= 6
    v = n - s
    while 0 < v:
        c += v % 9
        v //= 9
    ret = min(ret, c)
print(ret)

Measured memory_bytes: 12440
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] array = {in.nextInt(), in.nextInt(), in.nextInt()};
            Arrays.sort(array);
            if (array[0] == 5 && array[1] == 5 && array[2] == 7) {
                out.append("YES");
            } else {
                out.append("NO");
            }
        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<int> v[200200];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for(int i=1;i<n;i++){
        int a, b; cin >> a >> b;
        if(a > b) swap(a, b);
        v[b].push_back(a);
    }
    ll ans = 0, sum = 0;
    for(int i=1;i<=n;i++){
        sum += i;
        for(int x : v[i]) sum -= x;
        ans += sum;
    }
    cout << ans;
}

Measured memory_bytes: 14540
from bisect import bisect_right

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

s = [0] * N
for i in range(N) :
    s[i] = N - bisect_right(C, B[i])
for i in range(N-2, -1, -1) :
    s[i] += s[i+1]

ret = 0
for i in range(N) :
    a = bisect_right(B, A[i])
    if a < N :
        ret += s[a]
print(ret)

Measured memory_bytes: 105444
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), Sorted(N);
    map<int, int> m;
    int t;
    rep(i,N) {
        scanf("%d", &t);
        A[i] = t;
        Sorted[i] = A[i];
    }
    sort(Sorted.begin(), Sorted.end());
    rep(i,N) {
        m.insert(make_pair(Sorted[i], i));
    }
    int ans = 0;
    rep(i,N) {
        if (i % 2 != m.at(A[i]) % 2) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<vector>
#include<algorithm>
int main(){
    int n,a;
    long long k,b;
    std::vector<std::pair<int,long long>> v;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d%lld",&a,&b);
        v.push_back({a,b});
    }
    std::sort(v.begin(),v.end());
    for(auto itr=v.begin();itr!=v.end();itr++){
        k-=(*itr).second;
        if(k<=0){
            printf("%d",(*itr).first);
            return 0;
        }
    }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "Yes";
const string NO = "No";

signed main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  vector<string> A(N);
  vector<string> B(M);
  REP(x, N) {
    cin >> A.at(x);
  }
  REP(x, M) {
    cin >> B.at(x);
  }

  REP(sy, N-M+1) {
    REP(sx, N-M+1) {
      bool isSucced = true;
      FOR(y, sy, M+sy) {
        FOR(x, sx, M+sx) {
          if (!isSucced) break;
          if (A.at(y).at(x) != B.at(y-sy).at(x-sx)) isSucced = false;
        }
        if (!isSucced) break;
      }
      if (isSucced) {
        cout << YES << endl;
        return 0;
      }
    }
  }

  cout << NO << endl;
}


Measured memory_bytes: 256
def main():
    n = input()
    if n[0] == '0':
        print('111')
    elif n[0] < n[1] or n[0] < n[2]:
        print((int(n[0]) + 1) * 111)
    else:
        print(int(n[0]) * 111)


if __name__ == '__main__':
    main()


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

vector<long long int> a,b,c;

int main() {

    int n;

    cin >> n;

    a.resize(n);
    b.resize(n);
    c.resize(n);


    for(int i=0;i<n;i++){
        scanf(" %lld",&a[i]);
        a[i] = -a[i];
    }
    for(int i=0;i<n;i++){
        scanf(" %lld",&b[i]);
    }
    for(int i=0;i<n;i++){
        scanf(" %lld",&c[i]);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    int ai=0,bi=0,ci=0;

    long long int ans = 0;

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

        vector<long long int>::iterator a_lower = upper_bound(a.begin(),a.end(),-b[i]);
        
        if(a_lower == a.end()){
            continue;
        }

        vector<long long int>::iterator c_upper = upper_bound(c.begin(),c.end(),b[i]);

        if(c_upper == c.end()){
            continue;
        }

        ans += (a.end() - a_lower) * (c.end()  - c_upper);


        /*

        while(a[ai] >= b[bi]){
            bi++;
        }

        if(bi == n){
            break;
        }

        while (b[bi] >= c[ci]) {
            ci++;
        }

        if (ci == n) {
            break;
        }

        int copybi = bi, copyci = ci;

        long long int b_ans = ans;

        for (int j = copybi; j < n; j++) {

            while (b[copybi] >= c[copyci]) {
                copyci++;
            }

            if (copyci == n) {
                break;
            }

            ans += (n - copyci);

            copybi++;

        }




        ai++;

        */

    }

    cout << ans << endl;



    return 0;
}

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

using pii = std::pair<int, int>;

struct Node {
	int min{-10000000}, max{10000000};
	std::list<int> edges;
	bool visited{};
};
std::vector<Node> tree;

pii construct(int, int, int, int);

int main()
{
	int n;
	scanf("%d", &n);
	tree.resize(n);
	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		tree[a].edges.push_back(b);
		tree[b].edges.push_back(a);
	}
	int k, start_v, start_p;
	scanf("%d", &k);
	for (int i = 0; i < k; i++)
	{
		int v, p;
		scanf("%d%d", &v, &p);
		v--;
		tree[v].min = tree[v].max = p;
		if (!i)
		{
			start_v = v;
			start_p = p % 2;
		}
	}
	pii result{construct(start_v, start_p, tree[start_v].min, tree[start_v].max)};
	if (result.first == -1)
		printf("No\n");
	else
	{
		printf("Yes\n");
		for (auto& e: tree) e.visited = false;
		construct(start_v, start_p, tree[start_v].min, tree[start_v].max);
		for (auto& node: tree)
			printf("%d\n", node.min);
	}

	return 0;
}

pii construct(int v, int p, int min, int max)
{
	Node& node{tree[v]};
	if (node.visited) return pii(node.max + 1, node.min - 1);
	node.visited = true;
	if (node.min > -10000000 && node.min % 2 != p) return pii(-1, -1);
	if (node.max < min || node.min > max) return pii(-1, -1);
	node.max = std::min(max, node.max);
	node.min = std::max(min, node.min);
	for (auto &e: node.edges)
	{
		pii tmp{construct(e, 1 - p, node.min - 1, node.max + 1)};
		if (tmp.first == -1) return std::move(tmp);
		node.max = std::min(node.max, tmp.first);
		node.min = std::max(node.min, tmp.second);
		if (node.max < node.min)
			return pii(-1, -1);
	}
	return pii(node.max + 1, node.min - 1);
}

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

bool check(int n, int m, int k) {
    
    for (int b = 0; b <= m; ++b) {
        int p = k - b * n;
        int q = m - 2 * b;
        
        //cout<<b<<" "<<p<<" "<<q<<endl;
        if (q == 0) {
            if (p == 0)
                return true;
            continue;
        }
        if (p % q == 0 && p / q <= n && p / q >= 0)
            return true;
    }
    return false;
}

int main() {
    int n, m, k;
    cin>>n>>m>>k;
    cout<<(check(n,m,k)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll dp[1010][1010];
const int MOD = 1e9+7;

int main(){
    int H,W;cin >> H >> W;
    char grid[1010][1010];
    rep(i,H)rep(j,W)cin >> grid[i][j];
    dp[1][1]=1;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
        if(!(i==1&&j==1)){
            if(grid[i-1][j-1]!='#')dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%MOD;
            else dp[i][j]=0;
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int a, b;
    cin >> a >> b;

    if (b > 9 && b != 100) {
        a *= 100;
    }
    else if (b == 100) {
        a *= 1000;
    }
    else {
        a *= 10;
    }
    a += b;
    for (int i = 0; i * i <= a; i++) {
        if (i * i == a) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
    int N, maxim = 0;
    cin >> N;
    vector<int> C(N);
    vector<int> V(N);
    vector<int> CmnV;
  
    rep(i,N)cin>>V[i];
    rep(i,N) {
        cin >> C[i];
        CmnV.push_back(V[i] - C[i]);
    }
    sort(CmnV.begin(),CmnV.end(),greater<int>());//()
    rep(i,N){
        if(maxim>maxim+CmnV[i])
            break;
    maxim+=CmnV[i];
    }
    cout<<maxim<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    if(n > 8 || m > 8)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main (void) {
    int a, b;
    cin >> a >> b;
    a--; b--;

    vector<string> brd;
    string s = string(100, '#');
    string t = "";
    rep(i, a) {
        t += ".#";
        if(t.size() == 100) {
            brd.push_back(t);
            brd.push_back(s);
            t = "";
        }
    }
    t += string(100 - t.size(), '#');
    brd.push_back(t);
    brd.push_back(s);

    s = string(100, '.');
    t = "";
    brd.push_back(s);
    rep(i, b) {
        t += "#.";
        if(t.size() == 100) {
            brd.push_back(t);
            brd.push_back(s);
            t = "";
        }
    }
    t += string(100 - t.size(), '.');
    brd.push_back(t);

    cout << brd.size() << " " << 100 << endl;
    rep(i, brd.size()) cout << brd[i] << endl; 

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
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;

void solve(){
    map <string, int> m;
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string str;
    cin >> str;
    m[s] = a;
    m[t] = b;
    m[str] -= 1;
    cout << m[s] << ' ' << m[t];
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
N = input()#str
a = list(map(int,input().split()))
N = int(N)
ave = 0.0
for i in a:
    ave += i
#print("ave",ave)
ave /= N
ave = round(ave)
#print("ave",ave)
sum = 0
for i in range(N):
    sum += (a[i]-ave)**2
print(sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
 
signed main(){
 
	lli n;
	cin>>n;
 
	lli now=0;
	lli x=0;
	lli y=0;
 
	REP(i,0,n){
		lli t,tx,ty;
		cin>>t>>tx>>ty;
 
		lli length = abs(x-tx)+abs(y-ty);
		lli time = t-now;
		if(length>time){
			cout<<"No"<<endl;
			return 0;
		}
		if(length%2!=time%2){
			cout<<"No"<<endl;
			return 0;
		}
		now = t;
		x = tx;
		y = ty;
	}
	cout<<"Yes"<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int val,flag=0;
    for(val=B*10; (val*8)/100<=A; val++){
        if(val/10==B && (val*8)/100==A){
            flag++;
            break;
        }
    }
    if(flag){
        cout << val;
    }else{
        cout << -1;
    }
    return 0;
}


Measured memory_bytes: 256
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    int N, T;
    vector<int> A;
    
    cin >> N >> T;
    A.resize(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    int max_profit = 0;
    int nr = 0;

    int min_buy = A[0];
    for (int i = 1; i < N; i++) {
        if (A[i] - min_buy > max_profit) {
            max_profit = A[i] - min_buy;
            nr = 1;
        } else if (A[i] - min_buy == max_profit) {
            nr++;
        }
        min_buy = min(min_buy, A[i]);
    }

    cout << nr << "\n";

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N), B(N); rep(i, N){cin >> A.at(i) >> B.at(i);}

    vector<int> indices(N);
    iota(indices.begin(), indices.end(), 0);
    sort(indices.begin(), indices.end(), [&A](ll i1, ll i2) {
        return A[i1] < A[i2];
    });
    ll cost = 0;
    for (auto v: indices){
        if (M > B.at(v)){
            cost += A.at(v) * B.at(v);
            M -= B.at(v);
        } else {
            cost += A.at(v) * M;
            break;
        }
    }
    cout << cost << endl;
}

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


Measured memory_bytes: 2176
var
	a, b: integer;

begin 
	readln(a,b);
	if (a>b) and (b>1) then
		writeln('Alice')
	else if (b>a) and (a>1) then
		writeln('Bob')
	else if (a>b) and (b=1) then
		writeln('Bob')
	else if (b>a) and (a=1) then
		writeln('Alice')
	else 
		writeln('Draw');
end.

Measured memory_bytes: 128
import scala.io.StdIn
import scala.collection.mutable.ListBuffer

object Main extends App {
  var n = Int.MaxValue
  var i = 1
  val buff = ListBuffer.empty[(Int, Int)]
  while(n != 0){
    n = StdIn.readLine().trim.toInt
    if(n != 0) {
      buff += ((i, n))
    }
    i += 1
  }
  buff.foreach{ p =>
    println(s"Case ${p._1}: ${p._2}")
  }
}



Measured memory_bytes: 64352
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
#define maxn 300000
int par[maxn];
int ra[maxn];

void init(int n){
    rep(i,n){
        par[i] = i;
        ra[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    
    if(ra[x] < ra[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(ra[x] == ra[y]) ra[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}
int main(){
    int n,m;
    cin >> n >> m;
    int k;
    int l;
    init(maxn-1);
    rep(i,n){
        cin >> k;
        rep(j,k){
            cin >> l;
            unite(i+1,l+1e5+1);
        }
    }
    for(int i=0;i<n;i++){
        if(same(1,i+1)==false) {
            cout << "NO" << endl;
            //cout << i << endl;
            return 0;
        }
    }
    /*rep(i,n){
        cout << find(i+1) << endl;
    }*/
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
max_a = max(A) + 1
counter = [0 for _ in range(max_a)]
 
for i in A:
    for j in range(i, max_a, i):
        counter[j] += 1
res = 0
 
for a in A:
    if counter[a] == 1:
        res += 1
#print(counter)
print(res)

Measured memory_bytes: 195564
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ    見ちゃだめ！
　　 　 /　　　 　 |　
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  vector<vector<int>> dp(1000000, vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        int s;
        if (j == 0)
          s = a[i + 1];
        else if (j == 1)
          s = b[i + 1];
        else if (j == 2)
          s = c[i + 1];
        chmax(dp[i + 1][j], dp[i][k] + s);
      }
    }
  }
  int ma = 0;
  rep(i, 3) ma = max(ma, dp[n - 1][i]);
  cout << ma << endl;
}


Measured memory_bytes: 56064
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = int(input())

x1 = 0
y1 = 0
x2 = -1
y2 = 0
x3 = 1
y3 = -1


# S = abs(x2 * y3 - y2 * x3)
l = round(math.sqrt(S))
x2 = l
y3 = l
while x2 * y3 < S:
    y3 += 1

if x2 * y3 != S:
    y2 = x2 * y3 - S

print(x1, y1, x2, y2, x3, y3)

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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;
    ll k; cin >> k;

    for(int i=0; i<min(k, (ll)s.size()); i++)
        if(s[i]>='2') return cout << s[i], 0;

    cout << 1;
    return 0;
}


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

int main() {
    int S, h, m, s;

    cin >> S;
    // 時間の計算
    h = S / 3600;
    m = (S % 3600) /60;
    s = S % 60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007

ll fastpow(ll x, ll y){
    ll res=1;
    while(y){
        if(y&1){
            res*=x;
            res%=mod;
        }
        x*=x;
        x%=mod;
        y>>=1;
    }
    return res;
}

ll invmod(ll x){
    return fastpow(x, mod-2);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, x, c;
    cin >> n;
    map<int, int> mp;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        res += invmod(x);
        if (res > mod) res -= mod;
        for (int j = 2; j * j <= x; j++) {
            c = 0;
            while (x % j == 0) c++, x /= j;
            if (c) {
                if (mp.find(j) != mp.end()) mp[j] = max(c, mp[j]);
                else mp[j] = c;
            }
        }
        if (x) {
            c = 1;
            if (mp.find(x) != mp.end()) mp[x] = max(c, mp[x]);
            else mp[x] = c;
        }
    }
    for (auto it:mp) {
        res *= fastpow(it.first, it.second);
        res %= mod;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>

int main(){
    int a,b,i,l;
    scanf("%d %d\n",&a,&b);
    while(a!=0 || b!=0){
        int kumi=0;
        for(i=1;i<=b/3 && i<=a;i++){
            for(l=i+1;l<=(b-i)/2 && l<=a;l++){
                if(b-i-l>l && b-i-l<=a)kumi++;
            }
        }
        printf("%d\n",kumi);
        scanf("%d %d\n",&a,&b);
    }
    return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int main(void){
    int i,j;
    int person;
    int match[200][3];
    int score[101];
    int answer[200];
    
    scanf("%d",&person);
    for(i=0;i<person;i++){
        for(j=0;j<3;j++){
            scanf("%d",&match[i][j]);
        }
    }
    
    for(i=0;i<person;i++){
        answer[i]=0;
    }
    
    for(i=0;i<3;i++){
        for(j=0;j<=100;j++){
            score[j]=0;
        }
        for(j=0;j<person;j++){
            score[match[j][i]]++;
        }
        for(j=0;j<person;j++){
            if(score[match[j][i]]==1){
                answer[j]+=match[j][i];
            }
        }
    }
    
    for(i=0;i<person;i++){
        printf("%d\n",answer[i]);
    }
}



Measured memory_bytes: 2032
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	int a = 100000;
	rep(i, n) {
		a = a / 100 * 105;
		a = (a + 1000 - 1) / 1000 * 1000;
	}
	cout << a << endl;
}


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

int main(){
  int count=0;;
  char s[101];
  scanf("%s",s);
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){count++;}
  //printf("%c%c%c%c\n",s[0],s[1],s[2],s[3]);
  if(count==0){printf("%s\n","Good");}
  else{printf("%s\n","Bad");}
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

int n;
double ans,x,d;

int main(){
	scanf("%d%lf%lf",&n,&x,&d);
	n<<=1;
	while (n>0){
		ans+=(double)(n-1)*d/2.0+x;
		x=((double)(n+2)*x+5.0*d)/n;
		d=((double)d*(n+4))/n;
		n-=2;
	}
	printf("%.9f\n",ans);
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if i != 0 {
			a[i] += a[i-1]
		}
		a[i] %= m
	}

	var ans int64
	mp := make(map[int]int)

	for i := 0; i < n; i++ {
		mp[a[i]]++
		if a[i] == 0 {
			ans += int64(mp[0])
		} else {
			ans += int64(mp[a[i]]) - 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7040
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception;

  int n; rd(n);
  void q(int i){
    writeln(i); stdout.flush();
  }
  const M=0, F=1, V=-1;
  int read(){
    auto t=readln.chomp.to!(char[]);
    if(t[0]=='M') return M;
    else if(t[0]=='F') return F;
    else return V;
  }

  int l=0, r=n-1;
  q(l); auto ls=read();
  if(ls==V) return;
  q(r); auto rs=read();
  if(rs==V) return;

  void fun(int l, int ls, int r, int rs){
    if((r-l+1)&1){ // odd
      enforce(ls!=rs);
      auto m=(r+l)/2;
      q(m); auto ms=read();
      if(ms==V) return;
      if(ls==ms){
        if((m-l+1)&1) fun(m, ms, r, rs); 
        else fun(l, ls, m, ms);
      }else{
        if((m-l+1)&1) fun(l, ls, m, ms);
        else fun(m, ms, r, rs);
      }
    }else{
      enforce(ls==rs);
      auto m=(r+l)/2;
      q(m); auto ms=read();
      if(ms==V) return;
      if(ls==ms){
        if((m-l+1)&1) fun(m, ms, r, rs);
        else fun(l, ls, m, ms);
      }else{
        if((m-l+1)&1) fun(l, ls, m, ms);
        else fun(m, ms, r, rs);
      }
    }
  }
  fun(l, ls, r, rs);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 852
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int A, B, C;
    int t;
    int D;
    cin>>A>>B>>C;
    t = 0;
    D = 7 * A;
    while(C>0)
    {
        if (C-D>0)
        {
            C = C-D-B;
            t += 7;
        }
        else
        {
            C -=A;
            t +=1;
            
        }
    }
    std::cout << t << std::endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define pr pair<ll,ll>
using namespace std;
const ll INF = 1000000000000;
ll mat[302][302], n, m, l;
ll fil[302][302];
inline ll read()
{
	static char ch;
	bool sgn = false;
	while ((ch = getchar()) < '0' || ch > '9')
		if (ch == '-')
			sgn = true;
	ll res = ch - 48;
	while ((ch = getchar()) >= '0' && ch <= '9')
		res = res * 10 + ch - 48;
	return sgn ? -res : res;
}
void getmin() {
	for (int i = 1; i <= n; i++)mat[i][i] = 0;
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
			}
		}
	}
}
void init() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			mat[i][j] = INF;
		}
	}
}
void solve() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (mat[i][j] <= l) {
				fil[i][j] = 0;
			}
			else fil[i][j] = INF;
		}
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				fil[i][j] = min(fil[i][j], fil[i][k] + fil[k][j] + 1);
			}
		}
	}
}
int main() {
	n = read(), m = read(), l = read();
	init();
	for (int i = 0; i < m; i++) {
		ll f = read(), t = read(), c = read();
		mat[f][t] = mat[t][f] = min(mat[f][t], c);
	}
	getmin();
	solve();
	ll q = read();
	while (q--) {
		ll s = read(), t = read();
		if (fil[s][t] >100000)cout << -1<<'\n';
		else cout << fil[s][t] << '\n';
	}
	return 0;
}


Measured memory_bytes: 5008
#include <bits/stdc++.h>
//v.erase(unique(v.begin(),v.end()),v.end());
 
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
 
typedef double ld;
typedef long long ll;
const ll N = 5000500;
const ll mod = 1000000007;
const ll INF = 1e+9;
using namespace std;
//using namespace __gnu_pbds;
 
//typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
      
 
void solve(){
	int k, x; cin >> k >> x;
  
  for(int i = x - k + 1; i <= x + k - 1; i++) cout << i << " "; cout << endl;
	
}
 
int main(){
    
    int tc = 1;
    //cin >> tc;	
	
    while(tc--) solve();
    
    return 0;
}

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

int main(){
  int n, u, v; cin >> n >> u >> v;
  vector<vector<int>> node(n + 1);
  for(int i = 0; i < n - 1; i++){
    int a, b; cin >> a >> b;
    node[a].push_back(b);
    node[b].push_back(a);
  }

  stack<int> st;
  st.push(u);
  vector<bool> visited(n + 1, false);
  visited[u] = true;
  vector<int> parent(n + 1);
  parent[u] = -1;

  while(st.size() > 0){
    int now = st.top();
    if(now == v){
      break;
    }
    st.pop();
    for(int i = 0; i < node[now].size(); i++){
      int next = node[now][i];
      if(visited[next] == true) continue;
      st.push(next);
      visited[next] = true;
      parent[next] = now;
    }

  }
  vector<int> path;
  int p = v;
  while(p != -1){
    path.push_back(p);
    p = parent[p];
  }
  /*for(int i = 0; i < path.size(); i++){
    cout << path[i] << " ";
  }
  cout << endl;*/

  vector<bool> visited2(n + 1, false);
  int pathi = 0;
  for(; pathi < (path.size() + 1) / 2; pathi++){
    visited2[path[pathi]] = true;
    //cout << path[pathi] << endl;
  }
  int start = path[pathi];
  int maxnode = start;
  queue<int> q;
  vector<int> distance(n + 1);
  distance[start] = 0;
  q.push(start);
  visited2[start] = true;
  while(q.size() > 0){
    int now = q.front();
    q.pop();
    for(int i = 0; i < node[now].size(); i++){
      int next = node[now][i];
      if(visited2[next] == true) continue;
      distance[next] = distance[now] + 1;
      visited2[next] = true;
      q.push(next);
      if(distance[next] > distance[maxnode]){
        maxnode = next;
      }
    }
  }
  //cout << start << endl;
  //cout << maxnode << endl;
  int ans = pathi + distance[maxnode] - 1;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 9668
#include <bits/stdc++.h>
using namespace std;
int a[20][20];
int d[20][20];
int n, m;
int dx[] = {0,0,-1,1},
    dy[] = {-1,1,0,0};


bool inside(int u,int v){
    return (u >= 0 && u < n && v >= 0 && v < m && !a[u][v]);
}

int bfs(int u,int v){
    memset(d,0,sizeof(d));
    queue<pair<int,int>> q;
    q.push(make_pair(u,v));
    d[u][v] = 1;
    while (!q.empty()){
        int ux = q.front().first;
        int vx = q.front().second;
        q.pop();
        for (int k = 0; k < 4; k++){
            int uy = ux + dx[k];
            int vy = vx + dy[k];
            if (inside(uy,vy) && !d[uy][vy]){
                d[uy][vy] = d[ux][vx] + 1;
                q.push(make_pair(uy,vy));
            } 
        }
    }

    int rs = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            rs = max(rs,d[i][j]);
    return rs - 1;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++){
            char x;
            cin >> x;
            if (x == '.') a[i][j] = 0;
            else a[i][j] = 1;
        }

    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (!a[i][j])
                ans = max(ans,bfs(i,j));
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/*A - The Number of Even Pairs*/
#include <bits/stdc++.h>

using namespace std;

int main(){
	
	int m;
	int n;
	int ans = 0;
	cin >> n >> m;

	if(n > 1){
		ans += (n * (n - 1) / 2);
	}

	if(m > 1){
		ans += (m * (m - 1)  / 2);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int[] nk = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ls = new List<double>();
            for (int i = 1; i <= nk[0]; i++)
            {
                long now = i;
                long cnt = 0;
                while (now <nk[1])
                {
                    now *= 2;
                    cnt++;
                }

                ls.Add(
                    (1D / nk[0]) * Pow(1D/2D,cnt)
                    );
            }
            WriteLine(ls.Sum());
        }
        
    }
}


Measured memory_bytes: 12896
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static int64_t table[10001];

void solve(int64_t n) {
  for (int64_t x = 1;; x++) {
    if (x * x > n) {
      break;
    }
    for (int64_t y = 1;; y++) {
      if (x * x + y * y > n) {
        break;
      }
      for (int64_t z = 1;; z++) {
        int64_t const nn = x * x + y * y + z * z + x * y + y * z + z * x;
        if (nn > n) {
          break;
        }
        table[nn]++;
      }
    }
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  solve(n);
  for (int i = 1; i <= n; i++) {
    std::cout << table[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{
    int n;

    cin >> n;
    double ans;
    int counter;
    counter = floor((n+1)/2);
    //cout << counter << endl;
    ans = counter/n;
    cout << (double) counter/n << endl;
}

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

int sqdis(int *a, int *b, int d)
{
	int i = 0;
	int sum = 0;
	while (i < d)
	{
		sum += (a[i]-b[i])*(a[i]-b[i]);
		i++;
	}
	return(sum);
}

int main(void)
{
	int n, d;
	scanf("%d %d",&n, &d);
	int **x;
	x = (int **)malloc(sizeof(int *)*(n));
	int i = 0;
	int j = 0;
	double sq = 0;
	double tmp = 0;
	while (i < n)
	{
		x[i] = (int *)malloc(sizeof(int)*(d));
		j = 0;
		while (j < d)
		{
			scanf("%d",&(x[i][j]));
			j++;
		}
		i++;
	}

	i = 0;
	j = 0;
	int sum = 0;
	double integer;
	while (i < n - 1)
	{
		j = i + 1;
		while(j < n)
		{
			tmp = (double)sqdis(x[i],x[j],d);
			sq = sqrt(tmp);
			if(modf(sq, &integer) == 0.0)
			{
				sum++;
				//printf("debug i:%d, j:%d sq:%.4f, tmp:%.4f\n",i,j,sq,tmp);
			}
			j++;
		}
		i++;
	}
	printf("%d\n",sum);
	return (0);
}


Measured memory_bytes: 128
def actual(N):
    max_count = 0

    for n in range(1, N + 1):
        i = n

        count = 0

        while n % 2 == 0:
            count += 1
            n //= 2

        if count >= max_count:
            max_count = count
            answer = i

    return answer

N = int(input())
print(actual(N))

Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,m,ans=0;//n-switch,m-lit
struct lit
{
	int num;
	int ask[17];
	int ode;//odevity
	int cnt=0;
};
int fun(int x[])
{
	int i;
	for(i=1;i<=n;i++)
		if(x[i]!=1)
		{
			x[i]=1;
			return 0;
		}
		else
			x[i]=0;
			return 0;
}
int main(){
	//输入 
	cin>>n>>m;
	int x[n+7];memset(x,0,sizeof(x));
	lit b[m+7];
	for(int i=1;i<=m;i++)
	{
		cin>>b[i].num;
		for(int j=1;j<=b[i].num;j++)
		{
			cin>>b[i].ask[j];
		}
	}
	for(int i=1;i<=m;i++)
		cin>>b[i].ode;
	//功能 
	for(int i=1;i<=pow(2,n);i++)//开关组合数 
	{
		fun(x);
		for(int j=1;j<=m;j++)//灯数 
		{
			b[j].cnt=0;
			for(int k=1;k<=b[j].num;k++)//每灯关联开关数 
			{
				if(x[b[j].ask[k]]==1)
				{
					b[j].cnt++;
					continue;
				}
			}
			if(b[j].cnt%2==b[j].ode)
			{
				if(j<m) continue;
				else 
					ans++;
					break;
			}
			else break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//  ⚫⚫ | ⚫➖➖ ⚫⚫ ⚫➖⚫⚫ ⚫➖⚫⚫ | ➖⚫⚫⚫ ⚫ | ⚫➖ | ⚫➖⚫ ⚫ ➖⚫⚫ | ➖⚫➖⚫ ➖➖➖ ➖⚫⚫ ⚫ ⚫➖⚫
#include<bits/stdc++.h>
#define n0_nnE int main(){
using namespace std;
typedef long long ll;
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //Use common MaxNum to reduce the compuation time
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4028