akhauriyash/Code-Regression huggingface dataset:
X, N = map(int,input().split())
L = list(map(int,input().split()))

NL = []
for i in range(102):
    NL.append(i)

for l in L:
    NL.remove(l)

NL.append(X)
NL.sort()

LR = NL.index(X)+1
LL = NL.index(X)-1


if (NL[LR]-X) < (X-NL[LL]):
    print(NL[LR])
else:
    print(NL[LL])


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N, vector<int>(0));
  vector<P> edge(N-1);
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    edge[i].first = a; edge[i].second = b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  queue<int> node;
  vector<int> color(N, 0);
  vector<bool> seen(N, false);
  vector<int> depth(N);

  node.push(0);
  seen[0] = true;
  depth[0] = 0;

  int dep = 1;
  
  while (!node.empty()) {
    int p = node.front(); node.pop();
    int n = 1;
    
    for (auto q : G[p]) {
      if (!seen[q]) {
        seen[q] = true;
        depth[q] = dep;
        node.push(q);
        if (n != color[p]) {
          color[q] = n;
        }
        else {
          color[q] = ++n;
        }
        ans = max(ans, n);
        n++;
      }
    }
    dep++;
  }
  cout << ans << endl;
  for (int i = 0; i < N-1; i++) {
    if (depth[edge[i].first] > depth[edge[i].second]) {
      cout << color[edge[i].first] << endl;
    }
    else {
      cout << color[edge[i].second] << endl;
    }
  }
}

Measured memory_bytes: 7680
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int A,B,C,D,E;
int NA,NB,NC;
ll sums[1000001];
int main(){

  while(cin>>A>>B>>C>>D>>E&&(A|B|C|D|E)){
    cin>>NA>>NB>>NC;
    vector<int> v;
    for(int i=0;i<NC;i++)
      v.push_back(C);
    for(int i=0;i<NB;i++)
      v.push_back(B);
    for(int i=0;i<NA;i++)
      v.push_back(A);
    memset(sums,0,sizeof(sums));
    for(int i=0;i<(int)v.size();i++)
      sums[i+1]=sums[i]+v[i];
    ll res=1LL<<60;
    for(int i=0;i<(int)v.size();i++){
      ll sum=0;
      ll tmp=0;
      tmp+=sums[i+1];
      if(i+1>=D){
        if(tmp>(i+1)*E){
          sum=E*(i+1);
          //cout<<i<<" "<<sum<<endl;
        }
        else sum=tmp;
      }
      else{
        if(tmp>D*E)sum=D*E;
        else sum=tmp;
      }
      sum+=sums[(int)v.size()]-sums[(i+1)];
      //cout<<i<<" "<<sum<<endl;
      res=min(res,sum);
    }
    cout<<res<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 12052
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  string s;
  cin >> s;

   string ans = "No";
  if (s[0] != s[1]){
    if ((s[0] == s[2] && s[1] == s[3]) || (s[0] == s[3] && s[1] == s[2])) ans = "Yes";
  }
  else{
    if (s[2] == s[3] && s[0] != s[2]) ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


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

#define SQ(x) ((x) * (x))

int main(void)
{
    int s;
    int i;
    double x1, x2, x3;
    double y1, y2, y3;
    double a, b, c, d, e, f;
    double l, m, n;
    
    scanf("%d", &s);
    for (i = 0; i < s; i++){
        scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
        
        a = (x1 - x2);
        b = (y1 - y2);
        c = -1 * (SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2));
        d = (x1 - x3);
        e = (y1 - y3);
        f = -1 * (SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3));
        
        l = (c * e - b * f) / (e * a - b * d);
        m = (d * c - a * f) / (d * b - e * a);
        
        n = -1 * (SQ(x1) + SQ(y1) + l * x1 + m * y1);
        
        printf("%.3f %.3f %.3f\n", l / -2.0, m / -2.0, sqrt(SQ(l) + SQ(m) - 4 * n) / 2.0);
    }
    
    return (0);
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll N,X,T;
    cin >> N >> X >> T;
    cout << (N+X-1)/X*T << endl;
}

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

Measured memory_bytes: 3620
// 6/25 解き直し
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int dp[3010][3010];

int main() {
    int N, T;
    cin >> N >> T;
    // vector<int> A(N), B(N);
    // rep(i, N) cin >> A[i] >> B[i];
    vector<P> dish(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        dish[i] = P(a, b);
    }

    sort(dish.begin(), dish.end());

    dp[0][0] = 0;

    int ans = 0;

    rep(i, N) {
        // printf("dish[%d] = %d, %d\n", i, dish[i].first, dish[i].second);
        rep(j, T) {
            dp[i+1][j] = dp[i][j];
            if (j>=dish[i].first) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-dish[i].first]+dish[i].second);
            }
            // printf("dp[%d][%d] = %d\n", i+1, j, dp[i+1][j]);
        }

        int now = dp[i][T-1] + dish[i].second;
        ans = max(ans, now)
