akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,day=0,full=0;
  bool change=true;
  cin >> n;
  ll next[n],ind[n],bday[n];
  ll a[n][n-1],riv;
  fill(next,next+n,-1);
  fill(ind,ind+n,0);
  fill(bday,bday+n,-1);
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  while(change){
    change=false;
    day++;
    for(int i=0;i<n;i++){
      if(ind[i]>n-2)continue;
      if(next[i]==-1){
        next[i]=a[i][ind[i]];
      }
      riv = a[i][ind[i]];
      if(i==next[riv]&&bday[riv]!=day&&bday[i]!=day){
        ind[riv]++;
        next[riv]=-1;
        next[i]=-1;
        ind[i]++;
        bday[i]=day;
        bday[riv]=day;
        change=true;
        if(ind[riv]==n-1)full++;
        if(ind[i]==n-1)full++;
      }
    }
    /*
    cout << "ind";
    for(int i=0;i<n;i++)cout <<ind[i]<<" ";
    cout << endl;
    */
    if(full==n)break;
  }
  change=true;
  for(int i=0;i<n;i++){
    if(ind[i]!=n-1){
      change=false;
      break;
    }
  }
  if(change){
    cout <<day<<endl;
  }else{
    cout << "-1\n";
  }
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    VL A(3*N);
    rep(i, 0, 3*N) cin >> A[i];

    VL S(2*N+1, 0);
    priority_queue<ll, vector<ll>, greater<ll>> d1;

    rep(i, 0, N){
        S[i+1] = S[i] + A[i];
        d1.push(A[i]); 
    }
    rep(i, N, 2*N){
        auto q = d1.top();
        if(q < A[i]){
            d1.pop();
            d1.push(A[i]);
            S[i+1] = S[i] - q + A[i];
        }else{
            S[i+1] = S[i];
        }
    }

    VL T(2*N+1, 0);
    priority_queue<ll> d2;
    rep(i, 0, N){
        d2.push(A[N*3 - 1 - i]);
        T[i+1] += T[i] + A[3*N - 1 -i];
    }
    rep(i, N, 2*N){
        auto q = d2.top();
        if(A[3*N - 1 - i] < q){
            d2.pop();
            d2.push(A[3*N - 1 -i]);
            T[i+1] = T[i] - q + A[3*N - 1 - i];
        }else{
            T[i+1] = T[i];
        }
    }

    ll ans = -1e18;
    rep(i, N, 2*N+1){
        ans = max(ans, S[i]-T[3*N - i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8052
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

LL gcd(LL a, LL b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b-a, a);
}

LL lcm(LL a, LL b) {
    LL g = gcd(a, b);
    return (a / g) * b;
}

int main(void) {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (double)w * (double)h / 2.0 << " " << (x*2 == w && y*2 == h) << endl;
}

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

int main() {
	int n, i;
	cin >> n;
	int x[n];
	for (i = 0; i < n; i++ ){
		cin >> x[i];
	}
/*	i = n;
	while(true){
		i--;
        cout << x[i] << " ";
		if(i == 1)break;
	}*/
	for(i = n - 1; i > 0; i--){
		cout << x[i] << " ";
	}
	cout << x[i] << endl;
	return 0;
}

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

int main() {
    int n, m, c;
    cin >> n >> m >> c;

    int b[m];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

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

    int cnt = 0, ab;
    for (int i = 0; i < n; i++) {
        ab = 0;
        for (int j = 0; j < m; j++) {
            ab += a[i][j] * b[j];
        }
        if (ab + c > 0) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
  int main(void)
{
  int x,y;
  y=1;
  while(1)
    {
        scanf("%d",&x);
        if(x==0)break;
        printf("Case %d: %d\n",y,x);
        y=y+1;
    }
    return 0;
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
int main(){
  int n;
  cin >> n;
  vector<ll>v(n);
  rep(i,n)cin >> v[i];
  rep(i,n)v[i] *= 2;
  ll tmp = 0;
  rep(i,n)tmp = v[i] - tmp;
  ll ans = tmp / 2;
  rep(i,n){
    cout << ans << " ";
    ans = v[i] - ans;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3976
#include <stdio.h>
int main(void) {
int N,x[10];
double ans=0,X;
char s[4];
scanf("%d",&N);
for(int i=0;i<N;i++) {
scanf("%lf%s",&X,s);
if(s[0]=='B'&&s[1]=='T'&&s[2]=='C')X=X*380000;
ans+=X;
}
printf("%lf",ans);
}

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

int main(void){
  int N,Q;
  scanf("%d%d",&N,&Q);

  int sum[N+1];
  char S[100000];
  scanf("%s",S);

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

  int flag = 0;
  for(int i = 0;i < strlen(S);i++){
    if(S[i] == 'A'){
      flag = 1;
    }else if(S[i] == 'C' && flag == 1){
      sum[i] = 1;
      flag = 0;
    }else{
      flag = 0;
    }
  }

  for(int i = 1;i <= N;i++){
    sum[i] += sum[i-1];
  }

  int r,l;
  int res;
  for(int i = 0;i < Q;i++){
    scanf("%d%d",&r,&l);
    r--; l--;
    res = sum[l]-sum[r];
    printf("%d\n",res);
  }

  return 0;
}

Measured memory_bytes: 1280
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e7+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
LL two[SIZE];
void build(){
    assert(MOD>=SIZE);
    two[0]=1;
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD,two[i]=two[i-1]*2%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
int main(){
    MOD = 998244353;
    build();
    int N;
    R(N);
    LL an=1;
    REP(i,N)an=an*3%MOD;
    FOR(i,N/2+1,N){
        ADD(an,-C(N,i)*2*two[N-i]);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 234624
N=int(input())
p=[int(i) for i in input().split()]
flag=1
for k in range(N-1):
    if p[k]>p[k+1]:
        flag=0
        break
if flag==1:
    print("YES")
    exit()
for i in range(N):
    for j in range(N):
        if i>=j:
            continue
        q=[p[i] for i in range(N)]
        q[i],q[j]=q[j],q[i]
        flag=1
        for k in range(N-1):
            if q[k]>q[k+1]:
                flag=0
                break
        if flag==1:
            print("YES")
            exit()
print("NO")


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;
  int start, end;

  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'A'){
      start = i;
      break;
    }
  }

  for(int i = s.length()-1; i >= 0; i--){
    if(s[i] == 'Z'){
      end = i;
      break;
    }
  }

  cout << end - start + 1 << endl;


  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define lmod 15000000000031
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define vll vector<ll>
#define sll set<ll>
#define pb(a) push_back(a) 
#define loop(i,a,b) for(ll i = (ll)a ; i < (ll)b ; i++)
#define rtloop(i,a,b) for(ll i = (ll)a ; i >= (ll)b ;i--)

/*long long moduloMultiplication(long long a, 
                            long long b, 
                            long long modu) 
{ 
    long long res = 0; // Initialize result 
  
    // Update a if it is more than 
    // or equal to mod 
    a %= modu; 
  
    while (b) 
    { 
        // If b is odd, add a with result 
        if (b & 1) 
            res = (res + a) % modu; 
  
        // Here we assume that doing 2*a 
        // doesn't cause overflow 
        a = (2 * a) % modu; 
  
        b >>= 1; // b = b / 2 
    } 
  
    return res; 
} */

int main(){    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t,n;
    cin >> t;
    bool flag = 0, flag2 = 0 , flag3 = 0;
    rtloop(i,9,1){
        if(t % i == 0){t /= i; flag3 = 1; break;}
    }
    
    rtloop(i,9,1){
        if(t % i == 0){t /= i; flag2 = 1;break;} 
        
    }
    if(flag3 ==0 ||flag2 == 0)flag = 1;
    
    if( t != 1) cout << "No";
    else cout << "Yes";
    
    return 0;
    
}

    
    


Measured memory_bytes: 256
#include<stdio.h>

void x(int,int);

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

  return 0;
}

void x(int a,int b){
  int key,status;

  if(a<b){
    key=a;
    a=b;
    b=key;
  }

  status=a%b;
  while(status != 0){
    a=b;
    b=status;
    status=a%b;
  }

  printf("%d\n",b);
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    for(int i = 0; i <= s.size(); i++){
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
        rotate(s.rbegin(), s.rbegin()+1, s.rend());
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))
    elif op == "?":
        break


Measured memory_bytes: 5596
#include <cstdio>
#define abs(x) ((x)<0?-(x):(x))
int main(){
    long long x,k,d,y;scanf("%lld%lld%lld",&x,&k,&d);
    y=abs(x)/d;
    if(k<=y) printf("%lld\n",abs(x)-k*d);
    else{
        long long now=abs(x)-d*y;
        if(k-y&1ll) printf("%lld\n",abs(now-d));
        else printf("%lld\n",now);
    }
    return 0;
}

Measured memory_bytes: 1724
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xa = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(xa[0] < xa[1] ? 0 : 10);
        }
    }
}


Measured memory_bytes: 13396
<?php

fscanf(STDIN, "%d", $n);
$X = array_map('intval', explode(' ', trim(fgets(STDIN))));

$sortX = $X;
sort($sortX);
$l = $sortX[$n / 2 - 1];
$r = $sortX[$n / 2];

for ($i = 0; $i < $n; $i++) {
    if ($X[$i] <= $l) {
        echo $r, PHP_EOL;
    } else {
        echo $l, PHP_EOL;
    }
}


Measured memory_bytes: 37816
num = int(input())
lst = list(map(int,input().split()))
count = 0
counta = 0
for i in range(num):
  if lst[i] % 2 == 0:
    count += 1
    if lst[i] % 3 == 0 or lst[i] % 5 == 0:
      counta += 1
if count == counta:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#define LOCAL
#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 rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int dp[MAX * 10];

vector<ll> dividedNum(ll n){
    //n == 2 && n == 1の時エラー
    vector<ll> res;
	ll lim = sqrt(n)+1;
    for(ll i=1; i<lim; i++){
        if(n%i==0){
            res.push_back(i);
            if(i != n / i && lim <= n/i){
                res.push_back(n/i);
            }
        }
    }
    return res;
}


int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	memr(dp, 0);

	ll N; cin >> N;
	vector<ll> A(N);
	rep(i, N){
		cin >> A[i];
		if(dp[A[i]] != 0){
			dp[A[i]] = -1;
			continue;
		}
		dp[A[i]] = i + 1;
	}

	ll ans = 0;
	rep(j, N){
		vector<ll> divs = dividedNum(A[j]);
		bool ok = false;
		for(ll x : divs){
			if(dp[x] && dp[x] != j + 1){
				ok = true;
			}
		}
		if(ok) continue;
		ans ++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8808
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [[0 for _ in range(S+1)] for __ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2 * dp[i][j]
        dp[i+1][j] %= MOD
        if j+A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= MOD

print(dp[N][S])

Measured memory_bytes: 147444
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int yakusu( int x, int y ) {
	int k;
	if ( x == 0 || y == 0 ) return 1;
	if ( x < y ) {
		k = x;
		x = y;
		y = k;
	}
	while(true) {
		k = x % y;
		if ( k == 0 ) break;
		x = y;
		y = k;
	}
	return y;
}

int main(){
	while(true) {
		int a;
		cin >> a;
		int b;
		cin >> b;
		int c;
		cin >> c;
		if ( a == 0 ) break;
		double x = b * b - 4 * a * c;
		double y = sqrt(x);
		if ( (int) y != y ) {
			cout << "Impossible" << endl;
			continue;
		}
		int bunsi = b - y;
		int bunbo = 2 * a;
		int k = yakusu( abs(bunsi), bunbo );
		int p = bunbo / k;
		int q = bunsi / k;
		if ( bunsi == 0 ) {
			p = 1;
		}
		bunsi = b + y;
		k = yakusu( abs(bunsi), bunbo );
		int r = bunbo / k;
		int s = bunsi / k;
		if ( bunsi == 0 ) {
			r = 1;
		}
		if ( p < r || ( p == r && q < s ) ) {
			cout << r << " " << s << " " << p << " " << q << endl;
		}else {
			cout << p << " " << q << " " << r << " " << s << endl;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int x, y ;
    cin >> x >> y ;
    REP(i,101){
        REP(j,101){
            if(i+j==x && 2*i+4*j==y){
                yes() ;
                return 0 ;
            }
        }
    }
    no() ;

    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

using namespace std;

int main() {

    int x, y;
    int ans = 0;

    cin >> x >> y;

    if(x == y && x ==1)
        cout << "1000000\n";
    else
    {
        switch(x)
        {
            case 1:
                ans += 300000;
                break;
            case 2:
                ans += 200000;
                break;
            case 3:
                ans += 100000;
                break;
        }

        switch(y)
        {
            case 1:
                ans += 300000;
                break;
            case 2:
                ans += 200000;
                break;
            case 3:
                ans += 100000;
                break;
        }

        cout << ans << endl;

    }
        
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long i,j,c=1,real=0;
  long adigi,bdigi;
  char a[100000]={0},b[100000]={0};
  long reala=0,realb=0,reals[100000]={0},digit[100000]={0};
  while(c){
    a[0]=getchar();
    for(i=0;a[i]!=' ';){
      if(a[i]==EOF){
	c=0;
	break;
      }
      i++;
      a[i]=getchar();
    }
    adigi=i;
    if(a[0]!=EOF){
      b[0]=getchar();
      for(i=0;b[i]!='\n';){
	i++;
	b[i]=getchar();
      }
      bdigi=i;
    
      for(i=adigi-1,j=1;i>=0;i--,j*=10){
	reala+=(a[i]-48)*j;
      }
      for(i=bdigi-1,j=1;i>=0;i--,j*=10){
	realb+=(b[i]-48)*j;
      }
      reals[real]=reala+realb;
      reala=0;
      realb=0;
      real++;
    }
  }
  for(i=0;i<real;i++){
    for(;reals[i];){
      reals[i]/=10;
      digit[i]++;
    }
    printf("%d\n",digit[i]);
  }
  return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    long long int h;
    cin >> h;
    long long int log2ans = (long long int)log2(h);

    cout << dec << (long long int)(pow(2, log2ans) * 2 - 1) << endl;
    return 0;
}

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

char N[5];

int main() {
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
  else if (N[1] == N[2] && N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

//#define DEBUG

const int INF = 1 << 30;

int bitcount(int f) {
	int res = 0;
	for (int i = 0; i < 31; ++i)
		if (f & (1 << i))
			++res;
	return res;
}

int main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> s(H);
	for (int i = 0; i < H; ++i) cin >> s[i];
	int res = INF;
	for (int flag = 0; flag < (1 << (H - 1)); ++flag) {
#ifdef DEBUG
		cout << "flag : " << flag << endl;
#endif
		// flag : 横割りの場所
		vector<int> cnt(bitcount(flag) + 1, 0);
		int tmp = bitcount(flag); bool f = false;
		// 縦方向に割る場所を検査
		for (int j = 0; j < W; ++j) {
			int ptr = 0;
			for (int i = 0; i < H; ++i) {
				if (s[i][j] == '1') ++cnt[ptr];
				if (flag & (1 << i)) ++ptr;
			}
			bool ok = true;
			for (auto ci : cnt)
				ok = ok && ci <= K;
			if (!ok) {
				++tmp;  cnt = vector<int>(bitcount(flag) + 1, 0);
				ptr = 0;
				for (int i = 0; i < H; ++i) {
					if (s[i][j] == '1') ++cnt[ptr];
					if (flag & (1 << i)) ++ptr;
				}
				ok = true;
				for (auto ci : cnt)
					ok = ok && ci <= K;
				if (!ok) goto FIN;
			}
		}
		res = min(res, tmp);
	FIN:;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        Console.WriteLine(Solve(int.Parse(input[0]),int.Parse(input[1])));
    }
    static int Solve(int a, int b)
    {
        int small,mod;
        if(a>b){
            small=b;
            mod=a%b;
        }else{
            small=a;
            mod=b%a;
        }
        if (mod == 0) return small;
        else return Solve(small, mod);
    }
}

Measured memory_bytes: 19868
#!/usr/bin/env python3


def main():

    N = int(input())
    A = list(map(int, input(). split()))

    cnt = 0
    for i, a in enumerate(A):
        if i % 2 == 0 and a % 2 == 1:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 505;

int n, m, x, y, s[MAXN][MAXN], a, b;
LL sum;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = read(), m = read(), x = read(), y = read();
	if (x * y == 1) return puts("No"), 0;
	a = (1000000000 - 1) / (x * y - 1), b = - a * (x * y - 1) - 1;
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) s[i][j] = a;
	for (int i = x; i <= n; i += x) for (int j = y; j <= m; j += y) s[i][j] = b;
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) sum += s[i][j];
	if (sum <= 0) return puts("No"), 0;
	puts("Yes");
	for (int i = 1; i <= n; i ++, putchar(10))
		for (int j = 1; j <= m; j ++)
			printf("%d ", s[i][j]);
}


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

const int N = 1e5 + 9;

int ar[ N ], dp[ N ];

int main(){
    int n, k;
    ios::sync_with_stdio( false );

    cin >> n >> k;
    for( int i = 1; i <= n; i++ ){
        cin >> ar[ i ];
    }


    fill( dp + 1, dp + 1 + n, 1e9 );
    dp[ 1 ] = 0;

    for( int i = 2; i <= n; i++ ) {
        for( int j = 1; j <= k && i > j; j++ ) {
            dp[i] = min(dp[i], dp[i - j] + abs(ar[i] - ar[i-j]));
        }
    }

//    for( int i = 1; i <= n; i++ )
//        cout << dp[ i ] << " ";

    cout << dp[ n ] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    ll n,d;
    cin>>n>>d;

    ll arr[n][d];
    for(ll i=0;i<n;i++)
        for(ll j=0;j<d;j++)
            cin>>arr[i][j];

    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ll sum=0;
            for(ll k=0;k<d;k++)
            {
                ll val  = (arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]);
                sum = sum+val;
            }

            ll test = sqrt(sum);
            if(test*test == sum)
                ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define rep1(i,n) for(int i=1;i<(int)(n);++i)

    #define rep(i,n) for(int i=0;i<(int)(n);++i)
    #define repone(i,n) for(int i=1;i<(int)(n);++i)

    #define Rep(i,n) for(int i=0;i<(int)(n);++i)

    #define int long long

    using namespace std;

    signed main()
    {
        string x;
        int n=0,m=0,i;
        cin>>x;
        rep(i,x.length()){
        if(x[i]==48) n++;
        else m++;
        }
        if(n>=m)        cout<<m*2<<endl;
        else cout<<n*2<<endl;
        return 0;
    }


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include <list>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll X,A;
  cin>>X>>A;
  if(X<A){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int N,M;
    cin >> N >> M;
    vint H(N);
    vector<pint> p(M);
    rep(i,N) cin >> H[i];
    rep(i,M) cin >> p[i].first >> p[i].second;

    vint a(N,0);
    rep(i,M){
        int x = p[i].first-1;
        int y = p[i].second-1;
        if(H[x] < H[y])a[x]=1;
        else if(H[x] > H[y])a[y]=1;
        else a[x]=1,a[y]=1;
    }
    cout << N -accumulate(a.begin(),a.end(),0);
    return 0;
}



Measured memory_bytes: 4844
#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) << " "
int main(){
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    int b[n];copy(a, a+n, b);
    sort(a, a+n, greater<int>());
    for(int i=0;i<n;i++){
        if(b[i]==a[0])co(a[1]);
        else co(a[0]);
    }
}


Measured memory_bytes: 3200
from math import ceil

N,K = map(int,input().split())
A = sorted([int(i) for i in input().split()]) # 消化コスト
F = sorted([int(i) for i in input().split()],reverse = True) # 食べにくさ
cost = [a*f for a,f in zip(A,F)]

# にぶたん
# K回以下の修行でチーム成績がMになるか
# Mを固定して考える
def grade_is(M:int):
    training = 0
    for i in range(N):
        if cost[i] > M:
            training += ceil((cost[i] - M) / F[i])
        if training > K:
            return False
    return True

def main():
    ok = 10 ** 18 + 1
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if grade_is(mid):
            ok = mid
        else:
            ng = mid

    print(ok)

if __name__ == "__main__":
    main()

Measured memory_bytes: 122572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  LL a[n];
  LL sum=0, absmin=(LINF);
  int negcount=0;
  REP(i, n){
    cin>>a[i];
    sum += abs(a[i]);
    absmin = min(abs(a[i]), absmin);
    if(a[i]<0)++negcount;
  }

  if(absmin==0 || negcount%2==0){
    cout<<sum<<endl;
  }
  else if(negcount%2==1){
    cout<<(sum-2*absmin)<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  int a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = A; i < 100000; i += A) {
    if (i % B == C) return cout << "YES" << "\n", 0;
  }
  cout << "NO" << "\n";
}

Measured memory_bytes: 3636
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    S = in_s()

    wsum = [0] * N

    for i in range(N):
        if S[i] == 'W':
            wsum[i] += 1

    for i in range(N - 1):
        wsum[i + 1] += wsum[i]

    ans = 10**9 + 7
    for i in range(N):
        t = N - (i + 1) - (wsum[N - 1] - wsum[i])
        if i != 0:
            t += wsum[i - 1]
        ans = min(ans, t)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    long long int curt=1, cura=1;
    for(int n=0; n<N; n++) {
        long long int T, A;
        cin >> T >> A;
        long long int kt=curt/T;
        long long int ka=cura/A;
        if(curt%T!=0) {
            kt++;
        }
        if(cura%A!=0) {
            ka++;
        }
        curt = max(kt, ka)*T;
        cura = max(kt, ka)*A;
    }
    cout << curt + cura << endl;


    return 0;
    
}

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

#define LIMIT 100

void printArray(int[],int);

int main(int argc, char** argv) {
    int count;
    int error = 0;
    
    int checkScan = scanf("%d", &count);
    if(checkScan != 1)
        return (EXIT_FAILURE);
    
    const int arraySize = count;
    int array[arraySize];
    
    if(count > LIMIT || count < 1)
        return(EXIT_FAILURE);
    
    int chkScan;
    for(int i = 0; i < count; i++){
        chkScan = scanf("%d", &array[i]);
        if(chkScan != 1)
            return(EXIT_FAILURE);
    }
    
    printArray(array, count);
        
    int temp, j;
    for(int i = 1; i < count; i++){
        temp = array[i];
        j = i - 1;
        while(j >= 0 && array[j] > temp)
            array[j+1] = array[j--];
        array[j+1] = temp;
        printArray(array, count);
    }
    
    return (EXIT_SUCCESS);
}

void printArray(int array[], int count){
    for(int i = 0; i < count; i++){
        if(i != count - 1)
            printf("%d ", array[i]);
        else if(i == count - 1)
            printf("%d", array[i]);
    }
    printf("\n");
}



Measured memory_bytes: 2136
s=input()
cnt_up=0
cnt=0
if s[0]=='A':
    for i in range(len(s)):    
        if s[i].isupper():
            cnt_up+=1
        if i>1 and i<len(s)-1 and s[i]=='C':     
            cnt+=1
if cnt_up==2 and cnt==1:
    print('AC')
else:
    print('WA')
    
            

Measured memory_bytes: 9024
#include<iostream>
#include<cstdio>
#include<cstring>
#define ma(a,b) (a<b?b:a)
#define mi(a,b) (a<b?a:b)
using namespace std;
inline int read(){
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9'){
        x=(x<<3)+(x<<1)+ch-48;
        ch=getchar();
    }
    return x;
}
const int maxn=1e5+4;
int head[maxn],siz[maxn],num[maxn];
long long dep[maxn],ans1=0;
int n,m,cnt=0,rt=0,sum=0x3f3f3f3f,minn=0x3f3f3f3f;
struct node{
    int to,next;
    long long w;
}e[maxn<<1];
inline void add(int u,int v,int w){
    e[cnt].to=v;e[cnt].next=head[u];e[cnt].w=w;head[u]=cnt++;
}
inline void findrt(int u,int fa){
    siz[u]=1;
    for(int i=head[u];i!=-1;i=e[i].next){
        int v=e[i].to;
        if(v==fa) continue;
        findrt(v,u);
        siz[u]+=siz[v];
        num[u]=ma(num[u],siz[v]);
    }
    num[u]=ma(num[u],n-siz[u]);
    if(num[u]<sum){sum=num[u];rt=u;}
}
inline void dfs(int u,int fa){
    ans1+=dep[u];
    for(int i=head[u];i!=-1;i=e[i].next){
        int v=e[i].to;
        if(v==fa) continue;
        dep[v]=(long long)e[i].w+dep[u];
        dfs(v,u);
    }
}
int main(){
    n=read();
    memset(head,-1,sizeof(head));
    for(int i=1;i<=n-1;i++){
        int u=read(),v=read(),w=read();
        add(u,v,w);add(v,u,w);
    }
    findrt(1,0);
    dfs(rt,0);
    ans1<<=1;
    for(int i=head[rt];i!=-1;i=e[i].next){
        int v=e[i].to;
        minn=mi(minn,e[i].w);
        if(num[v]==num[rt]){ans1=(long long)ans1-e[i].w;cout<<ans1;return 0;}
    }
    cout<<(long long)ans1-minn;
}

Measured memory_bytes: 7424
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;


int main() {

    string S;

    std:
    cin >> S;

    char previous = S[0];

    bool ok = true;

    for (int i = 1; i < S.length(); i++) {

        if (S[i] == previous) {
            ok = false;
            break;
        } else {
            previous = S[i];
        }
    }

    if (ok) {
        std::cout << "Good" << "\n";
    } else {
        std::cout << "Bad" << "\n";
    }


    return 0;
}

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

signed main() {
    int N;
    cin >> N;
    int a = 0;
    rep (i, 100) {
        a += 1000;
        if (a >= N) break;
    }

    cout << a - N << endl;
}

Measured memory_bytes: 3584
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	ll dp[1001];
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();

	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);

	Would you please return 0;
}

Measured memory_bytes: 128
while True:
    N, M, s, g1, g2 = map(int, input().split())
    if N == M == s == g1 == g2 == 0:
        break
    s, g1, g2 = s - 1, g1 - 1, g2 - 1
    INF = 10 ** 5
    D = [[INF] * N for _ in range(N)]
    for i in range(N):
        D[i][i] = 0
    for _ in range(M):
        b1, b2, c = map(int, input().split())
        b1, b2 = b1 - 1, b2 - 1
        D[b1][b2] = c
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if D[i][j] > D[i][k] + D[k][j]:
                    D[i][j] = D[i][k] + D[k][j]
    print(min(D[s][i] + D[i][g1] + D[i][g2] for i in range(N)))

Measured memory_bytes: 8036
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi s(n+1);
    s[0] = 0;

    rep(i, n) s[i+1] = s[i] + a[i];

    lint res = 0;

    unordered_map<lint, lint> m;

    rep(i, n+1) {
        m[s[i]]++;
    }

    for (auto&& p : m) {
        lint v = p.second;
        if (v >= 2) {
            res += v * (v - 1) / 2;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11592
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

void solve()
{
  ll a, b;
  cin >> a >> b;
  if (a == b)
  {
    cout << 2 * a - 2 << endl;
    return;
  }

  auto simulate = [&](ll x) {
    ll t = ((x + 1) / 2) * (x + 1 - ((x + 1) / 2));
    return t < a * b;
  };

  auto binary_search = [&]() {
    ll lo = 1, hi = (ll)INF * 10;
    while (hi - lo > 1)
    {
      ll mi = (lo + hi) / 2;
      if (simulate(mi))
        lo = mi;
      else
        hi = mi;
    }
    return lo;
  };
  ll ans = binary_search() - 1;
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int q;
  cin >> q;
  rep(qi, q)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << max({a+b, a-b, a*b}) << endl;
	return 0;
}


Measured memory_bytes: 764
if __name__ == "__main__":
    S = input()
    N = len(S)
    if S[0] == S[-1]:
        if N % 2 == 0:
            print("First")
        else:
            print("Second")
    else:
        if N % 2 == 0:
            print("Second")
        else:
            print("First")


Measured memory_bytes: 3316
n, sum_w = map(int, input().split())
weight = []
value = []
for i in range(n):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)

dp = [[0] * (sum_w + 1) for i in range(n+1)]

for i in range(n):
    for j in range(sum_w + 1):
        if j < weight[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i])

print(dp[-1][-1])


Measured memory_bytes: 121436
#include<stdio.h>
#define N 100
int main(){
  int M[N][N];
  int i, j, u, n, k, v;

  scanf("%d",&n);
  for(i = 0;i < n;i++ ){
    for(j = 0;j < n;j++ ){
      M[i][j]=0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 0; i < n;i++){
    for(j = 0;j < n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
} 

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int n, m;
	int a;
	long long int sum;
	cin >> n >> m;
	sum=0;
	for(int i=0;i<m;i++){
		cin >> a;
		sum+=a;
	}
	sum=n-sum;
	if(sum>=0) cout << sum << endl;
	else cout << "-1" << endl;
}

Measured memory_bytes: 3636
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  
  else:break
Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
  else:break

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)
print(max(C))

Measured memory_bytes: 67396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
ll n;cin >> n;
ll l[n];
l[0]=2;l[1]=1;
for(int i=2;i<=n;i++){
    l[i]=l[i-1]+l[i-2];
}
cout << l[n] << endl;

return 0;
}





Measured memory_bytes: 256