akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }


// a = 97, z = 122
int n;
int main() {
    cin >> n;
    vector<vector<string>> ans(10);
    ans.at(0).push_back("a");
    if(n == 1) {
        cout << ans.at(n-1).at(0) << endl;
    }else {
        for(int i = 1; i < n; ++i) {
            // cout << "now " << i << endl;
            int anslen = ans.at(i-1).size();
            for(int j = 0; j < anslen; ++j) {
                // cout << "h " << j << endl;
                string ansc = ans.at(i-1).at(j);
                int ansclen = ansc.length();
                int alp = 0;
                for(int ch = 0; ch < ansclen; ++ch) {
                    int cha = (int)(ansc.at(ch));
                    alp = max(alp, cha);
                }
                int alpmax = alp - 97;
                for(int k = 0; k <= alpmax+1; ++k) {
                    // cout << "k " << k << endl;
                    string anscc = ansc + (char)(97+k);
                    ans.at(i).push_back(anscc);
                }
            }
        }

        int alen = ans.at(n-1).size();
        for(int i = 0; i < alen; ++i) {
            cout << ans.at(n-1).at(i) << endl;
        }
    }
}

Measured memory_bytes: 11380
#include <iostream>

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

    int odd_num = 0;
    for(int i=0; i<n; ++i)
    {
        int tmp;
        std::cin >> tmp;
        if(tmp % 2 == 1)
        {
            odd_num++;
        }
    }

    if(n == 1 || odd_num % 2 == 0)
    {
        std::cout << "YES" << std::endl;
    }
    else
    {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 27/06/2020
 * 14:09:42.49
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n, k;
    cin >> n >> k;
    if(n % k == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
K = int(input())

import collections

run_list = collections.defaultdict(list)
run_list[1] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(2, 11):
    for j in run_list[i-1]:
        if 0 <= int(str(j)[0]) + 1 < 10:
            run_list[i].append(str(int(str(j)[0]) + 1)+str(j))
        if 0 <= int(str(j)[0]) - 1 < 10:
            run_list[i].append(str(int(str(j)[0]) - 1)+str(j))
        if 0 <= int(str(j)[0]) < 10:
            run_list[i].append(str(int(str(j)[0]))+str(j))
# print(sorted(run_list[3]))
all_list = []
for v in run_list.values():
    for vv in v:
        all_list.append(int(vv))
print(sorted(list(set(all_list)))[K])

Measured memory_bytes: 87884
from sys import stdin, gettrace
import sys
sys.setrecursionlimit(1000000)
if not gettrace():
    def input():
        return next(stdin)[:-1]
 
 
# def input():
#    return stdin.buffer.readline()

def recursion(li,i,n,w,dp):
    if i==n or w==0:
        return 0
    if li[i][0]>w:
        if dp[i+1][w]==-1:
            x=recursion(li,i+1,n,w,dp)
            dp[i+1][w]=x            
        else:
            x=dp[i+1][w]
        return x
    else:
        if dp[i+1][w]==-1:
            x=recursion(li,i+1,n,w,dp)
            dp[i+1][w]=x            
        else:
            x=dp[i+1][w]
        if dp[i+1][w-li[i][0]]==-1:
            y=recursion(li,i+1,n,w-li[i][0],dp)
            dp[i+1][w-li[i][0]]=y
        else:
            y=dp[i+1][w-li[i][0]]            
        return max(li[i][1]+y,x)

def main():
    n,w=[int(x) for x in input().split()]
    li=[]
    for i in range(n):
        temp=[int(x) for x in input().split()]
        li.append(temp)
    dp=[[-1 for j in range(w+1)] for i in range(n+1)]
    print(recursion(li,0,n,w,dp))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 221664
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N,T,A,H;
  cin >> N >> T >> A;
  vector<float> temp(N);

  for(int i=0;i<N;i++){
      cin >> H;
      temp[i] = T - H*0.006;
    //   cout << temp[i] << endl;
  }

  int nearNum = 0;
  for(int i=1;i<N;i++){
      if(abs(A-temp[nearNum]) > abs(A - temp[i])){
        nearNum = i;
      }
  }

  
  cout << nearNum+1 << endl;

}


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

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();

        var n = sc.nextInt();
        var k = sc.nextInt();

        for (int i = 1; i <= k; i++)
        {
            //仕切りの入れ方
            long ans = Combination(n - k + 1, i);
            //青の分け方(i分割)
            ans = ans * Combination(k - 1, i - 1) % MOD;
            Console.WriteLine(ans);
        };
    }

    static long Combination(int n, int r)
    {
        if (n == r) return 1;
        else if (n < r) return 0;
        const long MOD = 1000000007;
        long ans = 1;
        for (int i = r + 1; i <= n; i++)
        {
            ans = ans * i % MOD;
        }
        for (int i = 1; i <= n - r; i++)
        {
            ans = ans * Pow(i, MOD - 2, MOD) % MOD;
        }

        return ans;
    }

    static long Pow(long a, long b, long c)
    {
        long n = 1;
        long p = a;
        while (b > 0)
        {
            if (b % 2 == 0)
            {
                p = p * p % c;
                b = b / 2;
            }
            else
            {
                n = n * p % c;
                b = b - 1;
            }
        }

        return n;
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define mset(a,x) memset(a,x,sizeof(a))

int main() {
    int n;
    cin >> n;
    int x = 800 * n;
    int y = 200 * (n / 15);
    cout << x - y << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const int mod = 998244353;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= 100000; i++) {
		int t = (108*i)/100;
		if(t == n)
			return cout << i, 0;
	}
	cout << ":(";
}



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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long ans = long.MaxValue;
        for (int i = -100; i <= 100; i++)
        {
            long tmp = 0;
            for (int k = 0; k < n; k++)
            {
                tmp += (i - a[k]) * (i - a[k]);
            }
            ans = Math.Min(ans , tmp);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
program BegB
  implicit none
  integer :: H, N, k
  integer(8),allocatable,dimension(:) :: A
  read(*,*) H, N
  allocate(A(N))

  read(*,*) (A(k) ,k=1,N)
  if(sum(A).ge.H) then
     print*, 'Yes'
  else
     print*, 'No'
  end if


end program BegB

Measured memory_bytes: 1536
A,B = input().split()
A = int(A)
B = list(B)

if "." in B:
    C = B[:B.index(".")]+B[B.index(".")+1:]
    D = "".join(C)
    B = int(D)
else:
    D = "".join(C)
    B = int(D)


    
ans = (A*B)//100

print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	ll cnt=0LL;
	ll ans=0LL;
	cin >>s;
	rep(bit,1<<s.size()){
		rep(i,s.size()){
			if(bit&1<<i ){
				ans+=cnt;
				cnt=0LL;
			}else{
				cnt=cnt*10LL+(s[i]-'0');
			}

		}
		ans+=cnt;
		cnt=0LL;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#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>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    rep(i, x - k + 1, x + k) cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    int a[13]={0,1,0,3,0,5,0,7,8,0,10,0,12},b[13]={0,0,0,0,4,0,6,0,0,9,0,11},c[13]={0,0,2};
    int x,y;
    scanf("%d%d",&x,&y);
    if(a[x]!=0&&a[y]!=0)printf("Yes\n");
    else if(b[x]!=0&&b[y]!=0)printf("Yes\n");
    else if(c[x]!=0&&c[y]!=0)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
program colon
  implicit none
  real(8), parameter :: deg2rad = 3.14159265358979d0/180.d0
  real(8) :: a, b, h, m, c, p, q
  character(64) :: s
  read(*,*) a, b, h, m
  p = 30.d0*h+0.5d0*m
  q = 6.d0*m
  c = sqrt(a*a+b*b-2.d0*a*b*cos((p-q)*deg2rad))
  write(s,'(f32.16)') c
  write(*,'(a)') trim(adjustl(s))
end program colon

Measured memory_bytes: 3372
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c],E[d]=E[c]+[(e,d)],E[d]+[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

int main()
{
  long long N, K;
  cin >> N >> K;

  if (K >= N)
  {
    cout << 0 << endl;
    return 0;
  }

  vector<long long> H(N);
  long long sum = 0;
  for (int i = 0; i < N; ++i)
  {
    cin >> H[i];
    sum += H[i];
  }
  sort(H.begin(), H.end());

  for (int i = 0; i < K; ++i)
  {
    sum -= H[N - 1 - i];
  }
  cout << sum << endl;
}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int N = 2e5 + 5;

int n;
vector<int> g[N];
int color[N];

void dfs(int v, int cl) {
    color[v] = cl;
    for (int to : g[v]) {
        if (color[to] == -1) {
            dfs(to, cl ^ 1);
        }
    }
}

int perm[N];

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int u, v, i = 1; i < n; i++) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    fill(color + 1, color + n + 1, -1);

    dfs(1, 0);

    vector<int> ps[3];
    for (int i = 1; i <= n; i++) {
        ps[i % 3].push_back(i);
    }

    vector<int> cs[2];

    for (int i = 1; i <= n; i++) {
        cs[color[i]].push_back(i);
    }

    if (cs[0].size() > cs[1].size()) {
        swap(cs[0], cs[1]);
    }

    if (ps[2].size() <= cs[0].size() && ps[1].size() <= cs[1].size()) {
        for (int i = 0; i < (int) ps[2].size(); i++) {
            perm[cs[0][i]] = ps[2][i];
        }
        for (int i = 0; i < (int) ps[1].size(); i++) {
            perm[cs[1][i]] = ps[1][i];
        }
    } else {
        int j = 0;
        for (int i = 0; i < (int) ps[1].size(); i++) {
            perm[cs[1][j++]] = ps[1][i];
        }
        for (int i = 0; i < (int) ps[2].size(); i++) {
            perm[cs[1][j++]] = ps[2][i];
        }
    }

    for (int j = 0, i = 1; i <= n; i++) {
        if (perm[i] == 0) {
            perm[i] = ps[0][j++];
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << perm[i] << " ";
    }

    cout << "\n";

    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      long long x = a[i] * a[j];
      ans += x;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

def fact(n):
    if n <= 1:
        return 1
    return n * fact(n - 1)

n, m, r = map(int, raw_input().split())

if r - n * m < 0:
    print 0
else:
    print fact(r - n * m + n - 1) / fact(r - n * m) / fact(n - 1)


Measured memory_bytes: 22612
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

const int maxn = 1e5 + 100;
int n;
vector<vector<int> > tree;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  tree.clear();
  tree.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    tree[a].pb(b);
    tree[b].pb(a);
  }
  return true;
}

