akhauriyash/Code-Regression huggingface dataset:
import sys
Input = sys.stdin.readline

N = list(map(int, Input().split()))
count = 0

while not all(map(lambda x: x == N[0], N)):
    N.sort()
    while N[0]+1 < N[2]:
        N[0] += 2
        count += 1
    if N[0] != N[2]:
        N[0] += 1
        N[1] += 1
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template<Int Mod = 1000000007> class modint{
public:
	Int val;
	constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
	constexpr modint operator+(const modint rhs) const {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const {
		return modint(*this) /= rhs;
	}
	constexpr modint operator-() const {
		return modint(Mod - val);
	}
	constexpr modint &operator+=(const modint rhs){
		val += rhs.val;
		if(val >= Mod) val -= Mod;
		return *this;
	}
	constexpr modint &operator-=(const modint rhs){
		if(val < rhs.n) val += Mod;
		val -= rhs.n;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs){
		val *= rhs.val;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator/=(const modint rhs){
		return *this *= inv(rhs);
	}
	constexpr modint &operator++(){
		++val;
		if(val == Mod) val = 0;
		return *this;
	}
	constexpr modint &operator--(){
		--val;
		if(val == -1) val = Mod - 1;
		return *this;
	}
	constexpr modint operator<<(const Int rhs) const {
		return modint(*this) << rhs;
	}
	constexpr modint operator>>(const Int rhs) const {
		return modint(*this) >> rhs;
	}
	constexpr modint &operator<<=(const Int rhs){
		val <<= rhs;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator>>=(const Int rhs){
		val >>= rhs;
		val %= Mod;
		return *this;
	}
	constexpr bool operator==(const modint rhs) const {
		return val == rhs.val;
	}
	constexpr bool operator!=(const modint rhs) const {
		return val != rhs.val;
	}
	constexpr bool operator<(const modint rhs) const {
		return val < rhs.val;
	}
	constexpr bool operator>(const modint rhs) const {
		return val > rhs.val;
	}
	constexpr bool operator<=(const modint rhs) const {
		return val <= rhs.val;
	}
	constexpr bool operator>=(const modint rhs) const {
		return val >= rhs.val;
	}
	friend ostream& operator<<(ostream& os, const modint<Mod>& m){
		return os << m.val;
	}
	friend istream& operator>>(istream& is, modint<Mod>& m){
		return is >> m.val;
	}
	static constexpr modint inv(modint m){
		Int a = m.val, b = Mod, u = 1, v = 0;
		while(b){
			Int t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		u %= Mod;
		if(u < 0) u += Mod;
		return modint(u);
	}
	constexpr operator Int() const {
		return val;
	}
};
template<class T> T pwr(T a, T e, Int n){
	while(n > 0){
		if(n & 1) e *= a;
		a *= a;
		n >>= 1;
	}
	return e;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	using mint = modint<>;
	Int m, n; cin >> m >> n;
	mint ans = pwr<mint>(m, 1, n);
	cout << ans << "\n";
}


Measured memory_bytes: 3216
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <numeric>

int gcd(int x, int y){
    if(y%x)return gcd(y%x,x);
    return x;
}

int main(){
    int i,n;
    scanf("%d",&n);
    int *a = (int *)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)scanf("%d",a+i);
    if(a[0]==1)a[n-1]=1;
    else {
        for(i=1;i<n;i++){
            if(a[i-1]<a[i])a[i]=gcd(a[i-1],a[i]);
            else a[i]=gcd(a[i],a[i-1]);
        }
    }
    printf("%d\n",a[n-1]);
    return 0;
}


Measured memory_bytes: 512
n = int(input())
sp = [input().split() for _ in range(n)]
ps = [[p,s] for s,p in sp]
pn = {sp[1]:i+1 for i,sp in enumerate(sp)}

ps.sort(key=lambda x:int(x[0]), reverse=True)
ps.sort(key=lambda x:x[1])

for p, s in ps:
    print(pn[p])

Measured memory_bytes: 3060
N = int(input())

ans = [0 for i in range(10**4+1)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n <= 10**4:
                ans[n] += 1

for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 9224
N = int(input())
D = list(map(int,input().split()))

T = [0]*13
T[0] = 1
for d in D:
    T[d] += 1


Times = [0]*24
ones =[]
for i,t in enumerate(T):
    if t>=3 or (t==2 and (i==0 or i==12)):
        print(0)
        exit()
    elif t==2:
        Times[i] = 1
        Times[24-i] = 1
    elif t==1:
        ones.append(i)

ans = 0
L = len(ones)
for i in range(2**L):
    stats = [False]*L
    temp = i
    for j in range(L):
        stats[j] = temp&1
        temp >>= 1
    
    newTime = [t for t in Times]
    res = 10**9
    for j,t in enumerate(ones):
        nt = t if stats[j] else (24-t)%24
        newTime[nt] = 1
    
    gaps = []
    for j,t in enumerate(newTime):
        if t!=0:
            gaps.append(j)
    for j in range(len(gaps)-1):
        res = min(res,min(gaps[j+1]-gaps[j],gaps[j]+24-gaps[j+1]))
    if len(gaps)>=2:
        res = min(res, gaps[0]+24-gaps[-1])
    ans = max(ans, res)
print(ans)



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (x == 0 && y == 0) {
				break;
			} else {
				System.out.println(Math.min(x, y) + " " + Math.max(x, y));
			}
		}
	}
}



Measured memory_bytes: 35284
#include <algorithm>
#include <stdio.h>
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    ll A,B,C,D,X=0,Y=0;
    cin >> A>> B>>C>>D;
    if(A>B){
        X=B;
    }else{
        X=A;
    }
    if(C>D){
        Y=D;
    }else{
        Y=C;
    }
    cout << X+Y << endl;
    return 0;
}

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

