akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e6+3;

const int MAX_NM=5e4+10;

int n,m,s;
vector<pair<int,int>> es;
vector<pair<int,ll>> dp(MAX_NM);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m,n){
        es.clear();
        rep(i,m){
            int a,b; cin >> a >> b; --a,--b;
            if (a>b) swap(a,b);
            if ((b-a)%2==0) continue;
            es.push_back({b-a,a});
        }
        if (n%2==1){
            cout << 0 << endl;
            continue;
        }
        es.push_back({n-1,0});
        sort(es.begin(),es.end());
        s=es.size();
        rep(i,n-1) dp[i]={i+1,1};
        rep(i,s){
            int b=es[i].first,a=es[i].second; b+=a;
            ll res1=1,res2=1,l1=a,r1=b,l2=a+1,r2=b-1;
            while(l1<r1){
                res1=res1*dp[l1].second%MOD;
                l1=dp[l1].first+1;
            }
            while(l2<r2){
                res2=res2*dp[l2].second%MOD;
                l2=dp[l2].first+1;
            }
            dp[a]={b,(res1+res2)%MOD};
        }
        cout << dp[0].second << endl;
    }
}


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

using namespace std;

typedef long long int lli;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,p,q,total=0;

#define read(in) freopen("Input.txt","r",stdin)