bool ok;

int dfs(int v, int par) {
  int cnt = 0;
  for (auto to : tree[v]) {
    if (to == par) {
      continue;
    }
    cnt += dfs(to, v);
  }
  if (cnt > 1) {
    ok = false;
    return 0;
  } else if (cnt == 1) {
    return 0;
  } else {
    return 1;
  }
}

void solve() {
  ok = true;
  ok &= !dfs(0, -1);
  printf(!ok ? "First\n" : "Second\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 5888
# -*- coding: utf-8 -*-
N = int(input())

x_l_pairs = []
for _ in range(N):
    x, l = map(int, input().split(' '))
    x_l_pairs.append([x-l, x+l])

x_l_pairs.sort(key=lambda x: x[1])

ret = 1
cur = x_l_pairs[0][1]
for left, right in x_l_pairs:
    # print(left, right)
    if cur <= left:
        ret += 1
        cur = right

print(ret)




Measured memory_bytes: 63064
N = int(input())
p = tuple(map(int, input().split()))
a = list(p)
b = list(p)

c = 0
for i in range(N):
    if i+1 == a[i] and i == N-1:
        c += 1
    elif i+1 == a[i]:
        a[i], a[i+1] = a[i+1], a[i]
        c += 1
cc = 0        
for i in range(N)[::-1]:
    if i+1 == b[i] and i == 0:
        cc += 1
    if i+1 == b[i]:
        b[i], b[i-1] = b[i-1], b[i]
        cc += 1
        
print(min(c,cc))

Measured memory_bytes: 14008
using System;
 
namespace _0630
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());
            int E = int.Parse(Console.ReadLine());
            if (A < 0)
            {
                Console.WriteLine((0 - A) * C + D + (B * E));
            }
            else
            {
                Console.WriteLine((B - A) * E);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9112
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
  int n;
  cin>>n;
  int x=ceil(float(n)/1000);
  //cout<<x;
  int ans=x*1000-n;
  cout<<ans;

}


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

int main(){
  int A[1000000];
  int n;
  
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>A[i];
  }
  int q,k,sum=0;
  cin >>q;
  
  for (int i=0;i<q;i++){
    cin>>k;
    if(*lower_bound(A,A+n,k)==k) sum++;
  }
  cout<<sum<<endl;
  return 0;
}

  
 


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, K;
ll A[200010];

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 1;
    if(A[N - 1] < 0 && K % 2 == 1){
        for(int i = N - 1; i >= N - K; i--) ans = (ans * A[i]) % MOD;
        PRINT((ans + MOD) % MOD);
        return 0;
    }
    int l = 0, r = N - 1;
    if(K % 2 == 1){
        ans = (ans * A[r]) % MOD;
        r--; K--;
    }
    for(int i = 0; 2 * i < K; i++){
        if(A[l] * A[l + 1] >= A[r - 1] * A[r]){
            ans = (ans * ((A[l] * A[l + 1]) % MOD)) % MOD;
            l += 2;
        }else{
            ans = (ans * ((A[r - 1] * A[r]) % MOD)) % MOD;
            r -= 2;
        }
    }
    PRINT((ans + MOD) % MOD);
    return 0;
}


