akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int f(Int x) {
    if (x % 2 == 0) {
        return (f(x + 1) ^ (x + 1));
    } else {
        if (((x + 1) / 2) % 2 == 0) {
            return 0LL;
        } else {
            return 1LL;
        }
    }
}

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

    Int a, b;
    cin >> a >> b;

    a--;
    Int ans = f(a) ^ f(b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = int()
    val b = int()
    println(if ((b - a) % 2 == 0) "Alice" else "Borys")
}


class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 31520
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ok(n + 1, true);
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    ok[a] = false;
  }
  vector<ll> dp(n + 2, 0);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    if (ok[i]) {
      dp[i + 1] += dp[i];
      dp[i + 1] %= MOD;
      dp[i + 2] += dp[i];
      dp[i + 2] %= MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
using namespace std;
int n,a[1000000];
int g[100];
int cnt=0;

//void shellsort(int j){
//    int h=g[j];
//    int i;
//    for(i=h;i<n;i++){
//        int v=a[i];
//        int k=i-h;
//        while(k>=0&&a[k]>v){
//            a[k+h]=a[k];
//            cnt=cnt+1;
//            k-=h;
//        }
//        a[k+h]=v;
//    }
//}

void shellsort(int j){
    int h=g[j];
    int i;
    for(i=0;i<h;i++){
        int j=i+h;
        while(j<n){
            int k=j-h;
            int v=a[j];
            while(k>=0&&a[k]>v){
                a[k+h]=a[k];
                cnt++;
                k-=h;
            }
            a[k+h]=v;
            j=j+h;
        }
    }
}

int main()
{
    cin>>n;
    int i,j,k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    memset(g,0,sizeof(g));
    i=0;
    g[i]=1;
    //??????????????????
    if(n==1)i=1;
    else
        while(g[i]<n){g[i+1]=g[i++]*3+1;}
    cout<<i<<endl;
    for(j=i-1;j>=0;j--){
        cout<<g[j];
        if(j!=0)cout<<" ";
    }
    cout<<endl;
    for(j=i-1;j>=0;j--){
        shellsort(j);
    }
    cout<<cnt<<endl;
    for(k=0;k<n;k++){
        cout<<a[k]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6904
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	LL ans=max({a*c,a*d,b*c,b*d});
	cout<<ans;
}


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

int main() {
  int N;
  int H[100010];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> H[i];

  int ans = 0;
  vector<int> vec(100010);
  int elm = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) {
      ans++;
      if (i == N - 2) {
        vec[elm] = ans;
      }
    } else {
      vec[elm] = ans;
      elm++;
      ans = 0;
    }
  }
  cout << *max_element(vec.begin(), vec.end()) << endl;
}

