akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	ll K;
	cin >> S >> K;
	int upb = 0;
	char res;
	while (S[upb] == '1') upb++;
	if (K - 1 <= upb) res = S[K - 1];
	else res = S[upb];
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int N, M, D, a[15], r[109][15];
int main() {
	cin >> N >> M >> D;
	for (int i = 0; i < M; i++) cin >> a[i];
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < M; j++) cin >> r[i][j];
	}
	for (int i = 0; i < D; i++) {
		long long p = 0, q = 1;
		for (int j = 0; j < M; j++) {
			if (r[i][j] == -1) continue;
			int lim = 1000;
			for (long long k = p; lim >= 0; k += q) {
				if (k % a[j] == r[i][j]) {
					p = k; q = q / gcd(q, a[j]) * a[j];
					break;
				}
				lim--;
			}
			if (lim < 0) N = -1;
		}
		if (N < p) {
			N = -1; break;
		}
		N = (N - p) / q * q + p;
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

template <typename T> void read(T &x) {
  x = 0;
  char c = getchar();
  T sig = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      sig = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  x *= sig;
}

class Solution {
public:
  void solve() {
    int k;
    read(k);
    int idx = 1;
    ll num = 7;
    while (num % k != 0) {
      num = (num * 10 + 7) % k;
      idx++;
      if (idx > 1000000) {
        printf("-1");
        return;
      }
    }
    printf("%d", idx);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution solution = Solution();
  solution.solve();
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> dist(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int nv : g[v]) {
      if (dist[nv] != -1) continue;
      dist[nv] = v;
      que.push(nv);
    }
  }
  for (int i = 1; i < n; i++) {
    if (dist[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << dist[i] + 1 << endl;
  }

  // rep(i, n) {
  //   rep(j, g[i].size()) cout << g[i][j] << ", ";
  //   cout << endl;
  // }
  return 0;
}

Measured memory_bytes: 10128
#include<stdio.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a > b)
	    printf("a > b\n", a, b);
	if (b > a)
		printf("a < b\n", a, b);
	if (a == b)
		printf("a == b\n", a, b);


	return 0;
}

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

const int nMax = 1e6;
const int mod = 1e9 + 7;

class Sieve
{
private:
	int n;
	vector<int> f, primes;

public:
	Sieve(int v = 1) : n(v), f(n + 1)
	{
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; i++) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = f[i];
			}
		}
	}

	vector<int> factorList(int x)
	{
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<pair<int, int>> factor(int x)
	{
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}

	/*vector<pair<int, int>> factor(int x)
	{
		vector<pair<int, int>> res;
		for (const auto& p : primes) {
			int y = 0;
			while (x%p == 0) {
				x /= p;
				y++;
			}
			if (y != 0) res.emplace_back(p, y);
		}
		if (x != 1) res.emplace_back(x, 1);
		return res;
	}*/
};

ll modPow(ll a, ll x, ll mod)
{
	ll res = 1;
	while (0 < x) {
		if (x & 1) res = res * a%mod;
		a = a * a%mod;
		x >>= 1;
	}
	return res;
}