Measured memory_bytes: 5196
import sys

sys.setrecursionlimit(100000)

def rec(v):
    global dp, path
    if dp[v] != -1:
        return dp[v]

    res = 0
    for i in path[v]:
        res = max(res, rec(i)+1)

    dp[v] = res
    return res



N, M = map(int, input().strip().split(" "))

dp = [-1] * N
path = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().strip().split(" "))
    path[x-1].append(y-1)


result = 0
for i in range(N):
    result = max(result, rec(i))

print(result)

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

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

    vector<pair<long long int, int>> sushi(n);
    for(int i=0; i<n; i++){
        cin >> sushi[i].second >> sushi[i].first;
    }
    sort(sushi.begin(),sushi.end());
    reverse(sushi.begin(),sushi.end());

    long long int point = 0;
    vector<int> var(n);
    vector<pair<long long int, int>> multi;
    for(int i=0; i<k; i++){
        point += sushi[i].first;
        var[sushi[i].second - 1] += 1;
        multi.push_back(sushi[i]);// since sorted, most delicious ones are safely excluded
    }
    sort(multi.begin(), multi.end());

    long long int v = 0;
    for(int i=0; i<n; i++){
        if(var[i] >= 1) v += 1;
    }
    point += v * v;

    long long int ans = point;
    long long int test = point;
    int rec = 0;
    for(int i=k; i<n; i++){
        if(v == k) break;
        if(var[sushi[i].second - 1] >= 1) continue;

        // else
        //cout << i << " ";
        test += sushi[i].first + (v+1) * (v+1) - v * v;
		var[sushi[i].second - 1] += 1;
        while(1){
            if(rec == multi.size()) break;
            else if(var[multi[rec].second - 1] == 1){
                rec += 1;
            }
            else{
                test -= multi[rec].first;
                var[multi[rec].second - 1] -= 1;
                rec += 1;
                v += 1;
                break;
            }
        }
        ans = max(ans, test);
        //cout << test << " " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
//const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int res = 1;
	for(int i = 1; i < n; i++){
		if(s[i] != s[i-1]) res++;
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H * W - h * W - H * w + h * w << endl;

  return 0;
}


Measured memory_bytes: 256
import math

x=int(input())
ma=1

for i in range(2,int(x**0.5)+1):
    lo=int(math.log(x,i))
    a=i**lo
    b=i**(lo+1)
    if a<=x :
        ma=max(ma,a)
    if b<=x :
        ma=max(ma,b)

print(ma)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
    int k;
    cin >> k;
    if(k%2 == 0)
        cout << (k/2)*(k/2) << endl;
    else
        cout << (k/2) * (k /2 + 1) << endl;
  
}


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

