akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

int tt[100 + 1];

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

    int N, M, X;
    cin >> N >> M >> X;

    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        ++tt[a];
    }

    int ans1 = 0;

    for (int i = X - 1; i > 0; --i) {
        ans1 += tt[i];
    }

    int ans2 = 0;

    for (int i = X + 1; i < N; ++i) {
        ans2 += tt[i];
    }

    out(min(ans1, ans2));

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  int A[50];

  scanf("%d",&n);

  A[0]=A[1]=1;
  for(i=2;i<=n;i++)A[i]=A[i-1]+A[i-2];

  printf("%d\n",A[n]);

  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <string.h>

int main(void) {
    int i, j, len, c[26]={0}, t=0;
    char S[100010];
    scanf("%s", &S);
    len = strlen(S);
    for (i=1;i<len-1;i++) {
        c[S[i]-'a']++;
    }
    for (j=0;j<=25;j++) t += c[j];
    t += (S[0]==S[len-1]) ? 1 : 0;
    if (t%2) printf("First\n");
    else printf("Second\n");

    return 0;
}

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

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

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

bool period(int n, int d) {
	if (d == n) return false;
	if (d * 2 < n) return false;
	int l = n - d;
	return (n % l == 0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	bool eq = true;
	forn(i, 0, n) if (s[i] != s[0]) eq = false;
	if (eq) {
		cout << n << '\n';
		cout << 1 << '\n';
		return 0;
	}
	vector<int> pi (n);
	for (int i = 1; i < n; ++i) {
		int j = pi[i - 1];
		while (j > 0 && s[i] != s[j])
			j = pi[j - 1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
	}
	if (!period(n, pi[n - 1])) {
		cout << 1 << '\n';
		cout << 1 << '\n';
		return 0;
	}
	vector<char> ok(n - 1, true);
	forn(i, 0, n - 1) {
		if (period(i + 1, pi[i])) ok[i] = false;
	}
	reverse(all(s));
	fill(all(pi), 0);
	for (int i = 1; i < n; ++i) {
		int j = pi[i - 1];
		while (j > 0 && s[i] != s[j])
			j = pi[j - 1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
	}
	forn(i, 0, n - 1) {
		if (period(i + 1, pi[i])) ok[n - 2 - i] = false;
	}
	int ans = 0;
	forn(i, 0, n - 1) if (ok[i]) ++ans;
	cout << 2 << '\n';
	cout << ans << '\n';
	return 0;
}


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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(){
	int k;
	cin >> k;
	int t;
	cin >> t;
	vector<int> a(t);
	REP(i, t)
		cin >> a[i];
	priority_queue<int> que;
	REP(i, t)
		que.push(a[i]);
	int pre = -1;
	int res = 0;
	if (t == 1) {
		cout << a[0] - 1 << endl;
		return 0;
	}
	REP(i, k) {
		int x = que.top();
		que.pop();
		if(x!=0)
			x--;
		else {
			res += k - i;
			break;
		}

		if (pre != -1)
			que.push(pre);
		pre = x;

	}
	cout << res << endl;
	return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> P(n);
    rep(i, n)
    {
        string x;
        int y;
        cin >> x >> y;
        P[i] = make_pair(make_pair(x, -y), i + 1);
    }
    sort(all(P));
    rep(i, n) {
        cout << P[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21

int main() {
  int N, X;
  cin >> N >> X;
  int L[N];
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  int plot = 0;
  int count = 1;

  int bound;
  for (int i = 0; i < N; i++) {
    plot += L[i];
    if (plot > X) break;
    count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n, m, c, a[50][50], b[50], ans = 0;
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++)cin >> b[i];
	for (int i = 0; i < n; i++) {
		int sum = c;
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			sum += a[i][j] * b[j];
		}
		ans += (sum > 0);
	}
	cout << ans << endl;
}

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

//Union-find Tree
class UnionFind{
    private:
        vector<int> par;    //par[i]:iの親の番号

    public:
        UnionFind(int n) : par(n){  //初期化時はすべて根とする
            for(int i=0; i<n; i++){
                par.at(i) = i;
            }
        }

        int root(int x){    //データxが属する木の根を再帰で得る
            if(par.at(x) == x){
                return x;
            }else{
                return par.at(x) = root(par.at(x)); //経路圧縮を同時に実行
            }
        }

        void unite(int x, int y){   //xの属する木とyの属する木を併合
            int rx = root(x), ry = root(y);
            if(rx != ry){   //xとyの属する木が異なるとき
                par.at(rx) = ry;    //xの木の根をyの根につける
            }
        }

        bool same(int x, int y){    //x,yが同じ木に属するときtrue, そうでなければfalse
            return root(x) == root(y);
        }
};


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

    vector<pair<int,int>> vec(m);

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        vec.at(i).first = a - 1;
        vec.at(i).second = b - 1;
    }

    int ans = 0;

    for(int i=0; i<m; i++){
        vector<pair<int,int>> v(vec);
        v.erase(v.begin() + i);
        UnionFind tree(n);
        for(int j=0; j<v.size(); j++){
            tree.unite(v.at(j).first, v.at(j).second);
        }
        bool connect = true;
        for(int j=0; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                connect = (connect && tree.same(j, k));
            }
        }
        if(!connect){
            ans++;
        }
    }

    cout << ans << endl;    

    return 0;
}

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

using namespace std;

const int N = (int) 1e5;

int a[N];
int b[N];
int c[N];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n);
	for (int i = 0; i < n; i++) cin >> b[i]; sort(b, b + n);
	for (int i = 0; i < n; i++) cin >> c[i]; sort(c, c + n);
	long long ans = 0;
	for (int i = 0, j = 0, k = 0; j < n; j++) {
    	while (i < n && a[i] < b[j]) i++;
    	while (k < n && b[j] >= c[k]) k++;
		ans += i * 1LL * (n - k);		    	 
    }
	cout << ans;	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  
  vector<ll> x(n);
  for (int i = 0; i < n; i++){
    cin >> x[i];
  }
  ll ans = 0;
  for (int i = 0; i < n-1; i++){
    ans += min(a*(x[i+1]-x[i]), b);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<int64_t>> a(h + 1, vector<int64_t>(w + 1)),
            b(h + 1, vector<int64_t>(w + 1));
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> a[i][j];
        }
    }
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> b[i][j];
        }
    }

    vector<vector<vector<bool>>> dp(
            h + 1L, vector<vector<bool>>(w + 1L, vector<bool>(160 * 80 + 1)));
    dp[0][1][0] = true;
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            auto diff = a[i][j] - b[i][j];

            for (auto k : irange(0L, 160 * 80 + 1L)) {
                if (!dp[i - 1][j][k]) {
                    continue;
                }

                for (auto d : {k + diff, k - diff}) {
                    if (d < 0) {
                        d *= -1;
                    }
                    if (d < dp[i][j].size()) {
                        dp[i][j][d] = true;
                    }
                }
            }

            for (auto k : irange(0L, 160 * 80 + 1L)) {
                if (!dp[i][j - 1][k]) {
                    continue;
                }

                for (auto d : {k + diff, k - diff}) {
                    if (d < 0) {
                        d *= -1;
                    }
                    if (d < dp[i][j].size()) {
                        dp[i][j][d] = true;
                    }
                }
            }
        }
    }

    auto ans = find(dp[h][w].begin(), dp[h][w].end(), true) - dp[h][w].begin();

    cout << ans << endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    lint count = 0;
    REP(i, n) {
        lint a;
        cin >> a;
        count += (a % 2);
        }
        if((count%2)==0){
            cout << "YES"<< "\n";
        }else{
            cout << "NO"
                 << "\n";
        }
    return 0;
}

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

