akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[30000];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N, K;
	cin >> N >> K;
	int goukei = 0;
	int A[500];
	rep(i, N) {
		cin >> A[i];
		goukei += A[i];
	}

	int yakusuu[30000];
	int M = 0;
	int sq = sqrt(goukei);
	rep1(i, sq) {
		if (goukei % i == 0) {
			yakusuu[M++] = i;
			if (i * i != goukei) yakusuu[M++] = goukei / i;
		}
	}
	pakuri_sort(M, yakusuu);

	for (int i = M - 1; i >= 0; i--) {
		int k = yakusuu[i];
		int a[500];
		rep(j, N) a[j] = A[j] % k;
		pakuri_sort(N, a);

		int x = 0, y = N - 1;
		int tmp = a[0] + a[N - 1] - k;
		int kazu = a[0] + k - a[N - 1];
		while (x + 1 < y) {
			if (tmp <= 0) {
				tmp += a[++x];
				kazu += a[x];
			}
			else {
				tmp += a[--y] - k;
				kazu += k - a[y];
			}
		}
		if (kazu / 2 <= K) {
			printf("%d", k);
			break;
		}
	}

	Would you please return 0;
}

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

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

    std::vector<int> H(N);
    for(int i = 0; i < N; ++i) std::cin >> H[i];

    int cnt = 1;
    for(int i = 1; i < N; ++i)
    {
        for(int j = 0; j < i; ++j)
        {
            if(H[i] < H[j])
            {
                break;
            }

            if(j + 1 == i)
            {
                cnt++;
            }
        }
    }

    std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}


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

	ll a,mmin=99999999999,mmax=-1;
	for(ll i=0;i<n;i++)
	{
		cin>>a;
		mmin=min(mmin,a);
		mmax=max(mmax,a);
	}
	cout<<mmax-mmin;
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  for(int i=0;i<3;i++){
  if(S.at(i)=='1')
    S.at(i)='9';
    else
      S.at(i)='1';
  
  } cout<<S<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <queue>
using namespace std;


int main(){
    long long h, w;
    cin >> h >> w;
    vector<vector<int> > g(h + 2, vector<int>(w + 2, 0));
    char a;
    for(int i = 1; i <= h; ++i)
       for(int j = 1; j <= w; ++j){
           cin >> a;
           if(a == '.') g[i][j] = 1;
       }
    long long mx = 0;
    for(int i = 1; i <= h; ++i)
       for(int j = 1; j <= w; ++j){
            if(!g[i][j]) continue;
            queue<pair<int, int> > q;
            q.push(make_pair(i, j));
            vector<vector<bool> > used(h + 2, vector<bool>(w + 2, 0));
            vector<vector<int> > d(h + 2, vector<int>(w + 2, 0));
            used[i][j] = true;
            while (!q.empty()) {
                int v1 = q.front().first, v2 = q.front().second;
                q.pop();
                if(g[v1 - 1][v2]){
                    pair<int, int> to = make_pair(v1 - 1, v2);
                    if (!used[v1 - 1][v2]) {
                        used[v1 - 1][v2] = true;
                        q.push(to);
                        d[v1 - 1][v2] = d[v1][v2] + 1;
                    }
                }
                if(g[v1][v2 - 1]){
                    pair<int, int> to = make_pair(v1, v2 - 1);
                    if (!used[v1][v2 - 1]) {
                        used[v1][v2 - 1] = true;
                        q.push(to);
                        d[v1][v2 - 1] = d[v1][v2] + 1;
                    }
                }
                if(g[v1 + 1][v2]){
                    pair<int, int> to = make_pair(v1 + 1, v2);
                    if (!used[v1 + 1][v2]) {
                        used[v1 + 1][v2] = true;
                        q.push(to);
                        d[v1 + 1][v2] = d[v1][v2] + 1;
                    }
                }
                if(g[v1][v2 + 1]){
                    pair<int, int> to = make_pair(v1, v2 + 1);
                    if (!used[v1][v2 + 1]) {
                        used[v1][v2 + 1] = true;
                        q.push(to);
                        d[v1][v2 + 1] = d[v1][v2] + 1;
                    }
                }
            }
            for(int i = 1; i <= h; ++i)
               for(int j = 1; j <= w; ++j) mx = max(mx, (long long)d[i][j]);
       }
    cout << mx;
}


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

using namespace std;

int main() {

    double n,t, m = pow(10,16);
    cin >> n;
    for (int i = 0; i < 5; i++) {
        cin >> t;
        m = min(m, t);
    }
    long long ans = (long long)ceil(n / m);
    cout <<  ans + 4;
    return 0;
}

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

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.2")