int main()
{

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

	Sieve sieve(nMax);
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> f = sieve.factor(a[i]);
		for (const auto& item : f) mp[item.first] = max(mp[item.first], item.second);
	}

	ll lcm = 1;
	for (const auto& item : mp) {
		for (int i = 0; i < item.second; i++) {
			lcm *= item.first % mod;
			lcm %= mod;
		}
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll b = lcm * modPow(a[i], mod - 2, mod) % mod;
		ans = (ans + b) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4988
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// シミュレーション
		// 累積和の数え上げ
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
		String S = sc.next();

		// query
		int[][] lr = new int[Q][2];
		for (int i = 0; i < Q; i++) {
			lr[i][0] = Integer.parseInt(sc.next());
			lr[i][1] = Integer.parseInt(sc.next());
		}

		solve(N, Q, S, lr);
	}

	static void solve(int n, int q, String s, int[][] lr) {
		int[] t = new int[n];
		for (int i = 0; i < n - 1; i++) {
			int add = s.substring(i, i + 2).equals("AC") ? 1 : 0;
			// 累積和でl-rの区間の出現数をカウントできるようにする
			t[i + 1] = t[i] + add;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
			int l = lr[i][0];
			int r = lr[i][1];

			sb.append(t[r - 1] - t[l - 1]);
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 63372
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n;cin >> n;
    string s ;cin >> s;
    int ans = 0;
    for(char i='0';i<='9';i++){
        for(char j='0';j<='9';j++){
            for(char k='0';k<='9';k++){
                bool iflag = false;
                bool jflag = false;
                bool kflag = false;
                for(char tm : s){
                    if(!iflag){
                        if(tm==i)iflag=true;
                    } else if(!jflag){
                        if(tm==j)jflag=true;
                    } else if(!kflag){
                        if(tm==k)kflag=true;
                    }
                }
                if(iflag && jflag && kflag)ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
from collections import defaultdict

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

d = defaultdict(int)
for x in s:
    d[x] += 1
for x in t:
    d[x] -= 1
print(max(0, max(d.values())))

Measured memory_bytes: 3316
N = gets.to_i
hs = gets.split.map(&:to_i)

(N-1).downto(1) do |i|
  if hs[i] >= hs[i-1]
    next
  else
    hs[i-1] -= 1
    if hs[i] >= hs[i-1]
      next
    else
      puts 'No'
      exit
    end
  end
end

puts 'Yes'

Measured memory_bytes: 8580
using System;
class p
{
  static void Main()
  {
    int X = int.Parse(Console.ReadLine());
    for (int i = X; i <= 100003; i++) {
      int count = 0;
      bool sosu = true;
      for (int j = 2; j <= X; j++) {
        if (i % j == 0) {
          if (1 < ++count) {
            sosu = false;
            break;
          }
        }
      }
      if (sosu) {
        Console.WriteLine(i);
        return;
      }
    }
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

signed main(void) {
    vector<vi> in;
    string s;
    while(getline(cin,s)){
        vi t;
        int num = 0;
        rep(i,s.size()){
            if(s[i] == ','){
                t.push_back(num);
                num = 0;
            }else{
                num *= 10;
                num += s[i] - '0';
            }
        }
        t.push_back(num);
        in.push_back(t);
    }
    int n = in.size();
    vector<vi> ans = in;
    loop(i,1,n)rep(j,in[i].size())ans[i][j] = 0;

    rep(i,n/2)rep(j,ans[i].size()){
        ans[i+1][j] = max(ans[i+1][j], ans[i][j] + in[i+1][j]);
        ans[i+1][j+1] = max(ans[i+1][j+1], ans[i][j] + in[i+1][j+1]);
    }
    rep(k,n/2){
        int i = n/2+k+1;
        rep(j,in[i].size()){
            ans[i][j] = max(ans[i-1][j], ans[i-1][j+1]) + in[i][j];
        }
    }
    cout << ans.back().back() << endl;
}



Measured memory_bytes: 3072
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    X, Y ,Z = read_values()
    print(Z, X, Y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3952
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void solve() {
  int n, m;
  cin >> n >> m;
  int k[10];
  int s[10][10];
  REP(i, m) {
    cin >> k[i];
    REP(j, k[i]) cin >> s[i][j];
    REP(j, k[i]) s[i][j]--;
  }
  int p[10];
  REP(i, m) cin >> p[i];

  int res = 0;
  REP(i, (1<<n)) {
    bool ok = true;
    REP(j, m) {
      int on = 0;
      REP(kk, k[j]) {
        if ((1<<s[j][kk]) & i) on++;
      }
      if (on%2 != p[j]) ok = false;
    }
    if (ok) res++;
  }
  cout << res << endl;

}

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


Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if w < v:
    rel_vel = v - w
    dis = abs(a - b)
    time = dis / rel_vel
    if time <= t:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
    

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
	int N,A=0,B=0; cin >> N;
	string S,T;
	rep(i,N){
		cin >> S >> T;
		if(S>T) A+=3;
		else if(S==T) {A++; B++;}
		else B+=3;
		S.erase(S.begin(),S.end());
		T.erase(T.begin(),T.end());
	}
	cout << A << " " << B << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,m,v,p;
    cin>>n>>m>>v>>p;
    ll d = n-v;
    Vec a(n);
    Vec s(n);
    rep(i,n)cin>>a[i];
    ll b = n-p;
    sort(ALL(a));
    rep(i,n){
        if(i==0){
            s[0] = a[0];
            continue;
        }
        if(a[i])
        s[i] = s[i-1]+a[i];
    }

//    dbg(a);
//    dbg(b)
    ll L=-1,R=n-1;
    while(L+1<R){
        ll c = (L+R)/2;
        bool ok = [&]{
            bool ok2 = true;
            if(c>=b)return true;
            if(a[b]-a[c]>m){
                ok2 = false;
            }
//            dbg(c);
//            dbg(s[b]-s[c] - (b-c) * a[c]);
//            dbg(m * (min(b-c,d)));
            //右　減らせる数　//左　減らさなきゃダメな数
            if(s[b]-s[c] - (b-c) * a[c] > m * (min(b-c,d))){
                ok2 = false;
            }
            return ok2;
        }();
        if(ok){
            R = c;
        }else{
            L = c;
        }
    }
    //dbg(R);
    cout<<n-R<<endl;
    return  0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Insertion_Sort
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            string input = Console.ReadLine();

            string[] inputs = input.Split(' ');

            int[] nums = new int[num];

            for(int i = 0; i<num;i++)
            {
                nums[i] = int.Parse(inputs[i]);
            }

            Console.WriteLine(input);

            for (int i = 1; i < num; i++)
            {
                int temp = nums[i];
                int j = i - 1;
                while (j >= 0 && nums[j] > temp)
                {
                    nums[j + 1] = nums[j];
                    --j;
                }
                nums[j + 1] = temp;

                for (int k = 0; k<num;k++)
                {
                    Console.Write(nums[k]);
                    if (k != num - 1)
                    {
                        Console.Write(" ");
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                }
            }


        }
    }
}



Measured memory_bytes: 17700
#include <stdio.h>

void print_star(int va[], int num) {
    int i, j;
    
    for(i = 1; i <= 6; i++) {
        printf("%d:", i);
        for(j = 1; j <= va[i]; j++) {
            putchar('*');
        }
        putchar('\n');
    }
}

int main(void) {
    int num, i;
    int class[7] = {0};;
    
    scanf("%d", &num);
    
    double va[num];
    
    for(i = 0; i < num; i++) {
        scanf("%lf", &va[i]);
        
        if(va[i] < 165.0)
            class[1]++;
        else if(va[i] >= 165.0 && va[i] < 170.0)
            class[2]++;
        else if(va[i] >= 170.0 && va[i] < 175.0)
            class[3]++;
        else if(va[i] >= 175.0 && va[i] < 180.0)
            class[4]++;
        else if(va[i] >= 180.0 && va[i] < 185.0)
            class[5]++;
        else if(va[i] >= 185.0)
            class[6]++;
    }
    
    print_star(class, num);
    
    return(0);
 }

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;



int main() {
  io();
  
  string a, b;
  cin >> a >> b;
  cout << b << a;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

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

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long A, B;
    while (cin >> A >> B) {
        cout << max(A - B*2, 0LL) << endl;
    }
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  int H,W,cnt=0;
  cin>>H>>W;
  char c[H][W];
  int d[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>c[i][j];
      if(c[i][j]=='.') cnt++;
      d[i][j]=INF;
    }
  }
  int gx=W-1,gy=H-1;
  queue<pair<int,int>> q;
  q.push(pair<int,int>(0,0));
  d[0][0]=0;
  while(q.size()){
    pair<int,int> p=q.front();
    q.pop();
    if(p.first==gy&&p.second==gx){
      cout<<cnt-d[gy][gx]-1<<endl;
      return 0;
    }
    for(int i=0;i<4;i++){
      int nx=p.second+dx[i],ny=p.first+dy[i];
      if(0<=nx&&nx<W&&0<=ny&&ny<H&&d[ny][nx]==INF&&c[ny][nx]=='.'){
        q.push(pair<int,int>(ny,nx));
        d[ny][nx]=d[p.first][p.second]+1;
      }
    }
  }
  cout<<"-1"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	ll A, B, K;
	cin>>A>>B>>K;
	if(K > A){
		K-=A;
		A = 0;
		B-=K;
		B = max(0LL, B);
	} else{
		A -= K;
	}
	cout<<A<<" "<<B<<endl;
}
 
int main(){
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    map<ll, ll> m;
    rep(i, n){
        ll a; cin >> a;
        m[a]++;
        ans += a;
    }

    int q;
    cin >> q;
    rep(i, q){
        ll b, c;
        cin >> b >> c;
        ans = ans - m[b]*b + m[b]*c;
        cout << ans << endl;
        m[c] += m[b];
        m[b] = 0;
    }
}

Measured memory_bytes: 9348
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int32_t(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}ll ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
constexpr int maxn = 1e6+10; // remember to calculate. if tle, check maxn first.
int n;
char s[maxn];
int main()
{
    close;
    cin >> n;
    cin >> (s+1);
    int l = 1, r = n;
    int cnt = 0;
    while(l < r){
        while(s[l] == 'R')l++;
        while(s[r] == 'W')r--;
        if(l < r) {
            cnt++, swap(s[l], s[r]);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    N %= 10;
    if(N == 3) {
        cout << "bon" << endl;
    } else if(N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;
//vector<char> vc;
vector<string> vs;




int main() {
	int D;
	ll S = 0;
	cin >> D;
	v.resize(D + 1,0);
	w.resize(27, 0);
	vector<int> x(27, 0);
	vector<int> y(27, 0);
	vector<int> c(27);
	vv.resize(D + 1, vector<int>(27, 0));

	rep(i, 1, 27)cin >> c[i];
	rep(i, 1, D+1) {
		rep(j, 1, 27)cin >> vv[i][j];
	}
	y[0] -= 99999;
	rep(i, 1, D + 1) {
		rep(j, 1, 27) y[j] = vv[i][j] + c[j] * (i - x[j]) - c[j] * (D - i);
		int max_num = max_element(y.begin(), y.end()) - y.begin();
		x[max_num] = i;
		rep(j, 1, 27) {
			if (j == max_num)S += vv[i][j];
			else S -= c[j] * (i - x[j]);
		}
		cout << max_num << '\n';
	}
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  n=m/n;
  if(n>k)
  {
    printf("%d",k);
  }
  else
  {
    printf("%d",n);
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
li = list(enumerate(a))
li.sort(key = lambda x:x[1])
li.reverse()

dp = [[0 for _ in range(n+1)]for __ in range(n+1)]
ans = 0
for i in range(n+1):
    for j in range(n+1):
        cnt = i + j
        if cnt == 0: continue
        if cnt > n: continue
        if i == 0:
            dp[0][j] = dp[0][j-1] + li[cnt-1][1] * ((n - j) - li[cnt-1][0])
            continue
        if j == 0:
            dp[i][0] = dp[i-1][0] + li[cnt-1][1] * (li[cnt-1][0] - (i-1) )
            continue
        
        
        res1 = dp[i][j-1] + li[cnt-1][1] * (n - j - li[cnt-1][0])
        res2 = dp[i-1][j] + li[cnt-1][1] * (li[cnt-1][0] - (i-1))
        dp[i][j] = max(res1,res2)
        if cnt ==n:
            ans = max(ans,dp[i][j])

print(ans)

Measured memory_bytes: 101764
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n;cin>>n;
  vector<int> A(n);
  vector<int> B(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  for(int i = 0; n > i; i++){
    cin>>B[i];
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    ans += max(0,A[i]-B[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int min;
    int n;
    int min1;
    int flg = 0;

    for(int i = 0; i < 3; i++){
        cin >> n;
        if(flg == 1){
            if(min > n) min = n;
        }
        else{
            min = n;
            flg = 1;
        }
    }
    flg = 0;
    for(int i = 0; i < 2; i++){
        cin >> n;
        if(flg == 1){
            if(min1 > n) min1 = n;
        }
        else{
            min1 = n;
            flg = 1;
        }
    }
    cout << min + min1 - 50 << endl;

    return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

int si[4]={0,5,9,13};
int dxl[13]={0,-1,0,1,-2,-1,0,1,2,-1,0,1,0};
int dyl[13]={2,1,1,1,0,0,0,0,0,-1,-1,-1,-2};
int dxm[9]={-1,0,1,-1,0,1,-1,0,1};
int dym[9]={1,1,1,0,0,0,-1,-1,-1};
int dxs[5]={0,-1,0,1,0};
int dys[5]={1,0,0,0,-1};

int p[10][10];

main(){
  int x,y,b,i,j;
  int noi=0,maxi=0;
  while(scanf("%d,%d,%d",&x,&y,&b)!=EOF){
    if(b==1){
      for(i=0;i<5;i++){
	if(0<=x+dxs[i] && x+dxs[i]<10 && 0<=y+dys[i] && y+dys[i]<10) p[x+dxs[i]][y+dys[i]]++;
      }
    }
    if(b==2){
      for(i=0;i<9;i++){
	if(0<=x+dxm[i] && x+dxm[i]<10 && 0<=y+dym[i] && y+dym[i]<10) p[x+dxm[i]][y+dym[i]]++;
      }
    }
    if(b==3){
      for(i=0;i<13;i++){
	if(0<=x+dxl[i] && x+dxl[i]<10 && 0<=y+dyl[i] && y+dyl[i]<10) p[x+dxl[i]][y+dyl[i]]++;
      }
    }
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(p[i][j]==0) noi++;
      else if(p[i][j] > maxi) maxi=p[i][j];
    }
  }
  cout << noi << endl << maxi << endl;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


int gcd(int a, int b) {
  if(a < b)
    swap(a, b);

  int r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int gcd_n(const vector<int> &x){
  int g = x[0], size = SZ(x);
  for(int i=1; i<size; ++i)
    g = gcd(g, x[i]);
  return g;
}

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

  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  for(int i=0; i<N; ++i)
    cin >> x[i];

  for(int i=0; i<N; ++i)
    x[i] = abs(x[i] - X);

  cout << gcd_n(x) << endl;

  return 0;
}

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			if ((X - i * 500 - j * 100) >= 0) {
				int n = X - i * 500 - j * 100;
				if (n <= C * 50) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    bitset<10010> dp;
    dp.set(0);
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int s;
      cin >> s;
      dp = dp | (dp << s);
      sum += s;
    }
    int ans = 0;
    for (int s = sum; s >= 0; s--) {
      if (dp[s]) {
        ans = max(ans, s % 10 == 0 ? 0 : s);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int sum = L*N-N+(1+N)*N/2;
		int absMin = Math.abs(L);
		int bite = L;
		for (int i=2;i<=N;i++) {
			if (Math.abs(L+i-1)<absMin) {
				absMin = Math.abs(L+i-1);
				bite = L+i-1;
			}
		}
		System.out.println(sum-bite);
	}
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,t=0,M=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		t+=x;
		M=max(M,x);
	}
	cout<<t-M/2<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};

const INF: i64 = 1000_000_000_000_000;

fn main() {
    input! {
        n: usize,
        a: [[i64; n]; n],
    }

    let mut sum = vec![INF; 1 << n];

    for p in 0..1 << n {
        let mut cur = 0;
        for i in 0..a.len() {
            for j in i + 1..a.len() {
                if p & (1 << i) != 0 && p & (1 << j) != 0 {
                    cur += a[i][j];
                }
            }
        }
        sum[p] = cur;
    }

    let mut tbl = vec![INF; 1 << n];
    let mut ans = 0;

    for i in 0..(1 << n) {
        ans = max(ans, rec(((1 << n) - 1) & !i, &a, &sum, &mut tbl) + sum[i]);
    }

    println!("{}", ans);
}

fn rec(b: usize, a: &Vec<Vec<i64>>, sum: &Vec<i64>, tbl: &mut Vec<i64>) -> i64 {
    if b == 0 {
        return 0;
    }

    if tbl[b] != INF {
        return tbl[b];
    }

    let mut pos = vec![];
    for i in 0..a.len() {
        if b & (1 << i) != 0 {
            pos.push(1 << i);
        }
    }

    let mut ret = 0;
    for q in 0..1 << (pos.len()-1) {
        let q = (q<<1)|1;
        let mut p = 0;
        for i in 0..pos.len() {
            if q & (1 << i) != 0 {
                p += pos[i];
            }
        }
        let cur = sum[p];

        ret = max(ret, rec(b & !p, a, sum, tbl) + cur);
    }

    tbl[b] = ret;
    ret
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 1e5+5;
int n,K;
int h[maxn],f[maxn];

int abs(int x,int y) {
	if (x - y < 0) return y - x;
	return x - y;
}

int min(int x,int y) {
	if (x < y) return x;
	return y;
}

int main() {
	memset(f,0x3f,sizeof(f));
	scanf("%d %d",&n,&K);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&h[i]);
	}
	f[0] = f[1] = 0;
	for (int i = 2; i <= n; i++) {
		for (int k = 1; k <= K && k < i; k++){
			f[i] = min(f[i-k]+abs(h[i],h[i-k]),f[i]);
		}
	}
	printf ("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  map<string, int> num;
  num["AC"] = 0;
  num["WA"] = 0;
  num["TLE"] = 0;
  num["RE"] = 0;
  string res;
  for(int i = 0; i < N; i++){
    cin >> res;
    num[res] += 1;
  }
  cout << "AC x " << num["AC"] << endl;
  cout << "WA x " << num["WA"] << endl;
  cout << "TLE x " << num["TLE"] << endl;
  cout << "RE x " << num["RE"] << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if((a * b) %  2 == 0)
    cout << "Even" << endl;
  
  else if((a * b) % 2 == 1)
	cout << "Odd" << endl;
    
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll d=n/k;
    ll mn=min(abs(n-d*k),abs(n-(d+1)*k));
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        tt: u32,
        aa: [(u32,u32);n]
    }
    let aa: Vec<(u32,u32)> =
        aa.into_iter().filter(|e| e.1 <= tt).collect();
    if aa.is_empty() {
        println!("TLE");
        return;
    }
    println!("{}", aa.iter().map(|e| e.0).min().unwrap());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)

int main(){
	fast
	int n;
	cin>>n;
	ll a[n];
	ll x=0;
	for(int i=0;i<n;i++){
	 cin>>a[i];
	 x=x^a[i];
    }
    for(int i=0;i<n;i++)
     cout<<(x^a[i])<<" ";

	
	  
	  
	
}


Measured memory_bytes: 5152
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

ans = []
for b,c in BC:
  n = len(ans)
  for i in range(b):
    if n >  N-1: break
    if A[n] < c:
      ans.append(c)
      n += 1
    else: break

print(sum(ans) + sum(A[len(ans):]))

Measured memory_bytes: 32964
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
    	
	ll a[100010];

int main(){
	ll n,q;
	string s;
	cin>>n>>q;
	cin>>s;
	rep(i,1,s.size()){
		if(s[i-1]=='A'&&s[i]=='C')a[i]++;
	}
	rep(i,1,s.size())a[i]+=a[i-1];
	rep(i,0,q){
		ll l,r;
		cin>>l>>r;
		cout<<a[r-1]-a[l-1]<<endl;
	}
	
}

Measured memory_bytes: 1792
import collections
N = int(input())
A=[input() for i in range(N)]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
k = max (counts)
l =counts.count(k)
V = []
for i in range(l):
  V.append(values[i])
L = sorted(V)
for j in range(len(L)):
  print(L[j])

Measured memory_bytes: 59496