;    }

    // cout << dp[N-1][T-1] << endl;
    // cout << dish[N-1].first << endl;

    // cout << dp[N-1][T-1] + dish[N-1].second << endl;
    cout << ans << endl;
}

Measured memory_bytes: 38912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

using namespace std;
using PP = pair<int, int>;
int h, w;
int a[500][500];
vector<PP> v;

void pr(PP p, PP q) {
  cout << p.first + 1 << ' ' << p.second + 1 << ' '
    << q.first + 1 << ' ' << q.second + 1 << endl;
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      v.push_back(i % 2 == 0 ? PP(i, j) : PP(i, w - j - 1));
    }
  }
  
  long sum = 0;
  vector<pair<PP, PP>> ans;
  for (int k = 1; k < v.size(); ++k) {
    int i = v[k - 1].first;
    int j = v[k - 1].second;
    sum += a[i][j];
    if (sum % 2 == 1) {
      ans.push_back(make_pair(v[k - 1], v[k]));
    }
  }
  cout << ans.size() << endl;
  for (auto q : ans) {
    pr(q.first, q.second); 
  }
}


Measured memory_bytes: 7664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n-k) {
    if(a[i] < a[i+k]) cout << "Yes\n";
    else cout << "No\n";
  }
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int N,c=0;
    string S;
        cin >> S;
        N = S.size();
     for(int i=0; i<N; i++){
    if(i%2==0 && S[i]=='0'){
      c++;
        }
    else if(i%2==1 && S[i]=='1'){
        c++;
    }
     }
     cout << min(c,N-c) << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