Measured memory_bytes: 1024
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100001

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll N;
ll A[MAX], B[MAX];
int main() {
    
    cin >> N;
    REP(i, (N+1)) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }

    ll ans = 0;

    REP(i, N) {
        ll temp = B[i] - A[i];
        if (temp > 0) {
            ans += A[i];
            B[i] = temp;
            ll temp2 = B[i] - A[i+1];
            ll hoge;
            if (temp2 > 0) {
                hoge = A[i+1];
            } else {
                hoge = B[i];
            }
            ans += hoge;
            A[i+1] = A[i+1]-hoge;
        } else {
            ans += B[i];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
const ll MOD = 1e9 + 7;

ll power(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll N;
vector<ll> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    ll ai;
    cin >> ai;
    A[i] = ai;
  }

  ll ans = 0;
  for (ll d = 0; d < 60; d++) {
    ll n0 = 0, n1 = 0;
    for (ll i = 0; i < A.size(); i++) {
      ll r = A[i] % 2;
      A[i] /= 2;
      if (r == 0) {
        n0++;
      } else {
        n1++;
      }
    }
    ans += ((power(2, d) * n0 % MOD) * n1 % MOD);
    ans %= MOD;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
//
// Created by Myabu on 2020/01/15.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int H, W;
    char C[110][110];
    cin>>H>>W;

    for (int i = 0; i < H; ++i) {
        for (int k = 0; k < W; ++k) {
            cin>>C[i][k];
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int k = 0; k < W; ++k) {
            cout<<C[i][k];
        }
        cout<<endl;
        for (int k = 0; k < W; ++k) {
            cout<<C[i][k];
        }
        cout<<endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; i++) cin >> s[i] >> t[i];
    string x; cin >> x;
    int target;
    for(int i=0; i<n; i++) {
        if(s[i]==x) {
            target = i;
            break;
        }
    }
    int ans = 0;
    if(target==n-1) {
        cout << 0 << endl;
        return 0;
    }
    for(int i=target+1; i<n; i++) {
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import Counter

#
n = int(input().strip())
a = list(map(int, input().strip().split()))

#
C=Counter()
for i in range(n):
    C[a[i]] += 1
xsum=0
for key, value in C.items():
    xsum += value*(value-1)//2

#
for k in range(n):
    print( xsum - (C[a[k]] - 1) )

Measured memory_bytes: 82772
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = x/500;
		long z = (x-y*500)/5;
		long sum = y * 1000 + z*5;

		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <iomanip>
int main(){
    long double S, C, r;
    std::cin >> r;
    S = r * r *3.1415926535897932384626 ;
    C = 2 * 3.1415926535897932384626 * r;
    std::cout <<std::fixed << std::setprecision(6) << S <<
     " " <<std::fixed << std::setprecision(6) << C << std::endl;
    return 0;
}


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

int main(){
	int x[10010];
	int y[10010];
	int i = 0, i2, i3 = 0;
	while (i < 10010){
		cin >> x[i];
		cin >> y[i];
		if (x[i] == 0){
			if (y[i] == 0){
				i2 = i;
				break;
			}
		}
		i++;
	}
	while (i3 < i2){
		for (int i4 = 0; i4 < y[i3]; i4++){
			cout << "#";
		}
		cout << endl;
		for (int i5 = 0; i5 < x[i3] - 2; i5++){
			cout << "#";
			for (int i6 = 0; i6 < y[i3] - 2; i6++){
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (int i7 = 0; i7 < y[i3]; i7++){
			cout << "#";
		}
		cout << endl << endl;
		i3++;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<stdio.h>
#include<iostream>
using namespace std;

int n=0,q=0;
int A[2100];


int s(int i,int m){
  int tu=0;
  if(m==0)return 1;
  if(i>=n)return 0;
  if(s(i+1,m)==1||s(i+1,m-A[i])==1)tu=1;
  else tu=0;
  return tu;
}

int main(){
  
  int m=0;
  int M[2100];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>M[i];
    if(s(0,M[i])==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int h1 = stdIn.nextInt();
		int m1 = stdIn.nextInt();
		
		int h2 = stdIn.nextInt();
		int m2 = stdIn.nextInt();
		
		int k = stdIn.nextInt();
		
		
		int a = 60*h1+m1;
		int b = 60*h2+m2;
		
		System.out.println(b-a-k);
		
		
		
		
	}

}


Measured memory_bytes: 35756
import java.util.*;
        public class Main{
        	public static void main(String[] args){
        		Scanner s=new Scanner(System.in);
        		int W=s.nextInt();
        		int a=s.nextInt();
        		int b=s.nextInt();
        		if(a<=b){
        			if(b-(a+W)>0){
        			System.out.println(b-(a+W));
        			}else if(b-(a+W)<=0)System.out.println(0);
        		}
        		if(a>b){
        			if(a-(b+W)>0){
        			System.out.println(a-(b+W));
        			}else if(a-(b+W)<=0)System.out.println(0);
        }
        }
        }

Measured memory_bytes: 21972
def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

r,g,b,n = get_nums_l()

ans = 0
for ra in range(n//r + 1):
    for ga in range(n//g + 1):
        now = r * ra + g * ga
        nokori = n - now
        if nokori >= 0 and nokori % b == 0:
            ans += 1

print(ans)

Measured memory_bytes: 40812
#include<stdio.h>

int main()
{
   int n, i, j, v;
   int c = 0;
   int flag = 1;
   int a[1000];

   scanf("%d", &n);
   
   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }
 
   while(flag == 1){
	flag = 0;
	
	for(j = n-1; j >= 1; j--){
		if(a[j] < a[j-1]){
			v = a[j];
			a[j] = a[j-1];
			a[j-1] = v;
			c = c+1;
			flag = 1;
		}
	}
   }

      for(i = 0; i < n; i++){
         printf("%d", a[i]);

         if(i != n-1){
            printf(" ");
         } else if(i == n-1){
            printf("\n");
         }
      }
      
      printf("%d\n", c);

return 0;

}
 





Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    sp(10);
    double a,b;cin>>a>>b;
    double h,m;cin>>h>>m;
    double x=6*m,y=30*h+0.5*m;
    double buf=abs(x-y);
    double pi=acos(-1);
    buf*=pi/180;
    double res=a*a+b*b-2*a*b*cos(buf);
    //cout<<x<<" "<<y<<endl;
    res=sqrt(res);
    cout<<res<<endl;
}

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 998244353
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    ll a; double b;
    cin>>a>>b;
    ll b1 = (floor)(b*100+0.1);
    ll ans = a*b1;
    ans = ans/100;
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    // init();
    int t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 3864
N = int(input())
C = list(input())
Rc = 0
Wc = 0
for i in range(N):
    if C[i]=="R":
        Rc+=1
    else:
        Wc+=1
out = 0
for i in range(Rc):
    if C[i]=="W":
        out += 1
print(out)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vi> s(11);
  REP(i, M)
  {
    int k;
    cin >> k;
    REP(j, k)
    {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  REP(i, M)
  cin >> p[i];
  int ans = 0;
  for (int mask = 0; mask < (1 << N); ++mask)
  {
    // int cnt = 0;
    // int cnt2 = 0;
    bool ok = true;
    for (int i = 0; i < M; ++i)
    {
      int tmp = 0;
      for (int j = 0; j < s[i].size(); ++j)
      {
        if ((mask >> s[i][j]) & 1)
          tmp++;
      }
      if (tmp % 2 != p[i])
        ok = false;
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

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

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}
vector<vector<int>> dd;

int main()
{
	string s;
	cin >> s;
	cout << ((s == "ABC") ? "ARC" : "ABC");
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  int N; cin >> N;
  vector<string> S(N);
  REP(i, N) cin >> S[i];
  int ans = 0;
  REP(A, N) {
    vector<string> T(N);
    REP(i, N) T[i] = S[i];
    REP(i, N) REP(j, N) T[(i + A) % N][j] = S[i][j];
    bool flag = true;
    REP(i, N) REP(j, N) {
      flag &= T[i][j] == T[j][i];
    }
    if (flag) ans += N;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define abs(a,b) (a-b > 0 ?  a-b : b-a)
 
int main()
{
  int x,n;
  cin >> x >> n;
  int a[100];
  rep(i,0,n)cin >> a[i];
  
  int ans=0;
  int abso=10000;

  rep(i,0,102)
  {
      bool flag=false;
    rep(j,0,n)
    {
     if(i == a[j])
       flag=true;
    }
    if(flag)
      continue;
    if(abso > abs(i,x))
    {
   		abso=abs(i,x);
   		ans=i;
   	}
    
  }
    cout << ans << endl;
}
  

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
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 vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N, K;
  cin >> N >> K;

  vector<char> P(N);
  map<char, int> co;
  rep(i, N) {
    string s;
    cin >> s;
    co[s[0]]++;
  }

  priority_queue<int> q;
  forr(cn, co) q.push(cn.snd);

  int ans = 0;
  while (SZ(q) >= K) {
    vi h;
    rep(i, K) {
      int x = q.top(); q.pop();
      if (x >= 2) h.push_back(x-1);
    }
    forr(x1, h) q.push(x1);
    ans++;
  }

  _p("%d\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    string S, T;
    cin >> S >> T;

    int count =0;
    for (int i = 0; i <3;i++) {
        if (S[i] == T[i]) count++;
    }

    cout << count << endl;
    return 0;
}




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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n, x;
vi s;
vector<ll> ps;
ll dp[401][401];

ll calc(int l, int r){
	if(dp[l][r]!=-1) return dp[l][r];
	if(l==r) return 0;

	ll ans=1e18;
	rep(i, l+1, r){
		ans=min(ans, ps[r]-(l==0?0:ps[l-1])+calc(l, i-1)+calc(i, r));
	}
	return dp[l][r]=ans;
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n){
  	cin >> x;
  	s.pb(x);
  	ps.pb(x+(i==1?0:ps[i-2]));
  }
  rep(i, 0, 400){
  	rep(j, 0, 400){
  		dp[i][j]=-1;
  	}
  }
  cout << calc(0, n-1);
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll a, b, c;
  cin >> a >> b >> c;
  cout << max({a,b,c}) - min({a,b,c}) << endl;
  return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int l=s.length();
    vector<int>res;
    for(int i=0; i<l; i++)
    {
        if(s[i]=='0')
        {
            res.push_back(0);
        }
        else{
            if(s[i]=='1')
                res.push_back(1);
            else{
                if(!res.empty())
                    res.pop_back();
            }
        }
    }
    for(int v :res) cout<<v;
}


Measured memory_bytes: 3612
fun main(args: Array<String>){
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    var d = 0
    var s = 0
    while (s < c) {
        d += 1
        if (d % 7 == 0) s += b
        s += a
    }
    println(d)
}


Measured memory_bytes: 27360
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
 
long long MOD = 1000000007;
 
int main() {
    
    double z = -1;
    long long x = 0;
    long long y = 0;
    
    long long A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    
    long long w;
    for ( long long a = 0; a <= 30; a++ ) {
    for ( long long b = 0; b <= 30; b++ ) {
        
        if ( !a && !b ) { continue; }
        
        w = 100*A*a + 100*B*b;
        
        if ( F < w ) { continue; }
        
        long long s = min( (A*a + B*b)*E, F-w );
        
        long long m = 0;
        for ( long long c = 0; c <= 1500; c++ ) {
        for ( long long d = 0; d <= 1500; d++ ) {
            if ( c*C+d*D > s ) { continue; }
            m = max( m, (c*C+d*D) );
        }
        }
        
        s = m;
        
        double zs = (100*static_cast<double>(s))/(static_cast<double>(s)+static_cast<double>(w));
        
        if ( z < zs ) {
            x = w+s;
            y = s;
            z = zs;
        }
    }
    }
    
    if ( !x ) {
        cout << A*100 << " " << 0 << endl;
    }
    else {
        cout << x << " " << y << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){
	
	int a,b,sum = 0;
	
	cin>>a>>b;
	
	int vec[a];
	
	for(int i = 0; i < a; i++)
	{
		cin>>vec[i];
		sum+= vec[i];
		}
	int cnt = 0;
	for(int i = 0; i < a; i++){
		if((double)vec[i] >= (double)sum/(4*b)) cnt++;
		if(cnt == b) break;
		}
	if(cnt == b) cout<<"Yes\n";
	else cout<<"No\n";
		
	
	return 0;
}


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

int main() {
    string result = "No";
    string s, p, tmp;
    cin >> s >> p;

    tmp = s + s;

    if(tmp.find(p) != -1){
        result = "Yes";
    }

    cout << result << endl;
}



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

int main(){
  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;
  int jap = 0, over = 0;
  for(int i = 0; i < N; i++){
    if(s.at(i) == 'a' && jap + over < A + B){
      cout << "Yes" << endl;
      jap++;
    }
    else if(s.at(i) == 'b' && jap + over < A + B && over < B){
      cout << "Yes" << endl;
      over++;
    }
    else cout << "No" << endl;
  }
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n,q;
  cin>>n>>q;
  vector<ll> a(n);
  cin>>a;
  vector<pll> lr(q);
  cin>>lr;

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

  for(auto query:lr){
    auto fit = lower_bound( a.begin(), a.end(),query.first);
    auto sit = upper_bound(a.begin(),a.end(),query.second);
    cout<<(sit-fit)<<endl;
  }

}


Measured memory_bytes: 5172
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = [-1 for _ in range(N)]
for s, c in sc:
    if ans[s-1] == -1:
        ans[s-1] = c
    if ans[s-1] != c:
        print(-1)
        exit()

if N == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(ans[0])
    exit()

if ans[0] == 0:
    print(-1)
    exit()
if ans[0] == -1:
    ans[0] = 1
res = str(ans[0])
for i in range(1, N):
    if ans[i] == -1:
        res += "0"
    else:
        res += str(ans[i])
print(res)

Measured memory_bytes: 3064
#include<stdio.h>
int t[5],a,b;
 
int main(){
  int i,j;
  while(1){
    scanf("%d",&t[0]);
    if(t[0]==0)break;
    for(i=1;i<5;i++)scanf("%d",&t[i]);
    for(i=0;i<5;i++){
      a=0;
      b=0;
      for(j=0;j<5;j++){
        if(i==j)continue;
        if(t[i]%3+1==t[j])a=1;
        if(t[i]==t[j]%3+1)b=1;
      }
      if(a==b)printf("3\n");
      else if(a==0)printf("2\n");
      else printf("1\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1012
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        N: Chars,
    }

    let last_word = N[N.len()-1];

    let ans: &str = match last_word {
        '2' | '4' | '5' | '7' | '9' => "hon",
        '0' | '1' | '6' | '8' => "pon",
        '3' => "bon",
        _ => unreachable!()
    };

    println!("{}", ans)
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    ll n; cin>>n;
    vector<ll> v(n);
    ll ans=1;
    REP(i,n){cin>>v[i];if(v[i]==0){cout<<0<<endl;return 0;}}
    sort(ALL(v),greater());
    REP(i,n){
        if(v[i]<=1000000000000000000/ans)ans*=v[i];
        else{ans=-1;break;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=100005;
const ll inf=1e9+7;
ll dp[maxn];
ll n,W;
ll w[maxn],c[maxn];
int main()
{
    //IOS;
    while(cin>>n>>W)
    {
        for(int i=1;i<maxn;i++) dp[i]=inf;
        rep(i,n)
        {
            int v,w;
            cin>>w>>v;
            for(int j=100000;j>=v;j--)
            {
                dp[j]=min(dp[j],dp[j-v]+w);
            }
        }
        for(int j=100000;j>=0;j--)
            {
                if(dp[j]<=W)
                {
                    cout<<j<<"\n";
                    break;
                }
            }
    }
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = sum(b)-sum(a)
res=0
for i in range(n):
  if b[i]>a[i]:
    res += (b[i]-a[i]+1)//2
if res > t:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 4596
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int biMatch(const vector<vector<int>>& adj, int ln) {
    int n = adj.size();
    vector<int> matchTo(n, -1);
    vector<bool> used(n, false);
    function<bool(int)> dfs = [&](int v) {
        for(int nv : adj[v]) if(!used[nv]) {
            used[nv] = true;
            if(matchTo[nv] < 0 || dfs(matchTo[nv])) {
                matchTo[v] = nv;
                matchTo[nv] = v;
                return true;
            }
        }
        return false;
    };
    int ans = 0;
    for(int v : in(ln)) if(matchTo[v] < 0) {
        used.assign(n, false);
        if(dfs(v)) ++ans;
    }
    return ans;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l, r, m;
    cin >> l >> r >> m;
    vector<vector<int>> adj(l + r);
    for(int _ : in(m)) {
        int u, v;
        cin >> u >> v;
        v += l;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    cout << biMatch(adj, l) << endl;
    return 0;
}

Measured memory_bytes: 3308
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int binarysearch(vector<int>& v, int start,int end,int target)
{
    if(start==end)
    {
        return start;
    }
    else
    {
        int mid=(start+end)/2;
        if(v[mid]<target)
        {
            return binarysearch(v,start,mid,target);
        }
        else
        {
            return binarysearch(v,mid+1,end,target);
        }
    }
}

int main()
{
    int n;
    int s;
    int target;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<int> c;
    c.push_back(a[0]);
    for(int i=1;i<n;i++)
    {
        s=c.size();
        if(c[s-1]>=a[i])
        {
            c.push_back(a[i]);
        }
        else
        {
            target=binarysearch(c,0,s-1,a[i]);
            c[target]=a[i];
        }
        
    }
    cout<<c.size()<<endl;
}


Measured memory_bytes: 1276
N = int(input())
Darray = [list(map(int, input().split())) for _ in range(N)]

tmp = []
for D in Darray:
    if(D[0] == D[1]):
        tmp.append(1)
    
    else:
        tmp.append(0)

for i in range(N-2):
    if(tmp[i] + tmp[i+1] + tmp[i+2] == 3):
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 9188
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,tot,cnt1,cnt2,clr[100010],cnt[3],vis[100010],head[100010],nxt[200010],val[200010],to[200010];
ll ans=0;
void add_edge(int u,int v,int w){
	nxt[++tot]=head[u];
	to[tot]=v;
	val[tot]=w;
	head[u]=tot;
	return;
}
bool dfs(int u){
	bool ret=1;
	cnt[clr[u]]++;
	vis[u]=1;
	cnt1++;
	for(int i=head[u];~i;i=nxt[i]){
		int v=to[i],w=val[i],tmp=clr[u]+w;
		if(tmp>=3)
			tmp-=3;
		if(tmp<0)
			tmp+=3;
		cnt2+=(w>0);
		if(!vis[v]){
			clr[v]=tmp;
			if(!dfs(v))
				ret=0;
		}
		else
			if(clr[v]!=tmp)
				ret=0;
	}
	return ret;
}
char buffer[10000010],*hd;
char Getchar(){
	return *hd++;
}
int rd(){
	int x=0;
	char c;
	do c=Getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=Getchar();
	}while(isdigit(c));
	return x;
}
int main(){
	fread(buffer,1,10000000,stdin);
	hd=buffer;
	memset(head,-1,sizeof(head));
	n=rd();m=rd();
	for(int i=1;i<=m;i++){
		int u=rd(),v=rd();
		add_edge(u,v,1);
		add_edge(v,u,-1);
	}
	for(int i=1;i<=n;i++){
		if(vis[i])
			continue;
		cnt[0]=cnt[1]=cnt[2]=cnt1=cnt2=0;
		if(!dfs(i))
			ans+=1ll*cnt1*cnt1;
		else if(cnt[0]&&cnt[1]&&cnt[2])
			ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[0]*cnt[2]+1ll*cnt[1]*cnt[2];
		else ans+=cnt2;
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5+1; int A[MAXN]; ll D[MAXN];

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    for(int i = 0; i <= N; i++)
        cin >> A[i];
    if(N == 0){
      if(A[0] == 1)
        cout << 1 << endl;
      else
        cout << -1 << endl;
      return 0;
    }
    if(N > 0 && A[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    D[N] = 0; ll sum = A[N];
    for(int i = N-1; i >= 1; i--){
        D[i] = D[i+1]+A[i+1];
        sum += A[i];
    }
    bool test = true;
    D[0] = 1; sum++;
    for(int i = 1; i <= N; i++){
        D[i] = min(2*D[i-1]-A[i], D[i]);
        if(D[i] < 0){
            cout << -1 << endl; 
          	return 0;
        }
        sum += D[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll n;cin>>n;
    ll l[n];
	rep(i,0,n) cin >> l[i];
    sort(l,l+n);
    ll sum=0;rep(i,0,n-1)sum+=l[i];
    cout<<(l[n-1]<sum?"Yes":"No")<<ednl;
}


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

using namespace std;
int main() {
  int A, B, max2;
  cin >> A >> B;
  int sum, dif, pro;
  sum = A + B;
  dif = A - B;
  pro = A * B;
  max2 = max(sum, dif);
  int ans = max(pro, max2);
  cout << ans << endl;
  return 0;
  
}

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

int N,A,B,C;
int min_cost=1<<21;
int l[8];
int natural_num(int i){
    if(i < 0){
        return 0;
    } else {
        return i;
    }
}

void calc(vector<int> v){
    // cout << "calc" << endl;
    int a=0,b=0,c=0,i=-1;
    int A_sol=0,B_sol=0,C_sol=0;
    int cost=0;
    // 各枝での合体後のA,B,C候補を計算
    for(auto itr=v.begin();itr!=v.end();itr++){
        i++;
        // cout << i << endl;
        if(*itr == 0){
            a++;
            A_sol += l[i];
        } else if(*itr == 1){
            b++;
            B_sol += l[i];
        } else if(*itr ==2){
            c++;
            C_sol += l[i];
        }
    }
    if(a!=0 and b!=0 and c!=0){
        // 合体にかかるコストを計算
        cost += natural_num(a-1) * 10;
        cost += natural_num(b-1) * 10;
        cost += natural_num(c-1) * 10;
        // 差を計算
        cost += abs(A-A_sol);
        cost += abs(B-B_sol);
        cost += abs(C-C_sol);
        // costの最小値更新
        // cout << cost;
        if(cost < min_cost) min_cost=cost;
    }
}

void dfs(int depth, vector<int> v){
    // cout << "depth" << depth << endl<< "v[0]" <<v[0] <<"add" << &v[0];
    //cout <<endl << "v[1]" <<v[1]<<"add" << &v[1];
    //cout<<endl <<"v[2]" <<v[2] <<"add" << &v[2]<< endl;
    // if(depth==N) cout << "hoge" << endl;
    if(depth==N) calc(v);
    if(depth==N) return;
    for(int i=0;i<4;i++){
        v[depth]=i;
        // cout << i <<endl;
        dfs(depth+1, v);
    }
}

int main(void) {
    cin>>N>>A>>B>>C;
    for (int i=0;i<N;i++){
        cin>>l[i];
    }
    vector<int> v(N);
    dfs(0, v);
    cout << min_cost;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++){
        for (int k = 0; k < B.size(); k++){
            for (int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(100);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=0;
  sort(a.begin(),a.end(),greater<int>());
  for (int i=0;i<n;i+=2){
    ans+=a[i]-a[i+1];
  }
  cout << ans << endl;
}

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

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



int main(){
    int n,m;
    cin>>n>>m;
    map<ll,ll> mp[n];
    int s,t,e;
    while(cin>>s>>t>>e,s!=0){
        --s;--t;
        mp[s][t]=e;
    }
    int q;
    cin>>q;
    while(q--){
        ll c[m];
        rep(i,m)cin>>c[i];
        rep(i,n){
            ll ans = 0;
            for(auto e : mp[i]){
                ans += c[e.first]*e.second;
            }
            cout<<ans;
            if(i!=n-1)cout<<" ";
            else cout<<endl;
        }
    }
}


Measured memory_bytes: 6728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = int.Parse(Console.ReadLine());
            var h = S / 3600;
            var m = (S - 3600 * h) / 60;
            var s = (S - 3600 * h - 60 * m);
            Console.WriteLine(h.ToString() + ":" + m.ToString() + ":" + s.ToString());
        }
    }
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    vector<int> v(n);

    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int sum = 0, id = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        sum += v[i];
        if (i + 1 < n and 2 * sum < v[i + 1])
            id = i + 1;
    }
    cout << n - id << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#define MAXN 100001
#define INF 2147483647
using namespace std;
int A[MAXN],B[MAXN],M[MAXN];
int main()
{
	int a,b,m;
	scanf("%d%d%d",&a,&b,&m);
	int aa=INF/2,bb=INF/2;
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&A[i]);
		aa=min(aa,A[i]);
	}
	for(int i=1;i<=b;i++)
	{
		scanf("%d",&B[i]);
		bb=min(bb,B[i]);
	}
	int maxn=aa+bb;
	for(int i=1;i<=m;i++)
	{
		int ai,bi,cost;
		scanf("%d%d%d",&ai,&bi,&cost);
		maxn=min(maxn,A[ai]+B[bi]-cost);
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 1024
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 02, 2020 6:00 PM
 *    Problem Name  : C - Repsept
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc174/tasks/abc174_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    
    ll k,temp=0;
    cin >> k;

    for(int i=1; i<=k; i++){
        temp = temp * 10 + 7;
        temp = temp % k;
        if(temp == 0){
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;

    return 0 ;
}


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

int main(void){
    
    int K;
    string S;
    cin >> K;
    cin >> S;
    
    if(S.size()<=K)cout << S << endl;
    else cout << S.substr(0,K) <<"..."<<endl;

}

Measured memory_bytes: 3628