akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    string ans = "NO\n", k = "keyence";
    FOR(i, 0, 8) {
        if (s.substr(0, i) == k.substr(0, i) && s.substr(n - 7 + i) == k.substr(i)) {
            ans = "YES\n";
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var dic = new Dictionary<string, int>();
        var l = 0;
        var ls = "";
        foreach (var str in input)
        {
            if (dic.ContainsKey(str))
            {
                dic[str] += 1;
            }
            else
            {
                dic.Add(str, 1);
            }
            if (l <str.Length)
            {
                l = str.Length;
                ls = str;
            }
        }
        Console.WriteLine("{0} {1}", dic.OrderByDescending(x => x.Value).ToArray()[0].Key, ls);
    }
}



Measured memory_bytes: 18428
import java.io.*;
public class Main {
   public static void main(String[] args) throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String tmp = br.readLine();
       int cnt = 0;
       String[] ans = new String[1024];
       char[] s = tmp.toCharArray();
       for(int i=0;i<s.length;i++){
           if(s[i] == ',' || s[i] == '.')  s[i]= ' ';
       }
       tmp = String.valueOf(s);
       String[] data = tmp.split(" ");
       for(int i=0;i<data.length;i++){
           if(data[i].length() > 2 && data[i].length() < 7) {
               ans[cnt] = data[i];
               cnt++;
           }
       }
       for(int i=0;i<cnt;i++){
          if(i == cnt-1) System.out.println(ans[i]);
          else System.out.print(ans[i] + " ");
       }
   }
}

Measured memory_bytes: 16912
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))

d = [0] + [0] * n
for i in range(n):
  d[i + 1] = d[i] + l[i]

ans = 0
for a in d:
  if a <= x:
    ans += 1

print(ans)


Measured memory_bytes: 3060
import scala.io.StdIn._
object Main extends App {
  val s = readLine
  val k = readInt
  val ss = (0 to s.size - 1).map(i => s.slice(i, i + k)).sorted.take(k)
  val sorted = ss.flatMap(_.inits).distinct.sorted.tail // remove "" by tail
  println(sorted(k - 1))
}


Measured memory_bytes: 28472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 1e5 + 7;
const int maxM = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m, cnt, wrn;
int vis[maxN];
LL A, B, C;
LL res;

struct vec {
	static const int maxE = maxM;
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) {e[++te] = (edge){y, g[x]}; g[x] = te;}
	inline void link(int x, int y) {push(x, y), push(y, x);}
	inline int& operator () (int x) {return g[x];}
	inline edge& operator [] (int x) {return e[x];}
}e;

void dfs(int x, int kd) {
	vis[x] = kd; ++ cnt;
	fore (e, x, y) {
		if (vis[y]) {
			if (3 - kd != vis[y]) wrn = 1;
		}
		else dfs(y, 3 - kd);
	}
}

int main() {

	n = ri(), m = ri();
	rep (i, 1, m) e.link(ri(), ri());
	rep (i, 1, n) if (!vis[i]) {
		cnt = wrn = 0;
		dfs(i, 1);
		if (cnt == 1) ++ A;
		else {
			if (wrn == 0) ++ B;
			else ++ C;
			res += 2 - wrn;
		}
	}
	res += B * (B - 1) * 2;
	res += 2 * A * (n - A);
	res += A * A;
	res += 2 * B * C;
	res += C * (C - 1);
	
	printf("%lld\n", res);

	return 0;
}

Measured memory_bytes: 5888
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        
        if (n % 2 == 0) {
            double mid1 = (double)(a[n/2] + a[n/2-1]) / 2;
            double mid2 = (double)(b[n/2] + b[n/2-1]) / 2;
            
            double tmp = mid2 - mid1;
            // System.out.println(mid1);
            
            System.out.println((int)(tmp*2)+1);
        } else {
            int mid1 = a[n/2];
            int mid2 = b[n/2];
            
            System.out.println(mid2 - mid1 + 1);
        }
    }
}


Measured memory_bytes: 61660
def main():
    n, m, x = [int(x) for x in input().split()]
    prices = [None] * n
    contents = [None] * n
    for book_i in range(n):
        price, *content_in_a_manual = [int(x) for x in input().split()]
        prices[book_i] = price
        contents[book_i] = content_in_a_manual
    INF = 10 ** 9
    ans = INF
    for num in range(1 << n):
        payment = 0
        understanding = [0] * m
        for book_i in range(n):
            if num >> book_i & 1:
                payment += prices[book_i]
                for algo_i, value in enumerate(contents[book_i]):
                    understanding[algo_i] += value
        if min(understanding) >= x:
            ans = min(ans, payment)
    if ans == INF:
        return - 1
    else:
        return ans