using namespace std;

#define int long long
int const maxn = 1e5 + 5;
int a[maxn], inf = 1e18;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, cnt = 1, ans = 0, sum = 0;
    cin >> n;
    for (int i = 0; i <= n; ++i) cin >> a[i];
    for (int i = 0; i <= n; ++i) sum += a[i];
    for (int i = 0; i <= n; ++i) {
        if (a[i] > cnt) {
            cout << -1 << '\n';
            exit(0);
        }
        cnt -= a[i];
        sum -= a[i];
        ans += min(2 * cnt, sum);
        cnt *= 2;
        cnt = min(cnt, inf);
    }
    cout << ans + 1 << '\n';
    return 0;
}



Measured memory_bytes: 4392
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a==1) a=14;
  if (b==1) b=14;

  if (a>b) {
    printf("Alice\n");
  } else if (a<b) {
    printf("Bob\n");
  } else {
    printf("Draw\n");
  }
  return 0;
}

Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          ABC092-B
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,x,n) for(int i=x;i<(n);i++)
typedef pair<int,int> ii;
#define vii vector<ii>
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if(!e) return true;
    if(e&1)return qpow(b,e-1)*b;
    int pwur=qpow(b,e>>1);
    return pwur*pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// Criba de Eratostenes ------------------------------------