#define all(x) (x).begin(),(x).end()

long long inp(){
    long long x;
    cin >> x;
    return x;
}

void opting(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
}

const long long maxn = 1e5 + 69, lg = 19;
long long A[maxn];
int n;
bool solve(){
    long long O, E;
    O = E = 0;
    long long G = 0;

    for(int i = 0; i < n; i++){
        if(A[i] & 1)
            O++;
        else
            E++;
        G = __gcd(G, A[i] - (A[i] & 1));
    }

    if(E & 1)
        return 1;
    if(O > 1)
        return 0;
    for(long long i= 0; i < n; i++)
        if(A[i] == 1)
            return 0;
        else
            A[i] = (A[i] - (A[i] & 1)) / G;
    return !solve();
}


int main(){
    opting();
    n = inp();
    for(long long i = 0; i < n; i++) cin >> A[i];//A.push_back(inp());//, cout << n << endl;
    if(solve())
        cout <<"First";
    else
        cout <<"Second";
}


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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init() {

}

void solve() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> v[12];
	int P[12];
	for (int i = 0; i < m; i++) {
		int k, s;
		scanf("%d", &k);
		for (int q = 0; q < k; q++) {
			scanf("%d", &s);
			v[--s].push_back(i);
		}
	}
	for (int i = 0; i < m; i++) {
		int p; scanf("%d", &p);
		P[i] = p;
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		int A[12];
		for (int i = 0; i < m; i++)
			A[i] = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				for (auto q : v[j])
					A[q]++;
			}
		}
		int on = 0;
		for (int i = 0; i < m; i++) {
			if (P[i] == A[i] % 2) on++;
		}
		if (on == m) ans++;
	}
	printf("%d\n", ans);
}

const bool mtc = false;

int main() {
	int t;
	if (mtc) {
		scanf("%d", &t);
		while (t--) solve();
	}
	else solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<map>
using namespace std;
map<int, int>room;

int main() {
	int n;
	int cnt=1;
	cin >> n;
	room[n]++;
	while (true) {
		cnt++;
		if (n % 2 == 0) {
			n /= 2;
		}
		else n = 3*n + 1;
		if (room[n]!=0) {
			cout << cnt << endl;
			break;
		}
		else room[n]++;
	}
	return 0;
}

Measured memory_bytes: 3644
n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j]).is_integer():
      ans+=1
print(ans)

Measured memory_bytes: 30204
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]

n, m, k = map(int, input().split())

uf = UnionFind(n)
ex = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.merge(a,b)
    ex[a].append(b)
    ex[b].append(a)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.getRoot(c) == uf.getRoot(d):
        ex[c].append(d)
        ex[d].append(c)


ans = []
for i in range(n):
    r = uf.getRoot(i)
    ans.append(uf.sizes[r] - len(list(set(ex[i]))) - 1)
ans = [str(i) for i in ans]
print(' '.join(ans))

Measured memory_bytes: 47100
from collections import deque
 
H, W = [int(x) for x in input().split()]
cell = [list(input()) for i in range(H)]
black = 0
stack = deque([[0,0]])
for h in range(H):
    for w in range(W):
        if cell[h][w] == '#':
            black += 1

dp = [[-1]*W for _ in range(H)]
dp[0][0] = 0
while len(stack) > 0:
    y,x = stack.popleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        ny = y + dy
        nx = x + dx
        if 0 <= ny < H and 0 <= nx < W and cell[ny][nx] == '.' and dp[ny][nx] == -1:
            dp[ny][nx] = dp[y][x]+1
            stack.append([ny, nx])

if dp[-1][-1] != -1:
    print(H*W-black-dp[-1][-1]-1)
else:
    print(-1)

Measured memory_bytes: 73820
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

	vector<int> a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int ans = (a[0] * 10 + a[1]) + a[2];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0016
