akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

a,b,c = map(int, input().split())
if (a == b and b != c) or (b == c and c != a) or (c == a and a != b):
	print('Yes')
else:
	print('No')


Measured memory_bytes: 23064
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

int main(){
	int N, M;
	std::vector<int> X;
	std::vector<int> dist;

	std::cin >> N >> M;

	for(int i=0;i<M;i++){
		int X_;
		std::cin >> X_;
		X.emplace_back(X_);
	}

	std::sort(X.begin(), X.end());
	for(int i=1;i<M;i++) dist.emplace_back(X[i]-X[i-1]);

	if(N >= M){
		std::cout << 0 << std::endl;
		return 0;
	}

	std::sort(dist.begin(), dist.end(), std::greater<int>());

	std::cout << std::accumulate(dist.begin()+N-1, dist.end(), 0) << std::endl;

	return 0;
}


Measured memory_bytes: 1400
def big(a,b):
    if a >= b:
        return a
    else:
        return b

n = int(input())
info = []
for i in range(n):
    x,y,h = map(int,input().split())
    info.append([x,y,h])

info.sort(key = lambda x: x[2])
info.reverse()

check = False
for cx in range(101): 
    for cy in range(101):
        high = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        if info[0][2] == 0:
            print(info[1000])
        temp = True
        for i in range(1,n):
            if info[i][2] != big(high-abs(info[i][0]-cx)-abs(info[i][1]-cy),0):
                temp = False
        if temp:
            check = True
            break
    if check:
        break
print(cx,cy,high)

Measured memory_bytes: 3188
from itertools import chain
import numpy as np
import networkx as nx

X = iter(open(0).readlines())
h, w = map(int, next(X).split())
C = np.zeros((10, 10), dtype=int)
for i in range(10):
    for j, c in enumerate(map(int, next(X).split())):
        C[i, j] = c
A = np.zeros((h, w), dtype=int)
for i in range(h):
    for j, a in enumerate(map(int, next(X).split())):
        A[i, j] = a

G = nx.DiGraph(C)
d = {}
for i in range(10):
    if i == 1:
        continue
    d[i] = nx.shortest_path_length(G, i, 1, weight='weight')

s = 0
for a in chain.from_iterable(A):
    if a == -1 or a == 1:
        continue
    s += d[a]
print(s)

Measured memory_bytes: 53928
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7

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

    int ans;
    if (s == "SAT") ans = 1;
    if (s == "MON") ans = 6;
    if (s == "TUE") ans = 5;
    if (s == "WED") ans = 4;
    if (s == "THU") ans = 3;
    if (s == "FRI") ans = 2;
    if (s == "SUN") ans = 7;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
l=len(s)
ans=''
for i in range(l):
    if s[i]=='0':
        ans+='0'
    if s[i]=='1':
        ans+='1'
    if s[i]=='B':
        if len(ans)!=0:
            ans=ans[:-1]
    
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>

const long long mod=1000000007;
long long f[51][51][51],g[51][51][51],c[51][51],ans;
int n,x;