const int pr=10000;
map<int,int>isp;
void criba(){
    for(int i=0;i<=pr;i++)isp[i]=i;
    isp[0]=isp[1]=-1;
    for(int i=2;i*i<=pr;i++){
        if(isp[i]==i){
        for(int j=2*i;j<=pr;j+=i)
            isp[j]=i;
        }
    }
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    ///criba();
    int n,d,x;
    cin>>n>>d>>x;
    vi v(n);
    rep(i,n){
        cin>>v[i];
    }
    int s=x;
    rep(k,n){
        int cur=1,i=1;
        while(i*v[k]+1<=d)cur++,i++;
        s+=cur;
    }
    cout<<s<<enl;

    return 0;
}


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

class Med{
	int a, b, c;

	public Med(int a, int b, int c) {
		super();
		this.a = a;
		this.b = b;
		this.c = c;
	}
	
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	
	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), ma = fs.nextInt(), mb = fs.nextInt();
		Med ms[] = new Med[n];
		for(int i=0;i<n;i++) {
			int a = fs.nextInt(), b = fs.nextInt(), c = fs.nextInt();
			ms[i] = new Med(a,b,c);
		}
		//半分全列挙で解けそう。
		//0~N/2個の薬の組み合わせ
		
		int inf = Integer.MAX_VALUE/2;
		int ans = inf;
		
		int m = n/2;
		Map<Integer,Integer> mp = new HashMap<>();
		for(int i=1;i<(1<<m);i++) {
			int ta = 0, tb = 0, tc = 0;
			for(int j=0;j<m;j++) {
				if((i>>j&1)==1) {
					ta += ms[j].a;
					tb += ms[j].b;
					tc += ms[j].c;
				}
			}
			int t = ta*mb-tb*ma;
			if(t == 0) ans = Math.min(ans, tc);
			if(mp.get(t)==null)mp.put(t, tc);
			else {
				if(mp.get(t)>tc)mp.put(t, tc);
			}
		}
		
		int k = m;
		m = n-m;

		for(int i=1;i<(1<<m);i++) {
			int ta = 0, tb = 0, tc = 0;
			for(int j=0;j<m;j++) {
				if((i>>j&1)==1) {
					ta += ms[k+j].a;
					tb += ms[k+j].b;
					tc += ms[k+j].c;
				}
			}
			int t = -(ta*mb-tb*ma);
			if(t == 0) ans = Math.min(ans, tc);
			if(mp.get(t)==null)continue;
			else {
				int res = mp.get(t) + tc;
				ans = Math.min(ans, res);
			}
		}
		
		for(Med t :ms) {
			if(t.a * mb - t.b * ma == 0) {
				ans = Math.min(ans, t.c);
			}
		}
		
		if(ans == inf)System.out.println(-1);
		else System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

int main()
{
    int x[5];
    int pos;
    for (int i = 0;i < 5;i++)
    {
        cin >> x[i];
        if (x[i] == 0) pos = i + 1;
    }
    cout << pos << endl;
    return 0;
}

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

int N;
int X[8], Y[8];