void trace(int a[], int n) 
{
    for(int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}
void insertionSort(int a[], int n)
{
    for (int i = 1; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        
        a[j+1] = v;
        trace(a, n);
        
    }
}

            
int main()
{
    int a[100], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    trace(a,n);
    insertionSort(a, n);
    return 0;
}

Measured memory_bytes: 1160
/*
* @Author: dnhirapara
* @Date: 2020-04-25 18:57
* @Name: dp_a
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    // if(n<=2)ans = abs(a[0]-a[1]);
    ll dp[n] = {0};
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(ll i=2;i<n;i++){
            dp[i] = min(dp[i-2]+(abs(a[i]-a[i-2])),dp[i-1]+(abs(a[i]-a[i-1])));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1000200013;
const int Sz = 501;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, m;
vector < int > g[N], l, r;
bool in[N];

int main() {
  #ifdef wws
    freopen("in", "r", stdin);
   // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  int s, t;
  for (int i = 1, u, v;i <= m;i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
    s = u, t = v;
  }
  bool ch = 1;
  in[s] = in[t] = 1;
  l.pb(s);
  r.pb(t);
  while(ch) {
    ch = 0;
//    cout << s << " " << t << endl;
    for (auto x : g[s]) {
      if (!in[x]) {
        l.pb(x);
        s = x;
        ch = 1;
        break;
      }
    }
    in[s] = 1;
    for (auto x : g[t]) {
      if (!in[x]) {
        r.pb(x);
        t = x;
        ch = 1;
        break;
      }
    }
    in[t] = 1;
  }
  cout << (int)l.size() + r.size() << endl;
  for (int i = l.size() - 1;i >= 0;i--) cout << l[i] << " ";
  for (int i = 0;i < r.size();i++) cout << r[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 7036
#include<iostream>
#include<vector>
#include<stack>
using namespace std;

struct Vertex {
	int id;
	vector<int> vertices;
	int visited;
	int completed;
};

int getNext(Vertex vertices[], int id){
	Vertex v = vertices[id-1];
	int size = v.vertices.size();
	for(int i=0;i<size;i++){
		int nId = v.vertices[i];
		if (vertices[nId-1].visited==-1){
			return nId;
		}
	}
	return -1;
}

void dfs(int n, Vertex vertices[]){
	
	int time = 0;

	for(int i=0;i<n;i++){
		Vertex cur=vertices[i];
		stack<int> st;
		if(cur.visited==-1){
			st.push(cur.id);
		}
		while(!st.empty()){
			int id=st.top();
			if(vertices[id-1].visited==-1){
				vertices[id-1].visited=++time;
			}
			int nId=getNext(vertices,id);
			if(nId!=-1){
				vertices[nId-1].visited=++time;
				st.push(nId);
			} else {
				vertices[id-1].completed=++time;
				st.pop();
			}
		}
	}
}

int main(){
	int n;
	cin >> n;
	Vertex vertices[n];
	for(int i=0;i<n;i++){
		int id;
		cin >> id;
		vertices[i].id = id;
		vertices[i].visited = -1;
		vertices[i].completed = -1;
		int cnt;
		cin >> cnt;
		for(int j=0;j<cnt;j++){
			cin >> id;
			vertices[i].vertices.push_back(id);
		}
	}
	
	dfs(n,vertices);
	
	for(int i=0;i<n;i++){
		Vertex v = vertices[i];
		cout << v.id << " ";
		cout << v.visited << " ";
		cout << v.completed << endl;
	}
	return 0;
}



Measured memory_bytes: 3172
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int x[5];
  int k;

  for(int i=0;i<5;i++) cin >> x[i];
  cin >> k;

  if(x[4] - x[0] > k){
    puts(":(");
  } else {
    puts("Yay!");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m, sum = 0, t;
    cin >> n >> m;
    
    for(int i = 0; i < m; i++) {
        cin >> t;
        n -= t;
    }
    if(n < 0) n = -1;
    cout << n << endl;

  
    return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, H;
	cin >> N >> H;
	vector<int>c(N*2);
	map<int, int>mp;
	rep(i, N * 2) {
		cin >> c[i];
		if (i % 2==0)mp[c[i]] = 1;
	}
	ll cnt = 0;
	sort(c.begin(), c.end(),greater<int>());
	rep(i, N+1) {
		cnt++;
		H -= c[i];
		if (H <= 0) {
			cout << cnt << endl;
			return 0;
		}
		if (mp[c[i]]) {
			cnt += H / c[i] + (H%c[i] == 0 ? 0 : 1);
			cout << cnt << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
s = input()
C = []
x = s[0]
if x == '0':
    C.append(0)
cnt = 1
for i in range(1, n):
    if x != s[i]:
        C.append(cnt)
        cnt = 1
        x = s[i]
    else:
        cnt += 1
C.append(cnt)
if x != '1':
    C.append(0)
C = [0] + list(accumulate(C))
m = len(C)
if m < 2*k+1:
    print(C[-1])
else:
    ans = 0
    for i in range(2*k+1, m, 2):
        ans = max(ans, C[i] - C[i-(2*k+1)])
    print(ans)


Measured memory_bytes: 81632
s=list(input())
s1=s[2:-1]
f=True
if s[0]!='A':
	f=False
elif 'C' not in s1:
	f=False
else:
	s.remove('A')
	s.remove('C')
	if str(s).islower():
		pass
	else:
		f=False
if f:
	print('AC')
else:
	print('WA')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int H,W;
        Scanner sc = new Scanner(System.in);
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0 && W == 0)break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    System.out.printf("#");
                }
                System.out.println();
            }
            System.out.println();
            
        }
    }
}


Measured memory_bytes: 59396
#include <iostream>
#include <stack>
#include <vector>
#include <string>


using namespace std;
using ll = long long int;

string s, t;

vector<ll> map[26];

int main()
{
  cin >> s >> t;

  ll Ns = (ll)s.size();

  for (int c = 0; c < 26; c++) {
    map[c] = vector<ll>(100000);

    ll found = -1;
    for (ll i = (ll)s.size() - 1; i >= 0; i--) {
      if (s[i] == 'a' + c) {
        found = i;
      }
      map[c][i] = found;
    }
  }

  // check
  for (ll i = 0; i < (ll)t.size(); i++) {
    if (map[t[i] - 'a'][0] == -1) {
      // s doesnt have character t[i]
      cout << -1 << endl;
      return 0;
    }
  }

  ll total = 0;

  for (ll i = 0; i < (ll)t.size(); i++) {
//    cout << t[i] << " " << total << endl;
    // just match
    if (s[total % Ns] == t[i]) {
      total += 1;
    } else {
      // jump
      ll c = t[i] - 'a';
      ll foundpos = map[c][total % Ns];

      if (foundpos == -1) {
        foundpos = 0;
        total += Ns - (total % Ns);
        i--;
      } else {
        ll dpos = foundpos - (total % Ns);
        total += dpos + 1;
      }
    }
  }

  cout << total << endl;

  return 0;
}

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

const int nax=1e5+5;
ll dp[111][nax];
int n,w;
ll ww[111];
ll val[111];

int main()
{
    cin>>n>>w;
    for(int i=1;i<=n;i++) cin>>ww[i]>>val[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(ww[i]<=j) dp[i][j]=max(dp[i][j],dp[i-1][j-ww[i]]+val[i]);
        }
    }
    ll res=0;
    for(int i=0;i<=w;i++) res=max(res,dp[n][i]);
    cout<<res;
    return 0;
}


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

int main() {
  int N, X; cin >> N >> X;
  int bound = 1;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int L; cin >> L;
    sum += L;
    if (sum <= X) {bound++;}
  }
  cout << bound << endl;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX 1000

using namespace std;

int* sort(int*, int);

int main() {
    int n, k;
    int arr[MAX];
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int* ascending = sort(arr, n);
    int result = 0;
    for (int i = 0; i < k; i++) {
        result += ascending[i];
    }
    cout << result << endl;
    return 0;
}

int* sort(int* arr, int n) {
    for (int i = 0; i < n - 1; i++) {
        int min = i;
        for (int j = i + 1; j < n; j++) {
            if (arr[j] < arr[min]) {
                min = j;
            }
        }
        if (min != i) {
            int temp = arr[i];
            arr[i] = arr[min];
            arr[min] = temp;
        }
    }
    return arr;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef pair<string, string> SS;

const int maxn = 100550;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 2e18;
#define debug(x) cout << #x << " " << x << "\n";

int main()
{
    ios::sync_with_stdio(0);
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] != b[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll k; gi(k);
	iter(a, -2000, 2001) {
		iter(b, -2000, 2001) {
			if(a*a*a*a*a - b*b*b*b*b == k) {
				print(a), pc(' '), print(b);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))



using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

ll F(ll a, ll b) {
	ll c1=0, c2=0;
	while (a > 0) {
		a /= 10;
		c1++;
	}
	while (b > 0) {
		b /= 10;
		c2++;
	}
	return max(c1, c2);
}

int main() {
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	ll cost = min(4 * Q, min(2 * H, S));
	ll ans = 0;
	if (cost * 2 > D) {
		if (N % 2 == 0)ans = D * (N / 2);
		else ans = D * (N / 2) + cost;
	}
	else {
		ans = cost * N;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int n;
	cin >> n;
	if(n>=400&&n<600)
		printf("8");
	else if(n<800)
		printf("7");
	else if(n<1000)
		printf("6");
	else if(n<1200)
		printf("5");
	else if(n<1400)
		printf("4");
	else if(n<1600)
		printf("3");
	else if(n<1800)
		printf("2");
	else
		printf("1");
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M)
{
    cout << (N == M ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vvl = vector<vector<ll>>;
using vl = vector<ll>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(ll u, vvl &g, vl &ans, vector<bool> &used) {
  if (used[u])
    return;
  used[u] = true;
  AUTO(i, g[u]) dfs(i, g, ans, used);
  // 帰りがけ順で追加
  ans.push_back(u);
}

vl tsort(vvl &g, ll N) {
  vector<bool> used(N, false);
  vl ans;
  REP(i, N) dfs(i, g, ans, used);
  reverse(ans.begin(), ans.end());
  return ans;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vvl g(N);
  vvl parent(N);

  REP(i, N - 1 + M) {
    ll a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    parent[b - 1].push_back(a - 1);
  }

  vl ans = tsort(g, N);
  vl i2ans(N);
  REP(i, N) i2ans[ans[i]] = i;

  REP(i, N) {
    if (parent[i].size() == 0)
      cout << 0 << endl;
    else {
      ll m = -1;
      ll mi = -1;
      AUTO(j, parent[i]) {
        if (i2ans[j] > m) {
          m = i2ans[j];
          mi = j;
        }
        // cout << j + 1 << i2ans[j] << " ";
      }
      cout << mi + 1 << endl;
    }
  }

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


Measured memory_bytes: 17784
n,m = map(int, input().split())

ans = 1
for i in range(1,10**5):
    if m%i == 0:
        v = i
        cnt = m//i
        if cnt >= n:
            ans = max(ans,v)

        v = m//i
        cnt = i
        if cnt >= n:
            ans = max(ans,v)

print(ans)

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

int main() {
  int N, i, j;
  double sum = 0;
  cin >> N;
  
  vector<double> x(N);
  vector<string> u(N);
  
  for(i = 0; i < N; i++){
    cin >> x.at(i) >> u.at(i);
  }
  
  for(j = 0; j < N; j++){
    if(u.at(j) == "JPY"){
      sum += x.at(j);
    }
    else{
      sum += 380000.00000000 * x.at(j);
    }
  }

  cout << sum << endl;
  
}


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

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

  for(int i=0;i<n;i++){
    complex<long double> v[4];
    for(int j=0;j<4;j++){
      long double x,y;
      cin >> x >> y;
      v[j]=complex<long double>(x,y);
    }

    if((conj(v[1]-v[0])*(v[3]-v[2])).imag()==0.0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

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

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String line = br.readLine();
		String[] numbers = line.split(" ");
		int[] a = new int[n];
		
		for (int i = 0; i < numbers.length; i++) {
			a[i] = Integer.parseInt(numbers[i]);
		}
		
		printLine(a);
		
		for (int i = 1; i <= a.length - 1; i++) {
			int v = a[i];
			int j = i - 1;
			
			while(j >= 0 && a[j] > v){
				a[j + 1] = a[j];
				j--;
			}
			
			a[j + 1] = v;
			
			printLine(a);
			
		}
		
	}
	
	static void printLine (int[] b){
		String st = Integer.toString(b[0]);
		for (int k = 1; k < b.length; k++) {
			st += " " + b[k];
		}
		System.out.println(st);
	}
}

Measured memory_bytes: 36776
#include<stdio.h>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
char str[600][20];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int num[600][20];
long long mod=1000000007;
long long pow(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
typedef map<int,long long> vec;
typedef vector<vec> mat;
long long det(mat A){
	int n=A.size();
	long long val=1;
	for(int i=0;i<n;i++){
		int at=-1;
		for(int j=i;j<n;j++){
			if(A[j].count(i)&&A[j][i]){
				at=j;break;
			}
		}
		if(!~at)return 0;
		if(at!=i){
			swap(A[at],A[i]);
			val=(mod-val);
		}
		val=val*A[i][i]%mod;
		long long t=pow(A[i][i],mod-2);
		for(map<int,long long>::iterator it=A[i].begin();it!=A[i].end();it++){
			A[i][(*it).first]=(*it).second*t%mod;
		}
		for(int j=i+1;j<n;j++){
			if(A[j].count(i)&&A[j][i]){
				long long div=mod-A[j][i];
				for(map<int,long long>::iterator it=A[i].begin();it!=A[i].end();it++){
					if((*it).second==0){continue;}
					if(!A[j].count((*it).first))A[j][(*it).first]=(*it).second*div%mod;
					else A[j][(*it).first]=(A[j][(*it).first]+(*it).second*div)%mod;
				}
			}
		}
	}
	for(int i=0;i<n;i++)val=val*A[i][i]%mod;
	return val;
}
int main(){
	int a,b;
	int T=0;
	while(scanf("%d%d",&a,&b),a){
		T++;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		int at=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			num[i][j]=-1;
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]!='#')num[i][j]=at++;
		}
		mat A(at-1);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]!='#'){
				int deg=0;
				for(int k=0;k<4;k++){
					if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&~num[i+dx[k]][j+dy[k]]){
						deg++;
						if(num[i][j]<at-1&&num[i+dx[k]][j+dy[k]]<at-1){
							A[num[i][j]][num[i+dx[k]][j+dy[k]]]=mod-1;
						}
					}
				}
				if(num[i][j]<at-1)A[num[i][j]][num[i][j]]=deg;
			}
		}
	//	for(int i=0;i<at-1;i++,printf("\n"))for(int j=0;j<at-1;j++)printf("%lld ",A[i][j]);
		printf("Case %d: %lld\n",T,det(A));
	}
}

Measured memory_bytes: 18356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vll vector<ll>
#define M 100011
#define MOD 1000000007
ll md=MOD;
string s1;

ll a[10110];
ll dp[10110][110][2];
ll f(ll x,ll mod,ll k,ll m,ll sum){
	if(x<0){if(mod==0){return 1;}return 0;}
	if(dp[x][mod][k]!=-1&&k==0)return dp[x][mod][k];
	ll mx=9;
	if(k==1)mx=a[x];
	ll ans=0;
	for(ll i=0;i<=mx;++i){
		ll nc=0;
		if(i==a[x])nc=k;
		ans+=f(x-1,(mod+i)%m,nc,m,10*sum+i)%md;
		ans%=md;
	}
	dp[x][mod][k]=ans%md;
	return ans%md;

}


int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t,i,j,m,x,y,n,z,p,k,T;string s2,s3;x=1;
	cin>>s1>>m;
	n=s1.size();
	reverse(s1.begin(),s1.end());
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;++i)a[i]=s1[i]-'0';
	cout<<(f(n-1,0,1,m,0)%md-1+md)%md; 












	
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N  = fs.nextInt();
        char S[] = fs.next().toCharArray();
        int ans = 0;
        for (int i = 0; i + 2 < N; i++) {
          if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DChoosingPoints solver = new DChoosingPoints();
        solver.solve(1, in, out);
        out.close();
    }

    static class DChoosingPoints {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int d1 = in.nextInt();
            int d2 = in.nextInt();

            int cnt = 0;
            for (int i = 0; i < 2 * n; i++) {
                for (int j = 0; j < 2 * n; j++) {
                    int tmpI = i;
                    int tmpJ = j;
                    int tmpD1 = d1;
                    while (tmpD1 % 4 == 0) {
                        tmpI /= 2;
                        tmpJ /= 2;
                        tmpD1 /= 4;
                    }

                    boolean flg1;
                    if (tmpD1 % 2 == 1) {
                        flg1 = (tmpI + tmpJ) % 2 == 0;
                    } else {
                        flg1 = tmpI % 2 == 0;
                    }

                    tmpI = i;
                    tmpJ = j;
                    int tmpD2 = d2;
                    while (tmpD2 % 4 == 0) {
                        tmpI /= 2;
                        tmpJ /= 2;
                        tmpD2 /= 4;
                    }

                    boolean flg2;
                    if (tmpD2 % 2 == 1) {
                        flg2 = (tmpI + tmpJ) % 2 == 0;
                    } else {
                        flg2 = tmpI % 2 == 0;
                    }

                    if (flg1 && flg2) {
                        out.println(i + " " + j);
                        cnt++;
                        if (cnt == n * n) return;
                    }
                }
            }
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 38164
use std::cmp;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        val: [[i32; 3]; n],
    }

    let mut memo = [[-1; 3]; 100001];
    memo[0][0] = val[0][0];
    memo[0][1] = val[0][1];
    memo[0][2] = val[0][2];
    let mut maxv = 0;
    let r1 = dp(0, n-1, &mut memo, &val);
    if maxv < r1 {
        maxv = r1;
    }
    let r2 = dp(1, n-1, &mut memo, &val);
    if maxv < r2 {
        maxv = r2;
    }
    let r3 = dp(2, n-1, &mut memo, &val);
    if maxv < r3 {
        maxv = r3;
    }
    // println!("{} {} {}", r1, r2, r3);
    println!("{}", maxv);
}

fn dp(x: usize, i: usize, memo: &mut [[i32; 3]; 100001], val: &Vec<Vec<i32>>) -> i32 {
    // println!("x:{} i:{}", x, i);
    if memo[i][x] != -1 {
        // println!("memo x:{} i:{} = {}", x, i, memo[i][x]);
        return memo[i][x];
    }

    let index1 = (x + 1) % 3;
    let index2 = (x + 2) % 3;

    let v = cmp::max(dp(index1, i-1, memo, val), dp(index2, i-1, memo, val)) + val[i][x];
    // println!("x:{} i:{} = {}", x, i, v);
    memo[i][x] = v;
    return v
}


Measured memory_bytes: 17404
k = int(input())
a, b = map(int, input().split())

a1 = a//k
b1 = b//k
if (b1>a1):
    print("OK")
elif (a1 == b1 and (a%k == 0 or b%k ==0)):
    print("OK")
else:
    print("NG")

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

int digit(long long k){
    int cnt = 0;
    while(k){
        cnt++;
        k /= 10;
    }
    return cnt;
}

int main(){
    long long int n;
    cin >> n;
    int ans = 100;
    for(int i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            ans = min(ans,max(digit(i),digit(n/i)));
        }
    }
    cout << ans << endl;
    return 0;
}





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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    vector<int> a(100001);
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a[temp] = i + 1;
    }

    for(int i = 1; i <= n; i++)
        cout << a[i] << " ";

    return 0;
}


Measured memory_bytes: 1152
import Data.List

maximum' xs = if null xs then 0 else maximum xs

main = do
 s <- getLine
 let alphas = ['a'..'z']
 print (shrink alphas s)

shrink alphas s = minimum $ map (seg s) alphas

seg s c = maximum' $ map length $ words $ map (\c' -> if c'==c then ' ' else c') s

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < k; i++){
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i, c) for (int i = 0; i < c; i++)
#define MOD 1000000007
using namespace std;

int main() {
  double l;
  cin >> l;
  l /= 3;
  printf("%.12f\n", l*l*l);
  return 0;
}




Measured memory_bytes: 3668
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    char r, g, b;
    cin >> r >> g >> b;
    string temp;
    temp += r;
    temp += g;
    temp += b;
    if (stoi(temp) % 4 == 0) cout << "YES"; else cout << "NO";
}

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

int sum(int a) {
    int ans = 0;
    while (a > 0) {
        ans += a % 10;
        a /= 10;
    }
    return ans;
}

int main() {
    int i, j, n, ans;
    //freopen("input.txt", "r", stdin);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    ans = 1e9;
    for (i = 1; i < n; ++i)
        ans = min(ans, sum(i) + sum(n - i));
    cout << ans;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p, p + n);
    p[n - 1] /= 2;
    cout << accumulate(p, p + n, 0) << endl;
}

Measured memory_bytes: 256
N = int(input())
st = input()

s = []
t = []
for i in range(len(st)):
    if i == N:
        continue
    if i <= N:
        s.append(st[i])
    else:
        t.append(st[i])

ans = ""
for j in range(N):
    ans += s[j]+t[j]

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#define false -1
#define true 1
typedef struct{
  char design;
  int number;
}card;
int bubbleSort(card[],int);
int SelectionSort(card[],int);
int isStable(card[],card[],int);
int main(){
  int i,N = 0;
  scanf("%d",&N);
  card Card[N];
  for(i = 0; i < N; i++){
    scanf(" %c%d",&Card[i].design,&Card[i].number);
  }
  bubbleSort(Card,N);
  SelectionSort(Card,N);
  return 0;
}

int bubbleSort(card Card[],int N){
  int i,j;
  int count=0;
  card Ans[N],tmp;
  card Card2[N]; /*card change*/
  for(i = 0; i <= N-1; i++){
    Card2[i] = Card[i];
  }
  for(i =0; i <= N-1; i++){
    for(j = N-1; j>= i+1; j--){
    //printf("%d %d\n",i,j);
      if(Card2[j].number < Card2[j-1].number){
        tmp = Card2[j];
        Card2[j] = Card2[j-1];
        Card2[j-1] = tmp;
        count++;
      }
    }
  }
  for(i = 0; i <= N-1; i++){//
    if(0 < i){
      printf(" ");
    }
    printf("%c%d",Card2[i].design,Card2[i].number);/*??????*/
  }
  printf("\n");
  isStable(Card,Card2,N);
}

