akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx2,tune=native")
#include<bits/stdc++.h>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv1(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
template<typename a, typename b>
void minq(a& x, b y) {
	if (x > y)
		x = y;
}
template<typename a, typename b>
void maxq(a& x, b y) {
	if (x < y)
		x = y;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
//WHEN DOING MODULAR SUBTRACTION ALWAYS **ALWAYS** ADD MOD
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, c, cnt[3][40];
vvi mat, cl;
ll sim(vi u) {
	ll res = 0;
	for(int i = 0; i < 3; i++)
		for(int j = 1; j <= c; j++)
			res += cl[j][u[i]]*cnt[i][j];
	return res;
}
int main() {
	doin();
	cin >> n >> c;
	getv1(cl, c, c);
	getv(mat, n, n);
	ll ans = INT_MAX;
	for (int a = 0; a < n; a++)
		for (int b = 0; b < n; b++)
			cnt[(a+b+2)%3][mat[a][b]]++;
	for (int i = 1; i <= c; i++)
		for (int j = 1; j <= c; j++)
			for (int k = 1; k <= c; k++) {
				if(i == k || j == k || i == j) continue;
				ans = min(ans, sim( { i, j, k }));
			}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n, m, q;
long ans = 0;
vector<vector<long>> l;

vector<long> inputVector(long n)
{
    vector<long> vec(n);
    rep(i, n)
    {
        scanf("%d", &vec.at(i));
    }
    return vec;
}

void dfs(vector<long> vec)
{
    if (vec.size() < n)
    {
        long cur = vec.at(vec.size() - 1);
        while (cur <= m)
        {
            vec.push_back(cur);
            dfs(vec);
            vec.pop_back();
            cur++;
        }
    }
    else
    {

        long score = 0;
        rep(i, q)
        {
            long a = l.at(i).at(0);
            long b = l.at(i).at(1);
            long c = l.at(i).at(2);
            long d = l.at(i).at(3);
            if (vec.at(b - 1) - vec.at(a - 1) == c)
            {
                score += d;
            }
        }
        ans = max(ans, score);
    }
}

int main()
{
    cin >> n >> m >> q;
    rep(i, q)
    {
        l.push_back(inputVector(4));
    }

    // scanf("%d", &x);
    dfs(vector<long>(1, 1));
    // printf("%d\n", x * x * x);
    cout << ans << endl;
}

Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  
  set<char> alpcnt;
  
  rep(i,(ll)s.size()){
    char c = s[i];
    alpcnt.insert(c);
  }
  
  char ans = '0';
  
  rep(i,26){
    if(!alpcnt.count(small[i])){
      ans = small[i];
      break;
    }
  }
  
  if(ans == '0') cout << "None" << endl;
  else cout << ans << endl;
  
  
  
}

Measured memory_bytes: 3724
/*#include <bits/stdc++.h>
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define ld long double
#define ll long long
#define vec(a,b) (b-a)
#define pi acos(-1)
//#define x real()
//#define y imag()


using namespace std;
typedef complex <ld> point;
typedef vector<point> polygon;
typedef tuple<int,int,int> line; // represents a b c of line

vector <ll> v;
//vector <ll> vc;

//ll mod = 1e9 +7;
//ll fact[1000005], inv[1000005];
//int p;


bool prime(ll n)
{
   if(n==1)
    return false;
   for(int i=2; i<=sqrt(n); ++i)
   {
       if(n%i==0)
       {
           return false;
       }
   }
   return true;
}

/*unsigned long long fp(ll x, ll y)
{
    if(y==0)
    {
        return 1;
    }
    ll z = fp(x,(y/2));

    if(y%2==0)
    {
        return (z*z)%p;
    }
    else
        return (((z*z)%p)*(x%p))%p;
}*/
/*unsigned long long fp(ll x, ll y)
{
    if(y==0)
    {
        return 1;
    }
    ll z = fp(x,(y/2));

    if(y%2==0)
    {
        return (z*z)%mod;
    }
    else
        return (((z*z)%mod)*(x%mod))%mod;
}
void pre()
{
  fact[0]=inv[0]=1;
  for(int i=1; i<=1000005; ++i)
  {
      fact[i]=(fact[i-1]*i)%mod;
      inv[i]=fp(fact[i], mod-2);
  }
}
unsigned ll ncr(int n, int r)
{
    return (((fact[n]*inv[n-r])%mod) * inv[r])%mod;
}*/

/*int main()
{
    //pre();
    int n, ans=0;
    ll c;
    cin >> n;
    for(int k=1; k<=n; ++k)
    {
        c=0;
        bool arr[30005]={false};
        if(prime(k))
            continue;
        for(ll i=1; i*i<=k; ++i)
        {
            if(k%i==0 && prime(i) && arr[i]==false)
            {
                c++;
                arr[i]=true;
            }
            if(k%i==0 && prime(k/i) && arr[k/i]==false)
            {
                    c++;
                    arr[k/i]=true;
            }
        }
        if(c==2)
            ans++;
    }
    cout << ans << endl;*/
/*cin >>p;
int cnt=0;
bool ch=1;
for(int i=1; i<p; ++i)
{
    ch=1;
    for(int j=1; j<=p-2; ++j)
    {
            if(((fp(i,j)-1)+p)%p==0)
            {
                ch=0;
            }
            if( ((fp(i,p-1)-1)+p)%p!=0)
            {
                ch=0;
            }
            if(!ch)
            {
                break;
            }
    }
    if(ch)
        cnt++;
}
cout << cnt << endl;*/
//return 0;
//}

#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

ll ans[1001][1001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w;
    cin >> h >> w;
    char arr[h][w];
    for(int i=0; i<h; ++i)
    {
        for(int j=0; j<w; ++j)
        {
            cin >> arr[i][j];
        }
    }
    ans[0][0]=1;
    for(int i=0; i<h; ++i)
    {
        for(int j=0; j<w; ++j)
        {
            if(arr[i][j]=='#')
                continue;
            if(i){
                ans[i][j]+=ans[i-1][j];
            }
            if(j){
                ans[i][j]+=ans[i][j-1];
            }
            ans[i][j]%=mod;
        }
    }
    cout << ans[h-1][w-1];
    return 0;
}





Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  int mxLi = -1, mnRi = (int)1e8;
  for ( int i = 0; i < m; i++ ) {
    int x, y;
    cin >> x >> y;
    mxLi = max(mxLi, x);
    mnRi = min(mnRi, y);
  }
  cout <<  max(0,-mxLi + 1 + mnRi) << endl;
  return 0; 
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353
import numpy

N = int(input())
A = list(map(int, input().split()))

a = numpy.argsort(A)
b = []
for i in range(N):
    b.append(str(a[i]+1))

print(" ".join(b))

Measured memory_bytes: 40528
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
    if (a > 0) return a % MOD;
    if (a % MOD == 0) return 0;
    ll x = -a / MOD + 1;
    a += x * MOD;
    return a % MOD;
}

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll dp[403][403] = {};
ll a[402], s[403] = {};