if __name__ == '__main__':
    print(main())


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  long long l,r;
  cin >> l >> r;

  const long long mod = 2019;
  long long ans = 2e9 + 1;
  long long res = 0;
  for(long long i = l; i <= r; i++){
    for(long long j = i+1; j <= r; j++){
      res = i % mod;
      res *= j;
      res %= mod;
      ans = min(ans, res);
      if(ans == 0) break;
    }
    if(ans == 0) break;
  }
  cout << ans << endl;

  // int s = l % mod;
  // vector<int> a;
  // a.push_back(l%mod);
  // int cnt = 0;
  // for(int i = l + 1; i <= r; i++){
  //   if(i%mod == s) {
  //     cnt ++;
  //     if(cnt >= 3) break;
  //   }
  //   a.push_back(i%mod);
  // }
  // sort(a.begin(), a.end());
  // // for(int i = 0; i < a.size(); i++) cout << a[i] << endl;
  // cout << a[0] * a[1] % mod << endl;

  return 0;
}

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

int main(){
  int k;
  int A[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cin >> k;
  cout << A[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
//....SARANSH GUPTA....\\

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define mod 1000000007
bool comp(ll a,ll b)
{
    if(a<=b)
    return true;
    return false;
}
int main()
{
    FIO
    ll n,m,k;
    cin>>n>>m>>k;
    ll pre1[n+1],pre2[m+1],val=0;
    fo(0,n)
    {
        int x;
        cin>>x;
        pre1[i]=x+val;
        val=pre1[i];
    }
    val=0;
    fo(0,m)
    {
        int x;
        cin>>x;
        pre2[i]=x+val;
        val=pre2[i];
    }
    int ind=0,maxm=0;
    fo(0,m)
    {
        if(pre2[i]<=k)
        {ind=lower_bound(pre1,pre1+n,k-pre2[i],comp)-pre1;
        maxm=max(maxm,i+1+ind);
        }
    }
    fo(0,n)
    {
        if(pre1[i]<=k)
        {ind=lower_bound(pre2,pre2+m,k-pre1[i],comp)-pre2;
        maxm=max(maxm,i+1+ind);
        }
    }
    cout<<maxm<<endl;
}

Measured memory_bytes: 6760
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  vector<ll> a;

  pair<ll,ll> M = mp(0,0);
  pair<ll,ll> m = mp(0,0);
  ll ans = 0;
  vector<pair<ll,ll> > way;
  
  rep(i,N){
    ll inp; cin >> inp;
    a.pb(inp);
    if(inp > M.first) M=mp(inp,i);
    if(inp < m.first) m=mp(inp,i);

  }

  
  if((abs(M.first)<abs(m.first))){
    for(ll i = a.size()-2;i>=0;i--){
      if(a[i] > a[i+1]){
	ans++;
	way.pb(mp(m.second,i));
	a[i]+=m.first;
	if(a[i]<m.first)m=mp(a[i],i);
	if(a[i]>a[i+1]){
	  ans++;
	  way.pb(mp(m.second,i));
	  a[i]+=m.first;
	  if(a[i]<m.first)m=mp(a[i],i);
	}
      }
    }
    cout << ans << endl;
    rep(i,way.size()) cout << way[i].first+1 << " " << way[i].second+1 << endl;
    return 0;
  }

  for(ll i = 1; i<a.size();i++){
    if(a[i] < a[i-1]){
      ans++;
      way.pb(mp(M.second,i));
      a[i]+=M.first;
      if(a[i]>M.first)M=mp(a[i],i);
      if(a[i]<a[i-1]){
	ans++;
	way.pb(mp(M.second,i));
	a[i]+=M.first;
	if(a[i]>M.first)M=mp(a[i],i);
      }
    }
  }
  cout << ans << endl;
  rep(i,way.size()) cout << way[i].first+1 << " " << way[i].second+1 << endl;
  

  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

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

	if (n == 1) {		
		if (m == 0) cout << 0 << endl;
		else {
			map<int, int> data;
			data[1] = -1;
			bool num1 = true;
			bool ans = true;

			for (int i = 0; i < m; i++) {
				int s, c;
				cin >> s >> c;
				if (s == 1) {
					if (num1) {
						data[1] = c;
						num1 = false;
					}
					else {
						if (c != data[1]) {
							ans = false;
						}
					}
				}
			}
			
			if (!ans) cout << "-1" << endl;
			if (ans) {
				if (data[1] == -1) data[1] = 0;
				cout << data[1] << endl;
			}
		}
	}

	if (n == 2) {
		if (m == 0) cout << 10 << endl;
		else {
			map<int, int> data;
			data[1] = -1;
			data[2] = -1;
			bool num1 = true;
			bool num2 = true;
			bool ans = true;

			for (int i = 0; i < m; i++) {
				int s, c;
				cin >> s >> c;
				if (s == 1) {
					if (num1) {
						data[1] = c;
						num1 = false;
					}
					else {
						if (c != data[1]) {
							ans = false;
						}
					}
				}
				if (s == 2) {
					if (num2) {
						data[2] = c;
						num2 = false;
					}
					else {
						if (c != data[2]) {
							ans = false;
						}
					}
				}
			}
			if (data[1] == 0) ans = false;
			if (!ans) cout << "-1" << endl;
			if (ans) {
				if (data[1] == -1) data[1] = 1;
				if (data[2] == -1) data[2] = 0;
				cout << data[1] * 10 + data[2] << endl;
			}
		}
	}

	if (n == 3) {
		if (m == 0) cout << 100 << endl;
		else {
			map<int, int> data;
			data[1] = -1;
			data[2] = -1;
			data[3] = -1;
			bool num1 = true;
			bool num2 = true;
			bool num3 = true;
			bool ans = true;

			for (int i = 0; i < m; i++) {
				int s, c;
				cin >> s >> c;
				if (s == 1) {
					if (num1) {
						data[1] = c;
						num1 = false;
					}
					else {
						if (c != data[1]) {
							ans = false;
						}
					}
				}
				if (s == 2) {
					if (num2) {
						data[2] = c;
						num2 = false;
					}
					else {
						if (c != data[2]) {
							ans = false;
						}
					}
				}
				if (s == 3) {
					if (num3) {
						data[3] = c;
						num3 = false;
					}
					else {
						if (c != data[3]) {
							ans = false;
						}
					}
				}
			}
			if (data[1] == 0) ans = false;

			if (!ans) cout << "-1" << endl;
			if (ans) {
				if (data[1] == -1) data[1] = 1;
				if (data[2] == -1) data[2] = 0;
				if (data[3] == -1) data[3] = 0;
				cout << data[1] * 100 + data[2] * 10 + data[3] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  char U[2*N];
  
  for (int i=0; i<2*N; i+=2){
    cin >> U[i];
  }
  for (int i=1; i<2*N; i+=2){
    cin >> U[i];
  }
  for (int i=0;i<2*N;i++){
    cout << U[i];
  }
  cout << endl;   
}


Measured memory_bytes: 256
program main
  implicit none
  integer, parameter :: binsize = 2500, nbin = 200
  integer :: n, i, t, l, r, numq, cnt(26, nbin)
  character(500000) :: s
  character(100) :: q
  character(1) :: c
  read *, n
  read *, s
  call prep
  read *, numq
  do i = 1, numq
    read *, t, l, q
    if (t == 1) then
      read (q, *) c
      call type1(l, c)
    else
      read (q, *) r
      call type2(l, r)
    end if
  end do
  contains

  subroutine prep()
    integer :: i, j, b
    cnt(:, :) = 0
    do i = 1, n
      j = iachar(s(i:i)) - iachar("a") + 1
      b = i_to_bin(i)
      cnt(j, b) = cnt(j, b) + 1
    end do
  end subroutine prep

  subroutine type1(i, c)
    integer, intent(in) :: i
    character(1), intent(in) :: c
    integer :: b, j
    b = i_to_bin(i)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) - 1
    s(i:i) = c(1:1)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) + 1
  end subroutine type1

  subroutine type2(l, r)
    integer, intent(in) :: l, r
    integer :: scnt(26), b, tot, a
    scnt(:) = 0
    do b = 1, nbin
      scnt(:) = scnt(:) + query(b, l, r)
    end do
    tot = 0
    do a = 1, 26
      if (scnt(a) > 0) tot = tot + 1
    end do
    print "(i0)", tot
  end subroutine type2

  pure integer function i_to_bin(i)
    integer, intent(in) :: i
    i_to_bin = (i - 1) / binsize + 1
  end function i_to_bin

  pure integer function b_to_i(b)
    integer, intent(in) :: b
    b_to_i = (b - 1) * binsize + 1
  end function b_to_i

  function query(b, l, r)
    integer :: query(26)
    integer, intent(in) :: b, l, r
    integer :: i, j, k, ic
    query(:) = 0
    i = b_to_i(b)
    j = i + binsize - 1
    if (r < i) return
    if (l > j) return
    if (l <= i .and. j <= r) then
      query(:) = cnt(:, b)
    else
      do k = max(i, l), min(j, r)
        ic = iachar(s(k:k)) - iachar("a") + 1
        query(ic) = query(ic) + 1
      end do
    end if
  end function query
end program main


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> rotate(const vector<int>& vec, int i) {
  vector<int> ret = {vec[(0+i)%4], vec[(1+i)%4], vec[(2+i)%4], vec[(3+i)%4]};
  return ret;
}

vector<int> getfirst(const vector<int>& v) {
  vector<vector<int>> ret(4, vector<int>(4));
  rep(p, 4) {
    ret[p] = rotate(v, p);
  }
  sort(ret.begin(), ret.end());
  return ret[0];
}

int getdup(const vector<int>& vec) {
  if (vec[0] == vec[1] && vec[1] == vec[2] && vec[2] == vec[3]) {
    return 4;
  } else if (vec[0] == vec[2] && vec[1] == vec[3]) {
    return 2;
  } else {
    return 1;
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<vector<int>> tiles(n, vector<int>(4));
  vector<vector<int>> dice(4, vector<int>(4));
  map<vector<int>, int> mp, mp2;
  rep(i, n) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    tiles[i] = {a, b, c, d};
    tiles[i] = getfirst(tiles[i]);
    mp[tiles[i]]++;
  }

  ll ans = 0;
  rep(i, n-5) {
    vector<int> ti = tiles[i];
    mp[ti]--;
    for(int j=i+1; j<n; j++) {
      mp[tiles[j]]--;
      rep(k, 4) {
        vector<int> tj = rotate(tiles[j], k);
        dice[0] = {ti[0], tj[1], tj[0], ti[1]};
        dice[1] = {ti[1], tj[0], tj[3], ti[2]};
        dice[2] = {ti[2], tj[3], tj[2], ti[3]};
        dice[3] = {ti[3], tj[2], tj[1], ti[0]};
        rep(l, 4) {
          mp2[getfirst(dice[l])]++;
        }
        ll now = 1;
        for(auto& e: mp2) {
          auto cnt = mp[e.first];
          auto num = e.second;
          auto dup = getdup(e.first);
          for(int p=1; p<=num; p++) {
            now *= cnt*dup;
            cnt--;
          }
        }
        mp2.clear();
        ans += now;
      }
      mp[tiles[j]]++;
    }
  }
  cout << ans << endl;
}

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

unsigned long long calcGcd(long long a, long long b)
{
	if(a % b == 0){
		return b;
	}else{
		return calcGcd(b, a%b);
	}
}

unsigned long long calcLcm(long long a, long long b)
{
	unsigned long long gcd = calcGcd(a,b);
	return a / gcd * b;
}

int main()
{
	int n;
	cin >> n;
	unsigned long long t[n];
	for(int i = 0; i < n; i++)
		cin >> t[i];

	for(int i = 1; i < n; i++){
		t[i] = calcLcm(t[i-1],t[i]);
		//cout << t[i] << "\n";
	}

	cout << t[n-1] << "\n";

	return 0;
}


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

const double EPS = (1e-10);


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

const Int MOD = 1000000007;

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

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

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

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

int solve(int N, int M) {
    vector<pair<int, int>> scores(N);
    vector<pair<int, int>> minScores(N);
    for (int i = 0; i < N; i++) {
        scores[i] = minScores[i] = {0, i};
    }
    for (int i = 0; i < M; i++) {
        int s; cin >> s;
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int tmp; cin >> tmp;
            tmp--;
            scores[tmp].first += s;
            if (k == 1) {
                minScores[tmp].first += s;
            }
        }
    }
    sort(minScores.begin(), minScores.end());
    int ret = -1;
    for (int i = 0; i < N; i++) {
        int minScore;
        if (i != minScores[0].second) minScore = minScores[0].first;
        else minScore = minScores[1].first;
        if (scores[i].first - minScore >= 0) {
            ret = max(ret, scores[i].first - minScore);
        }
    }
    return ret + 1;
}

int main(void) {
    int N, M;
    vector<int> ans;
    while (1) {
        cin >> N >> M;
        if (!N && !M) break;
        ans.push_back(solve(N, M));
    }
    for (int &i : ans) {
        cout << i << endl;
    }
}   



Measured memory_bytes: 3272
n = int(input())
c,x,y,z = 0,0,0,0
for _ in range(n):
    s = input()
    c+=s.count("AB")
    if s[0]=="B" and s[-1]=="A": x+=1
    elif s[-1]=="A": y+=1
    elif s[0]=="B": z+=1
y,z = min(y,z),max(y,z)
if x and y+z: print(c+x+y)
elif x: print(c+x-1)
else: print(c+y)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			System.out.println(in.replaceFirst("2017", "2018"));

		}
	}
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