int SelectionSort(card Card[], int N){
  int i,j,minj;
  card tmp,Ans[N];
  for(i = 0; i <= N-1; i++){
    Ans[i] = Card[i];
    //printf("%c %d\n",Card[i].design,Card[i].number);
  }
  for(i = 0; i <= N-1; i++){
    minj = i;
    for(j = i; j <= N-1; j++){
      if(Card[j].number < Card[minj].number){
        minj = j;
      }
    }
    if(Card[i].number != Card[minj].number){
      tmp = Card[i];
      Card[i] = Card[minj];
      Card[minj] = tmp;
    }
  }
  for(i = 0; i <= N-1; i++){
    if(0 < i){
      printf(" ");
    }
    printf("%c%d",Card[i].design,Card[i].number);/*??????*/
  }
  printf("\n");
  isStable(Ans,Card,N);
}

int isStable(card in[],card out[],int N){
  int a,b,i,j;
  
  for(i = 0; i <= N-1; i++){
    for(j = i+1; j < N-1; j++){
      for(a = 0;a < N-1; a++){
        for(b = a+1; b < N-1; b++){
          if(in[i].number == in[j].number &&
             in[i].number == out[b].number &&
             in[j].number == out[a].number &&
             in[i].design == out[b].design &&
             in[j].design == out[a].design){
            printf("Not stable\n");
            return false;
          }
        }
      }
    }
  }
  printf("Stable\n");
  return true;
}

Measured memory_bytes: 612
using System;
using System.Collections.Generic;

namespace AOJ.Volume0
{
    class SwitchingRailroadCars
    {
        public static void Main()
        {
            Stack<int> train = new Stack<int>();

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                int no = int.Parse(input);
                if (no == 0)
                {
                    // 電車が出て行く
                    Console.WriteLine(train.Pop());
                }
                else { train.Push(no); }
            }
        }
    }
}

Measured memory_bytes: 5900