template <class Monoid> class SegTree {
    using OP = std::function<Monoid(Monoid, Monoid)>;

  private:
    int n;
    std::vector<Monoid> dat;
    OP op;
    Monoid e;

  public:
    SegTree(int n_, OP op, Monoid e) : op(op), e(e) {
        n = 1;
        while (n < n_) { n *= 2; }
        dat.resize(2 * n);
        for (int i = 0; i < 2 * n - 1; i++) { dat[i] = e; }
    }
    void update(int k, Monoid v) {
        k += n - 1;
        dat[k] = v;
        while (k > 0) {
            k      = (k - 1) / 2;
            dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    Monoid querySub(int a, int b) const {
        Monoid left  = e;
        Monoid right = e;
        a += n - 1;
        b += n - 1;
        while (a < b) {
            if ((a & 1) == 0) { left = op(left, dat[a]); }
            if ((b & 1) == 0) { right = op(dat[b - 1], right); }
            a = a / 2;
            b = (b - 1) / 2;
        }
        return op(left, right);
    }
    Monoid query(int a, int b) const { return querySub(a, b + 1); }
};

signed main() {
    IOS();
    ll n;
    cin >> n;
    vector<ll> a(n), h(n);
    function<ll(ll, ll)> f = [](ll i, ll j) { return max(i, j); };
    SegTree<ll> st(n + 1, f, 0);
    for (int i = 0; i < n; ++i) { cin >> h[i]; }
    for (int i = 0; i < n; ++i) { cin >> a[i]; }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll tmp = st.query(0, h[i] - 1) + a[i];
        ans    = max(ans, tmp);
        st.update(h[i], tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7552
#include "bits/stdc++.h"

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll K, X;
vector<ll> ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> K >> X;
    return true;
}

void solve() {
    for (ll i = X - K + 1; i <= X + K - 1; i++) {
        ANS.push_back(i);
    }
}

void output() {
    for (ll i = 0; i < ANS.size(); i++) {
        cout << (i ? " " : "") << ANS[i];
    }
    cout << endl;
}

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


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

cnt4,cnt2,cnt = 0,0,0

for i in A:
    if i%4==0:
        cnt4 += 1
    elif i%2==0:
        cnt2 += 1
    else:
        cnt += 1
cnt += cnt2%2

if cnt4+1>=cnt:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long a[n];
  REP(i,n) cin >> a[i];
  long long ans = 0;
  long long b0[65];
  long long b1[65];
  REP(j,65) b0[j] = 0;
  REP(j,65) b1[j] = 0;
  
  REP(i,n){
  	REP(j,65){
      if(a[i] % 2 == 0) b0[j]++;
      else b1[j]++;
      a[i] = a[i] / 2;
    }
  }
  
  REP(j,65){
    long long bit_ans = b0[j] * b1[j] % MOD;
    FOR(i,0,j) bit_ans = bit_ans * 2 % MOD;
    ans = (ans + bit_ans) % MOD;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 2560
s = input()
q = int(input())

t = ''
for i in range(q):
    query = input().split()
    if query[0] == '1':
        s,t = t,s
    else:
        if query[1] == '1':
            t += query[2] 
        else:
            s += query[2]

print(t[::-1] + s)


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

int sab(int a, int b){
  int sub = max(a,b)-min(a,b);
  return sub;
}

int main() {
  string s; cin >>s;
  string t;
  int buf;
  int ans = 9999;
  for (int i=0; i<s.size()-2; i++){
    t = "";
    t = t + s.at(i) + s.at(i+1) + s.at(i+2);
    ans = min(ans, sab(753, stoi(t)));
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>c(h);
	for (int i = 0; i < h; i++)cin >> c[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < 2; j++) {
			cout << c[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import Data.List

type Row = [Int]
type Matrix = [Row]

main = getContents >>= putOut.formatOut.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> (Matrix,Matrix) 
formatIn = (\((n:_):xs) -> splitAt n xs).map (map (read :: String -> Int).words).lines

formatOut :: Matrix -> String
formatOut = unlines.map (unwords.(map show))

solve :: (Matrix,Matrix) -> Matrix
solve (xs, ys) = map (flip (\x -> map (sum.(zipWith (*) x))) $transpose ys) xs

Measured memory_bytes: 12312
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B, C;
  cin >> A >> B >> C;
  ll ans = B;
  ans += min(C, A + B + 1);
  cout << ans << "\n";
}


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

flg = [False]*K

tmp = 7 % K
cnt = 1
if tmp == 0:
    print(cnt)
    exit()
while True:
    tmp = (tmp*10+7)%K
    if flg[tmp]:
        print(-1)
        break
    else:
        cnt += 1
        if tmp == 0:
            print(cnt)
            break
        flg[tmp] = True


Measured memory_bytes: 16560
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,W;
	cin>>n>>W;
//	map<int,int> m;
	long long w[n],v[n];
	for(int i{};i<n;i++){
		cin>>w[i]>>v[i];
	}
	long long dp[W+1]{};
//	for(int i{};i<=W;i++){
//		cout<<i<<"\t";
//	}
//
	for(int i=0;i<n;i++){
		for(int j=W;w[i]<=j;j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
//	cout<<endl;
//	for(auto x:dp){
//		cout<<x<<"\t";
//	}		
	}

	cout<<dp[W];
}


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

int main()
{
   int n,m,sum=0,c=0;
   float arr[1000],x;
   cin>>n>>m;
   for(int i=0;i<n;i++)
   {
    cin>>arr[i];
    sum+=arr[i];
   }

   x=(0.25*sum)/m;
   for(int i=0;i<n;i++)
   {
      if(arr[i]>=x)
        c++;
   }

   if(c>=m)
    cout<<"Yes";
   else
    cout<<"No";

  return 0;
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine((x[0]*x[1])/2);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

int N,M;
int FS[310][310];
vector<int>K;
  
int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>FS[i][j];
    }
  }
  for(int i=1;i<=M;i++){
    K.push_back(i);
  }
  int eachmaxcnt=0;
  int maxcnt=300;
  int C[310];
  int temp=0;
  
  //ゲームの種類分回す
  for(int i=0;i<M;i++){
    
    //各ゲームの参加者数を初期化
    for(int i=1;i<=M;i++){
      C[i]=0;
    }
      for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
          //最初にでてくるゲームの参加者を加算
          if(FS[i][j] != -1){
            C[FS[i][j]]++;
            break;
          }
        }
    }
    
    //最大参加者数を求める
    eachmaxcnt=0;
    for(int i=1;i<=M;i++){
      if(eachmaxcnt<C[i]){
        eachmaxcnt=C[i];
        temp=i;
      }
    }

    //最大参加者数の更新
    maxcnt=min(maxcnt,eachmaxcnt);
    
    //最大参加者のゲームを-1にする
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        if(FS[i][j]==temp){
          FS[i][j]=-1;
        }    
      }
    }
  }    

  cout<<maxcnt<<endl;
  return 0;
}

Measured memory_bytes: 4012
S = input()
if S == "SAT" :
    print(1)
if S == "FRI" :
    print(2)
if S == "THU" :
    print(3)
if S == "WED" :
    print(4)
if S == "TUE" :
    print(5)
if S == "MON" :
    print(6)
if S == "SUN" :
    print(7)



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    int N;
    cin >> N;
    set<string> SS;
    rep(i,N) {
        string S;
        cin >> S;
        SS.insert(S);
    }
    cout << SS.size() << endl;
}

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