using ll = int_fast64_t;
struct edge{
  ll from,to,cost;
  edge(){}
  edge(ll f,ll t,ll c):from(f),to(t),cost(c){}
};

signed main(){

  int n,m;
  cin>>n>>m;
  vector<edge> edges(m);
  for(int i=0;i<m;++i){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    edges[i] = {a,b,-c};
  }

  constexpr ll inf = 1LL<<60;
  vector<ll> dist(n,inf);
  dist[0] = 0;
  auto chmin = [](auto& a,auto b){if(a>b){a=b;return true;}return false;};
  for(int i=0;i<n;++i)for(auto& e:edges){
    chmin(dist[e.to],dist[e.from]+e.cost);
  }
  //念のためもう一度
  for(int i=0;i<n;++i)for(auto& e:edges){
    chmin(dist[e.to],dist[e.from]+e.cost);
  }

  vector<int> negaloop(n,false);
  for(int i=0;i<n;++i)for(auto& e:edges){
    if(negaloop[e.from])negaloop[e.to]=1;
    if(chmin(dist[e.to],dist[e.from]+e.cost))negaloop[e.to]=negaloop[e.from]=1;
  }
  if(negaloop.back())cout<<"inf"<<endl;
  else cout<<-dist.back()<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[20],t[20];
    int i,j;
    gets(s);
   for(i=strlen(s)-1,j=0;i+1!=0;--i,++j)
   {
       t[j]=s[i];
   }
   t[j]='\0';
   strcpy(s,t);
   puts(s);
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    
    if (x1 == 0) cout << 1;
    if (x2 == 0) cout << 2;
    if (x3 == 0) cout << 3;
    if (x4 == 0) cout << 4;
    if (x5 == 0) cout << 5;
}



