akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int cnt[101];
int cnt2[101];

int sum(int k,int n){
    int ret=0;
    while(n>0){
        ret+=n/k;
        n/=k;
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,100){
        if(i<=1)continue;
        if(cnt[i]==-1)continue;
        cnt[i]=sum(i,n);
        for(int j=2*i;j<100;j+=i)cnt[j]=-1;
    }
    rep(i,100)rep(j,min(100,cnt[i]+1))cnt2[j]++;
    int ans=0;
    ans+=cnt2[74];
    ans+=cnt2[24]*(cnt2[2]-1);
    ans+=cnt2[14]*(cnt2[4]-1);
    ans+=(cnt2[2]-2)*cnt2[4]*(cnt2[4]-1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


vector<Int> rev[108000];
Int height[108000];
Int cnt;
Int n, k, a[108000];
void dfs(int x, int last = -1){
  height[x] = 0;
  for(auto to: rev[x]){
    if(to == last)continue;
    if(to == 1)continue;
    dfs(to, x);
    if(height[to] == k-1 && x != 1)cnt++;
    else height[x] = max(height[x], height[to] + 1);
  }
}

int main(){
  cin >> n >> k;
  for(int i = 1;i <= n;i++){
    cin >> a[i];
    rev[a[i]].push_back(i);
  }
  if(a[1] != 1){
    a[1] = 1;
    cnt++;
  }

  dfs(1);
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 13696
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').toIndexedSeq).tail
  val jpy = ls.map{e =>
    //println(e.toSeq)
    if(e(1) == "JPY") e(0).toDouble else e(0).toDouble*380000.0
  }
  val ret = jpy.sum
  println(ret)
}


Measured memory_bytes: 25420
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;

void solve()
{
    string st;
    cin>>st;
    if(st[st.size()-1]=='s')
    st.pb('e');
    st.pb('s');
    cout<<st<<"\n";
}
int main()
{

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    io;
        solve();

    return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
int main(){
  int s[31];
  int n,w;
  int i,t,t1,t2;

  scanf("%d",&w);
  for(i=1;i<=w;i++)s[i]=i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d,%d",&t1,&t2);

    t=s[t1];
    s[t1]=s[t2];
    s[t2]=t;
  }
  for(i=1;i<=w;i++)printf("%d\n",s[i]);
  return 0;
}

Measured memory_bytes: 596
n, k = map(int, input().split())
alst = list(map(int, input().split()))
plus = []
zero = []
minus = []
for a in alst:
    if a > 0:
        plus.append(a)
    elif a == 0:
        zero.append(a)
    else:
        minus.append(-1 * a)
p = len(plus)
z = len(zero)
m = len(minus)
p_cnt = p * (p - 1) // 2 + m * (m - 1) // 2
z_cnt = p * z + m * z + z * (z - 1) // 2
m_cnt = p * m
minus.sort()
plus.sort()
if m_cnt >= k: # 答えがマイナス
    l = 0
    r = 10 ** 20
    while r - l > 1:
        num = (r + l) // 2
        p_pos = p - 1
        cnt = 0
        for m_pos in range(m):
            while minus[m_pos] * plus[p_pos] >= num and p_pos >= 0:
                p_pos -= 1
            cnt += p - p_pos - 1
        if cnt >= k:
            l = num
        else:
            r = num
    ans = l * -1
elif m_cnt + z_cnt >= k: # 答えがゼロ
    ans = 0

else: # 答えがプラス
    k -= (z_cnt + m_cnt)
    l = 0
    r = 10 ** 20
    while r - l > 1:
        num = (r + l) // 2
        m_r = m - 1
        cnt = 0
        cnt_sub = 0
        for m_l in range(m):
            while minus[m_l] * minus[m_r] > num and m_r >= 0:
                m_r -= 1
            cnt += m_r + 1
            if minus[m_l] * minus[m_l] <= num:
                cnt -= 1
        p_r = p - 1
        for p_l in range(p):
            while plus[p_l] * plus[p_r] > num and p_r >= 0:
                p_r -= 1
            cnt += p_r + 1
            if plus[p_l] * plus[p_l] <= num:
                cnt -= 1
        cnt //= 2
        if cnt >= k:
            r = num
        else:
            l = num
    ans = r
print(ans)

Measured memory_bytes: 109108
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int A, B, C;
        cin >> A >> B >> C;

        if (A==B&&B==C)
        {
                cout << 1 << endl;
        }
        else if(A==B||B==C||C==A)
        {
                cout << 2 << endl;
        } else{
                cout << 3 << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

bool judge(string s)
{
	return true;
}

ll solve(void)
{
	ll k, n;
	cin >> k >> n;
	vector<ll> A(n);
	for (auto& a:A)
		cin >> a;

	ll ans = inf;
	for (ll i = 0; i < n; i++)
	{
		ll j = (i + 1) % n;
		ll l = (i - 1 + n) % n;
		ans = min(abs(A[j] - k - A[i]), ans);
		ans = min(abs(A[l] + k - A[i]), ans);
	}
	ans = min(ans, A[n-1] - A[0]);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1792
s = input()
if "C" in s and "F" in s:
    for i in range(len(s)):
        if s[i]=="C":
            ind = i
            break
    flag = 0
    for j in range(ind,len(s)):
        if s[j]=="F":
            flag = 1
            break
    if flag==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 61744
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N; long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    long long left = 0, right = 1LL<<30;
    while (right - left > 1) {
        long long x = (left + right) / 2;
        long long con = 0;
        for (int i = 0; i < N; ++i) {
            long long tmp = (A[i] + x-1) / x - 1;
            con += tmp;
        }
        if (con <= K) right = x;
        else left = x;
    }
    cout << right << endl;
}

















Measured memory_bytes: 4740
#include <stdio.h>
int main(void)
{
    int n, k, count=0;
    scanf("%d%d", &n, &k);

    int h[n];
    for(int i=0; i<n; i++){
        scanf("%d", &h[i]);
        if(k<=h[i]){
        count++;
        }
    }
    printf("%d", count);

}

Measured memory_bytes: 512
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
ll vis[100005],z;

void solve()
{
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=0,r=0,p=0,q=0,flag=0,sum=0;
    double a[3005],dp[3005],z=0.0;
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>a[i];
    
    dp[0]=1;
    for(i=1;i<=n;i++)
    {
        dp[i]=(dp[i-1]*a[i]);
        for(j=i;j>=1;j--)
        {
            dp[j-1]=dp[j-1]*(1-a[i]) + dp[j-2]*a[i];
        }
    }
    for(i=(n+1)/2;i<=n;i++)
    z+=dp[i];
    cout<<setprecision(11)<<z<<endl;
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	int A, B, C;
	cin >> A >> B >> C;
	Cout(Yes(A <= C && C <= B));
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
const ll INF = 1001001001;

int main() {
  long double n, k;
  cin >> n >> k;

  long double pr = 0;
  for (ll i = 1; i <= n; i++) {
    long double res = 1 / n;
    ll j = i;
    while (j < k) {
      res *= 0.5;
      j *= 2;
    }
    pr += res;
    // cout << pr << " ";
  }
  cout << fixed << setprecision(10) << pr;

  return 0;
}


Measured memory_bytes: 3764
s = input()
t = input()
result = []
st = len(s) - len(t)
for i in range(st+1):
    _ = s[:i]
    flg = False
    for j in range(i, i+len(t)):
        if s[j] == t[j-i]:
            _ += t[j-i]
        elif s[j] == '?':
            _ += t[j-i]
        else:
            flg = True
    
    if flg == False:
        _ += s[i+len(t):]
        _ = _.replace('?', 'a')
        result.append(_)

if len(result) != 0:
    result.sort()
    print(result[0])
else:
    print('UNRESTORABLE')

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

int f(int o) {
	if (o == 1) {
		return 300000;
	} else if (o == 2) {
		return 200000;
	} else if (o == 3) {
		return 100000;
	}
	return 0;
}

int main() {
	int X, Y;
	cin >> X >> Y;
	int ans = 0;
	ans += f(X);
	ans += f(Y);
	if (X == 1 && Y == 1) {
		ans += 400000;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * @Author       : nonameless
 * @Date         : 2020-09-13 20:02:06
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-14 00:51:11
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

template<class T>
inline void read(T &x){
    x = 0;
    int f = 1;
    char c = getchar();
    while(c < '0' || c > '9') if(c == '-') { f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    x = x * f;
}

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }


int main(){

    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = -LNF;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    // if(ans < 0){
    //     if(a <= 0 && b >= 0) ans = 0;
    //     if(c <= 0 && d >= 0) ans = 0;
    // }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll X,Y;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>X>>Y;
    cout <<(abs(X-Y)<=1?"Brown":"Alice")<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll N, K;
  cin >> N >> K;
  map<ll, ll> A;
  for (int i = 0; i < N; i++){
    ll tmp = 0;
    cin >> tmp;
    A[tmp]++;
  }
  if(A.size()<=K){
      cout << 0 <<endl;
      return 0;
  }
  vector<ll> sum;
  for(auto i : A){
      sum.push_back(i.second);
  }
  sort(sum.begin(), sum.end());
  ll dif = A.size() - K;
  ll cnt = 0;
  for (int i = 0;i<dif; i++) {
    cnt += sum[i];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 17760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
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(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AAccepted {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string s;
        in>>s;
        int ans = 0;
        for(auto& c : s) if(c=='1') ++ans;
        out<<ans<<'\n';
    }
};


int main() {
	AAccepted solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] table = new int[51];
        
        for(int a = 0; a < 10; a++) {
            for(int b = 0; b < 10; b++) {
                for(int c = 0; c < 10; c++) {
                    for(int d = 0; d < 10; d++) {
                        table[a + b + c + d]++;
                    }
                }
            }
        }
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            int i = scan.nextInt();
            System.out.println(table[i]);
        }
    }
}

Measured memory_bytes: 26344
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  string str;
  cin >> str;
  if (str == "SUN") {
    cout << 7 << endl;
    return 0;
  }
  if (str == "MON") {
    cout << 6 << endl;
    return 0;
  }
  if (str == "TUE") {
    cout << 5 << endl;
    return 0;
  }
  if (str == "WED") {
    cout << 4 << endl;
    return 0;
  }
  if (str == "THU") {
    cout << 3 << endl;
    return 0;
  }
  if (str == "FRI") {
    cout << 2 << endl;
    return 0;
  }
  if (str == "SAT") {
    cout << 1 << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int n; cin>>n;

    switch(n % 10){
        case 3:
            cout << "bon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
n = int(input())
h = list(map(int, input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
# DP テーブル全体を初期化 (最小化問題なので INF に初期化)
dp = [INF] * n

# 初期条件
dp[0] = 0
dp[1] = abs(h[0] - h[1])

# ループ
for i in range(2,n):
    # ...
    h1 = dp[i-2] + abs(h[i-2] - h[i])
    h2 = dp[i-1] + abs(h[i-1] - h[i])
    dp[i] = min(h1,h2)
    
# 解を得て出力
print(dp[n-1])

Measured memory_bytes: 20660
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  long int N,A;
  cin >> N;
  for(int B = 1; B<=sqrt(N); B++){
    if(N%B==0){
      A=B;
    }
  }
  cout << A+(N/A)-2 << endl;
  return 0;
}

Measured memory_bytes: 256
#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>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
int n,k;
    cin>>n>>k;
    int x;
    vector<int>v(n,1);
    vector<int>a(n-k+1);
    for(int i=0;i<n;i++){
        cin>>v[i];
       
    }
    
    for(int i=0;i<n-k+1;i++){
        a[i]=(min(abs(v[i])+abs(v[i+k-1]-v[i]),abs(v[i+k-1])+abs(v[i+k-1]-v[i])));


    }
    sort(a.begin(),a.end());
    cout<<a[0]<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k=0,n,m;
	scanf("%d",&n);
	int a,b,aa=0,bb=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		if(a>aa)
		{
			aa=a;
			k=a+b;
		}
	}
	printf("%d\n ",k);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a;cin>>a;
    co(a+a*a+a*a*a);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> v(M);
    rep(i, M) cin >> v[i];

    vector<vector<int>> v2(N, vector<int>(M));
    rep(i, N) rep(j, M) cin >> v2[i][j];

    int ans = 0;
    rep(i, N) {
        int subsum = 0;
        rep(j, M) { subsum += v2[i][j] * v[j]; }
        if(subsum + C > 0) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
num = [int(input()) for _ in range(5)]
a = []

for i in range(5):
  if num[i]%10 == 0:
    a.append(10)
  else:
    a.append(num[i]%10)
    
num_min = min(a)
index_min = a.index(num_min)
if num[index_min]%10 != 0:
  num_minus = num[index_min]//10*10 + 10
else:
  num_minus = num[index_min]
num_plus = num[index_min]

for j in range(5):
  if num[j]%10 != 0:
    num[j] = num[j]//10*10 + 10

ans = sum(num) - num_minus + num_plus
print(ans)

Measured memory_bytes: 3064
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=998244353):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res


n,m,k = map(int, input().split())
MOD = 998244353
ans = 0
comb = Combination(n)
for i in range(k + 1):
    tmp = m*power_func(m - 1, n - i - 1,MOD)%MOD
    tmp *= comb(n - 1,i)
    ans += tmp%MOD
print(ans%MOD)

Measured memory_bytes: 102288
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;



int main(void){
    int W,H,N,ans=INF;
    cin>>W>>H>>N;
    VI ymax(W+1,0);
    REP(i,N){
        int x,y;
        cin>>x>>y;
        ymax[x]=max(ymax[x],y);
    }
    REPR(i,W-2){
        ymax[i]=max(ymax[i],ymax[i+1]);
        //cout<<ymax[i]<<" "<<i<<endl;
    }
    REP(i,W){
        ans=min(ans,i+ymax[i+1]);
    }
    cout<<ans<<endl;
}


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

int main(){
	int n,m,a,b;
  	int count[51]={};
  	cin>>n>>m;
	for(int i=0;i<m;++i){
      cin>>a>>b;
      count[a]++;count[b]++;
    }for(int i=1;i<=n;++i)cout<<count[i]<<endl;
  	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 1010

int H, W;
vector<string> ans;

signed main()
{
    cin >> H >> W;

    REP(i, H) {
        string s;
        cin >> s;
        ans.push_back(s);
        ans.push_back(s);
    }
    REP(i, ans.size()) {
        printf("%s\n", ans[i].c_str());
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if ((N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3])) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort(reverse = True)
t = []
for _ in range(X): t.append(p.pop())
for _ in range(Y): t.append(q.pop())
t.sort()
for i in range(min(C, X + Y)):
  if t[i] < r[i]: t[i] = r[i]
print(sum(t))

Measured memory_bytes: 98668
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        out.println(n/2+n%2);


        // out.println(res);
        out.flush();
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21332
# https://atcoder.jp/contests/abc104/tasks/abc104_b


S = gets.chomp

s1 = S[0]
s2 = S[1]
s3 = S[2..-2]
s4 = S[-1]

b1 = s1 == 'A'
b2 = s3.count('C') == 1
b3 = (s2 + s3.gsub('C', '') + s4) =~ /^[a-z]+$/

puts b1 && b2 && b3 ? 'AC' : 'WA'


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    int a[n];
    map<int,int>mp;
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<mp[i]<<endl;
}


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int n, k;
    cin >> n >> k;
    vector<int> heights(n, 0);
    for(int i=0; i<n; i++) {
        cin >> heights[i];
    }
    sort(heights.begin(), heights.end());
    //PRINT_ARRAY_INLINE(heights);
    vector<int> diffs(n-k+1, 0);
    for(int i=0; i<n-k+1; i++) {
        diffs[i] = heights[i+k-1] - heights[i];
    }
    //PRINT_ARRAY_INLINE(diffs);
    cout << *min_element(diffs.begin(), diffs.end()) << endl;


    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    int m;
    cin>>n>>m;
    vector<ll> s(n+1,0);
    S si;
    for(int i = 0;i < m; i++){
        int nn;
        cin>>nn;
        si.insert(nn);
    }
    s[0]=1;
    if(si.find(1)==si.end()) s[1]=1;
    for(int i = 2;i < n+1; i++){
        if(si.find(i)!=si.end()) s[i]=0;
        else s[i]=(s[i-1]+s[i-2])%MOD;
    }
    //cout<<n+1<<endl;
    //for(int i = 0;i < n+1; i++){
    //    cout<<s[i]<<" ";
    //}
    //cout<<endl;
    cout<<s[n]<<endl;
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a+b>c+d)
  cout << "Left";
  
  else if (a+b==c+d)
  cout << "Balanced";
  
  else if (a+b<c+d)
  cout << "Right";
}

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

#define ll long long
#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    ll count = 0;
    cin >> N;
    for(ll i = 1;i <= N;i++) {
        if(!(i % 3 == 0 && i % 5 == 0) && !(i % 3 == 0) && !(i % 5 == 0)) count += i;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i]<a[i+1]){
            ans++;
        }else if(a[i]==a[i+1]){
            ans+=0;
        }else break;
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for j in range(h):
        if j % 2 == 0:
            for i in range(w):
                if i % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        else:
            for i in range(w):
                if i % 2 == 1:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
    print()


Measured memory_bytes: 7004
N,P = [int(_) for _ in input().split()]
if N == 1:
    print(P)
    exit()
def addP(dP:dict,a:int):
    if a in dP:
        dP[a] += 1
    else:
        dP[a] = 1
dP = {}
iLim  = int(P**0.5)+1
for i in range(2,iLim+1):
    while P % i == 0:
        P //= i
        addP(dP,i)
    if P == 1:
        break
if P != 1:
    addP(dP,P)
iC = 1
for i in dP:
    if N <= dP[i] :
        iC *= i ** (dP[i]//N)
print(iC)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;


int stack[1000], top;


void push(int x){
    top++;
    stack[top] = x;
}

int pop(){
    top--;
    return stack[top+1];
}



int main(){
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if (s[0] == '+')
        {
            push(pop() + pop());
        }
        else if (s[0] == '-')
        {
            int a, b;
            a = pop(); b = pop();
            push(b - a);
        }
        else if (s[0] == '*')
        {
            push(pop() * pop());
        }
        else
        {
            push(atoi(s));
        }

    }
    printf("%d\n", stack[1]);
}


Measured memory_bytes: 2752
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[] l = new int[n];
	for(int i=0; i<n; i++) {
		l[i] = sc.nextInt();
	}
	int sum = 0;
	Arrays.sort(l);
	int[] m = new int[n];
	for(int i=0; i<n; i++) {
		m[i] = l[n-1-i];
	}
	for(int i=0; i<n; i++) {
		l[i] = m[i];
	}
	for(int i=0; i<k; i++) {
		sum += l[i];
	}
	System.out.println(sum);
}
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	string tmp;

	cin >> tmp;
	int bitnum = tmp.size();
	bitset<100002> b(tmp);
	int tmp0 = 0;
	int tmp1 = 0;

	REP(i, bitnum)
	{
		if (b[i] == 0)
		{
			tmp0++;
		}
		else
		{
			tmp1++;
		}
	}

	cout << 2 * min(tmp1, tmp0) << endl;

	return 0;
}



Measured memory_bytes: 512
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int n;
vector<int> a;

ll calc(int s) {
	ll res = 0;
	for (int i = 0; i < n; i++) {
		if (i < s) {
			res -= a[i] * 2;
		} else {
			res += a[i] * 2;
		}
	}

	return res;
}

signed main() {
	cin >> n;
	a.resize(n);
	for (auto& e : a) cin >> e;

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

	ll sum = 0;
	ll sum2 = 0;
	if(n & 1) {
		sum = calc((n + 1) / 2);
		sum += a[n / 2] + a[n / 2 - 1];
		sum2 = calc(n / 2);
		sum2 -= a[n / 2] + a[n / 2 + 1];
	} else {
		sum = calc(n / 2);
		sum += a[n / 2 - 1] - a[n / 2];
	}

	cout << max(sum, sum2) NL;

	return 0;

}



Measured memory_bytes: 640
#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>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int ab[50][50];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[a][b] = 1;
        ab[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) perm[i] = i+2;
    sort(perm.begin(), perm.end());

    int cnt = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!ab[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size()-1) cnt++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << cnt << "\n";

    return 0;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

ll solve(ll a, ll b) {
	if (a == b)
		return 1;
	int k = 0;
	while ((1ll << (k + 1)) <= b)
		++k;
	if (a >= (1ll << k))
		return solve(a - (1ll << k), b - (1ll << k));
	ll ans = (1ll << k) - a;
	if (b == (1ll << k)) {
		if (a == 0)
			return ans * 2;
		else
			return ans * 2 + 1;
	}
	int l = 0;
	while ((1ll << k) + (1ll << (l + 1)) <= b)
		++l;
	ll ans2 = min((1ll << k), (1ll << (l + 1)) + ans);
	return ans + ans2;
}

int main() {
	ll a, b;
	cin >> a >> b;
	cout << solve(a, b) << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int N=1e6+5;
typedef long long ll;
int n,a[N];
int gcd(int x,int y){
    if(!y)
        return x;
    return gcd(y,x%y);
}
bool dfs(int a[]){
    if(n==1)
        return false;
    int cnte=0,cnto=0,poso=-1;
    for(int i=1;i<=n;i++)
        if(a[i]%2)
            cnto++,poso=i;
        else
            cnte++;
    if(cnte%2)
        return true;
    else if(cnto>1)
        return false;
    else{
        if(a[poso]==1){
            ll tmp=0;
            for(int i=1;i<=n;i++)
                tmp+=a[i]-1;
            return tmp%2;
        }
        a[poso]--;
        int g=a[1];
        for(int i=2;i<=n;i++)
            g=gcd(g,a[i]);
        for(int i=1;i<=n;i++)
            a[i]/=g;
        return dfs(a)^1;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    puts(dfs(a)?"First":"Second");
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 200010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int a[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}

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

int main() {
	int flag=0;
	string S;
	cin >> S;
	for(int i=0;i<S.size();i++){
		for(int j=i+1;j<S.size();j++){
			if(S[i]==S[j])flag=1;
		}
	}
	if(flag==1){
		cout << "no" << endl;
	}else{
		cout << "yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;

const double PI = 3.14159265358979323846;

const int mod = 1000000007;

int main(int argc, char *args[]) {
	int n; cin >> n;
	int ans = 0;
	if (n % 2 == 0) {
		ans = n / 2;
	}
	else {
		ans = n / 2 + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    double te = 1e9;
    int id = -1;
    rep(i, n)
    {
        int h;
        cin >> h;
        double dh;
        dh = t - h * 0.006;
        dh = abs(a - dh);
        if (te > dh)
        {
            te = dh;
            id = i + 1;
        }
    }
    cout << id << endl;
    return 0;
}

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

const int INF = 1e9;

struct Edge {
    int to, cost, enemy;
    Edge(int t, int c, int e) : to(t), cost(c), enemy(e) {}
};

struct info {
    int cur, cost, enemy;
    info(int s, int c, int e) : cur(s), cost(c), enemy(e) {}
};

bool operator<(const info &a, const info &b) { return a.enemy >= b.enemy; }

int main() {
    int n, m, l;
    while (cin >> n >> m >> l) {
        if (n == 0 && m == 0 && l == 0) break;
        vector<Edge> g[n];
        for (int i = 0; i < m; i++) {
            int s, t, d, e;
            cin >> s >> t >> d >> e;
            g[s - 1].push_back(Edge(t - 1, d, e));
            g[t - 1].push_back(Edge(s - 1, d, e));
        }
        priority_queue<info> que;
        que.push(info(0, 0, 0));
        vector<vector<int> > dp(110, vector<int>(110, INF));
        dp[0][0] = 0;
        while (!que.empty()) {
            int cur = que.top().cur;
            int cost = que.top().cost;
            int enemy = que.top().enemy;
            que.pop();
            if (dp[cur][cost] < enemy) continue;
            for (int i = 0; i < g[cur].size(); i++) {
                Edge nx = g[cur][i];
                int nxc = cost + nx.cost;
                if (nxc <= l && dp[nx.to][nxc] > enemy) {
                    dp[nx.to][nxc] = enemy;
                    que.push(info(nx.to, nxc, enemy));
                }
                if (dp[nx.to][cost] > enemy + nx.enemy) {
                    dp[nx.to][cost] = enemy + nx.enemy;
                    que.push(info(nx.to, cost, enemy + nx.enemy));
                }
            }
        }
        int ans = INF;
        for (int i = 0; i <= l; i++) {
            ans = min(ans, dp[n - 1][i]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main()
{
    int N_MAX = 2000;

    double A, B;
    std::cin >> A >> B;

    int ans = -1;
    for (int i = 0; i < N_MAX; i++)
    {
        double tgt_num = double(i);

        int num_A = tgt_num * 0.08;
        int num_B = tgt_num * 0.10;
        // std::cout << i << ": " << num_A << ", " << num_B << std::endl;

        if (num_A == A && num_B == B)
        {
            ans = i;
            break;
        }
    }

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

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

int main() {
    int input = 0;
    int five100 = 0;
    int five = 0;
    int amari = 0;
    int amari2 = 0;
    int a = 0;
    
    cin >> input;

    amari = input % 500; //24
    a = input - amari;  //1000
    five100 = a / 500;  //500の枚数
    amari2 = amari % 5; //4
    five = (amari - amari2) / 5;

    cout << five100 * 1000 + five * 5;

    
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, a, b, c) = in.readLine.split(" ").map(_.toInt)
  val t = Iterator.continually(in.readInt)
    .take(n)
    .toArray

  val w = Array(a,b,c,0)

  val ans = {
    val enum = Array.ofDim[Int](n)
    var min = 10000000

    def evalute():Unit = {
      if(!(0 until 3).forall(i => enum.exists(_==w(i)))) {
        // println(enum.mkString(" "))
        return
      }
      var res = 0
      for(i <- 0 until 3) {
        var v = 0
        var isFirst = true
        for(j <- 0 until n if enum(j) == w(i)) {
          v += t(j)
          if(isFirst) isFirst = false
          else res += 10
        }
        res += (w(i) - v).abs
      }
      if(min > res) min = res
    }

    def bfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(i <- 0 until 4) {
          enum(cnt) = w(i)
          bfs(cnt+1)
        }
      }
    }
    
    bfs(0)
    min
  }

  println(ans)
}

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

int main()
{
  int n;
  int x1,x2,y1,y2,z1,z2,w1,w2;
  int x,y,z,w;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;
      x = x1*x2 - y1*y2 - z1*z2 - w1*w2;
      y = x1*y2 + y1*x2 + z1*w2 - w1*z2;
      z = x1*z2 - y1*w2 + z1*x2 + w1*y2;
      w = x1*w2 + y1*z2 - z1*y2 + w1*x2;
      printf("%d %d %d %d\n",x,y,z,w);
    }
  }
}

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

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

    vector<pair<int, int> > v;
    for(int i=0; i< m; i++){
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    int l = 1, count = 0;
    while(true){
        int ml = 0;
        for(int i=0; i< v.size(); i++){
            if(v[i].first <= l && l <= v[i].second && ml <= v[i].second){
                ml = v[i].second+1;
            }
        }
        if(l == ml){cout << "Impossible" << endl; return 0;}
        else l = ml;
        count++;
        if(n < l){cout << count << endl; return 0;}
    }
}

Measured memory_bytes: 1200