ll n, wt;
vii arr;
vvi dp;

ll solve (ll w, ll i) {
    if (i == n)
        return 0;
    if (dp[i][w])
        return dp[i][w];
    ll v = 0;
    if (w >= arr[i].first)
        v = solve(w - arr[i].first, i+1) + arr[i].second;
    v = max(v, solve(w, i+1));
    return dp[i][w] = v;
}

int main() {
    fast;
    cin >> n >> wt;
    arr.resize(n);
    dp.resize(n, vi (wt+1, 0));
    REP(i, 0, n)
        cin >> arr[i].first >> arr[i].second;
    cout << solve(wt, 0) << endl;
    return 0;
}


Measured memory_bytes: 79488
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b)swap(a, b);
	vector<int>p;
	for (int i = a; i >=1; i--) {
		if (a%i == 0 && b%i == 0) {
			p.push_back(i);
			if (p.size() == c) {
				cout << i << endl;
				return 0;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 256
SENTINEL = 10 ** 9 +1
cnt = 0
def merge(A, left, mid, right):
    global cnt

    L = A[left:mid] + [SENTINEL]
    R = A[mid:right] + [SENTINEL]
    
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += mid - left - i  # ☆

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

n = input()
A = list(map(int, input().split()))
merge_sort(A,0,len(A))
print(cnt)

Measured memory_bytes: 39500
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;

ll A,B,C,K;

int main(){
    cin>>A>>B>>C>>K;
    if(K<=A)cout<<K<<endl;
    else if(K<=A+B)cout<<A<<endl;
    else cout<<A-(K-A-B)<<endl;   
}

Measured memory_bytes: 3636
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

a = I()
print(a+(a**2)+(a**3))

Measured memory_bytes: 61716
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__)
constexpr int INF = 0x3f3f3f3f;

struct PP {
   int n;
   char c;
   PP() {}
   bool operator > (const PP& rhs) const { return (n > rhs.n); }
   bool operator < (const PP& rhs) const { return (n < rhs.n); }
   bool operator >=(const PP& rhs) const { return (n >= rhs.n);}
   bool operator <=(const PP& rhs) const { return (n <= rhs.n);}
   bool operator ==(const PP& rhs) const { return (n == rhs.n && c == rhs.c); }
   bool operator !=(const PP& rhs) const { return (n != rhs.n || c != rhs.c); }
   inline PP& operator = (int rhs){ n = rhs; return (*this); }
};

template <class T>
void swap(T& a, T& b){ T tmp = a; a = b, b = tmp; }

void merge(PP*, PP*, PP*);
void merge_sort(PP*, PP*);
PP* partition(PP*, PP*);
void quick_sort(PP*, PP*);
bool same(const PP*, const PP*, const int );

int main()
{
   static PP a[100005], b[100005];
   int N;
   scanf("%d", &N);
   rep(i, N)scanf(" %c %d", &a[i].c, &a[i].n );
   memcpy( b, a, sizeof(PP) * N );

   quick_sort(a, a+N);
   merge_sort(b, b+N);

   puts( same(a, b, N)? "Stable" : "Not stable" );
   rep(i, N) printf( "%c %d\n", a[i].c, a[i].n );

}
//=============================================================
void quick_sort(PP* begin, PP* end) {
   if( begin < end ) {
      PP* p = partition(begin, end);
      quick_sort(begin, p);
      quick_sort(p+1, end);
   }
}

PP* partition(PP* left, PP* right) {
   const PP x = *(--right);
   PP* lt = left - 1;

   for(PP* i = left; i != right; ++i) {
      if( *i <= x ) ++lt, swap( *lt, *i );
   }
   ++lt, swap( *lt, *right );

   return (lt);
}
//-------------------------------------------------------------
bool same(const PP* a, const PP* b, const int size){
   rep(i, size)
      if(a[i] != b[i])return (false);
   return (true);
}

void merge_sort(PP* begin, PP* end) {
   if( begin + 1 < end ) {
      PP* mid = begin + (end - begin) / 2;
      merge_sort(begin, mid);
      merge_sort(mid, end);
      merge(begin, mid, end);
   }
}

void merge(PP* left, PP* mid, PP* right) {
   const int hl = mid - left;
   const int hr = right - mid;
   PP L[hl+1], R[hr+1];

   L[hl] = R[hr] = INF;

   memcpy( L, left, sizeof(PP) * hl );
   memcpy( R, mid, sizeof(PP) * hr );

   int i(0), j(0);
   for(PP* k = left; k != right; ++k){
      (*k) = ( L[i] <= R[j] ) ? L[i++] : R[j++];
   }
   return ;
}




Measured memory_bytes: 4892
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	bool b[114514];
	int a[114514];
	for (int i = 1; i <= n; i++) {
		b[i] = (i == 1);
		a[i] = 1;
	}
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		if (b[x])b[y] = true;
		a[x]--; a[y]++;
		if (!a[x])b[x] = false;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) 
		ans += b[i];
	cout << ans << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ms(v, x) memset((v), (x), sizeof(v))
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define iopt ios::sync_with_stdio(false); cin.tie(0)

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int power(int x, int p, int MOD) {
    if(p == 0) return 1%MOD;
    if(p == 1) return x%MOD;
    int res = power(x, p/2, MOD);
    res = (long long)res*res%MOD;
    if(p&1) res = (long long)res*x%MOD;
    return res;
}

typedef pair<int, int> ii;
typedef long double LD;
typedef vector<int> vi;

const int oo = (int)1e18;

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

  if(K%2 == 0) cout << a-b << endl;
  else cout << b-a << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
inline long long e(long long n){ long long r = n; for (long long i = 2; i*i <= n; ++i)
	if (n%i == 0) {
		r -= r / i;
		while (n%i == 0)n /= i;
	}
	if (n > 1) r -= r / n; return r;
}
int main() {
	long long n; cin >> n;
	cout << e(n) << endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		
		int a[] = new int[100];
		
		for (int i = 0; i < N; i++) {
			int val = in.nextInt();
			a[i] = val;
		}
		
		for (int i = 1; i < N; i++) {
			output(a, N);
			int val = a[i];
			int j = i-1;
			while(j >= 0 && val < a[j]) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = val;
		}
		output(a, N);
	}
	
	static void output(int[] a, int N) {
		for (int i = 0; i < N-1; i++) {
			System.out.print(a[i]+ " ");
		}
		System.out.println(a[N-1]);
	}
}



