akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 1010;

int x;

int main()
{
    cin >> x;

    int res = 1;
    for(int i = 2; i <= x / i; i++)
    {
        int t = i, a = t;
        while(a <= x)
        {
            if(a > res) res = a;
            a = t * a;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int n, a[20][20],e;
	char d;
	cin >> n;
	for (int b = 0; b < 4; b++){
		for (int c = 0; c < 13; c++){
			a[b][c] = 0;
		}
	}
	for (int b = 0; b < n; b++){
		cin >> d >> e;
		if (d == 'S'){
			a[0][e - 1] = 1;
		}
		if (d == 'H'){
			a[1][e - 1] = 1;
		}
		if (d == 'C'){
			a[2][e - 1] = 1;
		}
		if (d == 'D'){
			a[3][e - 1] = 1;
		}
	}
	for (int f=0; f < 4; f++){
		for (int g=0; g < 13; g++){
			if (a[f][g] == 0){
				if (f == 0){
					cout << 'S' <<' '<< g+1 << endl;
				}
				if (f == 1){
					cout << 'H' << ' ' << g + 1 << endl;
				}
				if (f == 2){
					cout << 'C' << ' ' << g + 1 << endl;
				}
				if (f == 3){
					cout << 'D' << ' ' << g + 1 << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3068
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//vector<ll> cue: キューの宣言
//n重ループ：初期化の位置に注意
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

ll a(ll n, ll x) {
	ll r = pow(10, x);
	n = (n % r);
	n /= pow(10, x - 1);
	return n;
}

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

	for (int k = 1; k <= B; k++) {
		if ((k * A) % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p  = new int[n];
        int max = 0;
        int index = 0;
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();

        }
        Arrays.sort(p);

        int total = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            total += p[i];
        }

        System.out.println(total + p[n-1]/2);
    }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2)%mod;}
void comp() {
	ll i,j,k,n,m;
	string s,t;
	cin>>s>>t;
	ll ans=0;
	fl(i,s.length()) {
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<"\n";
}
int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.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;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;

using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {

    char c; cin >> c;
    if ('a' <= c and c <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
N=int(input().strip())
C=[0,]
S=[0,]
F=[0,]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c);S.append(s);F.append(f)
for i in range(1,N):
    dept=S[i]
    for j in range(i+1,N):
        arrive=dept+C[j-1]
        gap=arrive%F[j]
        dept=S[j] if arrive<=S[j] else arrive+((F[j]-gap)if gap>0 else 0)
    print(dept+C[N-1])
print(0)

Measured memory_bytes: 3188
def main():
    n = int(input())
    w1 = list(map(int,input().split()))
    w2 = list(map(int,input().split()))
    v1 = [0,0,0]
    for i in range(3):
        v1[i] = w2[i] - w1[i]
    dp1 = [0] * (n+1)
    for i in range(n):
        p = 0
        q = 0
        r = 0
        if i+1 - w1[0] >= 0:
            p = dp1[i+1 - w1[0]] + v1[0]
        if i+1 - w1[1] >= 0:
            q = dp1[i+1 - w1[1]] + v1[1]
        if i+1 - w1[2] >= 0:
            r = dp1[i+1 - w1[2]] + v1[2]
        dp1[i+1] = max(p,q,r,dp1[i])
    m = dp1[-1] + n

    v2 = [0,0,0]
    for i in range(3):
        v2[i] = w1[i] - w2[i]
    dp2 = [0] * (m+1)
    for i in range(m):
        p = 0
        q = 0
        r = 0
        if i+1 - w2[0] >= 0:
            p = dp2[i+1 - w2[0]] + v2[0]
        if i+1 - w2[1] >= 0:
            q = dp2[i+1 - w2[1]] + v2[1]
        if i+1 - w2[2] >= 0:
            r = dp2[i+1 - w2[2]] + v2[2]
        dp2[i+1] = max(p,q,r,dp2[i])
    print(m + dp2[-1])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 230296
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string S;

bool f(int c, int top, int len) {
	for (int i = 0; i < len; i++) {
		if (S[top + i] == c) {
			return true;
		}
	}
	return false;
}

int main(void) {
	int N;

	cin >> N;
	cin >> S;

	int max_num = 0;

	for (int i = 0; i < N; i++) {
		int mid = i + 1;
		int num = 0;
		for (int c = 'a'; c <= 'z'; c++) {
			bool b1 = f(c, 0, mid);
			bool b2 = f(c, mid, N - mid);
			if (b1 && b2) {
				++num;
			}
		}

		if (num > max_num) {
			max_num = num;
		}
	}

	cout << max_num << endl;

	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	float a[n],sum=0;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=1.0/a[i];
	}
	
	cout<<1.0/sum;
	
		
}

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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll DIM = 100007;
const ll INF = 1000000007;
ll n,m,k;
ll a,b,c;
ll v[DIM],ans[DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
      {

cin>>v[i];a=INF;
for(ll j=1;j<=k;j++)
    if(j<i)a=min(a,abs(v[i-j]-v[i])+ans[i-j]);else break;
if(i==1)a=0;
ans[i]=a;
      }

      cout<<ans[n];
    return 0;
}


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

using namespace std;

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

  vector<pair<int, int>> vab(m);
  vector<set<int>> va(n);
  for (auto &p : vab) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    p.first = a;
    p.second = b;
    va[a].insert(b);
    va[b].insert(a);
  }

  bool ans = false;
  for (auto &s : va[0]) {
    if (va[s].count(n - 1) > 0) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << '\n';

  return 0;
}

Measured memory_bytes: 32744
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

vector<vector<int> > graph(200001);
long long int ans[200001];
long long int cost[200001] = {};

void solve(int node, long long int nowcost)
{
	long long int newcost = nowcost + cost[node];
	ans[node] = newcost;
	for(int i = 0; i < graph[node].size(); i++){
		int next = graph[node][i];
		if(ans[next] >= 0) continue;
		solve(next, newcost);
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	memset(ans, -1, sizeof(ans));
	for(int i = 0; i < q; i++){
		int p;
		long long int x;
		cin >> p >> x;
		p--;
		cost[p] += x;
	}
	solve(0, 0);
	for(int i = 0; i < n; i++){
		cout << ans[i];
		if(i == n - 1) cout << endl;
		else cout << " ";
	}
}

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

ll c[10][10];

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		string s = to_string(i);
		c[s[0] - '0'][s.back() - '0']++;
	}
	ll ans = 0;
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++){
			ans += c[i][j] * c[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;
    static int[][] books;
    static int[] algos;
    static int algoLen;
    static int minKnowledge;
    static long result = -1;
    static int bookLen;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        bookLen = in.intNext();
        algoLen = in.intNext();
        minKnowledge = in.intNext();
        books = new int[bookLen][algoLen+1];
        for (int i = 0; i < bookLen; i++) {
            int[] book = in.nextIntArray(algoLen + 1);
            books[i] = book;
        }
        algos = new int[algoLen];
        solve(0, 0);
        out.println(result);

        out.close();
    }

    static void solve(int idx, long cost) {
        if (idx >= bookLen) return;
        cost += books[idx][0];
        add(idx, cost);

        solve(idx + 1, cost);

        cost -= books[idx][0];
        subtract(idx);
        solve(idx + 1, cost);
    }

    static void add(int bookNum, long cost) {
        boolean isValid = true;
        int[] book = books[bookNum];
        for (int i = 0; i < algoLen; i++) {
            algos[i] += book[i + 1];
            if (algos[i] < minKnowledge) isValid = false;
        }
        if (isValid && (result == -1 || cost < result)) result = cost;
    }

    static void subtract(int bookNum) {
        int[] book = books[bookNum];
        for (int i = 0; i < algoLen; i++) {
            algos[i] -= book[i + 1];
        }
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

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

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

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 34808
#ABC070-C TLE
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    g=gcd(a,b)
    return a*b//g

n=I()
t=[]
ans=1
for i in range(n):
    tmp=I()
    ans=lcm(ans,tmp)
print(ans)

Measured memory_bytes: 3064
program atcoder
    implicit none
    integer(8) :: n,k,i,ans=10000000000_8
    integer(8),allocatable,dimension(:) :: a,b
    read*,n,k
    allocate( a(n) )
    allocate( b(n) )
    read(*,*)(a(i),i=1,n)
    call mergesort(a,1_8,n,b)
    do i=1,n-k+1
        ans = min(ans,a(i+k-1)-a(i))
    enddo
    write(*,'(I0)')ans
!----------------------functions--------------------------
contains
recursive subroutine mergesort(a, p, r, b)
  integer(8) a(:), b(:)
  integer(8) p, r
  integer(8) q
  if (p < r) then
    q = (p+r)/2
    call mergesort(a, p, q, b)
    call mergesort(a, q+1, r, b)
    call merge(a, p, q, r, b)
  end if
end subroutine mergesort
subroutine merge(a, p, q, r, b)
    integer(8) a(:), b(:)
    integer(8) p, r, q, i, j, k
    integer(8) t
    k = p;   i = p;   j = q+1
    do
      if (.not. (k <= r)) exit
      if (j > r) then
        t = a(i);   i = i+1
      else if (i > q) then
        t = a(j);   j = j+1
      else if (a(i) <= a(j)) then
        t = a(i);   i = i+1
      else
        t = a(j);   j = j+1
      end if
      b(k) = t;   k = k+1
    end do
    do i = p, r
      a(i) = b(i)  
    end do
end subroutine merge
end program atcoder

Measured memory_bytes: 2304
import java.util.*;
import java.math.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      Integer K = Integer.parseInt(sc.next());
      String S = sc.next();

      String answer = K >= S.length() ? S : S.substring(0,K) + "...";

      System.out.println(answer);
    }
}


Measured memory_bytes: 38492
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    ll a[n],s[n+1],p[(n*(n+1))/2];
    s[0]=0;
    rep(i,n){
     cin>>a[i];
     s[i+1]=s[i]+a[i];
    }
    ll c=0;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<=n;j++){p[c]=s[j]-s[i];c++;}
    sort(p,p+(n*(n+1))/2,greater<ll>());
    ll ans=0;
    for(int i=40;i>=0;i--){
        ll b=1ll<<i;
        int r=0;
        for(ll j=0;j<(n*(n+1))/2;j++){
            if ((b&p[j])!=0) r++;

        }
        if (r>=k){
            ans|=b;
            for(ll j=0;j<(n*(n+1))/2;j++){
            if ((b&p[j])==0) p[j]=0;
        }
     }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

void DFS(vector<vector<int> >& G,
        vector<pair<int, int> >& rec, int i) {
    if (rec[i].first != -1) return;
    static int t = 1;
    rec[i].first = t++;
    for (int j = 1; j <= G[i].size(); j++) {
        if (G[i][j]) DFS(G, rec, j);
    }
    rec[i].second = t++;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        int num, k;
        cin >> num >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[i][v] = 1;
        }
    }
    vector<pair<int, int> > record(n + 1, make_pair(-1, -1));
    int t = 1;
    for (int i = 1; i <= n; i++) {
        DFS(G, record, i);
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << record[i].first
                  << " " << record[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u)a--;
	else b--;
	cout<<a<<' '<<b<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
  int d[]={0,2,5,5,4,5,6,3,7,6};
  int n,m;
  cin >> n >> m;
  int a[20];
  FOR(i,m){
    cin >> a[i];
  }

  string dp[10010],s;

  FOR(i,10001){
    dp[i]="";
  }
  
  for(int i=1;i<=n;i++){
    FOR(j,m){
      if(d[a[j]]<=i){
        if(dp[i-d[a[j]]]=="" && i-d[a[j]]!=0)continue;
        if(dp[i].size()<dp[i-d[a[j]]].size()+1){
          dp[i]=dp[i-d[a[j]]];
          dp[i]+=('0'+a[j]);
          sort(dp[i].begin(),dp[i].end());
          reverse(dp[i].begin(),dp[i].end());
        }else if(dp[i].size()==dp[i-d[a[j]]].size()+1){

          s=dp[i-d[a[j]]];
          s+=('0'+a[j]);
          sort(s.begin(),s.end());
          reverse(s.begin(),s.end());
          if(dp[i]<s){
            dp[i]=s;
          }
        }
      }
    }
  }


  cout << dp[n] << endl;


}


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

using namespace std;

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

    int diff = B - A;

    if (diff <= 0) cout << "delicious" << endl;
    else if (diff > X) cout << "dangerous" << endl;
    else cout << "safe" << endl;
    
    return 0;
}

Measured memory_bytes: 3552
package main

import "fmt"

func lcm(a, b uint64) uint64 {
	if b%a == 0 {
		return a
	}
	return lcm(b%a, a)
}

func gcd(a, b uint64) uint64 {
	if a > b {
		a, b = b, a
	}
	return a / lcm(a, b) * b
}

func main() {
	var n uint64
	fmt.Scan(&n)
	t := make([]uint64, n)
	for i := uint64(0); i < n; i++ {
		fmt.Scan(&t[i])
	}
	ans := t[0]
	for i := uint64(1); i < n; i++ {
		ans = gcd(ans, t[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string s;

// 65-90
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> N;
  cin >> s;
  char ans[s.size()];

  rep(i, s.size()) {
    int n = s[i]-'0';
    if (n+N<=42) ans[i] = (char)('0'+n+N);
    else {
      int d = n-26+N;
      ans[i] = (char)('0'+d);
    }
  }

  rep(i, s.size()) cout << ans[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main(void) {
    int h, w, m,a,b,mh=0,mw=0,cnt=0,hc; cin >> h >> w >> m;
    vector<pair<int, int>> v(m);vector<int> H(h, 0), W(w, 0);
    rep(i, m) {
        cin >> a >> b;v[i] = { --a,--b };
        chmax(mh,++H[a]);chmax(mw, ++W[b]);
    }rep(i, m) {
        if (H[v[i].first] == mh && W[v[i].second] == mw) cnt++;
    }hc = count(ALL(H), mh) * count(ALL(W), mw);
     cout << mh + mw - (hc == cnt) << endl;
}

Measured memory_bytes: 8008
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToList();

            a.Sort();
            Console.WriteLine(a[n - 1] - a[0]);
        }
    }
}

Measured memory_bytes: 28184
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
l = make_divisors(n)
a = 0
b = 0
min = 10**13
for i in range(len(l)):
    a = l[i]
    b = n/l[i]
    if (a-1) + (b-1) < min:
        min = (a-1) + (b-1)
print(int(min))

Measured memory_bytes: 39024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++){
        cin >>a[i];
    }
    int b[n];
    for (int i=0; i<n; i++){
        b[i]=a[i];
    }
    sort(a,a+n);
    int x=a[n/2-1];
    int y=a[n/2];
    for (int i=0; i<n; i++){
        if (b[i]<=x){
            cout << y <<endl;
        }
        else {
            cout << x << endl;
        }
    }
}

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

int main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans=0;
    if(k%2==1) ans = b-a;
    else ans = a-b;
    if(1e+18<abs(ans)){
        cout << "Unfair" << endl;
    }
    else cout << ans << endl;
    


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{ 
   ll int n;
   cin>>n;
   ll int a[n],i,j,k;
   for(i=0;i<n;i++)
   {
   	cin>>a[i];
   }
   sort(a,a+n);
   ll int ans=0;
   for(i=0;i<n-2;i++)
   {
   	for(j=i+1;j<n-1;j++)
   	{
   		for(k=j+1;k<n;k++)
   		{
   			if (a[i]!=a[j] && a[j]!=a[k])
   			{
   				if (a[i]+a[j]>a[k])
   				ans++;
			   }
		   }
	   }
   	
   }
   cout<<ans<<endl;
}
   



	
		
	
	
	
	




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 5e5 + 5;

ll fac[nax], iv[nax], n, m;

ll pangkat(ll x, ll y){
	if(y == 0){
		return 1;
	}
	ll temp = pangkat(x, y / 2);
	if(y & 1){
		return temp * temp % mod * x % mod;
	}
	else{
		return temp * temp % mod;
	}
}

ll c (ll x, ll y){
	return fac[x] * iv[y] % mod * iv[x-y] % mod;
}

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

	fac[0] = 1;
	for(ll i = 1; i < nax; i++){
		fac[i] = fac[i-1] * i % mod;
	}
	iv[nax-1] = pangkat(fac[nax-1], mod - 2);
	for(ll i = nax - 2; i >= 0; i--){
		iv[i] = iv[i+1] * (i + 1) % mod;
	}
	cin >> n >> m;
	ll ans = 0;
	for(ll i = 0; i <= n; i++){
		ll ret = (fac[m] * iv[m-n] % mod) * c(n, i) % mod * (fac[m-i] * iv[m-n] % mod) % mod;
		if(i & 1){
			ans -= ret;
		}
		else{
			ans += ret;
		}
		ans = (ans + mod) % mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 11444
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 401;
const int INF = -9999999;

int main(){
  int n,m,a,b,c,g[MAX][MAX];
  fill(g[0],g[MAX],INF);

  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> a >> b >> c;
    g[a][b] = c;
  }

  for(int k = 0 ; k < n ; k++)
    for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < n ; j++)
	g[i][j] = max(g[i][j],g[i][k]+g[k][j]);

  cout << g[0][n-1] << endl;

  return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 55;

class C{
  public:
    int x1, x2, y1, y2, d1, d2;
    C(int _x1, int _x2, int _y1, int _y2, int _d1, int _d2){
      x1 = _x1; x2 = _x1;
      y1 = _y1; y2 = _y1;
      d1 = _d1; d2 = _d1;
    }
    C(){}
};

vector<int> X, Y, D;
int f[MAX_N * 2][MAX_N * 2][MAX_N * 2];

int main() {
  int N, K; cin >>N >>K;
  vector<C> v(N);
  set<int> xs, ys, ds;
  REP(i, N){
    cin >>v[i].x1 >>v[i].y1 >>v[i].d1 >>v[i].x2 >>v[i].y2 >>v[i].d2;
    xs.insert(v[i].x1); xs.insert(v[i].x2);
    ys.insert(v[i].y1); ys.insert(v[i].y2);
    ds.insert(v[i].d1); ds.insert(v[i].d2);
    //X[i * 2] = v[i].x1;
    //X[i * 2 + 1] = v[i].x2;
    //Y[i * 2] = v[i].y1;
    //Y[i * 2 + 1] = v[i].y2;
    //D[i * 2] = v[i].d1;
    //D[i * 2 + 1] = v[i].d2;
  }
  X = vector<int>(xs.begin(), xs.end());
  Y = vector<int>(ys.begin(), ys.end());
  D = vector<int>(ds.begin(), ds.end());

  map<int, int> dex, dey, ded;
  REP(i, X.size()) dex[X[i]] = i;
  REP(i, Y.size()) dey[Y[i]] = i;
  REP(i, D.size()) ded[D[i]] = i;

  //for(map<int, int>::iterator it = dex.begin(); it != dex.end(); ++it) cout <<it->first <<", " <<it->second <<endl;

  REP(i, v.size()){
    int nowx1 = dex[v[i].x1]; int nowx2 = dex[v[i].x2];
    int nowy1 = dey[v[i].y1]; int nowy2 = dey[v[i].y2];
    int nowd1 = ded[v[i].d1]; int nowd2 = ded[v[i].d2];
    FOR(x, nowx1, nowx2)
      FOR(y, nowy1, nowy2)
        FOR(d, nowd1, nowd2) f[x][y][d] += 1;
  }

  long long int ans = 0;
  REP(x, X.size()){
    REP(y, Y.size()){
      REP(d, D.size()){
        if (f[x][y][d] < K) continue;
        //cout <<"========" <<endl;
        //cout <<x <<", " <<y <<", " <<d <<endl;
        long long int dx = X[x + 1] - X[x];
        long long int dy = Y[y + 1] - Y[y];
        long long int dd = D[d + 1] - D[d];
        //cout <<dx <<", " <<dy <<", " <<dd <<endl;
        ans += dx * dy * dd;
      }
    }
  }
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 5500
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  // 時刻から極座標を計算
  double pi = M_PI;
  double arcH = -2*pi*h/12 + (-2*pi/12)*m/60 + pi/2, arcM = -2*pi*m/60 + pi/2;
  // 極座標系を直交座標系に変換
  double xH = a*sin(arcH), yH = a*cos(arcH), xM = b*sin(arcM), yM = b*cos(arcM);
  // 距離を計算
  double ans = sqrt(pow(xH-xM,2)+pow(yH-yM,2));

  cout << std::setprecision(10);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4040
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[1000];
void push(int x){
  S[++top]=x;
}
int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];
  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s)); 
    }
  }
  printf("%d\n",pop());
  
  return 0;
}

