akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000000
#define NINF -1000000000000000000
int main()
{
    int n,i,j;
    scanf("%d",&n);
    pair<int,int> arr[n];
    for(i=0;i<n;i++)
    {
        arr[i].second=i;
        scanf("%d",&arr[i].first);
    }
    sort(arr,arr+n);
    int ans=0;
    for(i=0;i<n;i++)
    {
        if((i+arr[i].second)%2) ans++;
    }
    ans=ans/2;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int d, n;
	cin >> d >> n;
	if (n == 100)
		printf("%d", (int)(pow(100.0, d) * 101));
	else
		printf("%d",(int)(pow(100.0, d)*n));
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
 
typedef long long ll;
using namespace std;
 
int main() {
  double a,b,c,d,e,f,x,y;

  while(cin >> a >> b >> c >> d >> e >> f){
    y = (c*d-a*f)/(b*d-a*e);
    x = (c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
  }
  

  return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    int N;
    ll W;
    cin >> N >> W;
    int weight[N], value[N];
    vector<vector<int>>values(4);
    ll pivot;
    rep(i, N) {
        cin >> weight[i] >> value[i];
        if(i == 0)pivot = weight[i];
        values[weight[i] - pivot].pb(value[i]);
    }
    rep(i, 4) {
        if(!values[i].empty())
            sort(values[i].begin(), values[i].end(), greater<int>());
    }
    int ans = 0;
    int sumValues[4][N + 1];
    rep(i, 4) {
        sumValues[i][0] = 0;
        rep(j, values[i].size()) {
            sumValues[i][j + 1] = sumValues[i][j] + values[i][j];
        }
    }
    rep(i_0, values[0].size() + 1) {
        rep(i_1, values[1].size() + 1) {
            rep(i_2, values[2].size() + 1) {
                rep(i_3, values[3].size() + 1) {
                    if(ll(i_0) * (pivot) + ll(i_1) * (pivot + 1) + ll(i_2) * (pivot + 2) + ll(i_3) * (pivot + 3) <= W)
                        ans = max(ans, sumValues[0][i_0] + sumValues[1][i_1] + sumValues[2][i_2] + sumValues[3][i_3]);
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
  }
  int ans = 1, sum = k;
  while (true) {
    if (sum >= n) {
      break;
    }
    ans++;
    sum += k - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()
for i in range(A + B + 1):
    if (i < A or i > A) and S[i] == "-":
        print("No")
        break
    elif i == A and S[i] != "-":
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
 
int hiro_start[100005];
int hiro_end[100005];
vector<int> connect[100005];

int main() {
    stack<int> S;
    int N, M, a, b, stock = 0, count = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        hiro_start[i] = 0;
        hiro_end[i] = 0;
    }
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        a--;
        b--;
        hiro_start[a]++;
        hiro_end[b]++;
        connect[a].push_back(b);
    }
    for (int i = 0; i < N; i++) {
        if (hiro_end[i] != 0 && stock != 0) {
            count++;
            stock = 0;
            while (!S.empty()) {
                int now = S.top();
                S.pop();
                for (int j = 0; j < connect[now].size(); j++) {
                    hiro_end[connect[now][j]]--;
                }
            }
        }
        if (connect[i].size() > 0) {
            S.push(i);
        }
        if (hiro_start[i] != 0) {
            stock += hiro_start[i];
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}

int64_t
gcd( int64_t x,  int64_t y )
{
     int64_t min = ( x < y ) ? x : y;
     int64_t max = ( x < y ) ? y : x;
    
    while( 1 )
    {
         int64_t mod = max % min;
        
        if( mod == 0 )
        {
            return min;
        }

        max = min;
        min = mod;
    }
    
    return 1;
}

int main()
{
    int64_t a,b,c,d;
    std::cin>> a;
    std::cin>> b;
    
    c = gcd( a, b );

    d = ( a * b ) / c;

    std::cout<< d;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll a,b,c,k,ans=0;
  cin>>a>>b>>c>>k;
  ans += min(a,k);
  k -= min(a,k);
  if (k>0){
  	k-=min(b,k);
    if (k>0){
    	ans -= min(c,k);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,l[60],sum = 0;
    cin >> n >> k;
    for (int i = 0;i < n;i++){
        cin >> l[i];
    }
    sort(l,l+n,greater<int>());
    for (int i = 0; i < k;i++){
        sum += l[i];
    }
    cout << sum << endl;
}

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

int main()
{
    string s;
    cin >> s;

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

    string ret = (s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) ? "Yes" : "No";

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N, K;
	cin >> N >> K;
	lls h;
	cinv(h, N);

	ll count = 0;
	for (auto hOne : h) {
		if (hOne >= K) count++;
	}

	cout << count << '\n';

	return 0;
}



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



int main(){
    char c;

    cin >> c;


    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 110
int a[MAXN];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  REP(i, N) cin >> a[i];
  sort(a, a + N);
  reverse(a, a + N);
  int sumA = 0;
  int sumB = 0;
  REP(i, N) {
    if (i % 2 == 0)
      sumA += a[i];
    else
      sumB += a[i];
  }
  print(sumA - sumB);
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int stones[100001];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n , k;
    cin >> n >> k;

    rep(i, 0, n){
        cin >> stones[i+1];   
    }

    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = dp[1] + abs(stones[2]-stones[1]);
    rep(i, 3, n+1){
        int cost = 1e9;
        rep(j, 1, k+1){
            if(i-j>=1  ){
                cost = min( cost, dp[i-j]+abs(stones[i] - stones[i-j]));
                //cout << cost << endl;
            }
        }
        //cout << i << '-' << cost << endl; 

        dp[i] = cost;
    }
    // rep(i, 1, n+1){
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << dp[n];
}



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

using namespace std;

int main() {
	int n; cin >> n;
	int p[4], t[4], maxi = 0;
	for (int i = 0; i < 4; ++i) cin >> p[i];
	for (int i = 0; i < 4; ++i) {
		cin >> t[i];
		maxi = max(maxi, t[i]);
	}
	vector<vector<int> > dp(5, vector<int>(n + maxi + 1, 1e5));
	for (int i = 1; i < 5; ++i) dp[i][0] = 0;
	for (int i = 1; i < 5; ++i) {
		for (int j = 0; j <= n + maxi; ++j) {
			if (j >= t[i - 1]) dp[i][j] = min(dp[i][j - t[i - 1]] + p[i - 1], dp[i - 1][j]);
			else if (dp[i - 1][j] != 1e5) dp[i][j] = dp[i - 1][j];
		}
	}
	int ans = 1e5;
	for (int i = n; i <= n + maxi; ++i) ans = min(ans, dp[4][i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(),h.end(),greater<int>());
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for (int i = k; i < n; ++i) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
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(' ')))
 
eat = sorted(p, reverse=True)[:X]
eat[len(eat):] = sorted(q, reverse=True)[:Y]
eat[len(eat):] = R
eat.sort(reverse=True)


print(sum(eat[:X+Y]))

Measured memory_bytes: 23328
N, M, x, y = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]

X.append(x)
Y.append(y)

maX = max(X)
miY = min(Y)

ans = ""
if maX < miY:
    ans = "No War"
else:
    ans = "War"

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s; cin >> s;
  int count=0;
  int rest=0;
  for (int i=0;i<s.size();i++) {
   if (s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
    count++;
   rest=max(rest,count);
   }
   else {
   count = 0;
   }
  }
  cout << rest << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j;
  int h,w;

  while(1){
    scanf("%d %d",&h, &w);

    if(h == 0 && w == 0) break;

    for(i= 0; i < h; i++){
      for(j = 0; j < w; j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
    int N, v_i; cin >> N;
    vector<double> v; v.reserve(N);
    REP0(i, N) {
        cin >> v_i;
        v.push_back(v_i);
    }
    SORT(v);
    double ans=(v[0] + v[1])/2;
    FOR(i, 2, N) {
        ans = (ans + v[i])/2;
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f

typedef long long LL;




const int N = 1000;

int n, ans;

struct node{
	int x,y;
	bool take;
	node(){}
	bool operator < (const node &temp) const{
		if (x < temp.x) return true;
		else if (x > temp.x) return false;
		else return y < temp.y;
	}	
}a[N],b[N];


int main()
{
	cin >> n;
	REP(i,0,n) cin >> b[i].x >> b[i].y;
	REP(i,0,n) cin >> a[i].x >> a[i].y;
	sort(a,a+n);
	sort(b,b+n);
	REP(i,0,n) {
	//	cout << a[i].x << ' ' << a[i].y << endl;
		int p, maxy = -INF;
		REP(j,0,n){
			if (b[j].x < a[i].x && b[j].y > maxy && b[j].y < a[i].y && b[j].take == false){
				maxy = b[j].y;
				p = j;
			}
		}
		if (maxy != -INF){
			ans++;
			b[p].take = true;
		}
	}
	cout << ans;



	return 0;
}


Measured memory_bytes: 256
N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
    for i in range(1, j):
        res[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1

for i in range(1, N):
    print(res[i])


Measured memory_bytes: 3444
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long llong;

int main() {
    llong a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        puts("0");
    } else {
        llong ans = min({a * b, b * c, c * a});
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
map<int,int> mp;

void input() {
    cin >> n;
    REP(i,n) {
        int k;
        cin >> k;
        mp[k]++;
    }
}

void solve() {
    if (sz(mp) > 2) {
        cout << "No" << endl;
        return;
    }
    if (sz(mp) == 1) {
        int num = (*mp.begin()).fi;
        cout << (num * 2 <= n || num == n - 1? "Yes":"No") << endl;
        return;
    }
    auto it = mp.begin();
    int k1 = (*it).fi;
    int num1 = (*it).se;
    it++;
    int k2 = (*it).fi;
    int num2 = (*it).se;
    int different_nums = k1 - num1 + 1;
    if (different_nums < 1 || different_nums * 2 > num2) {
        cout << "No" << endl;
        return;
    }
    if (k2 != k1 + 1) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
	string s;
	cin>>n;
	bool ans = true;
	cin>>s;
	if(n%2==1) cout<<"No\n";
	else{
		forn(i,n/2){
			if(s[i]!=s[n/2+i]){ans = false;break;}
		}
		(ans)?cout<<"Yes\n":cout<<"No\n";
	}
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3648
def score(x):
  sc = 0
  th = 1
  for _ in [0]*10:
    a = x[th]+x[th+1]
    if x[th]==10:
      sc += 10+x[th+1]+x[th+2]
      th -= 1
    elif a==10: sc += 10+x[th+2]
    else: sc += a
    th += 2
  return x[0], sc

while 1:
  n = input()
  if n==0: break
  A = sorted([score(map(int, raw_input().split())) for _ in [0]*n], key=lambda x: (-x[1], x[0]))
  for a, b in A: print a, b

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
ll coun[100005] = {0};
int main()

{
    ll n, k;
    cin >> n;
    ll arr[n];
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        coun[arr[i]]++;
        sum += arr[i];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        ll x, y;
        cin >> x >> y;
        sum = sum + (y - x) * coun[x];
        coun[y] += coun[x];
        coun[x] = 0;
        cout << sum << "\n";
    }

    return 0;
}

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


int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
	else	cout << "win" << endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 1001001001;
	for(int i = -100; i <= 100; i++) {
		int now = 0;
		rep(j, n) {
			now += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s,t;
    int flag=0;
    int count=0;
    
    cin >>s>>t;

    for (int i = 0; i < s.length(); i++){
        for (int j = 0; j < t.length(); j++){
            if(s.compare(i,1,t,j,1) < 0)flag=1;
            else if(s.compare(i,1,t,j,1)==0){
                count++;
            }
        }
    }


    if(flag==0 && count==(s.length()*t.length())){
        if(s.length()<t.length())flag=1;
    }
    //cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> PII;
int main()
{
	// freopen("in.txt", "r", stdin);
	int n;
	int ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (i % 2 == 1 && x % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define FRE(i,a,b)  for(i = a; i <= b; i++)
#define FRL(i,a,b)  for(i = a; i < b; i++)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << #x " = " << (x) << '\n'
#define DBG         cerr << "Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i, j, cs, t;
    char s[100];
    scanf("%s",s);
    int len = strlen(s);
    for(i = 0; i<len; i++)
        if(s[i] == ',')
            s[i] = ' ';
    cout << s << endl;
    return 0;
}




Measured memory_bytes: 384
s = list(input())
L = len(s)

result = ""

for i in range(0, L):
  if s[i] == "0":
    result = result + "0"
  elif s[i] == "1":
    result = result + "1"
  else:
    if result == "":
      pass
    else:
      result = result[:-1]

print(result)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.nextLine();
            int maxLen = 0;
            int lastPos = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c == 'A' || c == 'C' || c == 'G'|| c== 'T') {
                    maxLen = Math.max(maxLen, i - lastPos + 1);
                } else {
                    lastPos = i + 1;
                }
            }
            System.out.println(maxLen);
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define  pii pair<int,int>
ll N,M;
ll A[100001],B[100000],ans[100001];
ll arr[100001];
ll sizes[100001];
ll root(ll i){
  while(i!=arr[i]) i=arr[i];
  return(i);
}
void weighted_union(ll a,ll b){
  ll root_a=root(a),root_b=root(b);
  if(sizes[root_a]>sizes[root_b]) swap(root_a,root_b);
  sizes[root_b]+=sizes[root_a];
  arr[root_a]=root_b;
}
int main(){
    ifstream fin("a.in");
    ofstream fout("a.out");
  cin>>N>>M;
  for(int i=0;i<M;i++) cin>>A[i]>>B[i];
  for(int i=0;i<=N;i++) arr[i]=i;
  ull cur_ans=N*(N-1)/2;
  for(ll i=0;i<=N;i++) sizes[i]=1;
  for(ll t=M-1;t>=0;t--){
    if(cur_ans<=0) cur_ans=0;
    ans[t]=cur_ans;
    if(t==0) break;
    if(root(A[t])==root(B[t])) continue;
    else{
      cur_ans-=((ll)sizes[root(A[t])])*((ll)sizes[root(B[t])]);
      weighted_union(A[t],B[t]);
    }
  }
  for(ll i=0;i<M;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 5248
// c++11 ~
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef struct info
{
    string name;
    double eff;

    info(string n, double e) : name(n), eff(e) {}
} info;

bool cmp(const info &a, const info &b)
{
    return a.eff == b.eff ? a.name < b.name : a.eff > b.eff;
}

int main()
{
    int N = 0;
    string L;
    int p, a, b, c, d, e, f, s, m;
    int t = 0, tprice = 0;
    double eff;
    vector<info> v;
    while (1)
    {
        v.clear();
        cin >> N;
        if (N == 0)
            break;

        for (size_t i = 0; i < N; i++)
        {
            cin >> L >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            t = (a + b + c + (d + e) * m);
            tprice = f * m * s - p;
            eff = (double)tprice / (double)t;
            v.push_back(info(L, eff));
        }

        sort(v.begin(), v.end(), cmp);

        for (size_t i = 0; i < v.size(); i++)
        {
            cout << v[i].name << endl;
        }
        cout << '#' << endl;

    }

    return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
    int A, B;
    cin >> A >> B;
    int ans = max(A + B, max(A - B, A * B));
    print(ans);
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int N = 2e5 + 5;

int n, dp[N][3], a[N][3];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 3; j++)
            cin >> a[i][j];
    }
    for(int i = 1; i < N; i++) {
        for(int j = 0; j < 3; j++)
            dp[i][j] = -LLONG_MAX;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(k != j)
                    dp[i][j] = max(dp[i - 1][k] + a[i][j], dp[i][j]);
            }
        }
    }
    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
}


Measured memory_bytes: 9600
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

class Main {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
  int m=sc.nextInt();
  int arr[][]=new int[m][3];
  for(int i=0;i<m;i++){
    for(int j=0;j<3;j++){
    arr[i][j]=sc.nextInt();
    }
  }
  int sto[][]=new int[m+1][3];
  sto[1][0]=arr[0][0];
  sto[1][1]=arr[0][1];
  sto[1][2]=arr[0][2];
  for(int i=2;i<=m;i++){
  sto[i][0]=arr[i-1][0]+Math.max(sto[i-1][1],sto[i-1][2]);
    sto[i][1]=arr[i-1][1]+Math.max(sto[i-1][0],sto[i-1][2]);
    sto[i][2]=arr[i-1][2]+Math.max(sto[i-1][1],sto[i-1][0]);
  }
  int maxi=Math.max(sto[m][0],Math.max(sto[m][1],sto[m][2]));
  System.out.println(maxi);
	}
}

Measured memory_bytes: 101632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <ll, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO";
		return 0;
	}
	v -= w;
	if (abs(a - b) <= (ll)t * v) {
		cout << "YES";
	}	else {
		cout << "NO";
	}
}


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

int main()
{
  string s;
  cin >> s;
  int i, back;
  back = 0;
  for(i = 0; i < s.size(); i++)
  {
    if(s.at(i) == 'B')
    {
      s.at(i) = 'E';
      while(s.at(i) == 'E' && i > 0)
      {
        i--;
      }
      s.at(i) = 'E';
    }
  }
  for(i = 0; i < s.size(); i++)
  {
    if(s.at(i) != 'E')
    {
      cout << s.at(i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double rad_h = 2 * M_PI * (h / 12.0 + m / (60.0 * 12.0));
  double rad_m = 2 * M_PI * m / 60.0;
  cout << setprecision(15) << sqrt(pow(a * sin(rad_h) - b * sin(rad_m), 2) + pow(a * cos(rad_h) - b * cos(rad_m), 2)) << endl;
}


Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
int main(){ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,j,cnt;
cin>>n>>k;
int a[n+1];
int b[n+2]={0};
for(i=1;i<=n;i++){
    cin>>a[i];
    b[max(0,i-a[i])]++;
    b[min(n+1,i+a[i]+1)]--;
}
int t[n+2];
for(i=1;i<=n;i++){b[i]+=b[i-1];}
k--;
for(j=0;j<k;j++){cnt=0;
    for(i=1;i<=n;i++){if(b[i]==n)cnt++;}
    if(cnt==n)break;
    memset(t,0,sizeof(t));
    for(i=1;i<=n;i++){
        t[max(0,i-b[i])]++;
        t[min(n+1,i+b[i])+1]--;
    }
   for(i=1;i<=n;i++){
       t[i]=t[i]+t[i-1];
       b[i]=t[i];
   }
}
for(i=1;i<=n;i++){cout<<b[i]<<" ";}
    return 0;}

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

int main(){

	ll N,K;
	cin >> N >> K;
	map<ll,ll> ma;
	for(int i=0;i<N;i++){
		ll A;
		cin >> A;
		ma[A]++;
	}
	ll cnt = ma.size();
	vector<ll> v;
	for(auto x:ma){
		v.push_back(x.second);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < (cnt-K); ++i){
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int MAXN = 100 + 10;

char str[MAXN];
int n;
bitset <100> s;
namespace solver1 {
  map <pair<int, string >, int> f;
  int dfs(bitset<100> s, int n) {
    if (n == 0) return 1;
    if (f.count(make_pair(n, s.to_string()))) return f[make_pair(n, s.to_string())];
    int ans = 1ll * dfs(s >> 1, n - 1) * (s[0] + 1);
    for (int i = 1; i <= n / 2; i++) {
      bitset <100> tmp = s, sub, full;
      for (int j = 0; j < i; j++) full[j] = 1;
      sub = tmp & full;
      tmp >>= i;
      for (int j = 2; i * j <= n; j++) {
        sub &= tmp & full;
        tmp >>= i;
        ans = (ans + 1ll * dfs(sub, i) * dfs(tmp, n - i * j) % MOD) % MOD;
      }
    }
    return f[make_pair(n, s.to_string())] = ans;
    
  }
  void main() {
    printf("%d\n", dfs(s, n));
  }
}
int main() {
  scanf("%s", str);
  n = strlen(str);
  for (int i = 0; i < n; i++) {
    s[i] = str[i] - '0';
  }
  solver1::main();
}


Measured memory_bytes: 9472
X, N = map(int, input().split())

if N==0:
  print(X)
  exit(0)
  
p = [int(i) for i in input().split()]

for i in range(101):
  for s in [-1,1]:
    a = X + i*s
    if a not in p:
      print(a)
      exit(0)
  

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, l, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a);
    sort(b);
    sort(c);
    ll ans = 0;
    rep(i,n){
        ll p = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll q = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += p*q;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#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>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll MOD=998244353;

int main(){
  int N; cin >> N; int a[N]; ll ans = longinf;
  rep(i, N){
    cin >> a[i];
  }
  rep(i, 500){
    ll tmp = 0;
    rep(j, N){
      tmp+=(ll) ((a[j] - (i-200)) * (a[j] - (i-200)));
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
input = gets.split(' ')
min = 100
conb = [
  [0, 1, 2],
  [0, 2, 1],
  [1, 0, 2],
  [1, 2, 0],
  [2, 0, 1],
  [2, 1, 0]]

conb.each { |conb_one|
  cost = 0
  last = -1
  conb_one.each { |c|
    if last > -1
      cost += (input[c].to_i - input[last].to_i).abs
    end

    last = c
  }

  if cost < min
    min = cost
  end
}

puts min

Measured memory_bytes: 1788
N, K = map(int, input().split())
A = list(map(int, input().split()))

current = 1
path = [1]
already = [False] * len(A)

while K > 0:
    if already[current - 1]:
        loop = path[path.index(A[current - 1]):]
        current = loop[(K - 1) % len(loop)]
        break

    path += [A[current - 1]]
    already[current - 1] = True
    current = A[current - 1]
    K -= 1

print(current)


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

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

int main() {
	int n;
	cin >> n;
	map<int, int> oddm, evenm;
	for (int i=0; i<n; ++i) {
		int vi;
		cin >> vi;
		++(i%2 ? evenm : oddm)[vi];
	}
	
	vector<pair<int, int>> odd, even;
	for (auto v : oddm) odd.push_back(v);
	for (auto v : evenm) even.push_back(v);
	sort(odd.begin(), odd.end(), comp);
	sort(even.begin(), even.end(), comp);

	pair<int, int> 
		of = odd[0],
		os = odd.size()>0 ? odd[1] : make_pair(-1, n/2),
		ef = even[0],
		es = even.size()>0 ? even[1] : make_pair(-2, n/2);

	cout << 
		(of.first != ef.first 
			? n - of.second - ef.second
			: min(
				n - of.second - es.second,
				n - os.second - ef.second
			)
		) 
	<< endl;
}

Measured memory_bytes: 6136
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readLong();
    auto a = readLongs();
    int ans = 1;
    int i = 1;
    long sign = a[1] - a[0];
    while(i < a.length) {
        while(i < a.length) {
            if(sign == 0) {
                sign = a[i] - a[i-1];
            }
            if((a[i] - a[i-1]) * sign < 0) {
                ++ans;
                sign = 0;
            }
            ++i;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 4348
#include <cstdio>
#include <algorithm>
#include <cstring>
#define INF 0x3f3f3f3f
#define LL long long
#define MAX 100010
using namespace std;
int a[200010];
long long sum=0;
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0; i<N; i++)
        scanf("%d",&a[i]);
    if(a[0]!=0)
    {
        printf("-1\n");
        return 0;
    }
    for(int i=1; i<N; i++)
    {
        if(a[i]-a[i-1]>1)
        {
            printf("-1\n");
            return 0;
        }
        else if(a[i]-a[i-1]==1)
            sum++;
        else
            sum+=a[i];
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <set>

using namespace std;

const int N = 2e5 + 10;

string s[N];
set<string> res;

int main() {
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		res.insert(s[i]);
	}
	
	cout << res.size() << '\n';
	
	return 0;
}

Measured memory_bytes: 25516
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,h[100005],k;
ll dp[100005];
ll go(ll i){
    if(i==n-1) return 0;
    ll ans=1e17;
    if(dp[i]!=-1) return dp[i];
    for(ll j=i+1;j<=i+k and j<n;j++) ans=min(ans,go(j)+abs(h[i]-h[j]));
    return dp[i]=ans;
}

int main()
{
    io
    ll i,j;
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(i=0;i<n;i++) cin>>h[i];
    cout<<go(0);

    return 0;
}

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

typedef pair<int, int> P;

bool used[100005];
ll scores[100005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n,k;
  cin>>n>>k;
  // 全部の寿司を得点の高い順に
  priority_queue<P> all_pq;
  // タイプが重複した寿司のうち、得点の低いもの集合
  priority_queue<P, vector<P>, greater<P> > less_pq;
  for(ll i=0;i<n;i++){
    int t,d;cin>>t>>d;
    all_pq.push({d,t});
  }
  ll sum = 0;
  int cnt=0;
  for(ll i=0;i<k;i++){
    auto v = all_pq.top();all_pq.pop();
    if(!used[v.second]){
      used[v.second] = 1;
      cnt++;
    }else{
      less_pq.push(v);
    }
    sum += v.first;
  }
  scores[cnt]=sum;

  while(!all_pq.empty()&&!less_pq.empty()){
    auto v = all_pq.top();all_pq.pop();
    if(used[v.second])continue;
    auto v2 = less_pq.top();less_pq.pop();
    used[v.second]=true;
    sum -= v2.first;
    sum += v.first;
    cnt++;
    scores[cnt] = sum;
  }
  ll res=0;
  for(ll i=0;i<=n;i++){
    if(!scores[i])continue;
    res=max(res, scores[i] + i*i);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 //#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
//const int INF=4e18+10;
 const int INF=1e9+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

void precomp()
{
}


void solve()
{
    int c= 0;
    int n;
    cin>>n;
    for(int i= 1;i<=n;i++)
    {
        int p;
        cin>>p;
        if(p%2 && i%2)
            c++;
    }
    cout<<c<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3656
n = int(input())
a = list(map(int,input().split()))
m = 0
for i in range(n):
    if a[i] < 0:
        m += 1
        a[i] = abs(a[i])
if m % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - (min(a) * 2))

Measured memory_bytes: 19992
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
//using Graph = vector<vector<int>>;
//queue<long>que;
 
int main(){
    int n;
    cin >>n;
    string s;
    cin >>s;
    vector<int>a(n);
    long long cnt_r=0, cnt_g=0, cnt_b=0;
    rep(i,n){
        char RGB=s.at(i);
        if(RGB=='R'){
            a[i]=1;
            cnt_r++;
        }
        else if(RGB=='G'){
            a[i]=2;
            cnt_g++;
        }
        else{
            a[i]=3;
            cnt_b++;
        }
    }
    long long ans=cnt_r*cnt_g*cnt_b;

    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            int k = 2*j-i;
            if(k<n){
            if(a[i]==a[j])continue;
            if(a[j]==a[k])continue;
            if(a[i]==a[k])continue;
            ans--;
            }
        }
    }
    
    cout << ans <<endl;
    
}




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

int main() {
  int N, i;
  cin >> N;
  string S;
  
  for(i=0; i<N; i++) {
    cin >> S;
    
    if(S=="Y") {
      cout << "Four" << endl;
      break;
    }
  }
  
  if(S!="Y") {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3516
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int[] lines = new int[10001];

    void run(){
	part();
	while(sc.hasNext()){
	    int n = sc.nextInt();
	    System.out.println(lines[n]);
	}
    }

    void part(){
	lines[0] = 1;
	lines[1] = 2;
	lines[2] = 4;
	lines[3] = 7;
	for(int i=4; i<lines.length; i++){
	    lines[i] = lines[i-1]+i;
	}
    }
}

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

int main(){
    int n, min, count;
    cin >> n;
    int P[n];
    for (int i = 0; i < n; i++){
        cin >> P[i];
    }
    count = 0;
    min = 200001;
    for (int i = 0; i < n; i++){
        if(min > P[i]){
            min = P[i];
        }
        if(min == P[i]){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

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

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

struct Point {
  int x;
  int y;
};

double dist(Point p1, Point p2) {
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

int main() {
  cout << fixed << setprecision(10);
  int N;
  cin >> N;

  vector<Point> p;
  rep(i, N) {
    Point tmp;
    cin >> tmp.x >> tmp.y;
    p.push_back(tmp);
  }

  double s = 0;
  rep(i, N - 1) for (int j = i + 1; j < N; j++) {
    s += 2 * dist(p.at(i), p.at(j));
  }

  double ans = s / N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

struct Card
{
	char suit, value;
};

void printdata(Card C[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i > 0)
		{
			cout << " ";
		}

		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

void bubbleSort(Card A[], int N)
{
	int flg = 1;
	int replace = 0;

	while (flg)
	{
		flg = 0;
		for (int i = N - 1; i>0; i--)
		{
			if (A[i].value < A[i - 1].value)
			{
				swap(A[i], A[i - 1]);
				replace++;
				flg = 1;
			}
		}
	}
}

void selectSort(Card A[], int N)
{
	int min;
	int replace = 0;


	for (int i = 0; i < N; i++)
	{
		min = i;
		for (int j = i; j < N; j++)
		{
			if (A[min].value > A[j].value) 
			{
				min = j;

			}
		}
		if (min != i) 
		{
			swap(A[min], A[i]);
			replace++;
		}
	}
}

int main()
{
	int N, flg = 0;
	Card A[100],B[100];

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i].suit >> A[i].value;
	}
	memcpy(B,A,sizeof(A));
	bubbleSort(A, N);
	selectSort(B, N);

	printdata(A, N);
	cout<< "Stable" << endl;
	printdata(B, N);

	for (int j = 0; j < N; j++)
	{
		if (A[j].suit != B[j].suit) 
		{
			flg = 1;
		}
	}

	if (flg) 
	{
		cout << "Not stable" << endl;
	}
	else
	{
		cout <<"Stable" << endl;
	}

	return 0;
}


Measured memory_bytes: 3116