Measured memory_bytes: 3584
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    ni = 0

    def f(a):
        if len(a) == 1:
            return a[0] // 2 + 1
        cs = sorted([f(c) for c in a])
        return sum(cs[:len(cs)//2+1])

    while ni < n:
        ni += 1
        s = S()
        a = eval(s.replace('][', '],['))
        rr.append(f(a))

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 14296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int now = D*2+1;
		int count =1;
		while(N>now) {
			now +=D*2+1;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        S[i + 1] = S[i] + A[i];
    }
    ll ans = S[N];
    for (ll i = 0; i < N; i++) {
        auto t = abs(S[N] - 2 * S[i + 1]);
        if (t < ans) ans = t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
//created by pyoxiao on 2020/05/03
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int n, m, h[100010];
vector<int> ver[100010];
void solve() {
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; i ++) {
        scanf("%d", h + i);
    }
    for(int i = 1; i <= m; i ++) {
        int a, b;
        scanf("%d %d", &a, &b);
        ver[a].pb(b);
        ver[b].pb(a);
    }
    int ans = 0;
    for(int i = 1; i <= n; i ++) {
        bool ok = 1;
        for(auto to : ver[i]) {
            if(h[to] >= h[i]) {
                ok = 0;
                break;
            }
        }
        if(ok) ans ++;
    }
    printf("%d\n", ans);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 9236
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s;
  int mx=0,t=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='C' ||s[i]=='G' || s[i]=='T'){
      t=1;
      for(int j=i+1;j<s.size();j++){
        if(s[j]=='A' || s[j]=='C' ||s[j]=='G' || s[j]=='T') t++;
        else break;
      }
    }
    mx=max(mx,t);
  }
  cout<<mx<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,a,b,c[7];
	for(i=0;i<7;i++){
		scanf("%d %d",&a,&b);
		c[i]=a-b;
	}
		for(i=0;i<7;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;
const int MAXN = 100005;

struct Edge {
  int t, c;

  Edge(int t, int c): t(t), c(c) {}
};

vector<Edge> G[MAXN];

vector<int> color(MAXN, -1);

void dfs(int u) {
  for (Edge e: G[u]) {
    if (color[e.t] != -1) continue;
    color[e.t] = color[u] ^ e.c;
    dfs(e.t);
  }
}

int main() {
  int n;
  cin >> n;
  int u, v, w;
  rep(i, n - 1) {
    cin >> u >> v >> w;
    u--, v--, w %= 2;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }

  color[0] = 0;
  dfs(0);

  rep(i, n) cout << color[i] << endl;

  
  return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("000.txt","r",stdin);

    ll n,i,j,k,t;

    cin>>i>>j;

    if(i%3==0 || j%3==0)
    {
        cout<<0;
        return 0;
    }

    ll mi=10000000000000;

    mi=min(i,j);

    vll v1;
    fo(k,i-1)
    {
        v1.clear();
        v1.push_back((k+1)*j);
        v1.push_back((i-(k+1))*(j/2));
        v1.push_back((i-(k+1))*(j/2+j%2));
        sort(v1.begin(),v1.end());
        mi=min(mi,v1[2]-v1[0]);
    }
    fo(k,j-1)
    {
        v1.clear();
        v1.push_back((k+1)*i);
        v1.push_back((j-(k+1))*(i/2));
        v1.push_back((j-(k+1))*(i/2+i%2));
        sort(v1.begin(),v1.end());
        mi=min(mi,v1[2]-v1[0]);
    }

    cout<<mi;
    return 0;
}


Measured memory_bytes: 256
def function():
    N,M = map(int, input().split())
    paths = [[] for _ in range(N+1)]
    for _ in range(M):
        A,B = map(int, input().split())
        paths[A].append(B)
        paths[B].append(A)
    
    depths = [-1]*(N+1)
    depths[1] = 0
    pre = [-1]*(N+1)
    q = [1] # 1からスタート
    while len(q) != 0:
        i = q.pop(0)
        for ne in paths[i]:
            if depths[ne] == -1: # -1 は未踏破
                depths[ne] = depths[i]+1
                pre[ne] = i
                q.append(ne)
    print('Yes')
    for p in pre[2:]: print(p)

if __name__ == '__main__':
    function()


Measured memory_bytes: 35508
$_ = <>;
$_ = <>;
chmop;
@a = split(" ");

$sum = 0;
$min = 1000000000;
$minus = 0;
foreach $a1(@a){
  $sum += abs($a1);
  if($a1 < 0){
    $minus = 1 - $minus;
  }
  $min = min($min, abs($a1));
}
if($minus){
  $sum -= $min * 2;
}

print "$sum\n";

sub max(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $a;
  }else{
    $b;
  }
}

sub min(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $b;
  }else{
    $a;
  }
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, k;
	cin >> n >> m >>k;
	vector<ll> a(1,0);
	vector<ll> b(1,0);
	int aele, bele;
	for (int i = 1; i < n+1; i++){
		cin >> aele;
		a.push_back(aele);
		a[i] = a[i] + a[i-1];
	}
	for (int i = 1; i < m+1; i++){
		cin >> bele;
		b.push_back(bele);
		b[i] = b[i] + b[i-1];
	}
 
	int total = 0;
	int num = m;
	for (int i = 0; i < n+1; i++){
		if(a[i] > k) break;
		while (b[num] > k - a[i]) 
          {num--;}
		total = max(total,i+num);
	}
	cout << total;
 
 
    return 0;
}