int main()
{
    //read(in);

    cin>>n>>m;

    double ar[n]={0.0},sum=0.0,sp=0.0;

    sp=1/(4.0*m);

    for(i=0 ; i<n ; i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }
    sp=sp*sum;

    sort(ar,ar+n);

    total=0;

    for(i=0 ; i<n ; i++)
    {
        if(sp<=ar[i])   total++;
    }

    if(total>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
s = input()

a = s[0]
b = s[1]
if len(s) == 2:
  print('1 2' if  a==b else '-1 -1')
  exit(0)
  
for i in range(2,len(s)):
  c = s[i]
  if c in (a,b):
    print('{} {}'.format(i-1,i+1) if a==c else '{} {}'.format(i,i+1))
    break
  else:
    a = b
    b = c
else:
  print(-1, -1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  char b[200],c[200];
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    cout<<b[i]<<c[i];
  }
  cout<<endl;
  return(0);
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 string ans = "No";
  int N;
  cin >> N;
  if(N/100 == 7) ans = "Yes";
  N -= N/100 * 100;
  if(N/10 == 7) ans = "Yes";
  N -= N/10 * 10;
  if(N == 7) ans = "Yes";
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  int mi = 1e9; int ma = 0;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    ma = max(ma, k);
    mi = min(mi, k);
  }
  cout << ma - mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x; cin >> x;
    int n1=x/100, n2=x/105;

    bool ans=0;
    for(int i=n2; i<=n1; ++i){
        if(i*100<=x && x<=i*105){
            ans=1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	}while(isdigit(ch));
	return res * sign;
}
ll n;
int main()
{
	cin >> n;
	cout << (n - 1) * n / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        vector<ll> a = divisor(i);
        if (a.size() == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int h, w, m;
vector<int> vec[300010];
int cnt[300010], cnt2[300010];
int ans;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> h >> w >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		vec[x].push_back(y);
		cnt2[y]++;
	}
	int ma = 0;
	for (int i = 1; i <= h; i++)ma = max(ma, (int)vec[i].size());
	int k = 0;
	for (int i = 1; i <= h; i++) {
		if ((int)vec[i].size() == ma) {
			k++;
			for (int j = 0; j < (int)vec[i].size(); j++)cnt[vec[i][j]]++;
		}
	}
	for (int i = 1; i <= w; i++) {
		if (cnt[i] == k)ans = max(ans, cnt2[i] + ma - 1);
		else ans = max(ans, cnt2[i] + ma);
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl mark;
vvl adj;

bool dfs(ll i, ll p = -1) {
	ll k = -1;
	mark[i] = 1;
	for (ll j: adj[i]) {
		if (j == p) continue;
		if (mark[j] == 2) continue;
		if (mark[j] == 1 || dfs(j,i)) {
			if (k == -1) {
				k = j;
			} else {
				cout << i+1 << " " << k+1 << endl;
				cout << i+1 << " " << j+1 << endl;
				k = -1;
			}
		}
	}
	mark[i] = 2;

	if (k == -1) return true;

	cout << i+1 << " " << k+1 << endl;
	cout << i+1 << " " << p+1 << endl;
	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;
	adj.resize(n);
	
	if (m%2 == 1) {
		cout << -1 << endl;
		return 0;
	}

	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	mark.resize(n);
	dfs(0);
}



Measured memory_bytes: 15488
A,B,K = list(map(int, input().split()))

Al = []
Bl = []

for i in range(1, A + 1):
    if A % i == 0:
        Al.append(i)

for i in range(1, B + 1):
    if B % i == 0:
        Bl.append(i)

ABl = []
for i in range(len(Al)):
    for j in range(len(Bl)):
        if Al[i] == Bl[j]:
            ABl.append(Al[i])

ABl.sort(key=lambda x: -x)

print(ABl[K - 1])

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=5e3+11,INF=~0u>>2;
struct Edge{int nxt,to;}edge[N];
int f[N],g[N][2],a[N],head[N],num_edge,n;
void add_edge(int from,int to){
	edge[++num_edge].nxt=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void dfs(int u){
	for(int i=head[u];i;i=edge[i].nxt) dfs(edge[i].to);
	int now=0,pre=1;
	g[0][now]=0;
	rep(i,a[u]) g[i][now]=INF;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		now^=1;pre^=1;
		range(j,0,a[u]) g[j][now]=INF;
		for(int j=a[u]-a[v];j>=0;j--) g[j+a[v]][now]=min(g[j+a[v]][now],g[j][pre]+f[v]);
		for(int j=a[u]-f[v];j>=0;j--) g[j+f[v]][now]=min(g[j+f[v]][now],g[j][pre]+a[v]);
	}
	f[u]=INF;
	range(i,0,a[u]) f[u]=min(f[u],g[i][now]);
} 
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	range(i,2,n){
		int tmp=read();
		add_edge(tmp,i);
	}
	rep(i,n) a[i]=read();
	dfs(1);
	rep(i,n) if(f[i]==INF){
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,s1;
    //vector<string>s1;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
        {
            s1.push_back('0');
        }
        else if(s[i]=='1')
        {
            s1.push_back('1');
        }
        else if(s[i]=='B' && s1.size()>0)
        {
            s1.erase(s1.end()-1);
        }
    }
    cout<<s1<<endl;
    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


s = input()
x, y = map(int, input().split())


# In[17]:


# s = 'FTFFTFFF'


# In[18]:


s = s + 'x'


# In[19]:


s


# In[54]:


renzoku = 1
xyres = [1 << 8000, 1 << 8000]
xy = 0
M = (1 << 16001) - 1
first = s[0] == 'F'
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        renzoku += 1
    else:
#         print(s[i], renzoku)
        if first:
            xyres[0] = 1 << (8000 + renzoku)
            first = False
        else:
            if s[i] == 'F':
                xyres[xy] = (xyres[xy] << renzoku) | (xyres[xy] >> renzoku) & M
            elif renzoku % 2 == 1:
                xy = 1 - xy
        renzoku = 1
        


# In[58]:


if xyres[0] & 1 << (8000 + x) and xyres[1] & 1 << (8000 + y):
    print('Yes')
else:
    print('No')


# In[ ]:






Measured memory_bytes: 40428
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(long long i=0;i<(ll)(n);i++)
using namespace std;

int main(){
  int n,c,k;
  cin>>n>>c>>k;
  int t[n];
  rep(i,n)cin>>t[i];
  sort(t,t+n);
  int ans=1,s=t[0],p=1;
  for(int i=1;i<n;i++){
    if(p+1>c or s+k<t[i]){
      //cout<<i<<"+"<<endl;
      ans++;
      s=t[i];
      p=1;
    }else p++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
# ABC050 C - Lining Up
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
a.sort()

if n%2==0:
    for aa in a:
        if aa%2==0:
            print(0)
            exit()
    
    for i in range(n):
        if i%2==0:
            if a[i]!=a[i+1]:
                print(0)
                exit()
    print((2**(n//2))%mod)
else:
    for aa in a:
        if aa%2==1:
            print(0)
            exit()
    for i in range(n-1):
        if a[0]!=0:
            print(0)
            exit()
        if i%2==1:
            if a[i]!=a[i+1]:
                print(0)
                exit()
    print((2**(n//2))%mod)  



Measured memory_bytes: 14008
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
const int N=2010;
ll n,x,a[N],mn[N],ans,sum;
int main(){
	scanf("%lld%lld",&n,&x);
	for(int i=0;i<n;i++) scanf("%lld",a+i),ans+=a[i];
	memset(mn,0x3f,sizeof(mn));
	for(int i=0;i<n;i++){
		sum=0ll;
		for(int j=0;j<n;j++) mn[j]=min(a[(j-i+n)%n],mn[j]),sum+=mn[j];
		ans=min(ans,sum+i*x);
	}printf("%lld\n",ans);
}

Measured memory_bytes: 128
s = input().strip()
if "C" in s:
    indc = s.index("C")
else:
    indc = 10**3
if "F" in s[indc:]:
    indf = indc+s[indc:].index("F")
else:
    indf = -1
if indc<indf:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
int main(void){
  int n,m;
  scanf("%d%d",&n,&m);
 int a[100001];
  for(int i=0;i<m;i++){
	scanf("%d",&a[i]);
  }
long long ans[n],mod=1000000007;
  int c=0;
  if(a[0]==1&&a[1]==2){ans[0]=0;
                       ans[1]=0;
                      c+=2;}
  else if(a[0]==1){ans[0]=0;
                   ans[1]=1;
                  c++;}
  else if(a[0]==2){ans[0]=1;
                   ans[1]=0;
                  c++;}
  else {ans[0]=1;
        ans[1]=2;
       }
  for(int i=2;i<n;i++){
	ans[i]=0;
  }
  //printf("%lld %lld\n",ans[0],ans[1]);
  
  for(int i=2;i<n;i++){
    if(c<n&&a[c]-1==i){c++;
                  
      continue;
                 }
	ans[i]=(ans[i-2]+ans[i-1])%mod;
   // printf("ans[%d]=%lld\n",i,ans[i]%mod);
  }
  printf("%lld",ans[n-1]);
  return 0;
}       

Measured memory_bytes: 1280
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, k) = get!(usize, usize);
    let aa = util::gets::<usize>();

    let mut h = HashMap::new();
    for &a in &aa {
        *h.entry(a).or_insert(0) += 1;
    }

    if h.len() <= k {
        println!("{}", 0);
    } else {
        let mut v: Vec<usize> = h.values().cloned().collect();
        v.sort();
        let ans = v.iter().take(v.len() - k).sum::<usize>();
        println!("{}", ans);
    }

}


Measured memory_bytes: 18060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()), m = Integer.parseInt(sc.next());
        boolean[] a = new boolean[n + 1];
        for (int i = 0; i < m; i++) {
            a[Integer.parseInt(sc.next())] = true;
        }
        int mod = 1000000007;

        int[] dp = new int[n + 1];
        dp[0] = 1;
        dp[1] = a[1] ? 0 : 1;
        for (int i = 2; i <= n; i++) {
            if (a[i]) continue;
            dp[i] = dp[i - 1] + dp[i - 2];
            if (dp[i] >= mod) {
                dp[i] -= mod;
            }
        }

        System.out.println(dp[n]);
    }
}


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

using namespace std;
using pii = pair<int, int>;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<pii> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].second >> v[i].first;
  }
  sort(v.begin(), v.end());
  int t = 0;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    t += v[i].second;
    if (t > v[i].first) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(str) scanf("%s",str)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define NL printf("\n")
#define Max 300005
#define INF 1e9
#define mod 1000000007
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDD(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int setb(int n,int pos) { return n=n | (1 << pos); }
int resb(int n,int pos) { return n=n & ~(1 << pos); }
bool checkb(int n,int pos) { return (bool)(n & (1 << pos)); }

int cnt[Max],n,k;
vector <int> v;

int main()
{
	int i,x;
	sii(n,k);
	rep(i,n)
	{
		si(x);
		cnt[x]++;
	}
	rep(i,n) 
	{
		if( cnt[i] ) v.pb(cnt[i]);
	}
	sort(v.begin(),v.end());
	int now = sz(v);
	int need = now - k;
	int ret = 0;
	for(int i = 0; i < need; i++) ret += v[i];
	pi(ret); NL;
	return 0;
}

Measured memory_bytes: 2168
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            boolean ok = false;

            if (S.charAt(0) == S.charAt(1) && S.charAt(1) == S.charAt(2)) ok = true;
            if (S.charAt(1) == S.charAt(2) && S.charAt(2) == S.charAt(3)) ok = true;

            out.println(ok == true ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 21844
N = int(input())
XYH = [tuple(map(int,input().split())) for i in range(N)]

cands = []
for cy in range(101):
    for cx in range(101):
        h_tmp = None
        for x,y,h in XYH:
            if h==0: continue
            d = abs(cy-y) + abs(cx-x)
            if h_tmp is None:
                h_tmp = h+d
            else:
                if h+d != h_tmp:
                    break
        else:
            cands.append((cx,cy,h_tmp))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        if max(ch - abs(x-cx) - abs(y-cy), 0) != h:
            break
    else:
        print(cx,cy,ch)

Measured memory_bytes: 3828
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < n;i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        int count = 0;
        for(int i = 0;i < n - 1;i++){
            if(list.get(i) <= x){
                count++;
                x -= list.get(i);
            } else {
                break;
            }
        }

        if(x == list.get(list.size()-1)){
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22736
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		matrix = new boolean[n][n];

		for(int i = 0; i < m; i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;

			matrix[a][b] = true;
			matrix[b][a] = true;
		}

		visit = new boolean[n];

		dfs(0);

		System.out.println(result);
	}

	static boolean matrix[][];
	static boolean visit[];
	static int result = 0;

	static void dfs(int v){
		visit[v] = true;

		int n = visit.length;

		boolean end = true;

		for(int i = 0; i < n; i++){
			if(!visit[i] && matrix[v][i]){
				end = false;
				dfs(i);
			}
		}

		if(end){
			int count = 0;
			for(int i = 0; i < n; i++){
				if(visit[i]){
					count++;
				}
			}

			if(count == n){
				result++;
			}
		}

		visit[v] = false;
	}
}

Measured memory_bytes: 22356
#include <iostream>
#define IsWithinMaxSugar (max_sugar * (water1 * times_water1 + water2 * times_water2) >= (sugar1 * times_sugar1 + sugar2 * times_sugar2))
#define IsWithinMaxSolution (max_solution >= (100 * (water1 * times_water1 + water2 * times_water2) + sugar1 * times_sugar1 + sugar2 * times_sugar2))
using namespace std;

int main() {

	int water1, water2, sugar1, sugar2, max_sugar, max_solution;
	cin >> water1 >> water2 >> sugar1 >> sugar2 >> max_sugar >> max_solution;

	double consentration, max_consentration = 0;
	double tmp_sugar, tmp_solution; //doubleにしておかないとconsentrationを計算するときint/intになって結果が０になってしまう
	int times_water1 = 0, times_water2 = 0, times_sugar1 = 0, times_sugar2 = 0, amount_of_solution = 0, amount_of_sugar = 0;

	for (times_water2 = 0; IsWithinMaxSolution; times_water2++) {
		for (; IsWithinMaxSolution; times_water1++) {
			for (; IsWithinMaxSugar && IsWithinMaxSolution; times_sugar2++) {
				for (; IsWithinMaxSugar && IsWithinMaxSolution; times_sugar1++) {
					tmp_sugar = sugar1 * times_sugar1 + sugar2 * times_sugar2;
					tmp_solution = (100 * (water1 * times_water1 + water2 * times_water2) + sugar1 * times_sugar1 + sugar2 * times_sugar2);
					if (tmp_solution == 0) consentration = 0;
					else {
						consentration = tmp_sugar / tmp_solution;
					}
					if (max_consentration <= consentration) {
						max_consentration = consentration;
						amount_of_sugar = tmp_sugar;
						amount_of_solution = tmp_solution;
					}
				}
				times_sugar1 = 0;
			}
			times_sugar2 = 0;
		}
		times_water1 = 0;
	}
	cout << amount_of_solution << " " << amount_of_sugar << endl;

	return 0;
}

Measured memory_bytes: 256
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print(101)
    else:
        print(1*n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(100*n)
else:
    if n == 100:
        print(1010000)
    else:
        print(10000*n)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    string S; cin>>S;
    int cnt[3]={0};

    for (int i = 0; i < S.length(); ++i) {
        cnt[S[i]-'a']++;
    }

    sort(cnt,cnt+3);

    if(cnt[2]-cnt[0]<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


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

using namespace std;

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

	for (int i = 0; i < num; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;

		vector<int> foo;
		foo.push_back(a * a);
		foo.push_back(b * b);
		foo.push_back(c * c);
		sort(foo.begin(), foo.end());

		if (foo[2] == foo[0] + foo[1])
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}



Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
int ans[1005][1005];
int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=1;i<=b;++i)
		for(int j=1;j<=a;++j)
			ans[i][j]=1;
	for(int i=b+1;i<=h;++i)
		for(int j=a+1;j<=w;++j)
			ans[i][j]=1;
	for(int i=1;i<=h;++i,puts(""))
		for(int j=1;j<=w;++j)
			cout<<ans[i][j];
	return 0;
}


Measured memory_bytes: 7520
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt= 0;
    cin>>n;
    char arr[n];
    for(int i =0; i<n; ++i){
        cin >>arr[i];
    }
    for(int j= 0; j+2 < n; ++j){
        if((arr[j]=='A')&&(arr[j+1]=='B')&&(arr[j+2]=='C')){
            ++cnt;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n) cin >>a[i];
  sort(all(a));
  int res1 = a[n-1];
  int res2 = 0;
  rep(i, n){
    double n2 = (double)res1 / 2;
    if (abs(n2 - (double)res2) > abs(n2 - (double)a[i])) res2 = a[i];
  }

  cout <<res1 <<" " <<res2 <<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;

int main() {
	string s;
	int k;
	cin >> s >> k;
	vector<string> v;
	int unko = min(k, (int)s.size());
	for (int i = 1; i <= unko;i++) {
		for (int j = 0; j <= s.size() - i; j++) {
			v.push_back(s.substr(j, i));
		}
	}
	sort(v.begin(), v.end());
	unique(v.begin(), v.end());

	cout << v[k - 1] << endl;
}



Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cctype>
#define int long long
#define rg register
using namespace std;
inline int read(){
	rg int s=0,f=0;
	rg char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
int a,b;
signed main(){
	a=read(),b=read();
	if(b==1){
		printf("0");
		return 0;
	}
	else if(b<=a){
		printf("1");
		return 0;
	}
	else if(a==2){
		printf("%lld",b/(a-1)-1);
		return 0;
	}
	else{
		if(!(b%(a-1)) or b%(a-1)==1){
			printf("%lld",b/(a-1));
			return 0;
		}
		else{
			printf("%lld",b/(a-1)+1);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    string S;
    cin >> S;
    int n[S.length()] = {}, left, countR = 1, countL = 0;
    for(int i = 1; i < S.length(); i++){
        if(S[i] == 'R' && S[i-1] == 'R'){
            n[i-1] = 0;
            countR++;
        }else if(S[i-1] == 'R'){
            n[i-1] += countR/2 + countR%2;
            n[i] += countR/2;
            countR = 0;
            left = i;
            countL++;
            if(i == S.length()-1)n[i]++;
        }else if(S[i] == 'R'){
            n[left] += countL/2 + countL%2;
            n[left-1] += countL/2;
            countL = 0;
            countR++;
        }else{
            n[i] = 0;
            countL++;
            if(i == S.length()-1){
                n[left] += countL/2 + countL%2;
                n[left-1] += countL/2;
            }
        }
    }
    for(int i = 0; i < S.length(); i++)cout << n[i] << " " ;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    links[a].append((b, c))
    links[b].append((a, c))

Q, K = map(int, input().split())

d = [float('inf')] * (N + 1)
d[K] = 0
q = [K]
while q:
    i = q.pop()
    for j, c in links[i]:
        if d[i] + c < d[j]:
            d[j] = d[i] + c
            q.append(j)

result = []
for _ in range(Q):
    x, y = map(int, input().split())
    result.append(d[x] + d[y])
print('\n'.join(str(v) for v in result))


Measured memory_bytes: 55376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n,sum = 0;
    cin >> n;
    vector<int> a(n+2);
    for (int i = 1; i < n+1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i <= n; ++i) {
        sum += abs(a[i+1]-a[i]);
    }
    for (int i = 0; i < n; ++i) {
        int tmp = sum;
        tmp -= abs(a[i]-a[i+1]);
        tmp -= abs(a[i+1]-a[i+2]);
        tmp += abs(a[i]-a[i+2]);
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.IOException;
import java.util.stream.Stream;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int[] A = Arrays.stream(getContents().get(1).split(" ")).mapToInt(Integer::parseInt).toArray();
        int len = A.length;
        int sw = 0;
        boolean flag = true;
        for(int i = 0; flag; ++i){
            flag = false;
            for(int j = len - 1;  j >= i + 1; --j){
                if(A[j] < A[j - 1]){
                    int v = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = v;
                    flag = true;
                    ++sw;
                }
            }
        }
        System.out.println(String.join(" ", Arrays.stream(A).mapToObj(String::valueOf).toArray(String[]::new)));
        System.out.println(String.valueOf(sw));
    }
    
    public static ArrayList<String> getContents() throws IOException{
        String line;
        ArrayList<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((line = br.readLine()) != null) list.add(line);
        
        return list;
    }
}


Measured memory_bytes: 30888
//g++ t2.cpp -o t2 && t2 < p.txt

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; typedef long long ll; const int M = 998244353;

struct unf {
  vector<int> v; unf(int n){v.resize(n); for(int i=0;i<n;i++) v[i]=i;}
  int root(int x) { if (v[x]==x) return x; return v[x]=root(v[x]);}
  void unite(int x,int y) {int p=root(x), q=root(y); if (p==q) return; v[p]=q;}
  bool same(int x, int y) {return root(x)==root(y);}
  void print() {for(int x:v) cout<<x<<" "; cout<<endl;}
};

int main() {
  int n,m; cin>>n>>m;
  unf u(m); int p[n];
  for(int i=0;i<n;i++) {
    int k; cin>>k;
    int c0; cin>>c0; c0--; p[i]=c0;
    for(int j=1;j<k;j++) {
      int c; cin>>c; c--;
      u.unite(c0,c); 
    }
  }
  for(int i=1;i<n;i++) {
    if (!u.same(p[0], p[i])) {
      cout<<"NO"<<endl; return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
//ABC154A.cpp

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	string S,T,U;
	int A,B;
	cin>>S>>T>>A>>B>>U;
	if(S==U)A-=1;
	else B-=1;
	cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
   string s;
   cin >> s;
   s += "Z";
   
   int ans = 0;
   int temp = 0;
   for(int i = 0;i < s.size();i++){
       if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
           temp++;
       }else{
           ans = max(ans,temp);
           temp = 0;
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, i, j;
    cin>>n;
    string s, a;
    cin>>s;
    for(i=0; i<n; i++) {
    	a.pb(s[i]);
    	j = i + 1;
    	while(j < n && s[j] == s[i]) {
    		j++;
    	}
    	i = j - 1;
    }
    cout<<a.size()<<"\n";	
}

Measured memory_bytes: 592
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    /** 区切り文字 */
    private static final String DELIMITER = " ";
    /** Hit数を格納したKEY値 */
    private static final String KEY_HIT = "hit";
    /** Blow数を格納したKEY値 */
    private static final String KEY_BLOW = "blow";

    /**
     * メインメソッド
     *
     * @param args
     */
    public static void main(String[] args) {
        // ローカルテスト用。提出時は"System.in"に修正。
        // File input = new File("D:/Temp/AOJ/0025_HitAndBlow.txt");
        InputStream input = System.in;

        try (Scanner scanner = new Scanner(input)) {
            while (scanner.hasNextLine()) {
                String[] targets = scanner.nextLine().split(DELIMITER);
                String[] expects = scanner.nextLine().split(DELIMITER);

                Map<String, Integer> result = countHitAndBlow(targets, expects);

                System.out.println(result.get(KEY_HIT) + DELIMITER
                        + result.get(KEY_BLOW));
            }
        } catch (Exception e) {
            // 対応しない。
        }
    }

    /**
     * Hit数とBlow数を求める。
     *
     * @param targets Aさんの数字4つを格納した配列
     * @param expects Bさんの数字4つを格納した配列
     * @return Hit数とBlow数を格納したMap
     */
    private static Map<String, Integer> countHitAndBlow(String[] targets,
            String[] expects) {
        Map<String, Integer> result = new HashMap<String, Integer>();

        // Hit数のカウント
        int hitCounter = 0;
        List<String> blowChecker = new ArrayList<String>();
        for (int i = 0; i < targets.length; i++) {
            if (targets[i].equals(expects[i])) {
                hitCounter++;
            } else {
                // Hitした（＝位置も同じ）数を除外してからBlow数をカウントするため、リストに詰めていく。
                blowChecker.add(targets[i]);
            }
        }

        // Blow数のカウント
        // Hitしたものは除外しているため、Listに含まれているかどうかだけでよい。
        int blowCounter = 0;
        for (String expect : expects) {
            if (blowChecker.contains(expect)) {
                blowCounter++;
            }
        }

        result.put(KEY_HIT, hitCounter);
        result.put(KEY_BLOW, blowCounter);

        return result;
    }
}

Measured memory_bytes: 25940
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int res;
    for(int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        if(!a) res = i+1;
    }


    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(){
	int input = 0;
	scanf("%d",&input);
	
	if(input<1200){
		printf("ABC\n");
	}else if(input<2800){
		printf("ARC\n");
	}else{
		printf("AGC\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
function Main(input) {
  var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  var C = parseInt(input.split(" ")[2]);
  
  var sevenCount = 0;
  var fiveCount = 0;
  
  if(A == 5){
     fiveCount++;
  }else if(A == 7){
     sevenCount++;
  }
  if(B == 5){
     fiveCount++;
  }else if(B == 7){
     sevenCount++;
  }
  if(C == 5){
     fiveCount++;
  }else if(C == 7){
     sevenCount++;
  }
  
  if(fiveCount == 2 && sevenCount == 1){
     console.log("YES");
     }else{
     console.log("NO");
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int n,l;cin>>n>>l;
    vs s(n);rep(i,n)cin>>s.at(i);

    sort(all(s));
rep(i,n)
cout<<s.at(i);

}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10^^5] NS;
int[10^^5] ORIGIN, DEPS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (i; 0..N+M-1) {
        auto ab = readln.split.to!(int[]);
        NS[ab[1]-1] ~= ab[0]-1;
    }

    int root;
    foreach (i; 0..N) {
        if (NS[i].empty) {
            root = i;
            break;
        }
    }
    ORIGIN[0..N] = -1;

    int deps(int me) {
        if (me == root) return 0;
        if (ORIGIN[me] != -1) return DEPS[me];
        auto cs = NS[me];
        int p, d = -1;
        foreach (c; cs) {
            auto dd = deps(c);
            if (d < dd) {
                p = c;
                d = dd;
            }
        }
        ORIGIN[me] = p;
        DEPS[me] = d+1;
        return d+1;
    }

    foreach (i; 0..N) {
        if (i == root || ORIGIN[i] != -1) continue;
        deps(i);
    }

    foreach (org; ORIGIN[0..N]) {
        writeln(org+1);
    }
}

Measured memory_bytes: 14972
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

	int n = s.size();

	if (s[n - 1] == '1' || s[0] == '0')
	{
		printf("-1\n");
		return 0;
	}

	s.pop_back();

	string rev = s;
	reverse(all(rev));

	if (s != rev)
	{
		printf("-1\n");
		return 0;
	}

	printf("1 2\n");

	int last = 2;
	int root = 2;

	for (int i = 2; 2 * i <= n; i++)
	{
		last++;
		printf("%d %d\n", root, last);

		if (s[i - 1] == '1')
			root = last;
	}

	for (int i = last + 1; i <= n; i++)
		printf("%d %d\n", root, i);

	return 0;
}

Measured memory_bytes: 1664
program main
  implicit none
  integer :: n, i, ts, ptr, cnt
  integer, allocatable :: t(:), v(:), dp1(:), dp2(:), v2(:), v3(:)
  read *, n
  allocate (t(n), v(n))
  read *, t
  read *, v
  ts = sum(t)
  allocate (v2(0:ts), v3(1:ts), dp1(0:ts), dp2(0:ts))

  ! 各時刻の最高制限速度
  v2 = 10 ** 9
  v2(0) = 0
  v2(ts) = 0
  ptr = 0
  do i = 1, n
    v2(ptr:ptr + t(i)) = min(v2(ptr:ptr + t(i)), v(i))
    ptr = ptr + t(i)
  end do

  ! 各half-時刻の最高制限速度 v3(i) は i-0.5の最高速度 (i = 1, ..., ts)
  ptr = 0
  do i = 1, n
    v3(ptr + 1:ptr + t(i)) = v(i)
    ptr = ptr + t(i)
  end do

  ! 加速制約による最高速度
  dp1(0) = 0
  do i = 1, ts
    dp1(i) = min(dp1(i - 1) + 1, v2(i))
  end do

  ! 減速制約による最高速度
  dp2(ts) = 0
  do i = ts - 1, 0, -1
    dp2(i) = min(dp2(i + 1) + 1, v2(i))
  end do

  dp1 = min(dp1, dp2)

  ! 三角屋根補正
  cnt = 0
  do i = 1, ts  ! i-0.5を扱う
    if (dp1(i - 1) == dp1(i) .and. dp1(i) < v3(i)) then
      cnt = cnt + 1
    end if
  end do

  print "(f0.6)", sum(dp1) + 0.25d0 * cnt
end program main


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

using namespace std;

typedef long long ll;
typedef long double ld;

struct Shop{
    string name;
    int point;
    int index;
};

static bool sortasc(const Shop &a,const Shop &b)
{
    if(a.name==b.name)
    {
        return a.point>b.point;
    }
    return a.name<b.name;
}

int main()
{
    vector<Shop> v;
    int n;
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        Shop s;
        cin>>s.name>>s.point;
        s.index = i;
        v.push_back(s);
    }
    sort(v.begin(),v.end(),sortasc);
    for(int i=0;i<n;i++)
        cout<<v[i].index<<endl;
    return 0;

}


Measured memory_bytes: 256
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll a, b, c;
	scanf("%ld %ld %ld", &a, &b, &c);
	printf("%ld\n", b + std::min(a+b+1, c));
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  if ( N%10==7 || (N-(N%10))%100==70 || N-(N%10)-((N-(N%10))%100)==700 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
  int n, a, b;
  vector<int> v;
  int c1 = 0, c2 = 0, c3 = 0;

  cin >> n;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x <= a) {
      c1++;
    }
    else if (x >= a + 1 && x <= b) {
      c2++;
    }
    else if (x >= b + 1) {
      c3++;
    }
  }

  int ans = min(min(c1, c2), c3);

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = list(input()[:-1])
S.reverse()
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
MOD = 10**9+7

for i in range(len(S)):
    p = pow(10, i, 13)
    
    if S[i]=='?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*p)%13] += dp[i][k]
                dp[i+1][(k+j*p)%13] %= MOD
    else:
        for j in range(13):
            dp[i+1][(j+int(S[i])*p)%13] += dp[i][j]
            dp[i+1][(j+int(S[i])*p)%13] %= MOD

print(dp[len(S)][5])

Measured memory_bytes: 65400
class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
 
    def set(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def kaiten(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.set(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.set(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.set(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.set(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def tansaku(self,top_num,front_num):
 
        self.save = [i for i in range(6)]
        for i in range(len(self.number)):
            self.save[i] = self.number[i]
 
        ret = -1;
 
        for i in range(len(self.order)):
            self.kaiten(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break
 
        #元の値の復元
        for i in range(len(self.number)):
            self.number[i] = self.save[i]
 
        return ret;
 
 
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.set(table[0], table[1], table[2], table[3], table[4], table[5])
 
num_query = int(input())
for loop in range(num_query):
    top_num,front_num = map(int,input().split())
    print("%d"%(dice.tansaku(top_num, front_num)))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,K;
  cin>>A>>B>>K;
  if(A+B<K)cout<<"0 0"<<endl;
  else if(A<K)cout<<"0 "<<A+B-K<<endl;
  else cout<<A-K<<" "<<B<<endl;
}

Measured memory_bytes: 256