akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    string ans = "";
    while(a > 0 && c > 0){
        c -= b;
        if(c > 0){
            a -= d;
        } else {
            ans = "Yes";
            break;
        }

        if(a <= 0) {
            ans = "No";
            break;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  if(A<3){
    scanf("%d",&A);
  }
  if(B>20){
    scanf("%d",&B);
  }
  if(A>B && A-1>B){
    C=A-1;
    printf("%d",A+C);
  }
  else if(A>B && A-1<B){
    printf("%d",A+B);
  }
  else if(A<B && B-1>A){
    C=B-1;
    printf("%d",B+C);
  }
  else if(A<B && B-1<A){
    printf("%d",A+B);
  }
  else if(A>B && A-1==B){
    printf("%d",A+B);
  }
  else if(A<B && B-1==A){
    printf("%d",A+B);
  }
  else if(A==B){
    printf("%d",A+B);
  }
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n; cin>>n;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll a,b; cin>>a>>b;
        ans += (b-a+1);
    }
    cout<<ans;
    return 0;
}


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b)
{
  if (a < b)
  {
    return gcd(b, a);
  }
  while (b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

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

  string S, T;
  cin >> S;
  cin >> T;

  ll m = T.size();
  loop(0, S.size() - T.size()+1, i) {
    ll count = 0;
    loop(0, T.size(), j) {
      if (S[i+j] != T[j]) {
        count += 1;
      }
    }
    m = min(m, count);
  }
  print(m);
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
    int N;
    cin>>N;
    bool flag=true;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a%2==0){
            if(a%3==0 or a%5==0){
                continue;
            }
            else {
                flag=false;
            }
        }
    }
    if(flag){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if b - a == c - b:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    o = S()
    e = S()
    for i in range(len(e)):
        print(o[i] + e[i], end="")
    if len(e) != len(o):
        print(o[-1], end="")
    print()
    return

#C
def C():
    l = [inf] * 27
    n = II()
    for _ in range(n):
        b = [0] * 27
        for si in S():
            b[ord(si) - 97] += 1
        for i in range(27):
            l[i] = min(l[i], b[i])
    ans = []
    for i in range(27):
        ans.append(chr(97 + i) * l[i])
    print("".join(ans))
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s;
    ll k;
    cin >> s >> k;
    int slen = s.length();

    rep(i, slen){
        if(s[i] == 'a') continue;
        if(26 - (s[i]-'a') > k) continue;
        k -= 26 - (s[i]-'a');
        s[i] = 'a';
    }

    if(k > 0){
        int rest = k%26;
        //cout << rest sp s[slen-1] << endl;
        if(s[slen-1] + rest - 'a' > 25){
            s[slen-1] = 'a';
            rest -= 26 - (s[slen-1]-'a');
        }
        s[s.length()-1] = s[slen-1]+rest;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 592
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

int main() {
    SS(ll,x)
    ll ans=0;
    ans+=(x/500)*1000;
    ans+=(x%500/5)*5;
    p(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;

int main()
{
	string a;
	cin >> a;
	if(a.substr(a.size() / 2 + 1, a.size() / 2) == a.substr(0, a.size() / 2)) {
		cout << "Yes";
	} else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  cout << N * (N - 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
char m[21][21];
int w,h,ans;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

void solve(int x,int y) {
  m[y][x]='#';
  ans++;
  
  for(int i=0;i<4;i++) {
    int nx=x+dx[i],ny=y+dy[i];
    if(nx>=0 && nx<w && ny>=0 && ny<h && m[ny][nx]!='#') {
	solve(nx,ny);
    }
  }
}

int main() {
  int sx,sy;
  while(cin>>w>>h,w||h) {
    ans=0;
    for(int y=0;y<h;y++) {
      for(int x=0;x<w;x++) {
	cin>>m[y][x];
	if(m[y][x]=='@') {
	  sx=x;sy=y;
	}
      }
    }
    solve(sx,sy);
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;
typedef pair<int,int> P;
string s;
int k;
ll INF=10000000000000000;

set<ll> a;

void dfs(int n,int &count){
    a.insert(n);
    count++;
    if(count==k) return;
    int d=n%10;
    if(d!=9) dfs(n*10+d+1,count);
    dfs(n*10+d,count);
    if(d!=0) dfs(n*10+d-1,count);
}

int main(){
    string s;cin>>s;
    int n=s.size();
    ll ans=0;
    for(int bits=0;bits<(1<<(n-1));bits++){
        for(int i=0;i<=n-1;){
            for(int j=0;j<=n-1;j++){
                if(((bits>>j)&1)||j==n-1){
                    ans+=stoll(s.substr(i,j+1-i));
                    i=j+1;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>
using namespace std;

int main(void){
    int N; cin >> N;
    int P[N];
    int min = 20000;
    
    for(int i = 0;i < N;i++) cin >> P[i];
    
    for(int i = 0;i < 4;i++){
        int count = 0;
        int Q[N];
        for(int x = 0;x < N;x++)Q[x] = P[x];
       
        for(int j = 0;j <= N - 2;j++){
            
            if(j == 0){
                count += i;
                Q[j] -= i;
            }
            
            while(Q[j] > 0){
                Q[j] -= 1; 
                Q[j+1] -= 1;
                count += 2;
            }
        
        }
        
        if(Q[N - 1] > 0)count += Q[N-1];
        
        min = min > count ? count : min;
        
    }
    
    cout << min << endl;
    
    return 0;
    
}
        
        
    


Measured memory_bytes: 3132
S = str(input())

l = len(S)
count = 0

if S[0]=='W':
	isblue = 0
else:
	isblue = 1


for i in range (1, l):
	if isblue == 0 and S[i] == 'B':
		isblue = 1
		count+=1
	elif isblue == 1 and S[i] == 'W':
		isblue = 0
		count+=1
	else:
		continue

print(count)

Measured memory_bytes: 3188
ordA = ord('a')

N = int(input())

i = 1
acc = 0
while acc + 26**i < N:
    acc += 26**i
    i += 1
#print('i:', i)
#print('acc:', acc)

N -= acc + 1
#print('N:', N)

anss = ''
for _ in range(i):
    no = N % 26
    anss += chr(ordA + no)
    N //= 26

#print('#' + anss + '#')
print(anss[::-1])


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
#define lglg long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)

long long INF = 1LL<<60;
long long MOD = 998244353;

template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    FOR(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s;
    cin >> s;
    FOR(i, 0, s.size()) s[i] = 'x';
    cout << s;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){

    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '*') cout << a * b << endl;
        else if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '/') cout << a / b << endl;
        else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
def solve(h, w):
    print('#'*w,end='')
    print(('\n#'+'.'*(w-2)+'#')*(h-2))
    print('#'*w)
    print()

if __name__ == '__main__':
    while True:
        h, w = [int(i) for i in input().split()]
        if h == w == 0: break
        solve(h, w)

Measured memory_bytes: 6800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> vec(N,-1);
    bool ret = true;
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        if(vec.at(A - 1) != -1 && vec.at(A - 1) != B) {
            ret = false;
        }
        else {
            vec.at(A - 1) = B;
        }
    }
    if(N != 1 && vec.at(0) == 0) {
        ret = false;
    }
    if(ret == false) {
        cout << -1 << endl;
    }
    else {
        for(int i = 0;i < N;i++) {
            if(vec.at(i) == -1) {
                if(i == 0) {
                    if(N == 1) {
                        cout << 0;
                    }
                    else {
                        cout << 1;
                    }
                }
                else {
                    cout << 0;
                }
            }
            else {
                cout << vec.at(i);
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    char a,b;
    cin>>a>>b;
    char ans;
    if(a=='H'&&b=='H') ans='H';
    if(a=='H'&&b=='D') ans='D';
    if(a=='D'&&b=='H') ans='D';
    if(a=='D'&&b=='D') ans='H';
    cout<<ans<<endl;
}


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

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

INF=10**9+7

s=0
for i in a:
    s=(s+i)%INF

d=0
for i in a:
    d=(d+i**2)%INF

ans=(s**2-d)%INF

def modinv(a,m):
    b=m
    (x,lastx)=(0,1)
    (y,lasty)=(1,0)
    while not b==0:
        q=a//b
        (a,b)=(b,a%b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%m
ans=(ans*modinv(2,INF))%INF

print(ans)

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

char str[200010];

void MAIN() {
    int pt = 0;
    scanf("%s", str);
    int n = strlen(str);
    for(int i = 1; i < n; ++ i) {
        if(pt >= 0 && str[pt] == 'S' && str[i] == 'T') {
            -- pt;
        } else {
            str[++ pt] = str[i];
        }
    }
    printf("%d\n", pt + 1);
}

int main() {
    MAIN();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+1;
pair<int,int> s[maxn];
int n;
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 0;i < n;++i)cin >> s[i].first >> s[i].second, ++s[i].second;
    sort(s, s+n);
    int l = 0, r = 1000000001, w = 0;
    for(int i = 0;i < n;++i){
        l = max(l, s[i].first);
        r = min(r, s[i].second);
        w = max(w, s[i].second-s[i].first);
    }
    int res = w+max(0, r-l);
    int su = s[n-1].second;
    for(int i = n-2;i > -1;--i)res = max(res, max(0, r-s[i].first) + max(0, su-l)), su = min(su, s[i].second);
    cout << res << '\n';
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

ll gcd(ll a,ll b)
{
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
	if(a==INF || b==INF) return INF;
	if(a/gcd(a,b)>INF/b) return INF;
	return a/gcd(a,b)*b;
}

int main()
{
	for(ll n,m;cin>>n>>m && n|m;){
		vl as(n);
		rep(i,n) cin>>as[i];
		vd ps(n);
		rep(i,n) cin>>ps[i],ps[i]/=100;
		
		// f(S): -1^|S| × (Sのどの要素でも割り切れる1<=x<=mの個数)
		// g(S): Sのいずれかの要素で割り切れる1<=x<=mの個数
		vl f(1<<n);
		repi(i,1,1<<n){
			ll l=1;
			rep(j,n) if(i>>j&1)
				l=lcm(l,as[j]);
			if(l==INF) continue;
			
			int sign=__builtin_popcount(i)&1?1:-1;
			f[i]+=sign*m/l;
		}
		vl g=f;
		rep(i,n) rep(j,1<<n)
			if(j>>i&1)
				g[j]+=g[j^1<<i];
		
		double res=0;
		repi(i,1,1<<n){
			double p=1;
			rep(j,n) p*=i>>j&1?ps[j]:1-ps[j];
			res+=p*g[i];
		}
		printf("%.10f\n",res);
	}
}

Measured memory_bytes: 17496
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    int A,B;
    A = inputValue();
    B = inputValue();

    if(A>9||A<1){
        cout << -1 << endl;
        return 0;
    }
    if(B>9||B<1){
        cout << -1 << endl;
        return 0;
    }

    int seki = A * B;
    cout << seki << endl;
    
    return 0;
}

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

int main(){
  ll n,m;
  cin >> n >> m;
  if(n*m==1){
    cout << 1 << endl;
    return 0;
  }
  
  if((n-1)*(m-1)==0){
    cout << max(n,m)-2 << endl;
    return 0;
  }
  
  cout << (n-2)*(m-2) << endl;
}

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

using namespace std;
const int INF = 1e9;

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

    vector<int> dp(N, INF);
    dp.at(0) = 0;

    vector<int> heights(N);
    for(int i=0; i<N; i++)cin >> heights.at(i);

    for(int i=1; i<N; i++){
        if(i==1)dp.at(i) = dp.at(i-1) + abs(heights.at(i) - heights.at(i-1));
        else{
            dp.at(i) = min(dp.at(i-1) + abs(heights.at(i) - heights.at(i-1)), dp.at(i-2) + abs(heights.at(i) - heights.at(i-2)));
        }
    }

    cout << dp.at(N-1) << endl;
}


Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

const int INF=INT_MAX/3;
const int LIMIT=100;

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

int n;
string x,y;
int ans;

int main(){
    cin>>x>>y;
    if(x==y)cout<<'='<<endl;
    else if(x>y)cout<<'>'<<endl;
    else cout<<'<'<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_h>card_t:
            H+=3
        else:
            T+=3
print(T,H)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,X;cin>>N>>X;
    vector<int>x(N+1);
    x[0]=X;
    for(int i=1;i<=N;i++){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    int A[N];
    for(int i=0;i<N;i++){
        A[i]=x[i+1]-x[i];
    }
    long long ans=x[1]-x[0];
    for(int i=1;i<N;i++){
        ans=gcd(ans,A[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4004
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a') {
			for (int j = 0; j < 3; j++) {
				if (s[j] == 'b') {
					for (int k = 0; k < 3; k++) {
						if (s[k] == 'c') {
							cout << "Yes" << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++) cin>>s[i];
    for(int i=1;i<=a+b+1;i++)
    {
        if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1)//如果i位上不是数字且i!=a+1
        {
            cout<<"No"<<endl;//输出“No”
            return 0;
        }
        if(i==a+1&&s[i]!='-')//如果a+1位上不是“-”
        {
            cout<<"No"<<endl;//输出“No”
            return 0;
        }
    }
    cout<<"Yes"<<endl;//前面输出“No”的都return了，还在运行的肯定就是“Yes”
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0;i < N;i++) {
        cin >> S.at(i);
    }
    bool ret = true;
    for(int i = 0;i < N - 1;i++) {
        for(int j = i + 1;j < N;j++) {
            if(S.at(i) == S.at(j)) {
                ret = false;
            }
        }
    }
    for(int i = 0;i < N - 1;i++) {
        if(S.at(i).at(S.at(i).size() - 1) != S.at(i + 1).at(0)) {
            ret = false;
        }
    }
    if(ret == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
from collections import Counter
n, p = [int(item) for item in input().split()]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

fac = factorize(p)
cnt = Counter(fac)
ans = 1
for key in cnt.keys():
    ans *= key**(cnt[key] // n)
print(ans)

Measured memory_bytes: 3316
use std::io::*;
use std::str::FromStr;

fn main(){
    let x: String = read::<String>();
    let mut scount = 0;
    let mut ans = 0;
    for i in x.chars() {
        if i == 'S' {
            scount += 1;
        } else if scount > 0 {
            ans += 1;
            scount -= 1;
        }
    }
    println!("{}", x.len() - ans * 2);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

long long int memo[100];

long long int solve(int n){

  if(memo[n]) return memo[n];
  if(n == 1) return 1;
  if(n == 2) return 2;
  if(n == 3) return 4;

  return memo[n] = solve(n-1) + solve(n-2) + solve(n-3);
}

int main(){
  int n;

  solve(35);

  while(cin >> n, n) cout << memo[n]/3650+1 << endl;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<string.h>
int main(void) {
	char a;
	char b = 'a';
	int ans[26] = { 0 };
	int i = 0;
	while (scanf("%c", &a) != EOF) {
		if ('A' <= a && a <= 'Z') a += 'a' - 'A';
		ans[a - 'a']++;
		i++;
	} 
	for (i = 0; i < 26; i++) {
		printf("%c : %d\n", b + i, ans[i]);
	}

	return 0;
}


Measured memory_bytes: 2096
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    l = map(int,raw_input().split())
    ans = [0,0,0]
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*N
                for i in range(N):
                    R = (A*R+C)%M
                    O[i] = (l[i]+R)%M
                L = [0]*256
                for i in O: L[i] += 1
                tmp = -sum(float(i)/N*math.log(float(i)/N,2) for i in L if i != 0)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

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

int main()
{
    int n, a; cin >> n;
    char c;
    map<char, int> m {{'S', 0}, {'H', 1}, {'C', 2}, {'D', 3}};
    int card[4][13] = {0};
    
    for (int i = 0; i < n; i++) {
        scanf(" %c %d", &c, &a);
        card[m[c]][a-1]++;
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (card[i][j] == 0) {
                if (i == 0) putchar('S');
                if (i == 1) putchar('H');
                if (i == 2) putchar('C');
                if (i == 3) putchar('D');
                printf(" %d\n", j + 1);
            }
        }
    }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int th, ta, ah, aa;
  cin >> th >> ta >> ah >> aa;
  
  while(true) {
    ah = ah - ta;
    if (ah <= 0) break;
    th = th - aa;
    if (th <= 0) break;
  }
  if (th <= 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m== -1 && f== -1 && r== -1)
              break;
            if(m== -1 || f== -1){
                System.out.println("F");
            }else if(m+f >= 80){
                System.out.println("A");
            }else if(m+f >= 65){
                System.out.println("B");
            }else if(m+f >= 50 || r >= 50){
                System.out.println("C");
            }else if(m+f >= 30){
                System.out.println("D");
            }else if(m+f < 30){
                System.out.println("F");
            }  
        }
    }
}


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

typedef long long ll;
typedef long double ld;
const ll init = 1e18+7;

#define mkp make_pair
#define pb push_back
#define pq priority_queue
#define minpq priority_queue <int, vector<int>, greater<int> >
#define vi vector <int> 
#define vll vector <ll>
#define pii pair<int,int>

vll v(1e5+10);
vll dp(1e5+10,-1);
int n;

ll find_ans(int x){
	if(x>n) return init;
	if(dp[x]==-1){
		ll a = find_ans(x+1)+abs(v[x]-v[x+1]);
		ll b = find_ans(x+2)+abs(v[x]-v[x+2]);
		dp[x] = min(a,b);
	}
	return dp[x];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	for (int i = 1; i <= n; ++i){
		cin>>v[i];
	}
	dp[n]=0;
	dp[1]=find_ans(1);
	cout<<dp[1]<<endl;
    return 0;
} 

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

int main() {
  int K, S;
  cin >> K >> S;
  int result = 0;
  
  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      int z = S - x - y;
      if(z >= 0 && z <= K) {
        result++;
      }
    }
  }
  cout << result << endl;
  
  return 0;
}

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

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> res;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main(){
  int64_t N, P;
  cin >> N >> P;

  map<int64_t, int> p = prime_factor(P);

  int64_t ans = 1;
  for(auto itr = p.begin(); itr != p.end(); itr++){
    for(int i=0; i<(itr->second/N); i++) ans *= (itr->first);
  }

  cout << ans << endl;
}


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

int main() {
  int i,n,d1,ans,mae;
  vector<int> d;
  
  cin >> n;
  for (i=0;i<n;++i)
  {
    cin >> d1;
    d.push_back(d1);
  }

  sort(d.begin(),d.end());//ソート
  ans=mae=0;
  for (i=0;i<n;++i)
  {
    if (mae != d[i])
    {
      	++ans;
    	mae=d[i];
    }
  }
 
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());


int main(){
    int N;
    cin>>N;
    ll ans=0,now=2;
    for(int i=0;i<N;i++){
        ll a;
        cin>>a;
        if(i==0) ans+=a-1;
        else{
            if(a-now<=0){
                now=max(a+1,now);
                continue;
            }
            ans+=(a-1)/now;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
    ADITYA JAIN
    IIT INDORE
*/

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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

main(){
    int r, g;
    cin >> r >> g;
    cout << g*2 - r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve() {
	int n;
	cin >> n;
	vi v(n);
	map<int, ll> freq;
	ll ways = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		freq[v[i]]++;
	}
	for (auto &i : freq) {
		ways += i.second * (i.second - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		ll f = freq[v[i]];
		ll curWays = ways - f * (f - 1) / 2;
		f--;
		curWays += f * (f - 1) / 2;
		cout << curWays << endl;
	}

}
int main() {
	run();
	int t = 1;
	///cin>>t;
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 10368
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

int main() {
    int T, X;
    cin >> T >> X;

    cout << static_cast<double>(T) / static_cast<double>(X) << endl;
    return 0;
}


Measured memory_bytes: 3224
def dfs(i,f):
    if i == n-1:
        return(sum(map(int,f.split('+'))))

    return dfs(i+1,f+s[i+1]) +\
               dfs(i+1,f+'+'+s[i+1])
s = input()
n = len(s)
print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
int h,w,a[505][505],b[505][505];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) a[i][1]=1;
	for(int i=1;i<=h;i+=2)
		for(int j=1;j<w;j++)
			a[i][j]=1;
	for(int i=1;i<=h;i++) b[i][w]=1;
	for(int i=2;i<=h;i+=2)
		for(int j=2;j<=w;j++)
			b[i][j]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char c=getchar();
			while(c!='.'&&c!='#') c=getchar();
			if(c=='#') a[i][j]=b[i][j]=1;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]==0) putchar('.');
			else putchar('#');
		}
		printf("\n");
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(b[i][j]==0) putchar('.');
			else putchar('#');
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for (int i = 0; i < length; i++) {
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)==true){
                    answer += Character.toUpperCase(ch);
                }else{
                    answer += Character.toLowerCase(ch);
                }
            }
            System.out.println(answer);
            sc.close();
        }
    }
}




Measured memory_bytes: 31308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

vector<int> edge[1001];
int twice = 0;
int used[1001];
vector<int> cycle_node;

void dfs(int n) {
	if (used[n]) {
		twice = n;
	}
	else {
		used[n]++;
		rep(i, edge[n].size()) {
            int e = edge[n][i];
			dfs(e);
			if (twice > 0) {
				cycle_node.push_back(n);
				if (twice == n)
					twice = -1;
				break;
			}
			else if (twice < 0)
				break;
		}
		used[n]--;
	}
}

int main(){
    int N, M;
    cin >> N >> M;
    int next[N+1], a[M], b[M];
    fill_n(next, N+1, 0);
    rep(i, M){
        cin >> a[i] >> b[i];
        edge[b[i]].push_back(a[i]);
    }
    rep2(i, 1, N){
        if(!cycle_node.empty()) break;
        dfs(i);
    }
    if(cycle_node.empty()) cout << -1 << endl, exit(0);
    int n = cycle_node.size();
    rep(i, n) next[cycle_node[i]] = cycle_node[(i+1)%n];
    while(true){
        vector<int> redge[N+1];
        rep(i, M){
            if(next[a[i]] && next[b[i]]) redge[a[i]].push_back(b[i]);
        }
        int p = 0, q = 0;
        rep2(i, 1, N){
            if(redge[i].size() >= 2){
                q = i;
                rep(j, redge[i].size()){
                    if(redge[i][j] != next[i]){
                        p = redge[i][j];
                        break;
                    }
                }
                break;
            }
        }
        if(p == 0) break;
        int pos = p, n = cycle_node.size();
        bool finish = false;
        vector<int>::iterator ite;;
        ite = cycle_node.begin();
        rep(i, n) cycle_node.erase(ite);
        rep(i, n){
            int nt = next[pos];
            if(!finish) cycle_node.push_back(pos);
            else next[pos] = 0;
            if(pos == q) finish = true, next[q] = p;
            pos = nt;
        }
    }
    int m = cycle_node.size();
    cout << m << endl;
    rep(i, m) cout << cycle_node[i] << endl;
}

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

bool T[40][40];

int main(){
  int n;
  while(cin>>n,n){
    memset(T,0,sizeof(T));
    vector<string> name;
    string tmp;
    int occur;
    for(int i=0;i<n;i++){
      cin>>tmp>>occur;
      name.push_back(tmp);
      for(int j=0;j<occur;j++){
	int t;
	cin>>t;
	T[i][t]=true;
      }
    }
    int score[n];
    memset(score,0,sizeof(score));
    for(int row=0;row<40;row++){
      int cnt=0;
      for(int col=0;col<n;col++){
	if(T[col][row]==true)cnt++;
      }
      for(int col=0;col<n;col++){
	if(T[col][row]==true){
	  score[col]+=n - cnt+1;
	}
      }
    }
    int minS=1000;
    for(int i=0;i<n;i++){
      minS = min(minS,score[i]);
    }
    // for(int i=0;i<n;i++){
    //   for(bool a:T[i])cout << a;
    //   cout << endl;
    // }
    // cout << "score" << endl;
    // for(int a:score)cout << a << endl;
    // cout << endl;
    cout << minS << " ";
    vector<string> ans;
    for(int i=0;i<n;i++){
      if(score[i]==minS){
	ans.push_back(name[i]);
      }
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    vector<int> a(5,0);
    rep(i,5) cin>>a[i];
    int k; cin>>k;
    rep(i,5)rep(j,5){
        if(i==j) continue;
        if(abs(a[i]-a[j])>k){
            cout<<":("<<endl;
            return 0;
        }
    }
    cout<<"Yay!"<<endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(x-r<0 || x+r>w || y-r<0 || y+r >h)printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2100
#define P(x) cout << #x" = " << x << endl
#define PP(x, y) cout << "("#x", "#y") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "("#x", "#y", "#z") = (" << x << ", " << y << ", " << z << ")" << endl

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
ll n, k;
ll a[100000];
ll ct0[100000];
ll ct1[100000];
int main(){
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int shift = 60; shift >= 0; --shift) {
        int cnt0 = 0;
        for (int i = 0; i < n; ++i) {
            ll abit = (a[i] >> shift) & 1;
            if (abit == 0) cnt0++;
        }
        ct0[shift] = cnt0;
        ct1[shift] = n - cnt0;
    }

    ll maxans = 0;
    for (int force_zero = 60; force_zero > 0; force_zero--) {
        bool limited = true;
        ll x = 0;
        ll ans = 0;
        for (int shift = 60; shift >= 0; --shift) {
            ll bit = 0;
            ll kbit = (k >> shift) & 1;
            if (limited && kbit == 0) {
                bit = 0;
            } else if (force_zero == shift) {
                bit = 0;
            } else {
                if (ct0[shift] > ct1[shift]) {
                    bit = 1;
                } else {
                    bit = 0;
                }
            }
            if (kbit == 1 && bit == 0) {
                limited = false;
            }
            x += (1 << shift) * bit;
            ans += bit == 0 ? ct1[shift] * (1LL << shift) : ct0[shift] * (1LL << shift);
        }
        // PP(force_zero, ans);
        maxans = max(ans, maxans);
    }
    cout << maxans << endl;
}

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j-w[i] >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int par[MAX],cnt[MAX];

void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        cnt[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        cnt[root(a)]+=cnt[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    ll N;
    int M;cin>>N>>M;
    ll ans=N*(N-1)/2;
    vector<ll> S;
    vector<pair<int,int>> T(M);
    
    S.push_back(ans);
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        T[i]=make_pair(a,b);
    }
    
    init(N);
    
    for(int i=M-1;i>=0;i--){
        int a=T[i].first,b=T[i].second;
        if(check(a,b)){
             if(i) S.push_back(ans);
        }else{
            //ans+=cnt[root(a)]*(cnt[root(a)]-1)/2;
            //ans+=cnt[root(b)]*(cnt[root(b)]-1)/2;
            ans-=cnt[root(a)]*cnt[root(b)];
            unite(a,b);
            //ans-=cnt[root(a)]*(cnt[root(a)]-1)/2;
            if(i) S.push_back(ans);
        }
    }
    
    reverse(all(S));
    
    for(int i=0;i<S.size();i++){
        cout<<S[i]<<endl;
    }
    
    //cout<<S.size()<<endl;
}


Measured memory_bytes: 3828
a, b, k = list(map(int, input().split()))

s = []

if b - k + 1 > a + k - 1:
    for i in range(k):
        s.append(a + i)
    for i in reversed(range(k)):
        s.append(b - i)
else:
    for i in range(a, b+1):
        s.append(i)

for i in range(len(s)):
    print(s[i])

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

ll func(ll a, ll b, ll c) {
	ll smax, smin;
	smax = max(a, b);
	smax = max(smax, c);
	smin = min(a, b);
	smin = min(smin, c);
	return smax - smin;
}
bool bColor[8];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, sa;
	ll ans;
	scanf("%d %d", &N, &M);
	sa = abs(N - M);
	if (sa >= 2) {
		ans = 0;
	}
	else {
		ans = 1;
		for (int i = 1; i <= N; i++) {
			ans = ans * i % 1000000007;
		}
		for (int i = 1; i <= M; i++) {
			ans = ans * i % 1000000007;
		}
		if(sa == 0)ans = ans * 2 % 1000000007;
	}
	
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N;
  string s;
  cin >> N >> s;
  
  for(int i=0;i<s.size();i++){
    s.at(i) = (char) s.at(i) + N;
    if( s.at(i) > 'Z') s.at(i) = (char) s.at(i) - 26;
  }
  cout << s << endl;
}


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

int main() {
  int A, B, C, D, E, max;
  cin >> A >> B;
  C = A + B;
  D = A - B;
  E = A * B;
  max = C;
  if(max < D){
    max = D;
  }
  if(max < E){
    max = E;
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    ll a,b,k; cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i%2 == 0){
            b += a/2; a/=2;
        }else{
            a += b/2; b/=2;
        }
    }
    cout << a << " " << b << endl;
    return 0; 
}

Measured memory_bytes: 256