Measured memory_bytes: 548
#include <iostream>

using namespace std;

int main() {
  char s[3];
  int si[3];
  int count = 0;
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
    si[i] = s[i] - '0';
    if (si[i] == 1)
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::marker::*;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        d: usize,
        t: usize,
        s: usize,
    }

    println!("{}", if t * s >= d { "Yes" } else { "No" })
}


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

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	string s;
	bool foundC = false;
	cin >> s;
	if (s[0]!='A'){
		cout << "WA" << endl;
		return 0;
	}
	for (int i=1; i<s.length(); i++){
		//debug(s[i]);
		if ((s[i]>=97 && s[i]<=122) || (s[i]>=65 && s[i]<=90)){
			//debug(foundC);
			if (s[i]>=65 && s[i]<=90 && s[i]!='C'){
				cout << "WA" << endl;
				return 0;
			}
			if (i>=2 && i<=s.length()-2){
				if (s[i]=='C'){
					if (foundC){
						cout << "WA" << endl;
						return 0;
					}
					foundC = true;
				}
			}
		}else{
			cout << "WA" << endl;
			return 0;
		}
	}
	
	if (foundC){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int inDegree[110000];
int dist[110000];
vector<int> edges[110000];
bool wasVisited[110000];

void dfs(int a)
{
  assert(!wasVisited[a]);
  wasVisited[a] = true;
  rep(i, edges[a].size())
  {
    int b = edges[a][i];
    dist[b] = max(dist[b], dist[a] + 1);
    inDegree[b]--;
    if (inDegree[b] == 0)
      dfs(b);
  }
}

int main()
{
  int n, m;
  cin >> n >> m;
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    inDegree[b]++;
  }
  for (int i = 1; i <= n; i++)
    if (!wasVisited[i] && inDegree[i] == 0)
      dfs(i);

  int ans = 0;
  for (int i = 1; i <= n; i++)
    ans = max(ans, dist[i]);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
//#define lop(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << "\n";


}

Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys, math, fractions, itertools