Measured memory_bytes: 7936
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll d[210];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,2*n){
		int x,y;
		scanf("%d%d",&x,&y);
		d[i]=x*2000+y*2+(i/n);
	}
	sortup(d,2*n);
	ll ans=0;
	rep(i,0,2*n)if(d[i]%2){
		int index=-1;
		int ymax=-1;
		int iy=d[i]%2000/2;
		rep(j,0,i)if(d[j]%2==0){
			int jy=d[j]%2000/2;
			if(jy<iy&&jy>ymax){
				ymax=jy;
				index=j;
			}
		}
		if(ymax!=-1){
			ans++;
			d[index]=-1;
		}
		d[i]=-1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
int main(){
    char a;
 
    cin >> a;
    cout << ('a' <= a && a <= 'z' ? 'a' : 'A') << endl;
 
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int> > sw(m);
    vector<int> p(m);
    rep (i, m) {
        int k;
        cin >> k;
        rep (j, k) {
            int s;
            cin >> s;
            --s;
            sw[i].push_back(s);
        }
    } 
    rep (i, m) cin >> p[i];
    int res = 0;
    rep (bit, 1 << n) {
        vector<int> light(m);
        vector<int> turn(n);
        rep (i, n) if (bit & (1 << i)) turn[i] = 1;
        rep (j, m) {
            int cnt = 0;
            rep (k, sw[j].size()) {
                if (turn[sw[j][k]]) cnt++;
            }
            if (cnt % 2 == p[j]) light[j] = 1;
        }
        bool ok = true;
        rep (j, m) if (!light[j]) ok = false;
        if (ok) res++;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int n;
ll a[100010];

int main () {
  cin >> n;
  for (auto i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 1000000000000000;
  ll sum = 0;
  ll cost = 0;
  if (a[0] <= 0) {
    sum = 1;
  } else {
    sum = a[0];
  }
  cost += abs(sum - a[0]);
  bool positive = true;
  for (auto i = 1; i < n; ++i) {
    sum += a[i];
    if (positive && sum >= 0) {
      cost += abs(sum - (-1));
      sum = -1;
    } else if (!positive && sum <= 0) {
      cost += abs(sum - 1);
      sum = 1;      
    }
    positive = !positive;
  }
  ans = min(ans, cost);
  
  sum = 0;
  cost = 0;
  if (a[0] >= 0) {
    sum = -1;
  } else {
    sum = a[0];
  }
  cost += abs(sum - a[0]);
  positive = false;
  for (auto i = 1; i < n; ++i) {
    sum += a[i];
    if (positive && sum >= 0) {
      cost += abs(sum - (-1));
      sum = -1;
    } else if (!positive && sum <= 0) {
      cost += abs(sum - 1);
      sum = 1;      
    }
    positive = !positive;
  }
  ans = min(ans, cost);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  int n,a,b; cin >> n >>a >>b;
  int ans = min(a*n, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef queue<int>Q;
int main(void){
	int n,q;
	int x,y,z;
	Q que[1000];
	int i;
	cin>>n>>q;
	for(i=0;i<q;i++){
		cin>>x>>y;
		if(x==0){
			cin>>z;
			que[y].push(z);
		}
		else if(x==1){
			if(!que[y].empty())	cout<<que[y].front()<<endl;
		}
		else{
			if(!que[y].empty())	que[y].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int k;
string n;
int dp[100][4][2];

int main(){
  cin >> n >> k;
  dp[0][0][1] = 1;
  dp[0][1][1] = n.at(0)-'1';
  dp[0][1][0] = 1;
  for(int i = 1; i < n.size(); i++){
    dp[i][0][1] = dp[i-1][0][1];
    
    dp[i][1][1] = 9 * dp[i-1][0][1] + dp[i-1][1][1] + (n.at(i) == '0' ? 0 : dp[i-1][1][0]);
    dp[i][1][0] = n.at(i) == '0' ? dp[i-1][1][0] : 0;
    
    dp[i][2][1] = dp[i-1][2][1] + 9*dp[i-1][1][1] + dp[i-1][1][0] *  max(n.at(i) - '1', 0) + (n.at(i) == '0' ? 0 : dp[i-1][2][0]);
    dp[i][2][0] = n.at(i) == '0' ? dp[i-1][2][0] : dp[i-1][1][0];
    
    dp[i][3][1] = dp[i-1][3][1] + 9*dp[i-1][2][1] + dp[i-1][2][0] *  max(n.at(i) - '1', 0) +  (n.at(i) == '0' ? 0 : dp[i-1][3][0]);
    dp[i][3][0] = n.at(i) == '0' ? dp[i-1][3][0] : dp[i-1][2][0];
  }
  dp[n.size()-1][0][1]--;
  cout << dp[n.size() - 1][k][0] + dp[n.size() - 1][k][1] <<endl;
}
  

Measured memory_bytes: 256
x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s= 0
t = 0
for i,j in zip(a,b):
    if i > j :
        s+=i-j
    if j > i :
        t+=(j - i)//2+(j-i)%2
        s+= (j-i)%2
if s<=t:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	cout << max({abs(a-b), abs(c-b), abs(c-a)});
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,x=0;
	int t=0;
	char c[101];

	cin>>n;

	rep(i,n){
		cin>>c[i];
		if(c[i]=='I'){
			x++;
		}else{
			x--;
		}
		t=max(t,x);
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

int cost[200][20];
vector<P> G[200];// to cost;

int main(){
	int c, n, m, s, d;
	int a, b, money;
	while(cin >> c  >> n >> m >> s >> d && (c || n || m || s || d)){
		rep(i, 200) G[i].clear();
		fill(&cost[0][0], &cost[199][19] + 1, INF);
		rep(i, m){
			cin >> a >> b >> money;
			G[a].push_back(P(b, money));
			G[b].push_back(P(a, money));
		}

		cost[s][c] = 0;
		priority_queue<PP, vector<PP>, greater<PP> > que;
		que.push(PP(0, P(s, c)));
		while(!que.empty()){
			PP pp = que.top();
			que.pop();
			int cos = pp.first;
			int pos = pp.second.first;
			int num = pp.second.second;
			if(pos == d){
				cout << cos << endl;
				break;
			}

			if(cos > cost[pos][num]) continue;
			rep(i,(int)G[pos].size()){
				int v = G[pos][i].first;
				int fee = G[pos][i].second;
				if(cost[v][num] > cos + fee){
					cost[v][num] = cos + fee;
					que.push(PP(cost[v][num], P(v, num)));
				}
				if(num > 0 && cost[v][num-1] > cos + fee / 2){
					cost[v][num-1] = cos + fee / 2;
					que.push(PP(cost[v][num-1], P(v, num-1)));
				}
			}
		}
	}
	return 0;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s; cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s.at(i) != s.at(s.size() - i - 1)) ans++;
	}
	cout << ans / 2 << endl;
} 

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

typedef long long int llint;

int main()
{
  bool fur[55556];
  memset(fur, true, sizeof(fur));
  fur[0] = fur[1] = false;
  int x = sqrt(55555) + 1;

  for(int i = 2; i < x; i++) {
    if(!fur[i]) continue;
    for(int j = i + i; j <= 55555; j += i) fur[j] = false;
  }
  
  vector<int> v;
  for(int i = 0; i < 55556; i++) if(fur[i]) v.push_back(i);

  int n;
  cin>> n;
  
  int cnt = 0;
  vector<int> ans;
  for(int i = 0; i < v.size(); i++) {
    if(v[i] % 5 == 1) {
      cout<< v[i] << ' ';
      cnt++;
    }
    if(cnt == n) break;
  }

  cout<<endl;
  

  return 0;
}


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

int main() {
  int N;
  cin>>N;
  if (N==1) {
    cout<<"Hello World"<<endl;
  }
  else if (N==2) {
    int A,B;
    cin>>A>>B;
    cout<<A+B<<endl;
  }
  
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    ll x,y;
    cin>>x>>y;
    int i;
    for(i=0;i<=x;i++){
        ll val;
        val=i*2;
        val+=(x-i)*4;
        if(val==y){
            cout<<"Yes";
            exit(0);
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    double n;
  
    while(scanf("%lf",&n)==1){
        int count = 0;
        double a[10010];
        if(n==0){
            break;
        }
        else{
            for(int i=0;i<n;i++){
                scanf("%lf",&a[i]);
            }
            double sum = 0;
            for(int i=0;i<n;i++){
                sum += a[i];
            }
            double e = sum/n;
            
            for(int i=0;i<n;i++){
                if(a[i]<=e){
                    count++;
                }
            }
                
        }
        printf("%d\n",count);
        
    }
    
    
    return 0;
}



Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3
using namespace std;
class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2):p1(p1), p2(p2){}
};typedef Segment Line;
class EndPoint {
public:
    Point p;
    int seg, st;
    EndPoint(){}
    EndPoint(Point p, int seg, int st):p(p),seg(seg),st(st){}

    bool operator < (const EndPoint &ep) const {
        if (p.y == ep.p.y){
            return st < ep.st;
        }else return p.y < ep.p.y;
    }
};
EndPoint EP[2*100000];
int manhattanIntersection(vector<Segment> S){
    int n = S.size();

    for (int i = 0, k = 0; i < n; i++){
        if (S[i].p1.y == S[i].p2.y){
            if (S[i].p1.x > S[i].p2.x)
                swap(S[i].p1, S[i].p2);
        }else if (S[i].p1.y > S[i].p2.y) swap(S[i].p1, S[i].p2);
        if (S[i].p1.y == S[i].p2.y) {
            EP[k++] = EndPoint(S[i].p1, i, LEFT);
            EP[k++] = EndPoint(S[i].p2, i, RIGHT);
        }
        else{
            EP[k++] = EndPoint(S[i].p1, i, BOTTOM);
            EP[k++] = EndPoint(S[i].p2, i, TOP);
        }
    }
    sort(EP, EP + (2*n));

    set<int> BT;
    BT.insert(1000000001);
    int cnt = 0;

    for (int i = 0; i < 2*n; i++)
    {
        if (EP[i].st == TOP){
            BT.erase(EP[i].p.x);
        }else if (EP[i].st == BOTTOM){
            BT.insert(EP[i].p.x);
        }else if (EP[i].st == LEFT){
            set<int>::iterator b = BT.lower_bound(S[EP[i].seg].p1.x);
            set<int>::iterator e = BT.upper_bound(S[EP[i].seg].p2.x);
            cnt += distance(b, e);
        }
    }
    return cnt;
}
int main(){
    int n; cin >> n;
    vector<Segment> S;
    for (int i = 0; i < n; i++){
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        Segment s = Segment(Point(x1, y1), Point(x2, y2));
        S.push_back(s);
    }
    cout << manhattanIntersection(S) << endl;
}




Measured memory_bytes: 16328
N = int(input())
s = input()

def test(bm, b0):
    b = [True] * N
    b[-1] = bm
    b[0] = b0
    for i in range(N - 2):
        b[i + 1] = b[i - 1]
        if b[i] ^ (s[i] == 'o'):
            b[i + 1] = not b[i + 1]
    
    if b[-2] == ((s[-2] == 'o') == (b[-3] == b[-1])) and b[-1] == ((s[-1] == 'o') == (b[-2] == b[0])):
        printB(b)
        return True
    else:
        return False

def printB(b):
    for i in range(N):
        print('S' if b[i] else 'W', end='')
        
    print()
    

def main():
    if test(True, True):
        return
    elif test(True, False):
        return
    elif test(False, True):
        return
    elif test(False, False):
        return

    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5472
#include <stdio.h>
#include<string.h>
int main(void){
    char po[114];
    scanf("%s",po);
    for(int i=1;i<strlen(po);i++){
        if(po[i-1]=='A'&&po[i]=='C'){printf("Yes");break;}
        else if(i==strlen(po)-1)printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
n, q = map(int, input().split())
s = input()
ac_list = [0]*(n+1)

counter = 0

for i in range(n):
  if s[i:i+2] == 'AC':
    counter+=1
  ac_list[i+1]=counter
  
for _ in range(q):
  l, r = map(int, input().split())
  print(ac_list[r-1] - ac_list[l-1])

Measured memory_bytes: 6188
(defun digit (n &optional (c 0))
  (cond
    ((= n 0) c)
    (t       (digit (floor n 10) (1+ c)))))

(let* ((int1 (read))
       (int2 (read))
       (n (+ (* int1 (expt 10 (digit int2))) int2)))
      (if (= (expt (floor (sqrt n)) 2) n)
          (princ "Yes")
          (princ "No")))

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

int main() {
  string s;
  cin >> s;
  bool a = false,b = false;
  for(int i = 0;i < 3;i++){
    if(s[i] == 'A') a = true;
    else b = true;
  }
  if(a&&b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  bool cnt_flag = false;
  char cmp;
  int cnt = 0;
  rep(i, n) {
    if(cmp != s[i]) {
      cnt_flag = false;
    }
    else {
      cnt_flag = true;
    }
    if(!cnt_flag) {
      ++cnt;
    }
    cmp = s[i];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3772
#include <iostream>

using namespace std;

int main()
{
    char x;
    cin >> x;
    if (( x == 'a') || (x == 'e') || (x == 'i') || (x == 'o') || (x == 'u'))
        cout << "vowel";
    else
        cout << "consonant" ;
    return 0;
}

Measured memory_bytes: 256
package main
import "fmt"

func main(){
        var a, b string
        fmt.Scanf( "%s", &a )
        fmt.Scanf( "%s", &b )
        count := 0

        for i, _ := range a{
                if a[ i ] == b[ i ]{
                        count ++
                }
        }             
  fmt.Printf( "%d", count )

}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

bool f(vector<int>& a, int mid) {
  int N = a.size();
  vector<bool> v(N);
  REP(i, N) v[i] = a[i] >= mid;

  int m = N / 2;

  int l = m - 1;
  while (l >= 0 && v[l] != v[l + 1]) l--;

  int r = m + 1;
  while (r < N && v[r] != v[r - 1]) r++;

  if (l == -1 && r == N) {
    int nsteps = (N - 1) / 2;
    return v[m] ^ (nsteps % 2);
  }

  return m - l < r - m ? v[l] : v[r];
}

int main(void) {
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  N = 2 * N - 1;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  int lo = 1, hi = N;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (f(a, mid)) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int cnt(int a){
    int x = 0;
    while(a){
        x++;
        a /= 10;
    }
    return x;
}

int f(int a, int b){
    return max(cnt(a), cnt(b));
}

int solve(){
    ll n;
    cin >> n;
    int ans = inf;
    for(ll i = 1; i <= sqrt(n); ++i){
        ll j = n / i;
        if(i * j == n){
            ans = min(ans, f(i, j));
        }
    }
    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll x;   cin >> x;
    ll sum = 0;
    int t = 0;
    for(; sum < x; ++t){
	sum += t;
    }
    cout << t-1 << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  ll l,r;
  cin >> l >> r;
  ll a = r%2019;
  ll b = l%2019;
  int  ans = 3000;
  if(r>l+2018){
    cout << 0 << endl;
    return 0;
  }
  if(a>b){
  	rep2(i,b,a+1){
      //cout << i << endl;
      rep2(j,i+1,a+1){
        //cout << "a " << endl;
        ans = min(ans,(i*j)%2019);
      }
    }
  }
  if(b>a){
    
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
  
  
    
}


Measured memory_bytes: 256
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arm = [list(map(int,input().split())) for j in range(N)]

ans = -9999999999
for item in range(1,2**10):#joisinoお姉ちゃんが営業するしないの組み合わせ1024通り
  fund = 0
  for i in range(N):#店の数
    cou = 0
    for x in range(10):#営業タイミング（月~金それぞれ午前、午後）
      if (item >> x) % 2 == 1 and arr[i][x] == 1:#joisino姉の開店と店iの開店が一致
        cou += 1
    fund += arm[i][cou]
  ans = max(ans, fund)

print(ans)

Measured memory_bytes: 9144
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e3+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n,k;
    cin>>n>>k;
    ll z=n/k;
    z*=k;
    if(n%k==0)
    {
        cout<<0<<'\n';
        return; 
    }
    n-=z;
        cout<<min(abs(n-k),abs(abs(n-k)-k))<<'\n';
        return ;
}

int main()
{
    IOS();
 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ff;
int n,m,col[500100],blo,tot,le,ri,ans[500100],cnt[500100];
pair<pair<int,int>,int> que[500100];
bool pp(pair<pair<int,int>,int> x,pair<pair<int,int>,int> y){
	return x.first.second<y.first.second;
}
inline void inser(int val){cnt[val]++;if(cnt[val]==1) ff++;}
inline void eras(int val){cnt[val]--;if(cnt[val]==0) ff--;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&col[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&que[i].first.first,&que[i].first.second);
		que[i].second=i;
	}
	sort(que+1,que+m+1);
	blo=max(1,(int)(sqrt(m)));
	tot=(m+blo-1)/blo;
	for(int i=1;i<=tot;i++){
		le=blo*(i-1)+1;
		ri=min(blo*i,m);
		sort(que+le,que+ri+1,pp); 
		for(int j=1;j<=n;j++) cnt[j]=0;
		ff=0;
		for(int j=que[le].first.first;j<=que[le].first.second;j++)
			inser(col[j]);
		ans[que[le].second]=ff;
		for(int j=le+1;j<=ri;j++){
			for(int kk=que[j-1].first.first;kk<que[j].first.first;kk++)
				eras(col[kk]);
			for(int kk=que[j].first.first;kk<que[j-1].first.first;kk++)
				inser(col[kk]);
			for(int kk=que[j-1].first.second+1;kk<=que[j].first.second;kk++)
				inser(col[kk]);
			ans[que[j].second]=ff;
		}
	}
	for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main() {

    int n, k; cin >> n >> k;
    // 桁あふれ処理めんどいので、+5くらい余計にとっておく
    vector<int> h(n+5, INT_MAX);
    rep(i, n) cin >> h[i];

    // 桁あふれ処理めんどいので、+5くらい余計にとっておく
    vector<int> dp(n+5, INT_MAX);

    // 最初だけ初期化
    dp[0] = 0;

    // K<=100, N<=10^5,,, 10^7なのでぎりいける？
    rep(i, n) {
        rep(j, k) {
            dp[i+j+1] = min(dp[i] + abs(h[i]-h[i+j+1]), dp[i+j+1]);
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}



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

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

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll a1 = 2;
    ll a2 = 1;
    ll output;
    for (int ii = 1; ii < n; ii++) {
        if (ii % 2 == 0) {
            a2 = a1 + a2;
            output = a2;
        } else {
            a1 = a1 + a2;
            output = a1;
        }
    }

    cout << output << endl;
}

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

using namespace std;

int n, d;
int m[100];
vector<int> c[100];
int sum[100];

const int INF = 1000000000;

main(){
  while(cin >> n >> d && n && d){
    for(int i=0;i<n;i++){
      c[i].clear();
    }
    for(int i=0;i<n;i++){
      cin >> m[i];
      for(int j=0;j<m[i];j++){
        int input;
        cin >> input;
        c[i].push_back(input);
      }
    }
    fill(sum, sum+100, 0);
    for(int i=0;i<n;i++){
      for(int j=0;j<m[i];j++){
        sum[i] += c[i][j];
      }
    }
    bool f = true;
    while(f){
      f = false;
      for(int i=0;i<n;i++){
        if(m[i] <= 0) continue;
        sum[i] -= c[i][m[i]-1];
        int valM = -1;
        int valm = INF;
        for(int j=0;j<n;j++){
          valM = max(valM, sum[j]);
          valm = min(valm, sum[j]);
        }
        if(valM - valm <= d){
          m[i]--;
          f = true;
          break;
        }
        sum[i] += c[i][m[i]-1];
      }
    }
    bool ans = true;
    for(int i=0;i<n;i++){
      if(m[i] > 0){
        ans = false;
        break;
      }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////

int H,W;
char str[111][111];
int hc[111],wc[111];
char ref[111][111];

int main(){
    cin>>H>>W;
    for(i=0;i<H;i++){
        cin>>str[i];
    }

    for(i=0;i<H;i++)hc[i]=0;
    for(i=0;i<W;i++)wc[i]=0;

    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(str[i][j]=='#'){
                hc[i]=1;
                wc[j]=1;
            }
        }
    }

    for(i=0;i<H;i++){
        if(hc[i]==0)
            continue;
        for(j=0;j<W;j++){
            if(wc[j]==0)
                continue;
            cout<<str[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll k=in(),x=in();
    cout<<(500*k>=x?"Yes":"No")<<endl;
}


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

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
void writerLn(int x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000],que;
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };

void bfs(int u) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.back(); que.pop_back();
		int k = E[p].size();
		rep(i, k) {
			int v = E[p][i];
			if (d[v] > d[p] && !ok[v]) {
				ok[v] = 1; cnt++; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0;
	deque<int>que;
	que.emplace_back(0);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		int k = E[p].size();
		rep(i, k) {
			int v = E[p][i];
			if (!~d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]]);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

Measured memory_bytes: 13592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s;
	cin >> s;
	s = (double)s;
	double l;
	std::cout << std::fixed;
	l =(double) s/3.0;
	double ans = l * l * l; 
	std::cout.precision(12);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	h, w := readInt(), readInt()
	a := make([]string, h)
	for i := 0; i < h; i++ {
		a[i] = readString()
	}
	fmt.Println(strings.Repeat("#", w+2))
	for i := 0; i < h; i++ {
		fmt.Printf("#%v#\n", a[i])
	}
	fmt.Println(strings.Repeat("#", w+2))
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main() {
	int h, w;
	while (cin >> h >> w) {
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		cin.ignore();
		vector<string> grid(h*2-1);
		for(int i=0;i<h*2-1;i++)
			getline(cin,grid[i]);
		
		for(int i=0;i<grid.size();i++){
			if(!(i&1))
				grid[i]+=' ';
			for(int j=0;j<grid[i].size();j++){
				if((i&j)&1)
					grid[i][j]='1';
				if((~i&~j)&1)
					grid[i][j]='0';
			}
		}
		
		vector<vector<int> > vis(grid.size(),vector<int>(grid[0].size()));
		queue<pair<int,int> > q;
		q.push(make_pair(0,0));
		vis[0][0]=1;
		while(q.size()){
			pair<int,int> cur=q.front(); q.pop();
			int di[]={-1,1,0,0},dj[]={0,0,-1,1};
			for(int k=0;k<4;k++){
				int ni=cur.first+di[k],nj=cur.second+dj[k];
				if(ni<0 || grid.size()<=ni || nj<0 || grid[0].size()<=nj)
					continue;
				if(grid[ni][nj]=='1' || vis[ni][nj])
					continue;
				vis[ni][nj]=vis[cur.first][cur.second]+1;
				q.push(make_pair(ni,nj));
			}
		}
		
		int res=(vis.back().back()+1)/2;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
N=int(input())
a=list(map(int,input().split()))
two=0
four=0
odd=0

for i in range(N):
    cnt=0
    if a[i]%2==0:
        cnt+=1
    if a[i]%4==0:
        cnt+=1
    
    if cnt==0:
        odd+=1
    elif cnt==1:
        two+=1
    else:
        four+=1

if odd>four:
    if two==0:
        if odd==four+1:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Measured memory_bytes: 15020