int main(void) {
  string S;
  cin >> S;
  bool flag = true;
  vector<char> dict_odd = {'R', 'U', 'D'};
  vector<char> dict_even = {'L', 'U', 'D'};

  for (int i = 0, len = S.length(); i < len; i++) {
    if (i % 2 == 0) {
      flag &= find(dict_odd.begin(), dict_odd.end(), S[i]) != dict_odd.end();
    } else {
      flag &= find(dict_even.begin(), dict_even.end(), S[i]) != dict_even.end();
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<double> x, y;
    double dis[8][8];
    rep(i, n){
        double a, b;
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
    }
    rep(i, n-1){
        rep2(j, i+1, n){
            dis[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
            dis[j][i] = dis[i][j];
        }
    }
    vector<int> array;
    rep(i, n){
        array.push_back(i);
    }
    double sum = 0, cnt = 0;
    do{
        cnt += 1.0;
        rep(i, n-1){
            sum += dis[array[i]][array[i+1]];
        }
    }while(next_permutation(array.begin(), array.end()));
    cout << fixed << setprecision(10) << sum / cnt << endl;
    return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k;
  cin >> k;
  int T = 0;
  for (int i = 0; i < k; i++){
    int b;
    cin >> b;
    T |= (1 << b);
  }
  vector<int> t;
  for (int i = 0; i < n; i++){
    if (!((T >> i) & 1)){
      t.push_back(i);
    }
  }
  for (int i = 0; i < (1 << (n - k)); i++){
    int b = T;
    for (int j = 0; j < n - k; j++){
      if (i & (1 << j)){
        b += (1 << t[j]);
      }
    }
    cout << b << ':';
    for (int j = 0; j < n; j++){
      if (b & (1 << j)){
        cout << ' ' << j;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k, s = [int(item) for item in input().split()]
if s != 10**9:
    ans = [s] * k + [10**9] * (n-k)
else:
    ans = [s] * k + [10**9-1] * (n-k)
print(*ans)

Measured memory_bytes: 6652
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

int a, b, c, k;

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

	cin >> a >> b >> c >> k;

	cout << a + b + c + max({a,b,c})*(pow(2,k)-1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head &&head, Tail &&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n, m, x, y);
  vector<int> vx(n), vy(m);
  for (auto &e : vx) cin >> e;
  for (auto &e : vy) cin >> e;

  vx.push_back(x);
  vy.push_back(y);
  sort(all(vx));
  sort(all(vy));

  bool ok = true;
  if (!(x < y)) ok = false;
  if (!(vx.back() < vy[0])) ok = false;

  puts(ok ? "No War" : "War");
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0; i<(n); ++i)
 
 
struct union_find{
	vector<ll> v;
	union_find(ll n) : v(n, -1){}
	ll find(ll x) { return (v[x] < 0) ? x : (v[x] = find(v[x]));}
	bool unite(ll x, ll y){
		x = find(x); y = find(y);
		if(x==y) return false;
		if(-v[x] < -v[y]) swap(x,y);
		v[x] += v[y];
		v[y] = x;
		return true;
	}
	bool same(ll x, ll y) {return find(x) == find(y);}
	ll size(ll x) {return -v[find(x)];}
};
 
int main(){
	ll n;
	cin >> n;
	//
	ll MAX = 9000;
	vector<ll> deletable(n+2, MAX);
	//
	union_find uf(n+2);
	///
	vector<pair<ll,ll>> undeletable;
 
	ll deletable_i = 0;
	REP(i,n){
		char d;
		ll l;
		cin >> d >> l;
		if(d=='y'){
			deletable[deletable_i] = min(deletable[deletable_i], l);
		}else{
			undeletable.push_back(make_pair(l,undeletable.size()));
			deletable_i++;
		}
	}
 
	ll count = 0;
	auto undeletable_sorted = undeletable;
	sort(undeletable_sorted.begin(), undeletable_sorted.end());
	for(auto& x : undeletable_sorted){
		ll id = x.second; ll len = x.first;
		if(deletable[uf.find(id)] <= len){ count++; deletable[uf.find(id)] = MAX;}
		if(deletable[uf.find(id+1)] <= len) { count++; deletable[uf.find(id+1)] = MAX;}
		ll n_len = min(deletable[uf.find(id)], deletable[uf.find(id+1)]);
		uf.unite(id, id+1);
		deletable[uf.find(id)] = n_len;
	}
	if(deletable[uf.find(0)] != MAX ){
		count++;
	}
 
	cout << count << endl;
}

Measured memory_bytes: 3136
from collections import defaultdict
import math

N = int(input())
li = [input() for i in range(N)]
d = defaultdict(int)

count = 0

for i in li:
  s = sorted(list(i))
  t = "".join(s)

  if d[t] != 0:
    count += d[t]
  d[t] += 1
    
print(count)

Measured memory_bytes: 25328
n = int(input())
a = list(map(int,input().split()))
b = [0 for _ in range(100001)]
for x in a:
  b[x] += 1
ans = sum(a)
q = int(input())
for _ in range(q):
  x,y = map(int,input().split())
  ans += (y-x) * b[x]
  b[x],b[y] = 0,b[x]+b[y]
  print(ans)

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;
    int ans = 0;

    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        if (a & 1 && i & 1) {
            ++ans;
        }
    }

    cout << ans << endl;
}   

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


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
	int a, b;
	int count[4];
	for(int i = 0;i < 4;i++){
		count[i] = 0;
	}
	for(int i = 0;i < 3;i++){
		cin >> a >> b;
		count[a - 1]++;
		count[b - 1]++;
	}
	for(int i = 0;i < 4;i++){
		if(count[i] == 3){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    int x;
    scanf("%d",&x);
    int max = 0;
    for(int b=1;b<=31;b++){
        for(int p=2;p<10;p++){
            if(pow(b,p)<=x){
                if(pow(b,p) > max) max = pow(b,p);
            }
            else break;
        }
    }
    printf("%d\n",max);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
    cin >> n >> m;
    int x[200000] = {0} , y[200000] = {0};
    for (int i = 0 ; i < m ; i++ ) {
        int a , b;
        cin >> a >> b;
        if ( a == 1 ) x[b - 1] = 1;
        if ( b == n ) y[a - 1] = 1;
    }
    for (int i = 0 ; i < n ; i++ ) {
        if ( x[i] == 1 && y[i] == 1 ) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 1792
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int f[2][(1<<20)+5],c[25][25],n,m,K,x,y,z,q1,q2,i,j,s,ts,ns,ds,ans;
int main()
{
	scanf("%d %d %d",&n,&m,&K);
	n--;
	fo(i,1,K)
	{
		scanf("%d %d %d",&x,&y,&z);
		c[x][y-1]=z+1;
	}
	f[0][0]=1;
	q1=0;
	q2=1;
	ts=1<<n;ts--;
	fo(i,1,m)
		fo(j,0,n-1)
		{
			fo(s,0,ts)
			if (f[q1][s])
			{
				//left
				if (c[i][j]!=2&&((s>>j)&1)==0)
				{
					f[q2][s]+=f[q1][s];
					if (f[q2][s]>=mo) f[q2][s]-=mo;
				}
				//right
				if (c[i][j]!=1)
				{
					if ((s>>j)&1) ns=s;
					else
					{
						ns=((-1)^(1<<j+1)-1)&s;
						if (!ns) ds=0;
						else ds=ns&(-ns);
						ns=s^(1<<j)^ds;
					}
					f[q2][ns]+=f[q1][s];
					if (f[q2][ns]>=mo) f[q2][ns]-=mo;
				}
			}
			fo(s,0,ts) f[q1][s]=0;
			q1^=1;
			q2^=1;
		}
	fo(s,0,ts) 
	{
		ans+=f[q1][s];
		if (ans>=mo) ans-=mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8448
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rer(i,l,r) for(int i=(l); i<=(r); ++i)
#define gnr(i,l,r) for(int i=(r); i>=(l); --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
#define fil(a,v) memset((a),v,sizeof(a))
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;


int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>n; Int sn=0; Int a[n+1]; a[0]=0; rep(i,n){cin>>x; a[i+1]=a[i]+x;}
  Int ans=INF32;
  rer(i,1,n-1){
    cmin(ans,abs(a[n]-2*a[i]));
  }
  END
}

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

typedef long long ll;

int main(){
  	int N;

  	cin >> N;
	int A[N];
  	int B[N];
  	int count = 0;
	for(int i = 0; i < N ; i++){
      cin >> A[i];
      if(A[i]<0){
        	count++;
        	B[i]=-A[i];
      }else{
      	B[i]=A[i];
      }
      
    }
	ll sum =0;
  	sort(B,B+N,greater<int>());
  	
  	if(count %2==0){
    	for(int i = 0; i < N ; i++){
          	//cout << "A"<<B[i] <<endl;
        	sum += B[i];
        }
    }else{
        for(int i = 0; i < N-1 ; i++){
          //cout << "B"<<B[i] <<endl;
        	sum += B[i];
        }
      	sum = sum - B[N-1];
    }
  	cout << sum << endl;
  	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,k;
    cin >> n >> k;
    ld p[n];
    rep(i,n){
        ld a;
        cin >> a;
        p[i] = (a + 1) / 2;
    }/*
    ld max = 0;
    rep(i,k){
        max += p[i];
    }
    ld m = max;
    repi(i,k,n){
        m -= p[i - k];
        m += p[i];
        max = max(m,max);
    }
    cout << max << endl;*/
    ld a[n + 1];
    a[0] = 0;
    rep(i, n){
        a[i + 1] = a[i] + p[i];
    }
    ld max = 0;
    repi(i, k, n + 1){
        max = max(max,a[i] - a[i - k]);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  string s,t,ans;
  cin>>s>>t;
  for(int i=0;i<n;i++){
    ans.push_back(s[i]);
    ans.push_back(t[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ks(long long x,long long y){
  if(x%y==0) return x;
  else return y*(x/y+1);
}
int main(){
  long long n,i,j,c,s,f,now;cin >> n;
  long long k[n-1][3];
  for(i=0;i<n-1;i++) cin >> k[i][0] >> k[i][1] >> k[i][2];
  for(i=0;i<n;i++){
    now = 0;
    for(j=i;j<n-1;j++){
      if(now<=k[j][1]) now = k[j][1];
      else now = ks(now,k[j][2]);
      now += k[j][0];
    }
    cout << now << "\n";
  }
}
  
    

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

int n;
int idx[15], dst[15], num[15];
double dp[15][1 << 15];
int prv[15][1 << 15];
double spd[1 << 15];

int main() {
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> idx[i] >> dst[i] >> num[i];
  }

  int M = 1 << n;
  for(int S=0; S<M; S++) {
    int c = 0;
    for(int i=0; i<n; i++) {
      prv[i][S] = -1;
      dp[i][S] = DBL_MAX;

      if( S >> i & 1 ) {
	c += num[i];
      }
    }
    //spd[S] = 2000.0 / (70 + 20 * c);
    spd[S] = (7 + 2 * c) / 200.0;
  }

  for(int i=0; i<n; i++) {
    dp[i][1 << i] = 0.0;
  }

  for(int S=1; S<M; S++) {
    for(int i=0; i<n; i++) {
      if( !(S >> i & 1) ) continue;
      for(int j=0; j<n; j++) {
	if( S >> j & 1 ) continue;

	double tm = dp[i][S] + abs(dst[i] - dst[j]) * spd[S];
	int T = S | 1 << j;
	if( dp[j][T] > tm ) {
	  dp[j][T] = tm;
	  prv[j][T] = i;
	}
      }
    }
  }

  int x = 0;
  for(int i=1; i<n; i++) {
    if( dp[x][M-1] > dp[i][M-1] ) {
      x = i;
    }
  }

  //queue<int> q;
  stack<int> st;
  int U = M-1;
  while( x != -1 ) {
    //q.push(idx[x]);
    st.push(idx[x]);
    int y = prv[x][U];
    U ^= 1 << x;
    x = y;
  }

  //cout << q.front(); q.pop();
  cout << st.top(); st.pop();
  while( !st.empty() ) {
    cout << ' ' << st.top(); st.pop();
  }

  cout << endl;
}

Measured memory_bytes: 7216
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;



int main()
{
    ll L,R;
    cin >> L >> R;

    ll iMin = 2020;

    for(ll i = L; i <= R-1; ++i)
    {
        for(ll j = i+1; j <=R; ++j)
        {
            iMin = min(iMin, (i*j) % 2019);
            //2019で割れる値
            if(iMin == 0)break;
        }
        if(iMin == 0)break;
    }
    cout << iMin << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val S = input.next()
    val T = input.next()
    var operationCount = 0;
    
    for (i in 0..S.length - 1) {
      if (S[i] != T[i]) {
        ++operationCount
      }
    }
    
    println(operationCount)
  }
}

Measured memory_bytes: 42012
n=int(input())
S=[]
X=[]
for i in range(n):
    s=int(input())
    S.append(s)
    if s%10!=0:
        X.append(s)
ans=sum(S)

if ans%10==0:
    if len(X)!=0:
        print(ans-min(X))
    else:
        print(0)
else:
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define LOCAL 0
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define pii pair<int,int>
#define f80 long double
 
#define int long long int
//typedef long long int ll;
 
const int mod = 1e9 + 7;
const int N = 200005;
 
main(){
    IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
    }
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    forn(i, 0, n - 1)
    {
        if(c * i + (n - 1 - i) * (-d) <= b - a && b - a <= d * i + (n - 1 - i) * (-c))
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define MAXN	400005
#define INF	1e18
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {long long num; int type; };
bool operator < (info a, info b) {return a.num < b.num; }
info a[MAXN]; int n, tot;
long long x[MAXN], y[MAXN];
long long solve1() {
	long long mn = INF, mx = 0;
	for (int i = 1; i <= n; i++) {
		mn = min(mn, max(x[i], y[i]));
		mx = max(mx, min(x[i], y[i]));
	}
	return (a[tot].num - mn) * (mx - a[1].num);
}
int Cnt[MAXN];
long long solve2() {
	if (a[1].type == a[tot].type) return INF;
	int l = 1, r = 0, cnt = 0;
	long long ans = INF;
	while (r <= tot) {
		Cnt[a[++r].type]++;
		if (Cnt[a[r].type] == 1) cnt++;
		if (cnt != n) continue;
		while (Cnt[a[l].type] == 2)
			Cnt[a[l++].type]--;
		ans = min(ans, (a[tot].num - a[1].num) * (a[r].num - a[l].num));
	}
	return ans;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(x[i]), read(y[i]);
		a[++tot] = (info) {x[i], i};
		a[++tot] = (info) {y[i], i};
	}
	sort(a + 1, a + tot + 1);
	cout << min(solve1(), solve2()) << endl;
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;


ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int my_inv(int a) {
	return powmod(a, mod-2);
}


const int N=1e6+5;
int dp[N];
int answer[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];

    for(int i=0;i<n;i++){
        vector<int>ind;
        int x=v[i];
        for(int j=2;j*j<=x;j++){
            ind.push_back(j);
            while(x%j==0){
                dp[j]++;
                x/=j;
            }
        }
        if(x!=1){
            ind.push_back(x);
            dp[x]++;
        }
        for(int j: ind){
            answer[j]=max(answer[j],dp[j]);
            dp[j]=0;
        }
    }

    int lcm=1;
    for(int i=0;i<N;i++){
        int k=answer[i];
        for(int _=0;_<k;_++){
            lcm=mul(lcm,i);
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        int x=v[i];
        res=add(res,mul(lcm,my_inv(x)));
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long llu;
typedef long long ll;
typedef unordered_map<llu,llu>mymap;
typedef unordered_set<llu >myset;
#define endl '\n'

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	llu k,a,b;
	cin>>k;
	cin>>a>>b;
	llu count=0;
	for(llu i=a;i<=b;i++){
		if(i%k==0){count++;break;}
	}
	if(count==0){cout<<"NG";}
	else{cout<<"OK";}
	return 0;
	}



Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, W;
	cin >> N >> W;
	vector<ll> w(N);
	vector<ll> v(N);
	REP(i, N) cin >> w[i] >> v[i];
	vector<vector<ll>> dp(N, vector<ll>(101010, INF * INF));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	FOR(i, 1, N) REP(j, 101010) {
		dp[i][j] = dp[i - 1][j];
		if(j - v[i] >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
	}
	ll ans = 0;
	REP(i, 101010) if(dp[N - 1][i] <= W) ans = i;
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 80360
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fs first
#define se second
#define M 1000000007
ll exp(ll a,ll p)
{
	if(p==1)
		return a;
	if(p==0)
		return 1;
	ll st=exp(a,p/2);
	st=(st*st)%M;
	if(p%2 != 0)
		st=(st*a)%M;
	return st;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	string a,b,c;
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++)
	{
		c.pb(a[i]);
		c.pb(b[i]);
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int i, n, s, sum, head, tail, len, minlen;
  scanf("%d %d", &n, &s);
  int *a = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) scanf("%d", &a[i]);
  head = tail = sum = 0;
  minlen = n+1;
  for (i=0; i<n; i++) {
    sum += a[i];
    while (sum >= s) {
      len = i - tail + 1;
      if (len<minlen) minlen = len;
      sum -= a[tail];
      tail++;
    }
  }
  printf("%d\n", minlen>n?0:minlen);
  return 0;
}


Measured memory_bytes: 2188