#define rep(i,n) for (int i =0;i<(n);i++)
#define LL long long 

using namespace std;

int main(){
    int m,f,b;
    cin >>m>>f>>b;
    if(m+f<b){
        cout<<"NA"<<endl;

    }
    else if(b<m){
        cout<<0<<endl;
    }
    else{
        cout<<b-m<<endl;
    }
    return 0;
}


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

int BinaryResearch(string s,int key,int n){
  int left = 0,right = n;
  int mid;
  while(left < right){
  	mid = (left+right)/2;
    if((int)s.at(mid) == key) return mid;
    else if(key < (int)s.at(mid)) right = mid+1;
    else if(key > (int)s.at(mid)) left = mid;
  }
  return -1;
}
int main()
{
  int a,b; cin >> a >> b;
  int x = (a+b+1)/2;
  cout << x << endl;
}

Measured memory_bytes: 256
#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());
    ll N, K;
    cin >> N >> K;
    ll ans = 1e9;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    for(int i = 0; i < N - K + 1; i++) {
        ans = min(ans, v[i + K - 1] - v[i]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
N = int(input())
T,A = map(int,input().split())
H = map(int,input().split())

anss = 99999
ans = 0
i = 1

for hi in H:
    if abs(anss) > abs(A - (T - hi *0.006)):
        anss = A - (T - (hi *0.006))
        ans = i
    i = i +1
    
print(ans)

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

int main() {
  int N;
  cin >> N;
  
  bool flag = false;
  
  for(int i=0; i<N; i++)
  {
    string s;
    cin >> s;
    
//    cout << s << endl;
    
    if(s == "Y") flag = true;
  }
  
  if(flag)
  {
    cout << "Four" << endl;
  }else{ 
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    // read input
    int n;
    cin >> n;
    vector<ll> values(n);
    rep(i, 0, n) cin >> values[i];

    // initialize
    unordered_map<ll, ll> left, right;
    for (ll i=0; i<n; ++i)
    {
        ll now = i - values[i];
        ++right[now];
    }

    // counting
    ll cnt = 0;
    for (ll i=0; i<n; ++i)
    {
        ll now_left = i+values[i];
        ll now_right = i-values[i];

        // remove itself from right
        --right[now_right];

        // search
        cnt += left[i-values[i]];
        cnt += right[i+values[i]];

        // append itself to left
        ++left[now_left];
    }
    cout << cnt/2 << endl;
    return 0;
}


Measured memory_bytes: 35660
(N,M,K) = map(int,input().split())

for i in range(N+1):
    for j in range(M+1):
        if i*(M-j)+j*(N-i) == K:
            print('Yes')
            flag = 1
            break
        else:
            flag = 0
    if flag == 1:
        break
else:
    print("No")

Measured memory_bytes: 9080
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
int n,m,o,vis[100010],f[100010],du[100010],chu[100010],ru[100010],ch[100010];
vector<int> vec[100010];
struct part{
int u,v;
};
struct part ans[100010];
int faa[100010];
int find1(int x)
{
    if (faa[x]==x) return(faa[x]); else faa[x]=find1(faa[x]);
    return(faa[x]);
}

void dfs(int x)
{
    vis[x]=1;
    for (int i=0;i<vec[x].size();i++)
    if (!vis[vec[x][i]])
    {
        vis[vec[x][i]]=1;
        ch[x]++;
        f[vec[x][i]]=x;
        dfs(vec[x][i]);
    }
}
void dfs1(int x)
{
    for (int i=0;i<vec[x].size();i++)
    if (!vis[vec[x][i]])
    {
        vis[vec[x][i]]=1;
        dfs1(vec[x][i]);
        int y=vec[x][i];
        if (chu[y]%2==1)
        {
            o++;
            ans[o].u=y;
            ans[o].v=f[y];
            chu[y]++;
            ru[f[y]]++;
        } else
        {
            o++;
            ans[o].u=f[y];
            ans[o].v=y;
            chu[f[y]]++;
            ru[y]++;
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        faa[i]=i;
    int k=0;
    o=0;
    for (int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        int fa=find1(u);
        int fb=find1(v);
        if (fa!=fb)
        {
            vec[u].push_back(v);
            vec[v].push_back(u);
            du[v]++;
            du[u]++;
            faa[fa]=fb;
        } else
        {
            o++;
            ans[o].u=u;
            ans[o].v=v;
            du[u]++;
            du[v]++;
            chu[u]++;
            ru[v]++;
        }
    }

    if (m%2==1)
    {
      printf("-1\n");
      return(0);
    }
    memset(vis,0,sizeof(vis));
    f[1]=1;
    dfs(1);
    memset(vis,0,sizeof(vis));
    vis[1]=1;
    dfs1(1);
    for (int i=1;i<=o;i++)
        printf("%d %d\n",ans[i].u,ans[i].v);
    return(0);
}
/*
9 10
1 2
1 3
2 4
2 5
3 6
3 7
5 8
5 9
6 9
7 9
*/


Measured memory_bytes: 14336
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    int j = 2;
    int prevN = N;
    while(N > 1) {
        int cnt = 0;
        int k = 1;
        while(N % j == 0) {
            N /= j;
            cnt++;
            if(cnt >= k) {
                ans++;
                k++;
                cnt = 0;
            }
        }
        
        if(prevN < j * j) break;
        j++;
    }
    if(N > 1) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
typedef vector<ll>vec;
typedef vector<vector<ll>> mat;
set<int>s;
int a[5];
//vector<int>a[5];
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A')a[1]++;
    else  a[2]++;
  }
  if(a[1]&&a[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){

    int a,b,c,n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&a,&b,&c);
        int x,y,z;
        x=a*a;
        y=b*b;
        z=c*c;
        if(x+y ==z || x+z==y || z+y== x){
            printf("YES\n");
        }
    else{
        printf("NO\n");
     }
  }
}



Measured memory_bytes: 2040
N=int(input())
for i in range(1,3501):
    for j in range(i,3501):
        bw=4*i*j-N*i-N*j
        if bw<=0:
            continue
        if (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            exit()

Measured memory_bytes: 40668
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
    let A = parseInt(input[0], 10);
    const B = parseInt(input[1], 10);
    let C = parseInt(input[2], 10);
    const D = parseInt(input[3], 10);

    while (A > 0 && C > 0) {
        C -= B;
        A -= D;
    }
    if (C <= 0) {
        console.log("Yes");
    } else {
        console.log("No");
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29620
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    if(N>=64){cout<<64<<endl;}
    else if(N>=32){cout<<32<<endl;}
    else if(N>=16){cout<<16<<endl;}
    else if(N>=8){cout<<8<<endl;}
    else if(N>=4){cout<<4<<endl;}
    else if(N>=2){cout<<2<<endl;}
    else {cout<<1<<endl;}
    return 0;
}

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

const int MOD = 1e9+7;

//---------- べき乗 ----------
int64_t modpower(int64_t a, int64_t n){
    if(n == 0) return 1;
    
    int64_t res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }

    return res;
}

//---------- 逆元 ----------
int64_t modinv(int64_t a){
    return modpower(a, MOD-2);
}

int main(){
  int64_t N, K;
  vector<int64_t> A(2010);

  cin >> N >> K;
  for(int i=0; i<N; i++) cin >> A[i];

  int64_t in = 0, out= 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(A[j] < A[i]){
        out++;
        if(j > i) in++;
      }
    }
  }

  int64_t ans = ((in * K % MOD) + (((K*(K-1)%MOD) * modinv(2) % MOD) * out) % MOD) % MOD;
  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 dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
	string a,b;
	int	cnt = 0,ma = 0;
	cin >> a >> b;
	rep(i,a.size() - b.size() + 1){
		cnt = 0;
		rep(j,b.size()){
			if(a[i+j] == b[j]){
				cnt++;
			}
		}
		ma = max(cnt,ma);
	}
	cout << b.size() - ma <<endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

int solve(int X) {
    for (int t=1, last=0; ; ++t) {
        int mx = last+t;
        if (X <= mx) return t;
        last = mx;
    }
}

int main() {
    int X; cin >> X;
    cout << solve(X) << endl;
    return 0;
}


Measured memory_bytes: 256
use io::*;
use std::cmp::{max, min};

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let a: i64 = sc.next();
    let b: i64 = sc.next();

    println!(
        "{}",
        if a + b == 15 {
            '+'
        } else if a * b == 15 {
            '*'
        } else {
            'x'
        }
    );
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

int main() {
  int n,d;
  cin>>n>>d;
  d=2*d+1;
  int ans=0;
  while(n>0){
   ans++;
    n-=d;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define N 300005
using namespace std;
typedef long long ll;
ll n, a, b, k, ans, M=998244353;
ll fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};
 
ll c(ll p) {
	if(p>n) return 0;
	return fac[n] * fiv[n-p] % M * fiv[p] % M;
}
 
int main() {
	cin>>n>>a>>b>>k;
	ll i;
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	for(i=0; i<=n && a*i<=k; i++) {
		if((k-a*i)%b == 0) ans += c(i) * c((k-a*i)/b) % M;
	}
	cout<<ans%M;
	return 0;
}

Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector<ll> ans;
vector<vector<ll>> g;
vector<ll> a;
vector<ll> dp;

void dfs(ll v, ll p=-1) {
  // Update dp
  ll pre;
  ll len = dp.size();
  ll idx = lower_bound(all(dp), a[v]) - dp.begin();
  if (idx == len) { // idx is end(), should be added.
    dp.push_back(a[v]);
  } else { // idx < len. should replace.
    pre = dp[idx];
    dp[idx] = a[v];
  }

  ans[v] = dp.size();

  for (ll u : g[v]) {
    if (u == p) { continue; }
    dfs(u, v);
  }

  // Revert dp
  if (idx == len) {
    dp.pop_back();
  } else {
    dp[idx] = pre;
  }
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  ans.resize(n);
  g.resize(n);
  a.resize(n);

  rep(i,n) {
    cin >> a[i];
  }
  rep(iter,n-1) {
    ll u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);

  rep(i,n) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 31668
N=gets.to_i
hash = {}
N.times do |n|
  sum = gets.rstrip.chars.sort.join
unless hash.has_key? sum
  hash[sum] = []
end
  hash[sum].push(n)
end
count = hash.values.map{|a| a.combination(2).size }.reduce(:+)
print count

Measured memory_bytes: 28412
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll ans = 0;
    int a = 0;
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
        a = max(a,p[i]);
        ans += p[i];
    }
    ans = ans - a/2;
    
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int count = 0;

	for (int i = 0; i <= a; i++) {
		if (x < 500 * i) break;

		for (int j = 0; j <= b; j++) {
			if (x < 500 * i + 100 * j) break;

			for (int k = 0; k <= c; k++) {
				if (x < 500 * i + 100 * j + 50 * k) break;
				if (x == 500 * i + 100 * j + 50 * k) count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
class Fractional
    attr_reader :mod

    def initialize(max, mod)
        @max = max
        @mod = mod
        @frac     = { 0 => 1, 1 => 1 }
        @frac_inv = { 0 => 1, 1 => 1 }
        @inv      = {         1 => 1 }

        pre_calc(max)
    end

    def pre_calc(max)
        2.upto(max) do |i|
            @frac[i] = @frac[i - 1] * i % @mod;
            @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
            @frac_inv[i] = @frac_inv[i - 1] * @inv[i] % @mod
        end
    end

    def at(i)
        @frac[i]
    end

    def inv_at(i)
        @frac_inv[i]
    end
end

class Combination
  def initialize(fraction)
      @fraction = fraction
  end

  def calc(n, r)
      return 0 if n < r
      return 0 if (n < 0 || r < 0)

      denom_inv = (@fraction.inv_at(r) * @fraction.inv_at(n - r) % @fraction.mod)
      return @fraction.at(n) * denom_inv % @fraction.mod
  end
end

x, y = gets.chomp!.split(" ").map(&:to_i)
min, max = [x, y].minmax

if min * 2 < max
  puts 0
  exit 0
end

if (x + y) % 3 != 0
  puts 0
  exit 0
end

frac = Fractional.new(10 ** 6 - 1, 10 ** 9 + 7)
comb = Combination.new(frac)

p = (x + y) / 3
r = 
  if p % 2 == 0
    p / 2 - (max - min) / 2
  else
    p / 2 - ((max - min) / 2)
  end

puts comb.calc(p, r)


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

using namespace std;

int main(){
    int n;
    bool is = false;
    while(cin >> n){
        if(n == 0) break;
        if(is && n != 0) cout << endl;
        if(!is) is = true;
        int c[4], p[4], t[4] = {10, 50, 100, 500}, sum = 0;
        for(int i=0; i< 4; i++){cin >> c[i]; p[i] = 0; sum += c[i]*t[i];}
        sum -= n;
        for(int i=3; 0 <= i; i--){
            p[i] = sum/t[i];
            sum%=t[i];
        }
        for(int i=0; i< 4; i++) if(0 < c[i]-p[i]) cout << t[i] << " " << c[i]-p[i] << endl;
    }
}

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    int now = 1;
    bool f = false;
    for(int i = 0; i < n; i++){
        if(A[i] == now){
            f = true;
            now++;
        }
    }

    if(f) cout << n - now + 1 << endl;
    else cout << -1 << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	char s[n];
	int cnt = 1;
	cin >> s[0];
	for (int i=1; i<n; i++) {
		cin >> s[i];
		if (s[i] != s[i-1]) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int n;
bool flag;
int main(){
    read(n);
    int s=0,t=0;
    for (;n--;){
        int a,b,t;
        read(t),read(a),read(b);
        if (abs(s-a)+abs(t-b)>t){
            return puts("No"),0;
        }
        s=a,t=b;
    }
    puts("Yes");
    return 0;
}*/
int main(){
    ll a,b;
    cin>>a>>b;
    puts((a*b)&1?"Odd":"Even");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int S[100000];
int T[50000];

int search(int* S, int n, int* T, int q){
    int i;
    int left, mid, right;
    int ans = 0;
    for(i=0; i<q;i++){
        left = 0;
        right = n-1; 
        while(left <= right){
            mid = (left + right)/2;
            if(T[i] == S[mid]){
                ans++;
                break;
            }
            if(T[i] > S[mid]) left = mid + 1;
            else right = mid - 1;
        }
    }
    return ans;
}


int main(void){
    int n,q;
    int i;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%d", &T[i]);
    }
    
    printf("%d\n", search(S,n,T,q));
    return 0;
}

Measured memory_bytes: 1184
use std::io::*;
use std::str::FromStr;
use std::collections::LinkedList;

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

fn main() {
    let x: i64 = read();

    for i in -1000..1001 {
        for j in -1000..1001 {
            if pow5(i) - pow5(j) == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}

fn pow5(i: i64) -> i64 {
    i * i * i * i * i
}

fn prime_lists(limit: u64) -> LinkedList<u64> {
    let mut ret: LinkedList<u64> = LinkedList::new();
    ret.push_back(2);
    let mut i: u64 = 3;

    while i * i <= limit {
        if (&ret).into_iter().fold(true, |a, &b| a && i % b != 0) {
            ret.push_back(i);
        }
        i += 2;
    }
    ret
}

fn factorize(fact: u64) -> Vec<u64> {
    let mut i = fact;
    let mut ret: Vec<u64> = Vec::new();
    let primes = prime_lists(fact);
    println!("a");
    for p in &primes {
        while i % p == 0 {
            ret.push(*p);
            i /= p;
        }
    }
    ret
}

fn factorize_all(fact: u64) -> Vec<u64> {
    let mut factorized = factorize(fact);
    let mut ret:  Vec<u64> = Vec::with_capacity(factorized.len() * factorized.len());
    ret.push(1);

    while factorized.len() > 0 {
        let n = factorized.remove(0);
        let pushed = (&ret).into_iter().map(|&b| b * n).collect::<Vec<u64>>();
        for other in &pushed {
            ret.push(*other);
        }
    }
    ret.dedup();
    ret
}


Measured memory_bytes: 2168
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	
	long n = read.to!long;
	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;
	
	long old_a = 0;
	long ans = 0;
	foreach_reverse(a; as){
		if(a >= old_a){
			ans += a;
			}
		else if(a == old_a - 1){
			ans += 0;
			}
		else{
			ans = -1;
			break;
			}
		debug writeln("a:", a, " old_a:", old_a, " ans:", ans);
		old_a = a;
		}
	if(old_a > 0) ans = -1;
	
	ans.writeln;
	}

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

using namespace std;
const int N = 705;
const int INF = 1e9+5;
bool adj[N][N],viz[N],col[N],bad;
vector<int> v[N];
int black,white,n;
void dfs(int x, int c)
{
    viz[x] = 1;
    col[x] = c;
    if (c)
        black++;
    else
        white++;
    for (int i = 1; i<=n; i++)
        if (adj[x][i])
        {
            if (!viz[i])
                dfs(i,c^1);
            else if (col[i] == c)
                bad = 1;
        }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int m;
    cin >> n >> m;
    for (int i = 1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x][y] = adj[y][x] = 1;
    }
    for (int i = 1; i<=n; i++)
        for (int j = 1; j<=n; j++)
            if (i!=j)
                adj[i][j]^=1;
    vector< pair<int,int> > comps;
    for (int i = 1; i<=n; i++)
        if (!viz[i])
        {
            black = white = 0;
            dfs(i,0);
            comps.push_back({black,white});
        }
    if (bad)
    {
        cout << -1;
        return 0;
    }
    int k = comps.size();
    vector<vector<bool> > dp(k+1, vector<bool>(n+1,0));
    dp[0][0] = 1;
    for (int i = 1; i<=k; i++)
    {
        int x = comps[i-1].first, y = comps[i-1].second;
        for (int j = 1; j<=n; j++)
        {
            if (j>=x && dp[i-1][j-x])
                dp[i][j] = 1;
            if (j>=y && dp[i-1][j-y])
                dp[i][j] = 1;
        }
    }
    long long ans = INF;
    for (int i = 1; i<=n; i++)
        if (dp[k][i])
        {
            long long x = i, y = n-x;
            ans = min(ans,(x*(x-1))/2+(y*(y-1))/2);
        }
    cout << ans;
}


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

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

  int b = numeric_limits<int>::max();
  map<pair<int,int>, int> m;
  for (int i = 0; i < n; i++) {
    int x,y,h;
    cin >> x >> y >> h;
    
    m[make_pair(x,y)] = h;
    b = min(b,h);
  }

  for (int x = 0; x <= 100; x++) {
    for (int y = 0; y <= 100; y++) {
      for (int z = b; z <= b+200; z++) {
	bool t=true;
	for (auto it: m) {
	  if(max(0, z-abs(it.first.first-x)-abs(it.first.second-y)) != it.second) {
	    t=false;
	    break;
	  }
	}
	if(t){
	  cout << x << ' ' << y << ' ' << z << endl;
	  return 0;
	}
      }
    }
  }
  
  return 0;
}


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

int main()
{
	int n,x,t,c=0, ans=0;
	cin>>n>>x>>t;
	if(n%x==0)
		c=n/x;
	else
		c=n/x+1;
	cout<<c*t<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <locale>

static bool input(int &n)
{
	std::string s;
	std::locale loc;

	if (0x00 == &n) {
		return false;
	}

	std::cin >> s;
	if (std::isdigit(s[0], loc)) {
		n = std::atoi(s.c_str());
		return true;
	}

	return false;
}

static int xCubic(const int x)
{
	return x * x * x;
}

int main()
{
	int n;

	if (true == input(n)) {
		std::cout << xCubic(n) << '\n';
	}

	return (0);
}

Measured memory_bytes: 3160
function main(input){
    let lines = input.split("\n");
    let i=0;

    while(lines[i]!=="0 0"){
        let count = 0;
        let nums = arrint(lines[i].split(" "));
        for(let j=1;j<=nums[0];j++){
            for(let k=j;k<=nums[0];k++){
                let l = nums[1]-j-k;
                if(j===k || k===l || j===l)continue;
                if(l<=nums[0] && l>k){
                    count++;
                }
                
            }
        }
        console.log(count);
        i++;
    }
}
function arrint(arr){
    return arr.map(x=>parseInt(x));
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 16380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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() {
  ll N, A, B;
  cin >> N >> A >> B;
  cout << N/(A+B) * A + min(N%(A+B), A) << endl;
  return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  vint a(n);
  rep(i,n){
    cin>>a[i];
  }
  if((n-1)%(k-1)==0){
    cout<<(n-1)/(k-1)<<'\n';
  }
  else{
    cout<<(n-1)/(k-1)+1<<'\n';
  }
  return(0);
}


Measured memory_bytes: 640
# coding: utf-8

import heapq


class Dijkstra:

    """
    Dijkstra's algorithm: find the shortest path from a vertex
    Complexity: O(E + log(V))
    used in GRL1A(AOJ)
    """

    def __init__(self, V, G, INF=float("inf")):

        """
        V: the number of vertexes
        E: adjacency list (all edge in G must be 0 or positive)
        INF: Infinity distance
        """
        self.V = V
        self.G = G
        self.INF = INF
        self.distance, self.prev = list(), list()


    def dijkstra(self, start):

        Q = list()
        self.distance = [self.INF for _ in range(self.V)]
        self.prev = [-1 for _ in range(self.V)]

        self.distance[start] = 0
        heapq.heappush(Q, (0, start))

        while len(Q) > 0:
            dist, from_v = heapq.heappop(Q)
            if self.distance[from_v] < dist:
                continue
            for to_v, nxt_dist in self.G[from_v]:
                if self.distance[from_v] + nxt_dist >= self.distance[to_v]:
                    continue
                self.distance[to_v] = self.distance[from_v] + nxt_dist
                heapq.heappush(Q, (self.distance[to_v], to_v))
                self.prev[to_v] = from_v
        
        return self.distance


    def get_path(self, goal):

        path = [goal]
        while self.prev[goal] != -1:
            path.append(prev[goal])
            goal = self.prev[end]

        return path[::-1]


if __name__ == "__main__":
    
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n):
        v, _, *e = map(int, input().split())
        for u, d in zip(e[::2], e[1::2]):
            g[v].append((u, d))

    dist = Dijkstra(n, g).dijkstra(0)
    for i, d in enumerate(dist):
        print(i, d)



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

int main()
{
    int a, b, c, x, y, ans, mini;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

    if((a+b) <= 2*c) ans = a*x + b*y;
    else {
        mini = min(x,y);
        ans = c*2*mini;
        int dif;
        if(x > y)

            ans += min(a, 2*c)*(x - mini);
        else
            ans += min(b, 2*c)*(y - mini);
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
	int N,A;
	cin >> N >> A;
	cout << N*N-A << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<string>
#include<functional>
#include<set>
using namespace std;

#define INF 1<<21
#define DIV 1000000007
#define MAX 250000


#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

using namespace std;



int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int m = 30001;
  if (a + b < m)m = a + b;
  if (a + c < m)m = a + c;
  if (b + c < m)m = b + c;
  cout << m << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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 vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

typedef vector<double> vd;

int main(){
	cout.precision(16);
	int n,m;
	cin>>n>>m;
	vd l(n),a(n),b(n);
	REP(i,n){
		cin>>l[i]>>a[i]>>b[i];
	}
	double ans=0;
	REP(i,1<<n){
		int cnt=0;
		REP(j,n){
			cnt+=((i>>j)&1);
		}
		if(cnt==m){
			double dist=0;
			REP(j,n){
				FOR(k,j+1,n){
					if(((i>>j)&1)&&((i>>k)&1)){
						dist+=(l[j]-l[k])*(l[j]-l[k]);
						dist+=(a[j]-a[k])*(a[j]-a[k]);
						dist+=(b[j]-b[k])*(b[j]-b[k]);
					}
				}
			}
			ans=max(ans,dist);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int x = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'I') {
				x++;
			} else {
				x--;
			}
			if (ans < x) {
				ans = x;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
while 1:
    l = int(input())
    if l == 0:
        break;
    s = 0
    for i in range(1,13):
        m, n = [int(_) for _ in input().split()]
        l -= m - n
        if s == 0 and l <= 0:
            s = i
    print(s) if s != 0 else print('NA')
    


Measured memory_bytes: 5620
main :: IO()
main = do
    str <- getLine
    putStrLn $ if length (even' (map (countStr str) ['a' .. 'z'])) == 26
                   then "Yes"
                   else "No"

countStr :: String -> Char -> Int
countStr str chr
    | str  == [] 				= 0
    | head str == chr			= 1 + (countStr (tail str) chr)
    | otherwise					= (countStr (tail str) chr)

even' :: [Int] -> [Int]
even' [] = []
even' ls = if mod (head ls) 2 == 1 then even' (tail ls) else (head ls):(even' (tail ls))




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

int n, m, a = 0, b;

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

	for (int i = 0; i < m; i++) {
		int s, c, t = 1;

		cin >> s >> c;

		if (s == 1 && n > 1 && c == 0)
			a = -1;
		else if (a > -1){

			for (int j = 0; j < n - s; j++)
				t *= 10;

			b = (a / t) % 10;

			if (b != 0 && b != c)
				a = -1;
			else if (b == 0)
				a += c * t;
		}
	}
	
	if (a > -1) {
		b = a;

		for (int i = 0; i < n - 1; i++)
			b /= 10;

		if (n > 1 && b == 0) {
			int t = 1;

			for (int i = 0; i < n - 1; i++)
				t *= 10;

			a += t;
		}
	}

	cout << a << endl;

}


Measured memory_bytes: 256