MOD = 5  # type: int
YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(A: int, B: int, C: int):
    flag = False
    for i in range(B):
        if i * A % B == C:
            flag = True
    if flag:
        print('YES')
    else:
        print('NO')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    if(a>=b){
        for(int i=0;i<a;i++){
            cout << b;
        }
    }else{
        for(int i=0;i<b;i++){
            cout << a;
        }
    }
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

if A > B:
  A, B = B, A
  
D = B - A

if D % 2 == 0:
  print(D // 2)
  exit()
else:
  answer = (D - 1) // 2 + min(A, N - B + 1)
  print(answer)
  exit()
  




Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  string a,b;
  cin>>n>>a>>b;
  int ans;
  if(a[0]==b[0])ans=3;
  else ans=6;
  for(int i=0;i<n-1;i++){
    if(a[i]==b[i])ans*=2;
    else if(a[i+1]!=b[i+1]&&a[i]!=a[i+1])ans*=3;
    ans%=1000000007;
  }
  cout<<ans<<endl;
  return 0;
}


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

const int INF = 1<<30;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<int> A(H), B(H);
    for(int i=0; i<H; i++)
    {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    map<int, int> path;
    multiset<int> dist;
    for(int i=0; i<W; i++)
    {
        path[i] = i;
        dist.insert(0);
    }

    for(int i=0; i<H; i++)
    {
        int idx = -1;
        for(auto itr = path.lower_bound(A[i]); itr != path.end() && itr->first <= B[i] + 1; itr = path.erase(itr))
        {
            chmax(idx, itr->second);
            auto ditr = dist.find(itr->first - itr->second);
            dist.erase(ditr);
        }
        if(idx != -1 && B[i] + 1 < W)
        {
            path[B[i] + 1] = idx;
            dist.insert(B[i] + 1 - idx);
        }
        if(dist.size() == 0)
        {
            cout << "-1\n";
        }
        else
        {
            cout << *dist.begin() + i + 1 << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 23492
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a[n] = 2000000000;
    sort(a.begin(),a.end());
    int ans = 0;
    int count = 0;
    for(int i=0;i<n;i++){
        if(a[i] > 100000){
            ans ++;
        }
        else{
            count ++;
            if(a[i] != a[i+1]){
                if(count >= a[i]){
                    ans += count-a[i];
                    count =0;
                }
                else{
                    ans += count;
                    count = 0;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

llu gcm(llu x, llu y){
  llu r = 0;
  if(x<y) swap(x,y);

  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
llu lcm(llu x, llu y){
  return  x * (y / gcm(x, y));
}



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int cnt2 = 0;
  REP(i,n){
    int a;
    cin >> a;
    if(a%4==0){
      cnt2 += 2;
    }else if(a%2==0){
      cnt2++;
    }
  }
  if(n-cnt2 <= n%2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200000+9,mod=1e9+7;
int d[N][3];
int main(){
    GO();

    int T;
  //  cin>>T;
    T=1;
    while(T--){

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

        for(int i=0;i<n;i++){
            if(i+2>=n) break;
            if((d[i][0]==d[i][1])&&(d[i+1][0]==d[i+1][1])&&(d[i+2][0]==d[i+2][1])){
                cout<<"Yes\n";
                return 0;
            }
        }
        cout<<"No\n";
    }
}



















































































































































































Measured memory_bytes: 3648
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:k])
m = s
for i in range(1, n-k+1):
  s = s-p[i-1]+p[i+k-1]
  if s > m:
    m = s
print((m+k)/2)

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

using namespace std;

const int N = 100000 + 77 , L = 16;
int n , A , a[N] , T[L];
int dp[1 << L] , XOR[1 << L];
vector < int > V;
int main() {
   scanf("%d" , & n);
   for(int v , u , x , i = 1;i < n;++ i)
      scanf("%d %d %d" , & v , & u , & x) , a[++ v] ^= x , a[++ u] ^= x;
   for(int i = 1;i <= n;++ i)
      ++ T[a[i]];
   T[0] = 1;
   for(int i = 1;i < L;++ i)
      A += (T[i] >> 1) , T[i] &= 1;
   for(int i = 1;i < L;++ i)
      if(T[i] > 0)
         V.push_back(i);

   int sz = V.size();
   for(int msk = 1;msk < (1 << sz);++ msk) {
      dp[msk] = N - 1;
      for(int i = 0;i < sz;++ i)
         if((1 << i) & msk)
            XOR[msk] ^= V[i];
      if(XOR[msk] > 0)
         continue ;
      dp[msk] = __builtin_popcount(msk) - 1;
      for(int sub = msk;sub > 0;sub = (sub - 1) & msk)
         if(XOR[sub] == 0)
            dp[msk] = min(dp[msk] , dp[sub] + dp[msk ^ sub]);
   }
   printf("%d\n" , A + dp[(1 << sz) - 1]);
   return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    string s;
    cin>>s;
    int q;
    cin>>q;
    bool b=true;
    vector<char> v[2];

    while(q--){
        int t;
        cin>>t;
        if(t==1){
            b=!b;
        }else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1&&b||f==2&&!b){
                v[0].PB(c);
            }else{
                v[1].PB(c);
            }
        }
    }

    if(b){
        rrep(i,v[0].size()-1){
            cout<<v[0][i];
        }
        cout<<s;
        rep(i,v[1].size()){
            cout<<v[1][i];
        }
        cout<<endl;
    }else{
        rrep(i,v[1].size()-1){
            cout<<v[1][i];
        }
        rrep(i,s.size()-1){
            cout<<s[i];
        }
        rep(i,v[0].size()){
            cout<<v[0][i];
        }
        cout<<endl;
    }



}


Measured memory_bytes: 976
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int N;
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        if((int)(i*1.08)==N){
            printf("%d",i);
            return 0;
        }
    }
    printf(":(");
}


Measured memory_bytes: 1688
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,int((n**0.5))+1):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
        

        

Measured memory_bytes: 39556
#include <iostream>
#include <set>
using namespace std;
set<string> memo;
string reverse(string s)
{
  string ret = s;
  for(int i=0; i<s.length(); i++){
    ret[i] = s[s.length()-i-1];
  }
  return ret;
}
int main()
{
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    memo.clear();
    string s;
    cin >> s;
    memo.insert(s);
    for(int j=1; j<s.length(); j++){
      string s1 = s.substr(0,j);
      string s2 = s.substr(j);
      string revs1 = reverse(s1);
      string revs2 = reverse(s2);
      memo.insert(s1+revs2);
      memo.insert(s2+s1);
      memo.insert(s2+revs1);
      memo.insert(revs1+s2);
      memo.insert(revs1+revs2);
      memo.insert(revs2+s1);
      memo.insert(revs2+revs1);
    }
    cout << memo.size() << endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  ans += min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  ans -= min(c, k);
  cout << ans << endl;
}


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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int n;
	vector<int> p;
	int in;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> in;
		p.pb(in);
	}
	int ans = 0;
	sort(p.begin(), p.end());
	for(int i = 0; i < p.size()-1; i++)
		ans += p[i];
	cout << ans + p[p.size()-1]/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    string a, b;
    cin >> a >> b;
    int aa = stoi(a), bb = stoi(b);
    if(aa == 1){ aa = 14; }
    if(bb == 1){ bb = 14; }
    cout << (aa < bb ? "Bob" : aa == bb ? "Draw" : "Alice") << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF 2000000000
#define INFLL 9000000000000000000
using namespace std;
int main(void)
{
	int n, ans=0;

	cin>>n;

	vector<int> a(n);

	rep(i, n) cin>>a[i];

	vector<int> count(100000, 0);

	rep(i, n){
		if(a[i]>100000){
			ans++;
		}else{
			count[a[i]-1]++;
		}
	}

	rep(i, 100000){
		if(count[i]<i+1){
			ans+=count[i];
		}else if(count[i]>i+1){
			ans+=count[i]-i-1;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1024