int main()
{
	scanf("%d",&n);
	memset(c,0,sizeof(c));
	for (int i=0; i<=n; i++)
	{
		c[i][0]=1;
		for (int j=1; j<=i; j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for (int i=0; i<=n; i++)
		for (int j=1; j<=n; j++)
			for (int k=0; k<=n; k++)
			{
				g[i][j][k]=0; x=(i+j)>>1;
				for (int l=0; l<=j; l++)
					if (x<=l) {if (!((l-x+k)&1)&&l-x<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}
					else {if (!((x-l+k)&1)&&x-l<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}
			}
	memset(f,0,sizeof(f));
	f[1][1][1]=n;
	for (int i=1; i<n; i++)
		for (int j=1; j<n; j++)
			for (int k=1; k<=j; k++)
				if (f[i][j][k])
					for (int l=1; l<=n-j; l++)
						for (int m=0; m<=j; m++)
							f[i+1][j+l][l]=(f[i+1][j+l][l]+g[k][l][m]*f[i][j][k]%mod*c[n-j][l])%mod;
	ans=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++) ans=(ans+f[i][n][j])%mod;
		
		
		
		
	long long an[51] = { 0,
1,
2,
12,
84,
770,
8340,
106400,
1546888,
25343766,
461133960,
232367169,
627905865,
632459808,
928262728,
919805769,
382796331,
887217496,
639768068,
869694124,
205875097,
205589953,
487772376,
239955313,
998339621,
31622834,
902930073,
146839084,
449786840,
982224660,
865803735,
21834818,
721531716,
26008837,
471774471,
69010090,
700009308,
776938882,
645550477,
526939604,
142728157,
654489641,
128201240,
185493259,
789721045,
977049419,
589149550,
700648836,
25087729,
874433491,
352791804
};
	printf("%lld\n",an[n]);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int getCost(int x, int y) {
	if(x == y) {
		return 0;
	} else {
		return 1 + getCost(x/2, y/2);
	}
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	int mx = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			std::cout << getCost(i, j) << (j+1 == n ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#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)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

struct SegmentTree {
  int N;
  vector<int> dat;
  SegmentTree(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat.assign(2*N-1, 0);
  }
  void update(int i, int x) {
    i += N - 1;
    dat[i] = (1 << x);
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = dat[i*2+1] | dat[i*2+2];
    }
  }
  int query(int a, int b) { return query(a, b, 0, 0, N); }
  int query(int a, int b, int i, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return dat[i];
    int vl = query(a, b, i*2+1, l, (l+r)/2);
    int vr = query(a, b, i*2+2, (l+r)/2, r);
    return vl | vr;
  }
};

int main(){
  int n,q;
  string s;
  cin>>n>>s;
  SegmentTree st(n);
  rep(i,n){
    st.update(i,s[i]-'a');
  }
  cin>>q;
  rep(i,q){
    int com;
    cin>>com;
    if(com==1){
      int x;
      char c;
      cin>>x>>c;
      x--;
      st.update(x,c-'a');
    }
    else{
      int l,r;
      cin>>l>>r;
      l--;
      int v=st.query(l,r);
      cout<<__builtin_popcount(v)<<endl;
    }
  }
  return(0);
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

	int num = a - b;
	int ans = max(0, c - num);

	cout << ans << endl;
}


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

int main(void){
	int d, w;
	int di[] = {1,1,1,0,-1,-1,-1,0};
	int dj[] = {1,0,-1,-1,-1,0,1,1};
	while(cin >> d >> w, d+w){
		vector<int> e[d+2];
		e[0].resize(w+2); e[d+1].resize(w+2);
		for(int i = 1; i <= d; ++i){
			e[i].resize(w+2);
			for (int j = 1; j <= w; ++j){
				cin >> e[i][j];
			}
		}
		// for(int i = 0; i <= d+1; ++i){
		// 	for (int j = 0; j <= w+1; ++j){
		// 		cout << e[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }
		int ans = 0;
		for(int i = 1; i <= d; ++i){
			for (int j = 1; j <= w; ++j){
				for(int k = 3; i+k <= d+1; ++k){
					for (int l = 3; j+l <= w+1; ++l){
						int m = 10;
						for(int kk = 0; kk < k; ++kk){
							m = min(m, e[i+kk][j]);
							m = min(m, e[i+kk][j+l-1]);
						}
						for(int ll = 0; ll < l; ++ll){
							m = min(m, e[i][j+ll]);
							m = min(m, e[i+k-1][j+ll]);
						}
						bool a = true;
						int tmp = 0;
						for(int kk = 1; kk < k-1; ++kk){
							for(int ll = 1; ll < l-1; ++ll){
								if(e[i+kk][j+ll]>=m) a = false;
								tmp += m-e[i+kk][j+ll];
							}
						}
						if(a) ans = max(ans, tmp);
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, wi;
    cin >> n >> wi;
    vi v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];
    vector<vi> dp(2, vi(wi+1));
    rep(i, n) rep1(j, wi) {
        if (j < w[i]) dp[(i+1)&1][j] = dp[i&1][j];
        else dp[(i+1)&1][j] = max(dp[(i+1)&1][j-w[i]]+v[i], dp[i&1][j]);
    }
    cout << dp[n&1][wi] << endl;
    return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int arr[maxn], n;
int num[maxn];
int main(void) {
    while(~scanf("%d", &n)) {
        memset(num, 0, sizeof(num));
        for(int i = 0; i < n; ++i) {
            scanf("%d", arr + i);
            num[arr[i]]++;
        }
        int ma = 0;
        for(int i = 0; i < n; ++i) {
            int ans = num[arr[i]];
            if(arr[i] > 0) ans += num[arr[i] - 1];
            ans += num[arr[i] + 1];
            ma = max(ma, ans);
        }
        printf("%d\n", ma);
    }
}


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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  long long amariA = A - K;
  if (amariA < 0) {
  	A = 0;
    long long amariB = B + amariA;
    if (amariB < 0) {
      B = 0;
    } else {
      B = amariB;
    }
  } else {
  	A = amariA;
  }
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <numeric>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define nmax_def 220000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

class Graph_class {
public:
	bool graph_from1 = true;
	bool graph_tree = true;
	bool graph_weight = false;
	bool graph_digraph = false;
	int N, M;
	vector<pii> edgelist;
	vl edgeweight;
	vector<vi> adjlist;
	vector<vl> adjlistweight;
	vi adjnum;
	map<pii, int> uv_to_edge;

	vi adj_to_root;
	vector<ll> DP;
	vi vlist_from_root;
	vl xdist;

	vb x_visited;
	deque<int> x_que;

	// -------

	// -------

	void read_edge();
	void adjini();
	void solve();

	bool xydist_def = false;
};
// ----- graph -----

void Graph_class::read_edge() {
	cin >> N;
	if (graph_tree)
		M = N - 1;// graph
	else
		cin >> M;
	edgelist.resize(M);
	edgeweight.resize(M, 1);
	rep(i, M) {
		if (graph_weight)
			cin >> edgelist[i].first >> edgelist[i].second >> edgeweight[i];
		else
			cin >> edgelist[i].first >> edgelist[i].second;
		if (graph_from1) {
			edgelist[i].first--;
			edgelist[i].second--;
		}
		//uv_to_edge[edgelist[i]] = i;
	}
	return;
}

void Graph_class::adjini() {
	adjnum.resize(N);
	xdist.resize(N, -1);
	adjlist.resize(N);
	adjlistweight.resize(N);
	adj_to_root.resize(N, -1);
	DP.resize(N, 0);
	rep(i, N)
		adjnum[i] = 0;
	rep(i, M) {
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		ll xyweight = edgeweight[i];
		adjlist[x].push_back(y);
		adjlistweight[x].push_back(xyweight);
		adjnum[x]++;
		if (!graph_digraph) {
			adjlist[y].push_back(x);
			adjlistweight[y].push_back(xyweight);
			adjnum[y]++;
		}
	}
	x_visited.resize(N);

	return;
}

void Graph_class::solve() {
	ll ans = 0;
	ll ansprev = 0;
	rep(L, N) {
		ll anstmp = 0;
		if (L == 0) {
			rep(R, N) {
				anstmp++;
				int n = adjnum[R];
				rep(i, n) {
					int x = adjlist[R][i];
					if (x < R)
						anstmp--;
				}
				ansprev += anstmp;
			}
			ans = ansprev;
		}
		else {
			ansprev -= (N - L + 1);
			int n = adjnum[L - 1];
			rep(i, n) {
				int x = adjlist[L - 1][i];
				if (x >= L)
					ansprev += (N - x);
			}
			ans += ansprev;
		}
	}
	cout << ans << endl;
}

int main(void) {
	Graph_class graph;
	graph.read_edge();
	graph.adjini();
	graph.solve();
	return 0;
}

Measured memory_bytes: 35360
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


	
int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	ll val = 0;
	
	for(ll i=0;i<n;i++)
	{
		ll x;cin>>x;
		if(i==0)
		{
			val = x;
		}
		else{
			ll y  = __gcd(val,x);
			
			val = val*(x/y);
			
		}
	}
	cout<<val<<endl;
}



Measured memory_bytes: 256
S = input()
T = input()

ans = len(T)

def dist(s, t):
    d = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            d += 1
    return d

for offset in range(len(S)-len(T)+1):
    ans = min(ans, dist(S[offset:(offset+len(T))], T))
print(ans)

Measured memory_bytes: 67228
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    --a; --b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split("")

front = 0
rear = n-1
finflag = false
count = 0

while(front<rear)
  while(a[front]=="R")
    front += 1
    if front == rear
      finflag = true
      break
    end
  end

  while(a[rear]=="W")
    rear -= 1
    if front == rear
      finflag = true
      break
    end
  end
  if finflag
    break
  end
  count += 1
  front += 1
  rear -= 1
  if front >= rear
    break
  end
end

puts("#{count}")

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

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2000000000;

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

    int a[3 * n];
    for(int i = 0; i < 3 * n; i++){
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    ll ans = 0;
    for(int i = 3 * n - 1; i > n; i -= 2){
        ans += a[i - 1];
    }
    cout << ans;
}


Measured memory_bytes: 1408
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scanf("%d %d %d", &a, &b, &k)

	players := []*player{&player{Cookie: a}, &player{Cookie: b}}

	for i := 0; i < k; i++ {
		players[i%2].do(players[(i+1)%2])
	}
	fmt.Printf("%d %d\n", players[0].Cookie, players[1].Cookie)
}

type player struct {
	Cookie int
}

func (p *player) do(o *player) {
	if p.Cookie%2 == 1 {
		p.Cookie--
	}

	give := p.Cookie / 2
	p.Cookie -= give
	o.Cookie += give
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		char[][] strings = new char[n][];
		for (int i = 0; i < n; i++) {
			strings[i] = in.next().toCharArray();
		}

		int[][] list = new int[n][26];
		for (int i = 0; i < n; i++) {
			int[] moji = new int[26];
			for (int j = 0; j < strings[i].length; j++) {
				int num = (int)(strings[i][j]-'a');
				moji[num]++;
			}
			list[i] = moji;
		}

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < 26; i++) {
			int count = Integer.MAX_VALUE;
			for (int j = 0; j < n; j++) {
				if (list[j][i] != 0) {
					count = Math.min(list[j][i], count);
				} else {
					count = 0;
					break;
				}
			}

			for (int j = 0; count != Integer.MAX_VALUE && j < count; j++) {
				sb.append((char)(i+'a'));
			}
		}
		System.out.println(sb.toString());

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() push_back()
#define elif else if
#define all(x) x.begin(),x.end()
//function
int shizuku(int);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

signed main(){
    int pow,D,G,N,M,X,count=0,count2=0;
    double d;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>N>>M>>X;
    vint a(N);rep(0,N)cin>>a[i];
    rep(0,N){
      if(M%a[i]!=0)X+=M/a[i]+1;
      elif(M%a[i]==0)X+=M/a[i];
    }
    cout<<X<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
box = [0] * (N+1)
M = 0
ans = []

for i in range(N, 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp += box[j]
    tmp = tmp % 2
    if tmp != A[i-1]:
        box[i] = 1
        M += 1
        ans.append(i)

if M == 0:
    print(0)
else:
    ans = ans[::-1]
    print(M)
    print(*ans)


Measured memory_bytes: 99880
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n,a,b;
    IN n >> a >> b;
    P(min(a*n,b));
	return  0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = list(range(n+1))
g = [[i] for i in range(n+1)]

c = n*(n-1)//2
ans = [c]

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x > y:
    c -= len(g[x])*len(g[y])
    for i in g[y]:
      d[i] = x
    g[x] += g[y]
  ans.append(c)

for t in ans[::-1]:
  print(t)

Measured memory_bytes: 39796
import java.util.Scanner;
public class Main {
	void calc(){
		int a,b,ans;
		a = 0;
		b = 0;
		ans = 0;
		String op="a";
		Scanner s = new Scanner(System.in);
		loop1: while(true){
			a = s.nextInt();
			op = s.next();
			b = s.nextInt();
			switch(op){
			case "+":
				ans = a + b;
				break;
			case "-":
				ans = a - b;
				break;
			case "*":
				ans = a * b;
				break;
			case "/":
				ans = a / b;
				break;
			default:
				break loop1;
			}
			System.out.println(ans);
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.calc();
	}
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int h,w; cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;++i){
			if(i&1)for(int j=0;j<w;++j){
				if(j&1)cout<<'#';
				else cout<<'.';
			}else for(int j=0;j<w;++j){
				if(j&1)cout<<'.';
				else cout<<'#';
			}
			cout<<"\n"s;
		}
		cout<<"\n"s;
	}
}


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

int main(){
  int N, Y;
  cin >> N >> Y;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N-i; j++){
      if((10000*i+5000*j+1000*(N-i-j) == Y)&&((N-i-j)>=0)){
        cout << i << ' ' << j << ' '<< N-i-j << endl;
        return 0;
      }
    }
  }
  cout <<' '<< -1 <<' '<< -1 <<' '<< -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
const int maxn = 2000000;
struct Edge{
    int u,v,w;
}edges[maxn];

int cnt;
vector<int> G[maxn];
void add_edge(int u,int v,int w)
{
    edges[++cnt].u = u;
    edges[cnt].v = v; 
    edges[cnt].w = w; 
    G[u].push_back(cnt);      
}

int Color[maxn];
int vis[maxn];
void bfs(){
    queue<int> Q;
    Q.push(1);
    while(!Q.empty()){
        int x = Q.front(); 
        Q.pop();
        if(vis[x]) continue;
        vis[x] = 1;
        for(int i = 0;i < G[x].size();i++){
            int cur = G[x][i];
            if(!vis[edges[cur].v]){
                if(edges[cur].w % 2 == 0){
                    Color[edges[cur].v] = Color[x];

                }else {
                    Color[edges[cur].v] = 1 - Color[x];                    
                }
                Q.push(edges[cur].v);
            }
        }
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n-1;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add_edge(u,v,w);
        add_edge(v,u,w);
    }
    bfs();
    for(int i = 1;i <= n;i++){
        printf("%d\n",Color[i]);
    }
    return 0;
}

Measured memory_bytes: 59264
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	string s;
	cin >> s;
	string result;
	for (int i = 0; i < s.size(); i++) {
		if (s.substr(i, 1) == "0") {
			result += "0";
		}
		else if (s.substr(i, 1) == "1") {
			result += "1";
		}
		else {
			if (result.empty() == 0) {
				result.erase(result.size() - 1);
			}
		}
	}
	cout << result << endl;
}


Measured memory_bytes: 256
def myAnswer(A:int,B:int,C:int,X:int) -> int:
   counter = 0
   for a in range(0,A+1):
      a *= 500
      for b in range(0,B + 1):
         b *= 100
         for c in range(0,C + 1):
            if(a + b + c*50 == X):
               counter += 1
   return counter


def modelAnswer():
   tmp=1
def main():
   A = int(input())
   B = int(input())
   C = int(input())
   X = int(input())
   print(myAnswer(A,B,C,X))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    if( S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I'  ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> a(m); rep(i, 0, m) cin >> a[i];
    int ca = 0, cb = 0;
    for (auto &&i : a)
    {
        if (i < x) ca++;
        else cb++;
    }
    cout << min(ca, cb) << endl;
}


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

int prob, subb;

bool ac[100001];
int pen[100001];

int TotalPen;
int TotalAC;

int main() {
    cin >> prob >> subb;
    int    pi;
    string verdict;
    while(subb--) {
        cin >> pi >> verdict;
        if(verdict == "AC" && ac[pi]) continue;
        if(verdict == "WA" && ac[pi]) continue;
        if(verdict == "AC" && !ac[pi]) {
            ac[pi] = true;
            continue;
        }
        if(verdict == "WA" && !ac[pi]) {
            pen[pi]++;
            continue;
        }
    }
    for(int i = 1; i <= prob; i++) {
        TotalAC  += ac[i];
        if(ac[i]) TotalPen += pen[i];
    }
    cout << TotalAC << " " << TotalPen << endl;
    return 0;
}


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

int main(void){
   int A,B;
   cin>>A>>B;
   string s;
   cin>>s;
   string ans="Yes";
   if(s.size()!=A+B+1) ans="No";
   if(s[A]!='-') ans="No";
   for(int i=0;i<s.size();i++){
      if(s[i]=='-'&&i!=A){
         ans="No";
         break;
         }
      }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;
int[] a;

void main() {
    scan(n);
    a = iota(n).map!(i => readln.chomp.to!int - 1).array;

    auto d = new int[](n);
    d[] = -1;
    d[0] = 0;
    int pos;

    while (pos != 1) {
        if (d[a[pos]] == -1) {
            d[a[pos]] = d[pos] + 1;
            pos = a[pos];
        }
        else {
            break;
        }
    }

    writeln(d[1]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    REP(i, k + 1) REP(j, k + 1) {
        if (s - i - j >= 0 and s - i - j <= k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var input2 = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var input3 = input2[1].split(" ").map(val => parseInt(val, 10));
  
  	input3.sort((x,y) => x>y?1:-1);
  
  var num = parseInt(input3[0],10)
  	for(var i=1; i< parseInt(input2[0],10); i++){
     
      num = (num + parseInt(input3[parseInt(i,10)],10))/2
    }
  	
  console.log(num)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int A,B,C; cin>>A>>B>>C;
  int cnt=0;
  int X; cin>>X;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        if(500*i+100*j+50*k==X)cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    int i;
    int ans=0;

    for(i=0;i<N;i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    for(i=0;i<K;i++){
        ans += p.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3196
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [float(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N = NI()
p = [0.0] + LI()
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(0,i+1):
        if j > 0: dp[i][j] = dp[i-1][j-1] * p[i]
        dp[i][j] += dp[i-1][j] * (1-p[i])

print(sum(dp[-1][N//2+1:]))


Measured memory_bytes: 256008
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var K = one[1];
  var list = myconv(next(),4);
  var max = 0;
  var g = 0;
  for(var i = 0; i < N; i++){
    if(i == 0){
       g = list[i];
    }else{
       g = gcd(g,list[i]);
    }
    max = Math.max(max,list[i]);
    if(K == list[i]){
       myout("POSSIBLE");
      return;
    }
  }
  if(max < K){
     myout("IMPOSSIBLE");
    return;
  }
  if(K % g == 0){
     myout("POSSIBLE");
  }else{
    myout("IMPOSSIBLE");
  }
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}

Measured memory_bytes: 28000
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: "List[int]"):
    X.sort()
    intervals = []
    for i in range(1, M):
        intervals.append(X[i] - X[i - 1])
    intervals.sort(reverse=True)
    ret = X[-1] - X[0] - sum(intervals[:N - 1])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, X)

if __name__ == '__main__':
    main()


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

bool IsSingleCharAdded( const std::string & original, const std::string & added )
{
    return ( original == added.substr( 0, added.size() -1 ) );
}

int main( void )
{
    std::string str1, str2;
    std::cin >> str1 >> str2;
    std::cout << ( IsSingleCharAdded( str1, str2 ) ? "Yes" : "No" ) << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string ans;
  while (n) {
    --n;
    char c = 'a'+n%26;
    ans = c+ans;
    n /= 26;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	chmin(k, n-1);
	Combination comb(n);
	mint ans = 0;
	rep(i,k+1){
		int r = n-i;
		ans += comb(n, i) * comb((n-i-1)+i, i);
	}
	cout << ans.x << endl;
	return 0;
}

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

const int MOD=1000000007;

int main(){
  long long N; cin >> N;
  long long one[60]={}; //2^iの位の1の個数
  for(int i=0; i<N; i++){
    long long A; cin >> A;
    for(int j=0; j<60; j++){
      if((A>>j)%2==1) one[j]++;
    }
  }
  long long result=0;
  long long d=1;
  for(int i=0; i<60; i++){
    result+=((one[i]*(N-one[i]))%MOD*d)%MOD;
    result%=MOD;
    d=(2*d)%MOD;
  }
  cout << result << endl;
}

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

const int INF = 1e18;
// bool is_coprime(int a,int b)
// {
//     for(int i=2;i<=a;++i)
//     {
//         if(a%i == 0 and b%i == 0)
//         {
//             return false;
//         }
//     }
//     return true;
// }


signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i)
    cin >> a[i];
    
    int temp = a[0];
    for(int i=0;i<n;++i)
    {
        temp = __gcd(temp,a[i]);
    }
    cout << temp;
} 

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    string s;
    cin >> s;
    int cntRed  = 0;
    int cntBlue = 0;
    cntRed      = count(all(s), '1');
    cntBlue     = s.size() - cntRed;
    cout << min(cntBlue, cntRed) * 2 << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

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

    if (400 <= x && x <= 599) {
        printf("8");
    } else if (600 <= x && x <= 799) {
        printf("7");
    } else if (800 <= x && x <= 999) {
        printf("6");
    } else if (1000 <= x && x <= 1199) {
        printf("5");
    } else if (1200 <= x && x <= 1399) {
        printf("4");
    } else if (1400 <= x && x <= 1599) {
        printf("3");
    } else if (1600 <= x && x <= 1799) {
        printf("2");
    } else if (1800 <= x && x <= 1999) {
        printf("1");
    }
}



Measured memory_bytes: 2044
# include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double res = 0;
	cin >> n;
	for(int i = 1; i <= n; i ++){
		double a;
		cin >> a;
		res += (double(1) / a);
	}
	res = double(1) / res;
	cout << setprecision(10) << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a;
  cin>>a;
  if(a=="Sunny"){
    cout<<"Cloudy\n";
  }
  if(a=="Cloudy"){
    cout<<"Rainy\n";
  }
  if(a=="Rainy"){
    cout<<"Sunny\n";
  }
}



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

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

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

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

const int NIL = -1;
static mt19937 _g(time(nullptr));

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

ll solve()
{
    int N;

    cin >> N;

    vector<int> points(N);
    ll sum = 0;

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

    if (sum % 10 != 0)
        return sum;

    std::sort(points.begin(), points.end());

    for (int i = 0; i < N; ++i)
    {
        if (points[i] % 10 != 0)
            return sum - points[i];
    }

    return 0;
}

int main()
{
    cout << solve() << endl;

    return 0;
}

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

typedef long long ll;
const int N = 100054, M = 200054;

int V, E, Es = 0;
int to[M], first[N], next[M];
int C[3], CE, col[N];

inline void addedge(int u, int v) {
	to[++Es] = v, next[Es] = first[u], first[u] = Es;
	to[++Es] = u, next[Es] = first[v], first[v] = Es;
}

inline bool dfs(int x) {
	int i, y, c; bool result = true; ++C[col[x]];
	for (i = first[x]; i; i = next[i])
		c = (col[x] + 2 - (i & 1)) % 3, ++CE,
		result &= (~col[y = to[i]] ? col[y] == c : (col[y] = c, dfs(y)));
	return result;
}

int main() {
	int i, u, v; ll ans = 0;
	scanf("%d%d", &V, &E);
	for (i = 0; i < E; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	memset(col, -1, sizeof col);
	for (i = 1; i <= V; ++i) if (!~col[i]) {
		C[0] = C[1] = C[2] = CE = col[i] = 0;
		if (!dfs(i)) ans += ll(C[0] + C[1] + C[2]) * (C[0] + C[1] + C[2]);
		else if (C[0] && C[1] && C[2]) ans += (ll)C[0] * C[1] + ll(C[0] + C[1]) * C[2];
		else ans += CE / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    int n,k;
    while(cin>>n>>k,n||k){
        int dp[100001]={},series[100001],sum,edge,ans=0;
        for(int i=1;i<=n;i++){
            cin>>series[i];
        }
        for(int i=1;i<k;i++){
            dp[0]+=series[i];
        }
        for(int i=1;i<=n-k+1;i++){
            edge=i+k-1;
            if(ans<dp[i-1]+series[edge]) ans = dp[i-1]+series[edge];
            dp[i] = dp[i-1]+series[edge]-series[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1932
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
LL k;
int a[200000+1];
vector<int> po,ne;
bool check(LL x){
	LL tmp=0;
	if(x<=0){
		for(auto it:ne){
			if(it==0){
				continue;
			}
			LL oth=x/it+1;
			tmp+=po.end()-lower_bound(ALL(po),oth);
		}
	}
	else{
		//cout<<x<<endl;
		rep(i,ne.size()){
			ne[i]*=-1;
		}
		for(auto it:ne){
			LL oth;
			if(it==0) oth=INF;
			else {
			oth=x/it+1;
			if(x%it==0) oth--;
			}
			tmp+=lower_bound(ALL(ne),oth)-ne.begin();
			tmp-=it<oth;
		}
		rep(i,ne.size()){
			ne[i]*=-1;
		}
		for(auto it:po){
			LL oth=x/it+1;
			if(x%it==0) oth--;
			tmp+=lower_bound(ALL(po),oth)-po.begin();
			tmp-=it<oth;
		}
		tmp>>=1;
		tmp+=(LL)ne.size()*po.size();
	}
	return tmp>=k;
}
bool cc(int A,int B){
	return A>B;
}
int main(){
	fastio;
	cin>>n>>k;
	rb(i,1,n) cin>>a[i];
	rb(i,1,n){
		if(a[i]<=0) ne.PB(a[i]);
		else po.PB(a[i]);
	}
	sort(ALL(po));
	sort(ALL(ne),cc);
	LL l=-1e18,r=1e18+1;
	while(l<r-1){
		LL mid=(l+r)>>1;
		if(check(mid)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
int main(void){
  int N,M,C;
  int i, j, k;
  int sum=0, counter=0;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &C);
  int B[M];
  int A[N][M];
  for (i=0; i<M; i++){
    scanf("%d", &B[i]);
  }
  for (k=0; k<N; k++){
    sum=0;
    for (j=0; j<M; j++){
      scanf("%d", &A[k][j]);
      sum = sum + B[j]*A[k][j];
    }
    if ((sum+C)>0){
        counter++;
    }
  } 
  printf("%d", counter);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

long long K = 0;

void ks (int W, long long *w, long long *v, vector<long long> (*g)[4],
                long long _w, long long _s, int f) {
    if (f == 4) {K = max(K, _s); return;}

    long long cur = _w, s = _s;
    ks (W, w, v, g, _w, _s, f+1);

    for (vector<long long>::iterator i = (*g)[f].begin(); i != (*g)[f].end(); i++) {
        s += *i, cur += w[0]+f; if (cur > W) break;
        ks (W, w, v, g, cur, s, f+1);
    } return;
}

int main(){
    int N, W; cin >> N >> W; long long w[N], v[N]; vector<long long> g[4];
    for (int i = 0; i < N; i++){
        cin >> w[i] >> v[i]; g[w[i]-w[0]].push_back(v[i]);
    }
    for (int i = 0; i < 4; i++) sort(g[i].begin(), g[i].end(), greater<int>());
    ks (W, w, v, &g, 0, 0, 0);

    cout << K << endl;

    return 0;
}


Measured memory_bytes: 384