Measured memory_bytes: 31556
#include<bits/stdc++.h>
using namespace std;
int main() {
int i,j,l,t,a,b,k,p=0,x,n=0;
 cin>>x>>a>>b;
  if(b<=a){cout<<"delicious\n";}
  else if(b>a){
    if(b-a<=x){cout<<"safe\n";}
    else{cout<<"dangerous\n";}
  }





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

vector<P> v;
int main()
{
	int n, w, d;
	while (cin >> n >> w >> d, w)
	{
		v.clear();
		v.push_back(P(w, d));
		REP(i, n)
		{
			int p, s;
			cin >> p >> s;
			p--;
			int x = v[p].first, y = v[p].second;
			s %= 2 * (x + y);
			if (s < x)
			{ 
				P a(s, y), b(x - s, y);
				if (a>b) swap(a, b);
				v.erase(v.begin() + p);
				v.push_back(a);
				v.push_back(b);
			}
			else if (s < x + y)
			{
				s = s - x;
				P a(x, s), b(x, y - s);
				if (a>b) swap(a, b);
				v.erase(v.begin() + p);
				v.push_back(a);
				v.push_back(b);
			}
			else if (s < 2 * x + y)
			{
				s = s - x - y;
				P a(s, y), b(x - s, y);
				if (a>b) swap(a, b);
				v.erase(v.begin() + p);
				v.push_back(a);
				v.push_back(b);
			}
			else
			{
				s = s - 2 * x - y;
				P a(x, s), b(x, y - s);
				if (a > b) swap(a, b);
				v.erase(v.begin() + p);
				v.push_back(a);
				v.push_back(b);
			}
		}
		vi ans;
		REP(i, v.size())
		{
			ans.push_back(v[i].first*v[i].second);
		}
		sort(ALL(ans));
		REP(i, ans.size()) cout << ans[i] << (i == ans.size()-1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char n[105],m[105];
    // ll n,m;
    scanf("%s%s",n,m);
    ll nl=strlen(n),ml=strlen(m);
    if(nl>ml){
        printf("GREATER\n");
    }else if(nl<ml){
        printf("LESS\n");
    }else{
        rep(i,0,nl){
            if((ll)(n[i]-m[i])>0){
                printf("GREATER\n");
                return 0;
            }
            if((ll) (n[i]-m[i])<0){
                printf("LESS\n");
                return 0;
            }
        }
        printf("EQUAL\n");
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	h, count, max := 0, 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if h >= max {
			max = h
			count++
		}
	}

	fmt.Println(count)
}

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

int main(){
    int n;cin>>n;
    vector<int> x(100000,0);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        if(a-1>=0) x[a-1]++;
        x[a]++;
        if(a+1<100000) x[a+1]++;
    }
    
    int m=0;
    for(int i=0;i<100000;i++){
        m=max(m,x[i]);
    }

    cout<<m<<endl;
}

Measured memory_bytes: 640
class UnionFind():
  def __init__(self,n):
    self.parents = list(range(n))
    self.size = [1]*n
  
  def find(self,x):
    if self.parents[x] == x:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.size[x]<self.size[y]:
      x,y=y,x
	
    self.size[x]+=self.size[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def sizeofset(self,x):
    return self.size[self.find(x)]


N,M=map(int,input().split())
uf = UnionFind(N+1)

cnt=(N)*(N-1)//2
L=[[int(x) for x in input().split()] for _ in range(M)]
ans=[]

for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.sizeofset(a)*uf.sizeofset(b)
    uf.union(a,b)

for x in ans[::-1]:
  print(x)

Measured memory_bytes: 31788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	cout << max(C - (A - B), 0) << endl;

}



Measured memory_bytes: 256
code,machine = map(int,input().split())
ans = 0
if code == 1 and machine == 1:
    ans += 400000
if code == 1:
    ans += 300000
elif code ==2:
    ans += 200000
elif code == 3:
    ans += 100000

if machine == 1:
    ans += 300000
elif machine ==2:
    ans += 200000
elif machine == 3:
    ans += 100000

print(ans)

Measured memory_bytes: 3064
n = int(input())

al = []
bl = []
for i in range(n):
    a,b = [int(i) for i in input().split()]
    al.append(a)
    bl.append(b)
    
al = sorted(al)
bl = sorted(bl)

median_a = al[n//2]if n % 2 else (al[n // 2] + al[n//2 - 1]) / 2 
median_b = bl[n//2]if n % 2 else (bl[n // 2] + bl[n//2 - 1]) / 2 

if n % 2:
    print(int((median_b - median_a + 1)))
else:
    print(int((median_b - median_a) * 2 + 1))

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

int main() {
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    long long n;
    cin >> n;
    int remainder=0;
    string out="";
    while(n>0){
        n-=1;
        remainder=n%26;
        out = alphabet[remainder]+out;
        n = n/26;
    }
    cout << out;
    return 0;
}

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

#define F first
#define S second
#define pb push_back 
#define mp make_pair

#define ll long long 
#define ld long double 

#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>

#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >

#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >

#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >
//vector<vector<int>> v(n, vector<int>(n));

#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()

#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

const int MOD = 1e9 + 7 ;

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}
 
ll gcd (ll a, ll b) {
    if (b == 0) return a ;
	else return gcd (b , a % b) ;
}
 
ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}
 
ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

void solve (int test_case) {
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]=='s') cout<<s+"es";
	else cout<<s+'s';
}
int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int tc = 1 ;
	//cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