double dist(int i, int j)
{
	return ( sqrt(pow(X[i] - X[j], 2) + pow(Y[i] - Y[j], 2)) );
}

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

	vector < int > v(N);
	for ( int i = 0; i < N; i++ ) v[i] = i;
	
	double sum = 0.0;
	do {
		for ( int i = 0; i < N - 1; i++ ) sum += dist(v[i], v[i + 1]);
	} while ( next_permutation(begin(v), end(v)) );
	
	int fact = 1;
	for ( int i = 1; i <= N; i++ ) fact *= i;

	printf("%.10f\n", sum / fact);

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;
typedef vector<vector<lint>> mat;

int w, h, sx, sy;
char maze[30][30];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x, int y){
    maze[x][y] = '$';
    rep(i, 4){
        int nx = x + dx[i]; int ny = y + dy[i];
        if(0<=nx && nx<h && 0<=ny && ny<w && maze[nx][ny]=='.') dfs(nx, ny);
    }
}

int main(){
    while(true){
        cin >> w >> h;
        if(w == 0) return 0;
        rep(i, h)rep(j, w){
            cin >> maze[i][j];
            if(maze[i][j] == '@') sx = i, sy = j;
        }
        dfs(sx, sy);
        int cnt = 0;
        rep(i, h)rep(j, w)if(maze[i][j] == '$') cnt++;
        cout << cnt << endl;
    }
}


Measured memory_bytes: 2980
from sys import stdin

a=stdin.readline().split()
A,V=int(a[0]),int(a[1])
b=stdin.readline().split()
B,W=int(b[0]),int(b[1])
T=int(stdin.readline())

if A==B:
    print('YES')
elif A>B:
    if (V-W)<0:
        print('NO')
    else:
        if abs((V-W))*T>=(A-B):
           print('YES')
        else:
           print('NO')
else:
    if V-W>=0:
        if (V-W)*T>=(B-A):
           print('YES')
        else:
           print('NO')
    else:
        print('NO')

Measured memory_bytes: 9220
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;

#define MOD 1000000007
#define A first
#define B second

typedef long long ll;

inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}

inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}

inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}

inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}

inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}

inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}

const int N = 2e5 + 5;

int arr[N];

void solve(){
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  sort(arr, arr + n);
  ll s = 0;
  for(int i = 0; i < max(0, n - k); i++){
    s += arr[i];
  }
  cout << s;
  

}


int main(){
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  //cin >> t;
  t = 1;
  while(t--){
    solve();
  }
  return 0;
}



Measured memory_bytes: 1024
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    if N%2==0: 
        print(-1)
        return #10の倍数も含まれる
    cnt=7%N
    if cnt==0:
        print(1)
        return
    for i in range(2,10**7):
        cnt=cnt*10+7
        cnt%=N
        if cnt==0:
            print(i)
            return
    print(-1)
#%%submit!
resolve()

Measured memory_bytes: 62980
import math

N , M = map(int,input().split())

if M == 0:
    a = [-1 , N+1]
else :
    a = [-1] * (M+2)

    for i in range(1,M+1) :
        a[i] = int(input())


flag = True # 可能かどうか
for i in range(0,M+1) :
    if a[i] + 1 == a[i+1] :
        flag = False
        break

fib = [1] * (N+1) # フィボナッチ数列
for i in range(2,N+1) :
    fib[i] = fib[i-1] + fib[i-2]

if flag :
    a[M+1] = N + 1

    ans = 1

    for i in range(M+1) :
        length = a[i+1] - a[i] - 2 # 上がる長さ
        ans *= fib[length]

    print(ans % 1000000007)
else :
    print(0)

Measured memory_bytes: 463988
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int ans1=0,ans2=0,ans;
    for(int i=0;i<s.size();i++){
        if((i%2==0&&s[i]=='0')or(i%2==1&&s[i]=='1'))ans1++;
    }
    ans2=s.size()-ans1;
    ans=min(ans1,ans2);
//    cout<<ans1<<" "<<ans2<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const _n = stdin.split('\n')[0]
const n = Number(_n)

const v = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)
const c = stdin
  .split('\n')[2]
  .split(' ')
  .map(Number)

let x = 0
let y = 0
const diff = v.map((e, i) => {
  if (e - c[i] > 0) {
    x += e
    y += c[i]
  }
  return e - c[i]
})

const res = x - y

