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

int main(){
  int a,b,c,d,e,k;
  cin >> a>> b>>c>>d>>e>>k;
  if(b-a<=k&&c-b<=k&&d-c<=k&&e-d<=k&&c-a<=k&&d-a<=k&&e-a<=k&&d-b<=k&&e-b<=k&&e-c<=k) cout<<"Yay!" <<endl;
  else cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
import copy
h,w,k=map(int,input().split())
M=[list(input()) for _ in range(h)]
a=0
for i in range(2**w):
  for j in range(2**h):
    b=0
    for c in range(w):
      for r in range(h):
        if (i>>c)&1==0 and (j>>r)&1==0 and M[r][c]=='#':
          b+=1
    if b==k:
      a+=1
print(a)    

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

int main(){
  int a,b;
  scanf("%d %d\n",&a, &b);
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }
}



Measured memory_bytes: 2624
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 2e5+10;

int main()
{
	_SAD()
	int a,b;
	cin>>a>>b;
	if(a%b==0)
	{
		cout<<a/b<<nl;
	}
        else
	{
		cout<<(a/b)+1<<nl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
vector<int> G[100000];
int dfs(int v) {
	priority_queue<int, vector<int>, greater<int>> Q;
	int k = 0;
	for (int to : G[v]) {
		Q.push(dfs(to));
		k++;
	}
	if (k == 0) return 0;
	if (k == 1) return Q.top() + 1;
	int ret = 0;
	Q.push(0);
	int m1 = Q.top(); Q.pop();
	int m2 = Q.top(); Q.pop();
	ret = max(ret, m1 + k);
	ret = max(ret, m2 + k);
	for (int i = k - 1; i > 0; i--) {
		int m = Q.top(); Q.pop();
		ret = max(ret, m + i);
	}
	return ret;
}
int main() {
	int N;
	cin >> N;
	for (int i = 1; i < N; i++) {
		int a;
		cin >> a;
		a--;
		G[a].push_back(i);
	}
	cout << dfs(0) << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm


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

int64_t N;cin >> N;
VI a(N); rep(i, 0, N) cin >> a[i];

int64_t x = 0, y = accumulate(ALL(a), 0LL),
        mini = INF;
rep(i, 0, N-1){
    x += a[i], y -= a[i];
    mini = min(mini, abs(x - y));
}   

cout << mini << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  string S; cin >> S;
  string T = "CODEFESTIVAL2016";
  int ans = 0;
  REP(i,SZ(S)){
	if(S[i] != T[i]) ++ans;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int main(int argc, char* argv[]) {
	int n;
	cin >> n; 

	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			continue;
		}

		if (i % 5 == 0) {
			continue;
		}

		sum += i;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(){
    ll n,d,a; cin>>n>>d>>a;
    vector<pair<ll,ll>> arr(n); rep(n) cin>>arr[i].ff>>arr[i].ss;
    ll ct = 0;
    queue<pair<ll,ll>> red; // till, to-red
    ll bmbs=0;
    sort(all(arr));
    //for(auto i:arr) dpp(i);
    for(auto ar:arr){
        while(!red.empty()&&(red.front().ff<ar.ff)){ ct-=red.front().ss; red.pop(); }
        ar.ss -= ct;
        //cout<<ct<<" "; dpp(ar);
        if(ar.ss>0){
            ll left = (ar.ss+a-1)/a; 
            bmbs += left;
            left*=a;
            ar.ss -= left;
            ct+=left;
            red.push({ar.ff+2*d,left});
        }
    }
    cout<<bmbs<<endl;
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


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

using namespace std;

int main(){
    long H;
    cin >> H;

    long n = 1;
    int cnt = 0;
    while(n <= H){
        n *= 2;
        cnt++;
    }

    long sum = 0;
    for(int i=0; i<cnt; i++){
        sum += pow(2, i);
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 384
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
A = list(map(int,input().split()))
sell = [0]*N
buy = [0]*N
hand = [[1000,0] for i in range(N+1)]
for i in range(1,N-1):
    if A[i] >= A[i-1] and A[i] > A[i+1]:
        sell[i] = 1
    if A[i] <= A[i-1] and A[i] < A[i+1]:
        buy[i] = 1
if A[0] < A[1]:
    buy[0] = 1
if A[N-1] > A[N-2]:
    sell[N-1] = 1
for i in range(N-1):
    if buy[i] == 1:
        hand[i+1][0] = hand[i][0] % A[i]
        hand[i+1][1] += hand[i][1] + (hand[i][0] // A[i])
    elif sell[i] == 1:
        hand[i+1][0] = hand[i][0] + A[i]*hand[i][1]
        hand[i+1][1] = 0
    else:
        hand[i+1][0] = hand[i][0]
        hand[i+1][1] = hand[i][1]
if hand[N-1][1] != 0:
    hand[N][0] = hand[N-1][0] + A[N-1]*hand[N-1][1]
else:
    hand[N][0] = hand[N-1][0]
print(hand[N][0])
    

Measured memory_bytes: 10640
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define LAST(X) X[X.size()-1]
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int A, B;
	string S;
	cin >> A >>S>>B;
	if (S[0] == '+')
		cout << A + B;
	else
		cout << A - B;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


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

int main() {
	ll A, B, C, X, Y, Z;
	ll D = 0;
	ll sum = 0;
	cin >> A >> B >> C >> X >> Y;

	if (X > Y) {
		D = Y;
		Y = X;
		X = D;
		D = B;
		B = A;
		A = D;
	}
	Z = Y;
	if (C * 2 < A + B) {
		Y -= X;
		sum = X * C * 2;
		sum += Y * B;
	}
	else {
		sum = A * X + B * Y;
	}
	if (C * Z * 2 < sum)sum = C * Z * 2;
	cout << sum;

	return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    while (n != 0) {
        int t[n];
        rep(i, n) cin >> t[i];

        long long int ans = 0;
        sort(t, t+n);
        rep(i ,n) {
            //dump(t[i]);
            ans += t[i] * (n-i-1);
            //dump(ans);
        }
        cout << ans << endl;
        cin >> n;
    }

    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

const static long long INF = 1000000000;
int main() {
  string s;
  cin >> s;
  string ans="";
  for(int i=0;i<s.size()-8;i++) {
    ans+=s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
i=abs(N)
lis = [0 for i in range(150)]
ind= 0
if i>0:
    while i>0:
        am = i%4
        i = i//4
        if N>0:
            lis[ind]=am
            lis[ind+1]=0
        else:
            lis[ind]=am
            lis[ind+1]=am
        ind+=2

ind=0
for i in range(148):
    #print(lis)
    if lis[i]==2:
        lis[i]=0
        lis[i+1]+=1
        lis[i+2]+=1
    elif lis[i]==3:
        lis[i]=1
        lis[i+1]+=1
        lis[i+2]+=1
    elif lis[i]>=4:
        lis[i+2]+=lis[i]//4
        lis[i]%=4

lis.reverse()
if N!=0:
    fir = lis[50:].index(1)
    map = map(str,lis[fir:])
    tmp = ''.join(map)
    print(int(tmp))
else:
    print(0)


Measured memory_bytes: 38256
N = int(input())
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i, j in a.items():
    if j >= 2:
        b.append([i,j])
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print(b[0][0] ** 2)
elif len(b) >= 2:
    print(b[0][0] * b[1][0])
else:
    print(0)

Measured memory_bytes: 21980
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)

N,A,B,C,D=map(int, input().split())
A-=1
B-=1
C-=1
D-=1
S=list(input())

for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':   
        print('No')
        exit()

for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':   
        print('No')
        exit()

if C < D:
    print('Yes')
    exit()

X=[-1]*N
X[B-1] = 0 if S[B-1] == '#' else 1
for i in range(B,D+2):
    X[i] = 0 if S[i] == '#' else (X[i-1] + 1)
    if X[i] >= 3:
        print('Yes')
        exit()
print('No')




Measured memory_bytes: 6456
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string S;
	cin>>S;
	rep(i,8){
		if(S.substr(0,i)+S.substr(len(S)-(7-i))=="keyence"){
			cout<<"YES\n";return 0;
		}
	}
	cout<<"NO\n";
}


Measured memory_bytes: 3604
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++) arr[i] = sc.nextInt();
    int[] dp = new int[n];
    for(int i=1;i<n;i++) dp[i]=Integer.MAX_VALUE;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<=i+k;j++){
      if (j<n){
        dp[j]=Math.min(dp[j],dp[i]+Math.abs(arr[i]-arr[j]));
      }
    }
    System.out.println(dp[n-1]);
  }
}

Measured memory_bytes: 53620
# coding: utf-8
ll = list(map(int, list(input())))
pm = ["+", "-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = ll[0] + ll[1]*(-1)**i + ll[2]*(-1)**j + ll[3]*(-1)**k
            # print(ans)
            # print(ll[0], pm[i], ll[1], pm[j], ll[2], pm[k], ll[3])
            if ans == 7:
                print("{}{}{}{}{}{}{}=7".format(ll[0], pm[i], ll[1], pm[j], ll[2], pm[k], ll[3]))
                exit()

Measured memory_bytes: 3064
#include<iostream>
#include<string>

int main(){

    std::string s;
    std::cin >> s;

    size_t last = s.find('B');
    size_t ans = 0;
    for(size_t i = last; i < s.size(); i++){
        if(s.at(i) == 'W'){
            ans += i - last;
            last++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a>>b>>c>>d;

	int min, max,kotae;
	min = a > c ? a : c;
	max = b < d ? b : d;

	if (min < max) {
		kotae = max - min;
	}
	else {
		kotae = 0;
	}
	cout << kotae;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int &i : h)
        cin >> i;
    vector<int> dp(n, 1e9+9);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i+1, i+2}) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<ll>> G0(n,vector<ll>(n,1LL<<60)),G1(n,vector<ll>(n,1LL<<60));
    for (int i = 0;i < n;++i) G0[i][i] = 0;
    for (int i = 0;i < m;++i) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G0[a][b] = G0[b][a] = c;
    }
    for (int k = 0;k < n;++k) for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) G0[i][j] = min(G0[i][j],G0[i][k]+G0[k][j]);
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (G0[i][j] <= l) G1[i][j] = (G0[i][j]+l-1)/l;
    for (int k = 0;k < n;++k) for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) G1[i][j] = min(G1[i][j],G1[i][k]+G1[k][j]);
    int q;
    cin >> q;
    for (int i = 0;i < q;++i) {
        int s,t;
        cin >> s >> t;
        cout << (G1[s-1][t-1] < 1LL<<60 ? G1[s-1][t-1]-1 : -1) << "\n";
    }
    // for (int i = 0;i < n;++i) p_ary(G0[i],0,n);
    // cout << endl;
    // for (int i = 0;i < n;++i) p_ary(G1[i],0,n);
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if(b>a){
    if(c>a&&b>c){
      cout <<"Yes"<<endl;
    }else{
      cout <<"No"<<endl;
    }
  }else{
    if(c<a&&b<c){
      cout <<"Yes"<<endl;
    }else{
      cout <<"No"<<endl;
    }
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

int main(void) {
    int A;
    string S;
    cin >> A >> S;
    if (3200 <= A) cout << S << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 888
from itertools import product

N = int(input())

L = list(product([0,1], repeat=N))

T = [[]for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        T[i].append((x, y))

ans= 0

for l in L:
  F  = True
  for i,k in enumerate(l):
    if k == 1:
      for j in T[i]:
        if l[j[0]-1] != j[1]:
          F = False
  if F:
    ans = max(ans,sum(l))
print(ans)

Measured memory_bytes: 8820
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>(c=D[i][k]+D[k][j]))D[i][j]=c;
	for(i=0;i<N;i++)for(j=0;j<N;j++)
	{
		D[i][j]=D[i][j]>L?1000000000:1;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>(c=D[i][k]+D[k][j]))D[i][j]=c;
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d%d",&a,&b);
		--a;
		--b;
		printf("%d\n",D[a][b]<1000000000?D[a][b]-1:-1);
	}
}

Measured memory_bytes: 768
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define entire(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void solve()
{
  ll n;
  cin >> n;
  std::vector<ll> v(n);
  std::vector<ll> s(n);
  rep(i, n)cin >> v[i];
  s[0] = v[0];
  repe(i, 1, n) {
    s[i] = (s[i - 1] + v[i]) % MOD;
  }
  ll sum = 0;
  // rep(i,n)
  // cout<<s[i]<<" ";
  // cout<<endl;
  repe(i,1, n) {
    // if(i==0)
    // sum=(v[i]*s[i])%MOD;
    // else
    sum += (v[i] * s[i - 1]) % MOD;
    sum %= MOD;
  }
  cout << sum << endl;
}


int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast
  int T = 1;
  // cin >> T;
  while (T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 6360
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> P;
#define MAX (1000)
#define MAX_WH (61)
#define mp make_pair

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

// dfs では解けない?

int main(){
	int w, h;
	while( cin >> w >> h, w || h ){
		// input
		int H = 2*h+1, W = 2*w+1;
		vector<vi> maze(MAX_WH, vi(MAX_WH));
		for( int i = 0; i < H; i++ ){
			for( int j = 0; j < W; j++ ){
				if( i == 0 || i == H-1 || j == 0 || j == W-1 ){
					maze[i][j] = -1;
					continue;
				}
				if( (i%2 == 1 && j%2 == 0) || (i%2 == 0 && j%2 == 1) ){
					int wall;
					cin >> wall;
					maze[i][j] = -wall;
				}else if( i%2 == 0 && j%2 == 0 ){
					maze[i][j] = -1;
				}else{
					maze[i][j] = 0;
				}
			}
		}

		int gl_w = W-2, gl_h = H-2;
		maze[1][1] = 1;
		queue<P> que;
		que.push(mp(1,1));
		while( !que.empty() ){
			int x = que.front().first, y = que.front().second;
			que.pop();
			for( int i = 0; i < 4; i++ ){
				int nx = x + dx[i], ny = y + dy[i];
				if( nx <= 0 || W-1 <= nx || ny <= 0 || H-1 <= ny ) continue;
				if( maze[ny][nx] == 0 ){
					maze[ny][nx] = maze[y][x]+1;
					que.push(mp(nx,ny));
				}
			}
		}

		// output
		int ans = maze[gl_h][gl_w];
		if( ans == 0 ) cout << 0 << endl;
		else cout << (ans+1)/2 << endl;
	}
}

Measured memory_bytes: 1236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for (int i = 0; i * 4 <= n; i++) {
			for (int j = 0; i * 4 + j * 7 <= n; j++) {
				if (i * 4 + j * 7 == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		
		System.out.println("No");
		
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
using P = pair<ll, ll>;
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N, D, A;
    cin >> N >> D >> A;
    priority_queue<P, vector<P>, greater<P>> mon, bom;
    vector<ll> X(N), H(N);
    REP(i, N) {
        cin >> X.at(i) >> H.at(i);
        mon.push({X[i], H[i]});
    }

    ll ans = 0;
    ll now_bom = 0;
    while (!mon.empty()) {
        P next_m = mon.top();
        if (!bom.empty()) {
            P next_bom;
            next_bom = bom.top();
            if (next_bom.first <= next_m.first) {
                now_bom += next_bom.second;
                bom.pop();
                continue;
            }
        }
        // cout << "x:" << next_m.first << " h:" << next_m.second << " ans:" << ans << " now bom:" << now_bom << endl;
        mon.pop();
        if (next_m.second <= now_bom) {  // 既に死んだ
            continue;
        } else {
            ll rem = next_m.second - now_bom;
            ll times = (rem + A - 1) / A;
            ans += times;
            now_bom += times * A;
            bom.push({next_m.first + D + D + 1, -times * A});
            // cout << " push:" << next_m.first + D + D + 1 << " " << -times * A << endl;
        }
    }

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


Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> w,v;

long int dpv[100001][101];
long int dp(int W,int N)
{
	if(dpv[W][N])
		return dpv[W][N];
	if(W==0 || N==0)
		return 0;
	if(w[N]<=W)
		dpv[W][N]=max(dp(W-w[N],N-1)+v[N],dp(W,N-1));
	else
		dpv[W][N]=dp(W,N-1);
	return dpv[W][N];
}
int main()
{
  	w.pb(0);v.pb(0);
	int N,W,i,w1,v1;
	cin>>N>>W;
	for(i=1;i<=N;i++)
	{
		cin>>w1>>v1;
		w.pb(w1);
		v.pb(v1);	
	}
	cout<<dp(W,N);
}


Measured memory_bytes: 78848
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n,k,c=0;
  cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  for(int i=0;i<n;i++) {
    if(v[i]>=k) c++;
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 640
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var n = toInt(input[0]);
	var ans = (n<1200)? 'ABC': (n<2800)? 'ARC': 'AGC';
	console.log(ans);
}

Measured memory_bytes: 9676
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 12;
const int INF = (int)1e9;
int c[N], p[N], n, g;

int calc (int mask) {
	int res = 0, score = 0;
	For(i, 1, n + 1) if (mask & (1 << (i - 1))) {
		res += p[i];
		score += p[i] * 100 * i + c[i];
	}
	vi v;
	For (i, 1, n + 1) if (!(mask & (1 << (i - 1)))) {
		Foz(j, p[i] - 1) v.pb(100 * i);
	}
	while (!v.empty() && score < g) {
		res++;
		score += v.back();
		v.pop_back();
	}
	return score < g ? INF : res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n >> g;
	For(i, 1, n + 1) cin >> p[i] >> c[i];
	int ans = INF;
	Foz(i, (1 << n)) ckmin(ans, calc(i));
	cout << ans << '\n';
}



Measured memory_bytes: 256
while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    L=[True]*(N+1)
    L[1]=False
    data=[map(int,raw_input().split()) for i in range(M)]
    data.sort()
    for t,s,d in data:
        if L[s]==False:
            L[d]=False
    print L.count(False)

Measured memory_bytes: 12392
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		long k=s.nextInt(),a=s.nextInt(),b=s.nextInt(),i=0;
		long v=1;
		long l=k-a+1;
		long m=a+l/2*(b-a)+l%2;
		System.out.println(Math.max(k+1,m));
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H1 = Integer.parseInt(sc.next());
		int M1 = Integer.parseInt(sc.next());
		int H2 = Integer.parseInt(sc.next());
		int M2 = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();

		int total = 0;
		if(M1 <= M2) {
			total = 60 * (H2 - H1) + (M2 - M1);
		}else {
			total = 60 * (H2 - H1 - 1) + (60 + M2 - M1);
		}

		if(total - K > 0) {
			System.out.println(total - K);
		}else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 35620
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	string s,t;
	cin>>s>>t;
	int w=0;
	rep(i,3)w+=s[i]==t[i];
	cout<<w<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
const ll INF=(1ll<<60)-1;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    string s;
    cin>>s;
    ll flag=0;
    rep(i,0,3)
    {
        if( s[i]=='7')
        {
            flag=1;
            break;
        }
    }
    if( flag )
    cout<<"Yes\n";
    else 
    cout<<"No\n";
}
// 1. "\"D:\\\\mingw\\\\mingw32\\\\lib\\\\gcc\\\\i686-w64-mingw32\\\\8.1.0\\\\include\\\\c++\""
// 2.  "D:\\mingw\\mingw32\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include\\c++"

Measured memory_bytes: 3656
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String answer = "aa";
        for(int i = 0;i<s.length();i++){
            if(s.length() %2 == 0 && i==0){
                s = s.substring(0,s.length()-1);
            }
            if(s.length() %2 == 0){
                if(s.substring(0,s.length()/2).equals(s.substring(s.length()/2,s.length()))){
                    answer = s;
                }
                s = s.substring(0,s.length()-1);
            }else{
                s = s.substring(0,s.length()-1);
            }
        }
        System.out.println(answer.length());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//bitset<10000> issquare;
vector<int> sq(10000, -1);
 
int dist2(vector<vector<int>>& mat, int i, int j) {
    int res = 0;
    for (int d = 0; d < mat[0].size(); ++d) {
        res += (mat[i][d] - mat[j][d])*(mat[i][d] - mat[j][d]);
    }
    return res;
}
 
int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> mat(N, vector<int>(D,0));
    for (int i = 0 ; i < N; ++i)
        for (int j = 0; j < D; ++j)
            cin >> mat[i][j];
 
    //for (int i = 0; i < 100; ++i)
        //sq[i*i] = i;
        //issquare[i*i] = true;
    
    int count = 0;
    for (int i = 1 ; i < N; ++i)
        for (int j = 0; j < i; ++j) {
            int d = dist2(mat, i, j);
            int sq = sqrt(d);
            if (sq*sq == d) //(sq[d] != -1 && sq[d]*sq[d] == d)//issquare[d])
                ++count;
        }
    
     cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
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 int64_t lint;
lint gcd(lint a, lint b) { return b?gcd(b,a%b):a;}
lint lcm(lint a, lint b) { return a/gcd(a,b)*b;}

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	int a=1000001, b=0, c=v.at(0), x, y, z;
	vector<bool> P(a);
	fill(all(P), true);
	P.at(0) = false, P.at(1) = false;
	for(int i=2; i*i<=a-1; ++i) {
		if(P.at(i)) {
			for(int j=2; i*j<=a-1; ++j) {
				P.at(i*j) = false;
			}
		}
	}

	vector<int> PV;
	rep(i, a) {
		if (P.at(i)) PV.push_back(i);
	}

	bool f = true;
	rep(i, N) {
		x = v.at(i);
		rep(j, PV.size()) {
			y = PV.at(j);
			if (P.at(x)) {
				P.at(x) = false;
				break;
			}
			if (x < y) break;
			if (x % y == 0) {
				if (!P.at(y)) {
					f = false;
					break;
				}
				while (x % y == 0) x /= y;
				P.at(y) = false;
			}
		}
		if (!f) break;
	}
	if (f) {
		std::cout << "pairwise coprime" << '\n';
		return 0;
	}

	rep1(i, N) {
		c = gcd(c, v.at(i));
		if (c == 1) {
			std::cout << "setwise coprime" << '\n';
			return 0;

		}
	}

	std::cout << "not coprime" << '\n';
}


Measured memory_bytes: 7904
#include <cstdio>
const int MAXC = 1005;
char buff[MAXC]{ };
int count[4]{ };

int main()
{
	scanf(" %s", &buff);
	for(char * ptr = buff; *ptr; ++ptr)
	{
		switch(*ptr)
		{
			case 'N': ++count[0]; break;
			case 'E': ++count[1]; break;
			case 'S': ++count[2]; break;
			case 'W': ++count[3]; break;
		}
	}
	bool done=true;
	if(count[0])
		done &= !!count[2];
	if(count[2])
		done &= !!count[0];
	if(count[1])
		done &= !!count[3];
	if(count[3])
		done &= !!count[1];
	puts(done ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    ll i,j,k,n,m,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
	cin>>n>>m>>k;
  	ll ans =n/(m+k)*m;
  	n=n-n/(m+k)*(m+k);
    ans+=min(n,m);
  cout<<ans<<endl;
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()
if N %2 == 0:
    #偶数
    print(N/2/N)
else:
    print(((N//2)+1)/N)



Measured memory_bytes: 80364
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
#define fix() cout <<fixed <<  std::setprecision(10)
	
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
const ll INF = 1e18 ; 
double dp[3000][3000] ; 
void solve(){
	fix(); 
	int n ;
	cin >> n ;
	vector<double>p(n+1,0 );
	for(int i = 1 ; i <= n  ; ++i  )
		cin >> p[i] ;
	
	// dp[i][j] = probility of showing j heads in i tosses  

	dp[0][0] = 1.0 ;
	for(int i = 1 ; i <= n ; ++i )
		dp[i][0] = dp[i-1][0] * (1-p[i]) ; 
	for(int  toss = 1 ; toss <= n ; ++toss)
	{
		for(int heads = 1 ; heads <= n ; ++heads)
		{
			if(heads > toss ){ dp[heads][toss] = 0 ;continue; }
			dp[toss][heads] = dp[toss-1][heads-1] * p[toss] + dp[toss-1][heads] * (1-p[toss]);  
		}
	}

	// for(int i = 0 ; i <= n ; ++i )
	// {
		// for(int j = 0 ; j <=n ; ++j )
			// cout <<dp[i][j]<<" " ;
		// br 
	// }		
	
	double res = 0.0 ; 
	for(int i = n/2 + 1  ; i <= n ; ++i )
		res += dp[n][i] ; 
	cout << res , br 
}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 49956
using System;

namespace GoldenCoins
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());

            int pleasure = 0;
            int lest = x;

            int big = lest / 500;
            lest = lest % 500;

            int little = lest / 5;

            Console.WriteLine($"{(big*1000+little*5)}");
        }
    }
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
vi a;
void bfs(ll n, ll m, ll num)
{
    // Queue will contain all the stepping Numbers
    queue<ll> q;

    q.push(num);

    while (!q.empty())
    {
        // Get the front element and pop from the queue
        ll stepNum = q.front();
        q.pop();

        // If the Stepping Number is in the range
        // [n, m] then display
        if (stepNum <= m && stepNum >= n)
            a.pb(stepNum);

        // If Stepping Number is 0 or greater than m,
        // need to explore the neighbors
        if (num == 0 || stepNum > m)
            continue;

        // Get the last digit of the currently visited
        // Stepping Number
        ll lastDigit = stepNum % 10;

        // There can be 2 cases either digit to be
        // appended is lastDigit + 1 or lastDigit - 1
        ll stepNumA = stepNum * 10 + (lastDigit- 1);
        ll stepNumB = stepNum * 10 + (lastDigit + 1);
        ll stepNumC = stepNum * 10 + lastDigit;
        // If lastDigit is 0 then only possible digit
        // after 0 can be 1 for a Stepping Number
        q.push(stepNumC);
        if (lastDigit == 0)
            q.push(stepNumB);

        //If lastDigit is 9 then only possible
        //digit after 9 can be 8 for a Stepping
        //Number
        else if (lastDigit == 9)
            q.push(stepNumA);
        else
        {
            q.push(stepNumA);
            q.push(stepNumB);
        }
    }
}

// Prints all stepping numbers in range [n, m]
// using BFS.
void displaySteppingNumbers(ll n, ll m)
{
    // For every single digit Number 'i'
    // find all the Stepping Numbers
    // starting with i
    for (ll i = 0 ; i <= 9 ; i++)
        bfs(n, m, i);
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    displaySteppingNumbers(1, 3234566667);
    sort(all(a));
  //  for(auto i : a) cout << i << " "; cout << endl;
    int k;
    cin >> k;
    cout << a[k - 1];
    return 0;
}


Measured memory_bytes: 1636
import bisect
 
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))
bc.sort(key = lambda x: x[1], reverse = True)
a.sort(reverse = True)
count = 0 
count2 = 0
a2 = [0]
for i in range(n):
    a2.append(a2[-1] + a[i])
a.reverse()
sum_a = 0
for i in range(m):
    num = bc[i][1]
    num2 = bc[i][0]
    temp = n - bisect.bisect_left(a, num)
    count += temp
    count2 += temp
    temp2 = min(num2, n - count2)
    sum_a += num * temp2
    count2 += temp2
    if count2 == n:
        break
    count -= temp
    count2 -= temp
count3 = n - (count2 - count)
sum_a += a2[count3]
print(sum_a)

Measured memory_bytes: 37272
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<numeric>

#define REP(i, a) for(int i=0;i<(int)a;++i)
#define INF 1145141919;
typedef long long ll;
typedef long double ld;
using namespace std;

int H, W;
vector<ll> a;

void solver() {
    while (cin >> H >> W) {
        if (H == 0 && W == 0)break;
        REP(h, H) {
            REP(w, W) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

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

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    ll n;
    cin >> n;
    ll m = n;
    map<ll, int> mp;
    bool chk = 0;
    for (ll i = 2; i * i < m; i++) {
        if (m % i == 0) {
            while (m % i == 0) {
                m /= i;
                mp[i]++;
            }
            chk = 1;
        }
    }
    if (m != 1) mp[m]++;
    /*
    if (!chk) {
        if (n == 1) cout << 0 << "\n";
        else {
            cout << 1 << "\n";
        }
        return 0;
    }*/
    ll ans = 0;
    for (auto p : mp) {
        // cout << p.first << p.second << "\n";
        int cnt = 1;
        while (p.second >= cnt) {
            ans++;
            p.second -= cnt;
            cnt++;
        }
    }
    // if (n == 1) ans = 0;
    cout << ans << "\n";
}


Measured memory_bytes: 3632