int main() {
    int n, a[100000], ans[100000], i;

    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        ans[a[i]] = i;
    }

    for (i = 1; i <= n; i++) {
        printf("%d ", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
#define N 101
#define M 51
using namespace std;
int n,m,l;
double p[N],t[N],d[N],mem[M][M];

double nCr(int n, int r){
  if(mem[n][r]!=0)return mem[n][r];
  double a=1;
  for(int i=0;i<r;i++) a*=(n-i)/(i+1.0);
  return mem[n][r]=a;
}

double DP(){
  double dp[N][M]={};
  for(int i=0;i<=m;i++)dp[0][i]=pow(1-p[0],m-i)*pow(p[0],i)*nCr(m,i);
  
  for(int i=1;i<n;i++)
    for(int j=0;j<=m;j++)
      for(int k=0;k<=m;k++)
	if(d[0]+j*t[0]<d[i]+k*t[i]) 
	  dp[i][j]+=dp[i-1][j]*pow(1-p[i],m-k)*pow(p[i],k)*nCr(m,k);

  double res=0;
  for(int i=0;i<=m;i++)res+=dp[n-1][i];
  return res;
}

int main(){
  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    cin>>p[i]>>t[i]>>d[i];
    p[i]/=100;
    d[i]=l/d[i];
  }
  
  for(int i=0;i<n;i++){
      printf("%.10f\n",DP());
      swap(p[0],p[i+1]);
      swap(t[0],t[i+1]);
      swap(d[0],d[i+1]);    
  }
  return 0;
}

Measured memory_bytes: 3632
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000000007;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//
int a[300000];
int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	int n; ni(n);
	F(i, 3 * n)ni(a[i]);
	sort(a, a + 3 * n);

	ll ans = 0;
	F(i, n) {
		ans += a[3 * n - 2 - 2*i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1408
text = input()

textlist = list(text)

l = len(textlist)

countK = 0
countU = 0
countP = 0
countC = 0
for i in range(l):
    if textlist[i]=='K':
        countK += 1
    if textlist[i]=='U':
        countU += 1
    if textlist[i]=='P':
        countP += 1
    if textlist[i]=='C':
        countC += 1

COUNT = []
COUNT.append(countK)
COUNT.append(countU)
COUNT.append(countP)
COUNT.append(countC)
KUPC = min(COUNT)
print(KUPC)


Measured memory_bytes: 5564
#include<bits/stdc++.h>
#define N 1000005
#define LL long long
using namespace std;
char a[N],b[N];
int n,m,q,sa[N],sb[N];
int main()
{
	int i,l,r,u,v;
	scanf("%s",a+1);
	n = strlen(a+1);
	scanf("%s",b+1);
	m = strlen(b+1);
	for(i=1;i<=n;i++)
		sa[i]=sa[i-1]+a[i]-'A'+1;
	for(i=1;i<=m;i++)
		sb[i]=sb[i-1]+b[i]-'A'+1;
	scanf("%d",&q);
	while(q--){
		scanf("%d %d %d %d",&l,&r,&u,&v);
		if((sa[r]-sa[l-1])%3==(sb[v]-sb[u-1])%3)
			printf("YES\n");
		else printf("NO\n");
	  }
	return 0;
}


Measured memory_bytes: 7168
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

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

using namespace std;

int main()
{
	int a[100][100];
	int b[100];
	int ans[100];
	int n, m;

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)
	{
		scanf("%d", &a[i][j]);
	}

	for (int i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}

	for (int i = 0; i < n; i++)
	{
		ans[i] = 0;
		for (int j = 0; j < m; j++)
		{
			ans[i] += a[i][j] * b[j];
		}
		printf("%d\n", ans[i]);
	}

	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n, a, b; cin >> n >> a >> b;

    cout << min(a*n, b) << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
        int ans = Math.max(a+b, Math.max(a-b, a*b));
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1 or m+f < 30:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50 or (30 <= m+f <50 and r >= 50):
        print("C")
    else :
        print("D")



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

const long long mod = 998244353;
const long long check_m = 1e9 + 7;
const int MAX_N = 5 * 1e5 + 100;
const int MAX_n = 3 * 1e5;

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> l(k), r(k);
    for (int i = 0; i < k; ++i) {
        cin >> l[i] >> r[i];
        r[i]++;
    }
    vector<long long> num(MAX_N, 0), chnum(MAX_N, 0);
    num[1] = 1;
    num[2] = -1;
    chnum[1] = 1;
    chnum[2] = -1;
    vector<long long> ans(MAX_n, 0), check(MAX_n, 0);
    ans[1] = num[1];
    check[1] = num[1];
    vector<long long> mod_times(MAX_N, 0);
    for (int i = 1; i < MAX_n; ++i) {
        if (i != 1) {
            ans[i] = ans[i-1] + num[i];
            ans[i] %= mod;
            while (ans[i] < 0) ans[i] += mod;

            check[i] = check[i-1] + chnum[i];
            check[i] %= check_m;
            while (check[i] < 0) check[i] += check_m;
        }

        if (ans[i] == 0 && check[i] == 0) {
            continue;
        }
        for (int j = 0; j < k; ++j) {
            num[i + l[j]] += ans[i];
            num[i + r[j]] -= ans[i];
            chnum[i + l[j]] += check[i];
            chnum[i + r[j]] -= check[i];
        }
    }
    cout << ans[n] << endl;
}

Measured memory_bytes: 19608
n,a=int(input()),sorted(list(map(int,input().split())))
mn,mx=a[0],a[-1]
for i in a[1:-1]:
  if i<0:mx-=i
  else:mn-=i
print(mx-mn)
mn,mx=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(mx,i);mx-=i
  else:print(mn,i);mn-=i
print(mx,mn)


Measured memory_bytes: 14072