console.log(res)


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

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

	int n;
	cin>>n;
	int l[101];
	forn(i,0,n)
		cin>>l[i];
	int cnt=0;
	forn(i,0,n){
		forn(j,i+1,n){
			forn(k,j+1,n){
				if (l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k]){
					if (l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i]){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int Minimum(int [], int, int);

int DP[101][101];

int main()
{
  int i,j,n,a;

  scanf("%d",&n);

  int p[n+1];

  for(i=1; i<=n; i++) DP[i][i] = 0;

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

  for(i=1; i<n; i++){
    DP[i][i+1] = p[i-1]*p[i]*p[i+1];
  }

  for(i=0; i<=n-3; i++){
    for(j=3+i; j<=n; j++){
      DP[j-2-i][j] = Minimum(p,j-2-i,j);
    }
  }

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

  return 0;
}

int Minimum(int p[], int r, int c){
  int min = 100000000;
  int a = c - r;

  for(int i = 0; i<a; i++){
    if(min >= DP[r][r+i]+DP[r+i+1][c] + p[r-1]*p[r+i]*p[c])
      min = DP[r][r+i]+DP[r+i+1][c] + p[r-1]*p[r+i]*p[c];
  }
  return min;
}
  

  



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> pii;

struct record{
  string name,type;
  char com;
  int price;
  record(string a="", string b="", char c=' ', int d=0):name(a),type(b),com(c),price(d){}
};

int main(){
  int n;
  while(cin >> n, n){
    vector<record> r(n);
    vector<int> use(n,0);
    map<string,pii> dealers;
    vector< vector<int> > deals(26);

    for(int i=0;i<n;i++){
      string name,type;
      char com;
      int price;
      cin >> name >> type >> com >> price;
      r[i] = record(name,type,com,price);
      if(dealers.count(name) == 0)dealers[name] = pii(0,0);

      int id = -1;
      for(int j=0;j<i;j++){
	if(!use[j] && type!=r[j].type && com==r[j].com && name!=r[j].name){
	  if(type == "BUY" && price>=r[j].price){
	    if(id<0 || r[id].price > r[j].price)id = j;
	  }
	  if(type == "SELL" && price<=r[j].price){
	    if(id<0 || r[id].price < r[j].price)id = j;
	  }
	}
      }

      if(id>=0){
	use[i] = use[id] = 1;
	int money = (price + r[id].price)/2;
	if(type == "BUY"){
	  dealers[name].first += money;
	  dealers[r[id].name].second += money;
	  deals[com-'A'].push_back(money);
	}
	if(type == "SELL"){
	  dealers[name].second += money;
	  dealers[r[id].name].first += money;
	  deals[com-'A'].push_back(money);
	}
      }
    }

    for(int i=0;i<26;i++){
      if(deals[i].size()){
	cout << (char)('A'+i) << " " << *min_element(all(deals[i])) << " "
	     << accumulate(all(deals[i]),0)/deals[i].size() << " "
	     << *max_element(all(deals[i])) << endl;
      }
    }
    cout << "--" << endl;

    for(auto p : dealers){
      cout << p.first << " " << p.second.first << " " << p.second.second << endl;
    }
    cout << "----------" << endl;
  }
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define cyes cout << "YES" << endl
#define cno cout << "NO" << endl
#define f(i, a, n) for(int i = a; i < n; i++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mod 1000000007
int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); }  
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
using namespace std;

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  int t; cin >> t;
  string s[t];
  
  for(int i=0;i<t;i++){
    cin >> s[i];
  }

  int ac=0;int tle=0;int wa=0;int re=0;

  for(int i=0;i<t;i++){
    if(s[i]=="AC")
      ac++;
    if(s[i]=="WA")
      wa++;
    if(s[i]=="TLE")
      tle++;
    if(s[i]=="RE")
      re++;
  }
  cout <<"AC x " <<ac <<endl;
  cout <<"WA x " <<wa <<endl;
  cout <<"TLE x " <<tle <<endl;
  cout <<"RE x " <<re <<endl;

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
const ll inf = pow(2, 31) - 1;
int main()
{
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vll p(a), q(b), r(c);
	rep(i,a)cin >> p[i];
	rep(i,b)cin >> q[i];
	rep(i,c)cin >> r[i];
	sort(rall(p));
	sort(rall(q));
	ll s = x + y + c;
	vll ap(s);
	rep(i,x)ap[i] = p[i];
	rep(i,y)ap[i + x] = q[i];
	rep(i,c)ap[i + x + y] = r[i];
	sort(rall(ap));
	ll ans = 0;
	rep(i,x+y)ans += ap[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	string S;
	cin>>S;
	if(S.size()==3)
		reverse(S.begin(),S.end());
	cout<<S<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    string s;
    cin >> s;

    cout << s[0] << s.size() - 2 << *(s.end()-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
template <typename T> bool chmin(T &x, const T &y) {if (x < y) {x = y; return true;} return false;}
template <typename T> bool chmax(T &x, const T &y) {if (x > y) {x = y; return true;} return false;}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    
    vector<ll> B(N, 0), C(N, 0);
    B[0] = abs(A[0]);
    for (int i = 1; i < N; ++i) B[i] = B[i - 1] + abs(A[i] - A[i - 1]);
    reverse(ALL(A));
    C[0] = abs(A[0]);
    for (int i = 1; i < N; ++i) C[i] = C[i - 1] + abs(A[i] - A[i - 1]);
    reverse(ALL(A));
    reverse(ALL(C));
    rep(i, N) {
        if (i == 0) cout << C[i + 1] + abs(A[i + 1]) << "\n";
        else if (i == N - 1) cout << B[i - 1] + abs(A[i - 1]) << "\n";
        else cout << B[i - 1] + abs(A[i + 1] - A[i - 1]) + C[i + 1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 5576
import sys
import math

N, Q = map(int, input().split())
S = input()
a = [0 for _ in range(N)]

for i in range(1, N):
    if S[i-1]+S[i] == "AC":
        a[i] += 1 + a[i-1]
    else:
        a[i] += a[i-1]

for _ in range(Q):
    l, r = map(int, sys.stdin.readline().strip().split())
    print(a[r-1] - a[l-1])


Measured memory_bytes: 7872
#include <iostream>
using namespace std;
#define long long long
int main() {
	long n, l; cin >> n >> l; long t = 0;
	long a[n]; for(long i = 0; i < n; i++) a[i] = l + i, t += a[i];
	long best = 0;
	for(long i = 0; i < n; i++){
		if (abs(a[i]) < abs(a[best])) best = i;
	}
	cout << t - a[best];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

int main()
{
#ifndef ONLINE_JUDGE
    // freopen("1.in", "r", stdin);
    // freopen("1.out", "w", stdout);
#endif
    string s;
    while (cin >> s)
        cout << s.substr(0, s.length() - 8) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#define INF 123456789
#define MOD 1000000007

long long int data[1234567];
long long int N, K;
long long int list_num = 0;
long long int need_num = 0;

long long int list[1234567];
long long int need[1234567];

bool check_prime(long long int num);

bool check_prime(long long int num)
{
	bool k = false;
	if (num % 2 != 0)
	{
		for (long long int j = 3; j < sqrt(num); j++)
		{
			if (num % j == 0)
			{
				k = true;
				break;
			}
		}
	}
	return k;
}

int main(){


	scanf("%lld%lld", &N, &K);
	for (long long int i = 0; i < N; i++)
	{
		scanf("%ld", &data[i]);
		if (data[i] == K)
		{
			printf("POSSIBLE\n");
			return 0;
		}
		if (data[i] > K)
		{
			need[need_num] = data[i] - K;
			need_num++;
		}
	}

	std::sort(data, data + N);

	for (long long int a = 0; a < N - 1; a++)
	{
		list[a] = (data[a] - data[a + 1]);
	}
	list_num = N - 1;

	std::sort(list, list + list_num);
	std::sort(need, need + need_num);

	long long int old_list = -1;
	long long int old_need = -1;

	for (long long int a = 0; a < list_num; a++)
	{
		if (list[a] == old_list) continue;
		old_list = list[a];

		old_need = -1;
		if (list[a] == 0) continue;
		for (long long int b = 0; b < need_num; b++)
		{
			if (need[b] == old_need) continue;
			old_need = need[b];


			if (need[b] % list[a] == 0)
			{
				puts("POSSIBLE");
				return 0;
			}
		}
	}


	puts("IMPOSSIBLE");

	return 0;
}

Measured memory_bytes: 6528