int main(){
    int x,h,m,s;
    cin>>x;
    h=x/3600;
    m=(x-3600*h)/60;
    s=x-3600*h-60*m;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


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

typedef pair<int,int> pii;
struct LowLink{
    int n, k, rootCnt;
    vector<int> ord, low, parent;
    vector<bool> vis;
    vector<vector<int>> v;
    vector<pii> edge;

    LowLink(int n) : n(n){
        ord.resize(n);
        low.resize(n);
        parent.resize(n);
        vis.resize(n, 0);
        v.resize(n);
    }

    void add_edge(int a, int b){
        edge.push_back({a, b});
        v[a].push_back(b);
        v[b].push_back(a);
    }

    void dfs(int x, int p, int &k){
        parent[x] = p;
        ord[x] = low[x] = k++;
        vis[x] = true;
        for(int j : v[x]){
            if(vis[j]){
                if(j != p)  low[x] = min(low[x], ord[j]);
            }else{
                if(x == 0)  rootCnt++;
                dfs(j, x, k);
                low[x] = min(low[x], low[j]);
            }
        }
    }

    void build(){
        k = 0;
        rootCnt = 0;
        dfs(0, -1, k);
    }

    vector<pii> bridge(){
        vector<pii> ret;
        for(pii p : edge){
            int x = p.first, y = p.second;
            if(ord[x] > ord[y]) swap(x, y);
            if(ord[x] < low[y]) ret.push_back(p);
        }
        return ret;
    }

    vector<int> articulationPoint(){
        vector<int> ret;
        if(rootCnt > 1) ret.push_back(0);
        for(int i = 1; i < n; i++){
            int p = parent[i];
            if(p > 0 && low[i] >= ord[p])   ret.push_back(p);
        }
        sort(ret.begin(), ret.end());
        ret.erase(unique(ret.begin(),ret.end()),ret.end());
        return ret;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    LowLink l(n);
    while(m--){
        int u, v;
        cin >> u >> v;
        if(u > v)   swap(u, v);
        l.add_edge(u, v);
    }
    l.build();
    vector<int> res = l.articulationPoint();
    for(int i : res)    cout << i << endl;
    return 0;
}


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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int n , m , x , y , vis[N] , cnt[N];

int main()
{
    read(n) , read(m);
    vis[1] = 1; // cnt[1] = 1;
    while(m--)
    {
        read(x) , read(y);
        if(vis[x])
        {
            if(cnt[x] == 0) vis[x] = 0;
            vis[y] = 1;
        }
        cnt[x]-- , cnt[y]++;
    }
    int Ans = 0;
    rep(i , 1 , n)
        Ans += vis[i];
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        if(N == 1) System.out.println("Hello World");
        
        if(N == 2){
            int A = sc.nextInt();
            int B = sc.nextInt();
            System.out.println(A + B);
        }
    }
}


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

int main() {
    const int MAX = 100000;
    int n, C; cin >> n >> C;
    vector<vector<int>> imos(C, vector<int>(MAX + 1));
    while (n--) {
        int s, t, c; cin >> s >> t >> c; c--;
        imos[c][s - 1]++, imos[c][t]--;
    }
    vector<int> sum(MAX + 1);
    for (int c = 0; c < C; c++) {
        for (int i = 0; i < MAX; i++) imos[c][i + 1] += imos[c][i];
        for (int i = 0; i <= MAX; i++) sum[i] += bool(imos[c][i]);
    }
    int ma = 0;
    for (int i = 0; i <= MAX; i++) ma = max(ma, sum[i]);
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 12416
n, l = map(int, input().split())
apple = 0
if l >= 0:
    for i in range(2, n+1):
        taste = l + i -1
        apple += taste
elif l < 0 and n > abs(l):
    for i in range(1, n+1):
        taste = l + i -1
        apple += taste
else:
    for i in range(1, n):
        taste = l + i -1
        apple += taste

print(apple)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using PP = pair<int, int>;

int n;
int a[100000];
int b[100000];

bool possible() {
  vector<int> p(a, a + n);
  vector<int> q(b, b + n);
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  
  for (int i = 0; i < n; ++i) {
    if (p[i] > q[i]) return false;
  }
  return true;
}

bool ambiguous() {
  vector<int> p(a, a + n);
  vector<int> q(b, b + n);
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  
  for (int i = 1; i < n; ++i) {
    if (p[i] <= q[i - 1]) return true;
  }
  return false;
}

bool iscycle() {
  vector<PP> p;
  vector<PP> q;
  for (int i = 0; i < n; ++i) {
    p.push_back(PP(a[i], i));
    q.push_back(PP(b[i], i));
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  
  vector<int> mp(n);
  for (int i = 0; i < n; ++i) {
    mp[p[i].second] = q[i].second;
  }
  
  int c = 0;
  int cnt = 0;
  do {
    c = mp[c];
    ++cnt;
  } while(c != 0);
  
  return cnt == n;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  
  if (possible()) {
    if (ambiguous()) {
      cout << "Yes" << endl;
    } else {
      if (iscycle()) {
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
      }
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3444
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=500005;
//const ll Mod=1000000007;
const ll Mod=998244353;
using namespace std;

int n;
vector<int>g[500];
int d[500],cnt[500],zd;
string s;
int f;

int dfs(int u,int s)
{
    d[u]=s;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(d[v])
        {
            if((d[v]-d[u])%2==0)
                return 1;
        }
        else
        {
            if(dfs(v,s+1))
            {
                return 1;
            }
        }
    }
    return 0;
}

void bfs(int u)
{
    cnt[u]=1;
    queue<int>q;
    q.push(u);
    while(q.size())
    {
        int u=q.front();
        q.pop();
        zd=max(cnt[u],zd);
        for(int i=0;i<g[u].size();i++)
        {
            int v=g[u][i];
            if(cnt[v]==0)
            {
                cnt[v]=cnt[u]+1;
                q.push(v);
            }
        }
    }
    return;
}


int main()
{
    sync;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=0;j<n;j++)
        {
            if(s[j]=='1')
            {
                g[i].push_back(j+1);
            }
        }
    }
    
    f=0;
    if(dfs(1,1))
    {
        cout<<-1<<endl;
        return 0;
    }
    
    zd=0;
    for(int i=1;i<=n;i++)
    {
        mm(cnt);
        bfs(i);
    }
    
    cout<<zd<<endl;
    return 0;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    
    int Vans = 0;
    int Sans = 0;
    double dns = 0;
    
    REP(x,30) REP(y,30) {
        if ( x == 0 and y == 0 ) continue;
        int V = x * 100 * A + y * 100 * B; // 水の量
        if ( V > F ) continue;
        
        int Smax = min( 100 * F - 100 * V, V * E); // 砂糖の上限 * 100
        
        REP(i,3000) REP(j,3000){
            int S = i * 100 * C + j * 100 * D;
            if ( S <= Smax ){
                int Vall = V + S/100;
                double dns2 = (double)S / (double)Vall;
                if ( dns2 >= dns ){
                    Vans = Vall;
                    Sans = S/100;
                    dns = dns2;
                }
            }
        }
    }
    cout << Vans << " " << Sans << endl;
    
    return 0;
}


Measured memory_bytes: 3640
//Problem C
#include<bits/stdc++.h>
using namespace std;
int rd(){
    int a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}

char ch[256];
string str1,str2;
#define NO {printf("No");return 0;}
int main(){
    cin>>str1>>str2;
    int n=str1.length();
    for(int i=0;i<n;i++){
        if(ch[str1[i]]&&ch[str1[i]]!=str2[i])NO
        ch[str1[i]]=str2[i];
    }//printf("QAQ");
    for(char i='a';i<='z';i++)for(char j=i+1;j<='z';j++)if(ch[i]&&ch[i]==ch[j])NO
    printf("Yes");
    return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

int main(){
  ll H,W;
  cin >> H >> W;
  ll ans = 0;
  if(min(H,W) > 1){
    int h,w;
    h = H % 2; w = W % 2;
    H -= h; W -= w;
    ans += (H * W) / 2;
    H += h; W += w;
    if(h){
      ans += (W / 2) + W % 2;
    }
    if(w){
      ans += H / 2 + H % 2;
    }
    if(h && w){
      ans -= 1;
    }

    cout << ans << endl;
  }
  else{
    cout << 1 << endl;
  }
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

vector<int> adj[100005];
int minDis[100005];
int color[100005];
int v[100005];
int d[100005];
int c[100005];

void dfs(int node, int Dleft, int Cin){
	if(Dleft <= minDis[node])
		return;
	minDis[node] = Dleft;
	if(color[node] == 0)
		color[node] = Cin;
	rep(i,0,adj[node].size()){
		int to=adj[node][i];
		dfs(to, Dleft-1, Cin);
	}
}

int main(){
	int N, M, Q;
	scanf("%d%d", &N, &M);
	rep(i,0,N)
		minDis[i]=-1;
	rep(i,0,M){
		int a, b;
		scanf("%d%d", &a, &b);
		--a;--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	scanf("%d", &Q);
	rep(i,0,Q)
		scanf("%d%d%d", v+i, d+i, c+i);
	rrep(i,Q,0){
		dfs(v[i]-1, d[i], c[i]);
	}
	rep(i,0,N)
		printf("%d\n", color[i]);
}

Measured memory_bytes: 8440
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N+10], b[N+10], c[N+10], d[N+10];
    map<int, int> red, blue;
    for(int i = 0; i < N; ++i){
        cin >> a[i] >> b[i];
        red[a[i]] = b[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> c[i] >> d[i];
        blue[c[i]] = d[i];
    }
    int count = 0;
    vector<int> vr, vb;
    for(auto bitr = blue.begin(); bitr != blue.end(); ++bitr){
        auto bkey = bitr->first;
        auto bvalue = bitr->second;
        int tmp = -1;
        for(auto ritr = red.begin(); ritr != red.end(); ++ritr){
            auto rkey = ritr->first;
            auto rvalue = ritr->second;
            if(rkey < bkey && rvalue < bvalue && find(vr.begin(), vr.end(), rvalue) == vr.end() && find(vb.begin(), vb.end(), bkey) == vb.end() && rvalue > tmp) tmp = rvalue;
        }
        if (tmp != -1){
            count++;
            //cout << tmp << " " << bkey << bvalue << endl;
            vr.push_back(tmp);
            vb.push_back(bkey);
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double X[200100];
int N;
long long Count(long double len)
{
  long long Ans=0;
  for(int i=0;i<N;i++)
  {
    Ans+=(long long)(X[i]/len);
    //Ans+= (ceil(X[i])-1/len);
  }
  return Ans;
}
int main()
{
  long long K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
{
	cin>>X[i];
	//X[i]-=0.1;
}
  long double l=1,r=1e9;
  //while(l<r-0.1)
	for(int i=0;i<300;i++)
  //while(((long long)(r)-(long long)(l)) > 1)
  //while(!((ceil(r)-ceil(l)) == 0))
  {
    //long double mid=(l+r+0.1)/2;
    long double mid=(l+r)/2;
  //  cout<<l<<" "<<r<<" "<<mid<<endl;
    if(Count(mid)<=K) r=mid;
    else	l=mid;
    //else	l=mid+0.01;
  }
  cout<<(long long)(l+0.999)<<endl;
  return 0;
}

Measured memory_bytes: 6748
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    sort(ALL(a));
    int sum = accumulate(ALL(a), 0);
    if(sum % 10 != 0){
        cout << sum;
        return 0;
    }
    int mn = 105;
    for(auto &x : a){
        if(x % 10 != 0){
            mn = min(mn, x);
        }
    }
    if(mn == 105){
        cout << 0;
    }else{
        cout << sum - mn;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f>=65 and m+f<80:
        print("B")
    elif m+f>=50 and m+f<65:
        print("C")
    elif m+f>=30 and m+f<50:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

int main(){
  long long K;
  cin >> K;
  long long now = 7%K;
  vector<bool> S(K,false);
  
  for(int i=1;;i++){
    long long r = now%K;
    if(r==0){
      cout << i << endl;
      return 0;
    }
    if(S[r]==true){
      cout << -1 << endl;
      return 0;
    }
    S[r] = true;
    now *= 10;
    now += 7;
    now %= K;
  }
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll ans = -LINF;
    ans = max(A*C,A*D);
    ans = max(ans,B*C);
    ans = max(ans,B*D);
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
   
   
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int p = sc.nextInt();
		
		int A = a * p;
		int B = b + Math.max(p - c, 0) * d;
		
		System.out.println(Math.min(A, B));
		
		
		
	}
	
}

Measured memory_bytes: 26272
N = int(input())
l_h = list(map(int,input().split()))

l_cost = [0,abs(l_h[1]-l_h[0])]

for i in range(2,N):
  min_cost=min(abs(l_h[i]-l_h[i-1]) + l_cost[i-1] , abs(l_h[i]-l_h[i-2]) + l_cost[i-2])
  l_cost.append(min_cost) 

print(l_cost[N-1])

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

int main()
{
    string s; cin >> s;
    for (int i=0; i<s.size(); i++){
        if (s[i]==s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
S = input()

ans = 1
tmp = S[0]
for s in S:
    if s != tmp :
        ans += 1
        tmp = s

print(ans)



Measured memory_bytes: 12600
N,M=map(int,input().split())
A=[int(input()) for i in range(M)]
mod=10**9+7
dp=[0]*(N+1)
dp[0]=1
j=0
for i in range(1,N+1):
    if j<M and i==A[j] :
        j+=1
        continue
    if i==1:
        dp[1]=dp[0]
        continue
    dp[i]=dp[i-1]+dp[i-2]
    dp[i]%=mod
print(dp[N])

Measured memory_bytes: 50008
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int B = s.nextInt();
		int H = s.nextInt();
		int M = s.nextInt();
		
		BigDecimal lenax = BigDecimal.valueOf(A * Math.cos((Math.PI/6) * H + (Math.PI/360) * M));
		BigDecimal lenay = BigDecimal.valueOf(A * Math.sin((Math.PI/6) * H + (Math.PI/360) * M));
		
		BigDecimal lenbx = BigDecimal.valueOf(B * Math.cos((Math.PI/30) * M));
		BigDecimal lenby = BigDecimal.valueOf(B * Math.sin((Math.PI/30) * M));
		
		BigDecimal x = lenax.subtract(lenbx).pow(2);
		BigDecimal y = lenay.subtract(lenby).pow(2);
		
		System.out.println(x.add(y).sqrt(MathContext.DECIMAL128));
    }
}

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

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

    int n;
    cin >> n;

    vector<vector<int>> a(10, vector<int>(10, 0));

    for (int i = 1; i <= n; i++)
    {
        string str = to_string(i);
        int fir = str[0] - '0';
        int sec = str[str.length() - 1] - '0';
        a[fir][sec]++;
    }

    long long res = 0;

    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            res += a[i][j] * a[j][i];

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using lli =long long int;
int main(void){
    int roop,stk;
    vector<lli> a,b,c;
    
    cin >> roop;
    for(int i=0;i<roop;i++){
        cin >> stk;
        a.push_back(stk);
    }
    for(int i=0;i<roop;i++){
        cin >> stk;
        b.push_back(stk);
    }
    for(int i=0;i<roop;i++){
        cin >> stk;
        c.push_back(stk);
    }
    
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    
    lli ans = 0;
    for(int i=0;i<roop;i++){
        ans += (lower_bound(a.begin(),a.end(),b[i]) - a.begin()) * (c.end() - upper_bound(c.begin(),c.end(),b[i]));
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3316
#include <stdio.h>

int main(){

  int x, y;
  int tmp;

  while(1){
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0)
      break;
    if(x > y)
      printf("%d %d\n", y, x);
    else
      printf("%d %d\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 600
h,w,k=map(int,input().split())
cho=[]
for _ in range(h):
    a=list(input())
    for f in range(w):
      a[f]=int(a[f])
    cho.append(a)

ans=1000000000009

for i in range(2**(h-1)):
    cut=0
    cut_n=[]
    b=[]
    for j in range(h-1):
        if (i>>j)&1:
            cut_n.append(j+1)
            cut+=1
    if len(cut_n)==0:
        ok=1
        dp=0
        for i in range(w):
            wa=0
            for j in range(h):
                wa+=cho[j][i]

            if dp+wa>k:
                cut+=1
                dp=wa
            else:
              dp+=wa

            if wa>k:
                ok+=1
                break
            
        if ok==1:
          ans=min(ans,cut)

    else:
        st=0
        for t in range(len(cut_n)):
            if t==len(cut_n)-1:
                b.append(cut_n[t]-st)
                b.append(h-cut_n[t])
            else:
              b.append(cut_n[t]-st)
              st=cut_n[t]
        
        dp=[0 for _ in range(len(b))]
        ok=1
        for y in range(w):
            for g in dp:
                if g>k:
                    ok+=1
                    break
            st=0
            ch=0
            c=[]
            for e in range(len(b)):
              p=b[e]
              temp=0
              for q in range(p):
                  temp+=cho[st+q][y]
                    
                  dp[e]+=cho[st+q][y]

              c.append(temp)
                
              st+=p

            for g in dp:
                if g>k:
                    ch+=1

            if ch!=0:
                cut+=1
                dp=c

            
            for last in c:
                  if last>k:
                      ok+=1

        
        if ok==1:
            ans=min(ans,cut)

print(ans)




Measured memory_bytes: 75464
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
double a,b,x;
bool f(double theta)
{
	double y=a*tan(theta);
	if(y<=b)return a*a*b-a*a*y/2>=x;
	else return a*b*b>=x*tan(theta)*2;
}
main()
{
	cin>>a>>b>>x;
	double L=0,R=M_PI/2;
	for(int i=0;i<50;i++)
	{
		double M=(L+R)/2;
		if(f(M))L=M;
		else R=M;
	}
	cout<<fixed<<setprecision(16)<<L*180/M_PI<<endl;
}


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

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

int main()
{
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll g = a[0];
  rep(i, n) g = gcd(g, a[i]);
  rep(i, n) {
    if (a[i] < k) continue;
    ll t = a[i]-k;
    if (t%g == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;


int main(){
  cin >> N;
  map<ll,int> value_index;
  for(int i=1; i<=N; i++){
    ll val; cin >> val;
    value_index[val] = i;
  }
  
  ll ans=0;
  multiset<int> S;
  S.insert(0  ); S.insert(0  );
  S.insert(N+1); S.insert(N+1);
  
  auto init_iter = value_index.rbegin();
  for(int i=0; i<N; i++){
    ll X = init_iter->second;
    auto iter = S.lower_bound(X);
    int r1, r2, l1, l2;
    iter++; r2 = *iter;
    iter--; r1 = *iter;
    iter--; l1 = *iter;
    iter--; l2 = *iter;
    ans+=(X -l1)*(r2-r1)*init_iter->first;
	ans+=(l1-l2)*(r1-X )*init_iter->first;
    
    S.insert(X);
    init_iter++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 11136
#include <stdio.h>
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a % 3 == 0 || b % 3 == 0 || ((a + b) % 3 == 0)) {
		printf("Possible\n");
	} else {
		printf("Impossible\n");
	}
	return 0;
}

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

X_list = [int(n) for n in input().split()]
total = 0
for X in X_list:
    total += X

avg_left = total // N
avg_right = (total // N) + 1

dist_left = 0
dist_right = 0
for X in X_list:
    dist_left += (X - avg_left)**2
    dist_right += (X - avg_right)**2

print(min(dist_left,dist_right))


Measured memory_bytes: 3060
#include <complex>
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	double _x[6];
	while(cin >> _x[0]){
		for(int i = 1; i < 6; i++){
			char c;
			cin >> c;
			cin >> _x[i];
		}
		complex<double> x0(_x[0],_x[1]);
		complex<double> x1(_x[2],_x[3]);
		complex<double> q(_x[4],_x[5]);
		complex<double> r = polar(abs(q-x0),2*arg(x1-x0)-arg(q-x0)) + x0;
		printf("%.6f %.6f\n",real(r),imag(r));
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int N;
	int d[110] = {0};
	int i, j;
	int keisan = 1;

	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%d", &d[i]);

	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (d[j - 1] > d[j]) {
				int keep = d[j - 1];
				d[j - 1] = d[j];
				d[j] = keep;
			}
		}
	}

	for (i = 0; i < N - 1; i++) {
		if (d[i] < d[i + 1]) keisan++;
	}

	printf("%d", keisan);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int m,f,r,i,total=0;

	while(1){
	scanf("%d %d %d",&m,&f,&r);
	

	if(m == -1 && f ==-1 && r == -1) break;
	
	if(m == -1 || f == -1)
	puts("F");
	else if(m+f >= 80)
		puts("A");
	else if(m+f >= 65)
		puts("B");
	else if(m+f >= 50)
		puts("C");
	else if(m+f >= 30) {
	if(r >= 50)	puts("C");
	else puts("D");
	} else
		puts("F");
		
	}
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	set<char> t;
	for (int i = 0; i < s.size(); i++)
	{
		t.insert(s[i]);
	}
	
	if(s.size() == t.size()) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	string t = ReadLine();
	int ans = 0;
	for (int i = 0; i < 3; i++)
	    if(s[i] == t[i]) ans++;
	WriteLine(ans);
    }
}


Measured memory_bytes: 11092
main :: IO ()
main = do
  s <- getLine
  t <- getLine
  putStrLn $ solve s t 0

solve :: String -> String -> Int -> String
solve s t i
  | i > length s = "No"
  | otherwise = if s == t
                then "Yes"
                else solve news t (i + 1)
    where news = [last s] ++ init s


Measured memory_bytes: 892
#include    <bits/stdc++.h>
#define     ll long long
#define     ull unsigned long long
#define     ld long double
#define     prec(k) fixed << setprecision(k)
#define     up(i, k, n) for (int i = k ; i < n ; i ++)
#define     down(i, k, n) for (int i = k ; i >= n ; i --)
#define     ii pair<int, int>
#define     pll pair <ll, ll>
#define     X first
#define     Y second
#define     str basic_string <int>
#define     QuanPham
const int maxN = (int) 1e4 + 7;
const int maxM = (int) 1e5 + 7;
const int maxT = (int) 1e6 + 7;
const int INF = 2e9;

using namespace std;

int n, a[57], maxa = -INF, mina = INF, argmaxa = -1, argmina = -1;

void enter()
{
	cin >> n;
	up(i, 0, n)
	{
		cin >> a[i];
		if (a[i] > maxa)
		{
			maxa = max(maxa, a[i]);
			argmaxa = i;
		}
		if (a[i] < mina)
		{
			mina = min(mina, a[i]);
			argmina = i;
		}
	}
}

void solve()
{
	if (mina >= 0)
	{
		cout << n - 1 << '\n';
		up(i, 0, n - 1) cout << i + 1 << ' ' << i + 2 << '\n';
	}
	else if (maxa <= 0)
	{
		cout << n - 1 << '\n';
		down(i, n, 2) cout << i << ' ' << i - 1 << '\n';
	}
	else if (abs(maxa) >= abs(mina))
	{
		cout << 2 * n - 1 << '\n';
		up(i, 1, n + 1) cout << argmaxa + 1 << ' ' << i << '\n';
		up(i, 0, n - 1) cout << i + 1 << ' ' << i + 2 << '\n';
	}
	else
	{
		cout << 2 * n - 1 << '\n';
		up(i, 1, n + 1) cout << argmina + 1 << ' ' << i << '\n';
		down(i, n, 2) cout << i << ' ' << i - 1 << '\n';
	}
}

int main()
{
    #ifdef QuanPham
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen ("A.INP", "r", stdin);
    //freopen ("A.OUT", "w", stdout);

    enter();
    solve();
//////////////////

    #ifdef QuanPham
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vi buttonNum(n);
	int pos = 0, res = 0;
	for (int i = 0; i < n; i++) {
		buttonNum[pos]++;
		if (pos == 1) break;
		pos = a[pos] - 1;
		res++;
	}

	cout << (buttonNum[1] == 0 ? -1 : res) << endl;
	return 0;
}

Measured memory_bytes: 1024
class Node
  attr_accessor :order, :parent, :child, :edges, :lowest, :visited, :isArticulation
  def initialize
    @order = nil
    @parent = -1
    @child = []
    @edges = []
    @lowest = nil
    @visited = false
    @isArticulation = false
  end
end

def dfs(root, g)
  t = 1
  stack = []
  g[root].order = g[root].lowest = t
  g[root].visited = true

  stack << root
  while stack.size > 0
    u = stack[-1]
    flag = true
    g[u].edges.each{|x|
      if g[x].visited == false
        t += 1
        g[x].order = g[x].lowest = t
        g[x].visited = true
        g[x].parent = u
        g[u].child << x
        flag = false
        g[u].lowest = [g[u].lowest, g[x].lowest].min
        stack << x
        break
      elsif x != g[u].parent
        g[u].lowest = [g[u].lowest, g[x].order].min
      end
    }
    if flag
      stack.pop
      g[u].child.each{|v|
        g[u].lowest = [g[u].lowest, g[v].lowest].min
        g[u].isArticulation = true if (u != root && g[u].order <= g[v].lowest)
        # if g[u].order < g[v].lowest
        #   if u < v
        #     $bridge << [u, v]
        #   else
        #     $bridge << [v, u]
        #   end
        # end
      }
    end
  end
  g[root].isArticulation = true if g[root].child.size > 1
end

# $bridge = []

$t = 1
v, e = gets.split.map(&:to_i)
graph = Array.new(v){Node.new}
e.times{
  s, t = gets.split.map(&:to_i)
  graph[s].edges << t
  graph[t].edges << s
}

dfs(0, graph)

# v.times{|i|
#   puts "#{graph[i].order} #{graph[i].parent} #{graph[i].lowest} #{graph[i].child}"
# }

v.times{|i|
  if graph[i].isArticulation
    puts i
  end
}

# $bridge.sort.each{|a, b|
#   puts "#{a} #{b}"
# }

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    string s; cin >> s;

    vi e_csum(n+1), w_csum(n+1);
    rep(i,n) {
        e_csum[i+1] += e_csum[i] + (s[i] == 'E'? 1 : 0);
        w_csum[i+1] += w_csum[i] + (s[i] == 'W'? 1 : 0);
    }

    i32 ans = inf;
    for(i32 i = 0; i < n; ++i) {
        chmin(ans, w_csum[i]-w_csum[0] + e_csum[n]-e_csum[i+1]);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 8212
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char s[10];
	int len;
	scanf("%s",s+1);
	len=strlen(s+1);
	for(int i=1;i<len;i++)
		if(s[i]=='A'&&s[i+1]=='C') {puts("Yes");return 0;}
	puts("No");	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
    int x,n,p[100],ans=0,a[100],b;
    scanf("%d %d",&x,&n);
    for(int i=0;i<n;i++)
        scanf("%d",&p[i]);

    for(int i=1;i<=100;i++)
        a[i]=i;

    for(int i=0;i<n;i++)
        a[p[i]]=10000;

    for(int i=-100;i<=101;i++)
    {
        b=abs(x-i);
        if(b<abs(x-ans)&&a[i]!=10000)
            ans=i;
    }
printf("%d",ans);

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if((c-a-b)*(c-a-b)>4*a*b&&c-a-b>=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
int main(){
IOS;
lli a,c,b;
cin>>a>>b>>c;
c-=(a-b);
cout<<max(c,(lli)0)<<endl;
}


Measured memory_bytes: 256