akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val LR = Array(M) {
        readLine()!!.split(" ").map(String::toInt).let { Pair(it[0], it[1]) }
    }
    Math.max(LR.map { it.second }.min()!! - LR.map { it.first }.max()!! + 1, 0).let(::println)
}

Measured memory_bytes: 60908
a, b, x = map(int,input().split())

if a%x == 0 :
    first = a // x
else :
    first = ( a + x - a%x ) // x

if b%x == 0 :
    end = b // x
else :
    end = ( b - b%x ) // x

ans = end - first + 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

inline void readInt2(int *a, int *b) {
  int c, p = 0; char s[20] = "";
  for(int i = 0; (c = getchar()) != '\n'; i++) {
    if (c == ' ') { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
    else s[i] = c;
  }
  *b = atoi(s+p);
}

inline void readInt3(int *a, int *b, int *c) {
  int d, p = 0; char s[20] = "";
  for(int i = 0; (d = getchar()) != '\n'; i++) {
    if(d == ' ') {
      if(p == 0) { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
      else {*b = atoi(s+p); strcpy(s, ""); p = i+1; continue; }
    } else s[i] = d;
  }
  *c = atoi(s+p);
}

struct edge {
    int from, to;
    edge(int from, int to) : from(from), to(to) {}
};

int n, k, l, p, q;
vector<edge> v1, v2;
map<pair<int, int>, int> mp;

int par[2][200005], ranks[200005];

void init() {
    rep(i,n) {
        par[0][i] = par[1][i] = i;
        ranks[i] = 0;
    }
}

int find(int x, int i) {
    if (par[i][x] == x) {
        return x;
    } else {
        return par[i][x] = find(par[i][x], i);
    }
}

void unite(int x, int y, int i) {
    x = find(x, i);
    y = find(y, i);
    if (x == y) return;

    if (ranks[x] < ranks[y]) {
        par[i][x] = y;
    } else {
        par[i][y] = x;
        if (ranks[x] == ranks[y]) ranks[x]++;
    }
}

bool same(int x, int y, int i) {
    return find(x, i) == find(y, i);
}

void solve() {
    init();

    rep(i,v1.size()) {
        unite(v1[i].from, v1[i].to, 0);
    }
    memset(ranks, 0, sizeof(ranks));
    rep(i,v2.size()) {
        unite(v2[i].from, v2[i].to, 1);
    }

    rep(i,n) {
        mp[make_pair(find(par[0][i], 0), find(par[1][i], 1))]++;
    }
}

int main(void) {
    readInt3(&n, &k, &l);
    rep (i,k) {
        readInt2(&p, &q);
        v1.push_back(edge(p-1, q-1));
    }
    rep (i,l) {
        readInt2(&p, &q);
        v2.push_back(edge(p-1, q-1));
    }

    solve();

    rep(i,n-1) {
        printf("%d ", mp[make_pair(find(par[0][i], 0), find(par[1][i], 1))]);
    }
    printf("%d\n", mp[make_pair(find(par[0][n-1], 0), find(par[1][n-1], 1))]);
    return 0;
}


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

n, k = map(int, input().split())
a = [int(item) for item in input().split()]
l = 0; r = 1000000001
while r - l > 1:
    mid = (l + r) // 2
    cnt = 0
    for item in a:
        cnt += (item - 1) // mid
    # Can be cut in k times
    if cnt <= k:
        r = mid
    else:
        l = mid

print(l + 1)

Measured memory_bytes: 92180
def tyoudo(a,b,c,x):
  ans=0
  for i in range(a+1):
    for ii in range(b+1):
      for iii in range(c+1):
        if x==500*i+100*ii+50*iii:
          ans+=1
  return ans
a=int(input())
b=int(input())
c=int(input())
x=int(input())
print(tyoudo(a,b,c,x))

Measured memory_bytes: 3064
_,m=gets.chomp.split.map(&:to_i)
d=[]
for i in 1..m do
  d<<gets.chomp.split.map(&:to_i)+[i]
end
d.sort!
ans=[]
tmp=[0,0]
for ary in d do
  if tmp[0]!=ary[0] then
    tmp[0]=ary[0]
    tmp[1]=0
  end
  tmp[1]+=1
  str="0"*(6-ary[0].to_s.length)+ary[0].to_s+"0"*(6-tmp[1].to_s.length)+tmp[1].to_s
  ans[ary[2]]=str
end
ans.each do |v|
  puts v
end


Measured memory_bytes: 17640
//半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	double r = 0;
	double pai = 3.14159265359;
	
	scanf("%lf", &r);
	printf("%f %f\n", r*r*pai, 2 * r*pai);
	return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>

int A[1000000], n;

int binarysearch(int key){
    int left = 0;
    int right = n;
    int middle;
    
    while(left<right){
        middle = (left+right)/2;
        if(key==A[middle]) return 1;
        if(key>A[middle]) left=middle+1;
        else if(key<A[middle]) right=middle;
    }
    return 0;
}

int main(){
    int i,m,k,sum=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d",&k);
        if(binarysearch(k)) sum++;
    }
    
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 2148
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vector<vector<ll> >G(100010);
void dfs(ll v,vl& dist,ll p=-1){
  for(auto nv:G[v]){
    if(nv==p)continue;
    dist[nv]+=dist[v]+1;
    dfs(nv,dist,v);
  }
}
    
int main(){
  ll n;cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<ll>dist1(n),dist2(n);
  ll f_cnt=0,s_cnt=0;
  dfs(0,dist1);
  dfs(n-1,dist2);
  rep(i,n){
    if(dist1[i]<=dist2[i])f_cnt++;
    else s_cnt++;
  }
  if(f_cnt>s_cnt)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}
  
  
  

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


int main(){
  string s;
  cin >> s;
  rep(i,4){
    s[i] -= '0';
  }
  int a[2];
  bool m[2];
  
  rep(i,2){
    a[i] = s[2*i]*10 + s[2*i+1];
    if(a[i]>0 && a[i]<=12)
      m[i] = true;
    else
      m[i] = false;
  }
  
  if(m[0]&&!m[1])
    cout << "MMYY" << endl;
  else if(!m[0]&&m[1])
    cout << "YYMM" << endl;
  else if(m[0]&&m[1])
    cout << "AMBIGUOUS" << endl;
  else if(!m[0]&&!m[1])
    cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
n,x= map(int,input().split())
a = list(map(int, sys.stdin.readline().split()))
ru = [0]*(n+1)
for i in range(1,n+1):
  ru[i] = ru[i-1]+a[i-1]
ans = float("inf")
for i in range(1,(n+1)//2+1):
  tmp = x*i+ru[n]*5
  j = n-i*2
  while j > 0:
    tmp += ru[j]*2
    j -= i
  ans = min(ans,tmp)
print(ans+n*x)

Measured memory_bytes: 25744
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


int n;
string s1, s2;

int main(){
    cin >> n;
    cin >> s1 >> s2;
    vector<int> row;
    for(int i = 0;i < n;){
        if(s1[i] == s2[i]){
            row.push_back(1);
            i++;
        }
        else{
            row.push_back(2);
            i+=2;
        }
    }
    int last = 0;
    Int ans = 1;
    for(auto r: row){
        if(last == 0 && r == 1)ans *= 3;
        if(last == 0 && r == 2)ans *= 6;
        if(last == 1 && r == 1)ans *= 2;
        if(last == 1 && r == 2)ans *= 2;
        if(last == 2 && r == 1)ans *= 1;
        if(last == 2 && r == 2)ans *= 3;
        ans %= MOD;
        last = r;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定, iのｊ番目のbitが立っている
            for x,y in testimony[j]:#jの証言をiterate
                if (i>>x)&1 != y: # xのビット（0,1)とjの発言(0,1)が矛盾している
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Measured memory_bytes: 3064
//07
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    vector<string> v(n);
    for(int i=0;i<n;i++){
      cin>>v[i];
    }
  res:
    for(int i=0;i<v.size();i++){
      for(int j=0;j<v.size();j++){
	if(i==j)continue;
	if(v[i].find(v[j])!=string::npos){
	  v.erase(v.begin()+j);
	  goto res;
	}
      }
    }
    int l[14][14];
    for(int i=0;i<v.size();i++){
      for(int j=0;j<v.size();j++){
	for(int k=min(v[i].size(),v[j].size());;k--){
	  if(v[i].substr(v[i].size()-k,k)==v[j].substr(0,k)){
	    l[i][j]=v[j].size()-k;
	    break;
	  }
	}
      }
    }
    int dp[1<<14][14];
    fill(dp[0],dp[1<<14],1<<30);
    for(int i=0;i<v.size();i++){
      dp[1<<i][i]=v[i].size();
    }
    for(int i=0;i<1<<v.size();i++){
      for(int j=0;j<v.size();j++){
	for(int k=0;k<v.size();k++){
	  dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+l[j][k]);
	}
      }
    }
    cout<<*min_element(dp[(1<<v.size())-1],dp[1<<v.size()])<<endl;
  }
  return 0;
}

Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_set>
using namespace std;

int main() {
	unordered_set<int>u;
	int a, b, c;
	cin >> a >> b >> c;
	for (int d = 0;; d++) {
		int e = d * 60 + c;
		int f = e % (a + b);
		if (f <= a) { cout << e << endl; return 0; }
		if (u.find(f) != u.end()) { puts("-1"); return 0; }
		else u.insert(f);
	}
}

Measured memory_bytes: 3124
#include<stdio.h>
int main()
{
int n;
int i;
scanf("%d",&n);
for(i=3;i<=n;i++)
{
 if(i%3==0)
 {
  printf(" %d",i);
 }
 else if(i%10==3)
 {
  printf(" %d",i);
 }
 else if(i/10%10==3)
 {
  printf(" %d",i);
 }
 else if(i/100%10==3)
 {
  printf(" %d",i);
 }
 else if(i/1000%10==3)
 {
  printf(" %d",i);
 }


}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
 int main(void){
  int a,b,c;
  int d;
   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   d=a-b;
   while(d>=c){
   d=d-c;
}
 printf("%d",d);
   return 0;
 }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

const int maxv = 100100;
int n,W,v[110],w[110];
ll dp[110][maxv];

int main() {
  cin >> n >> W;
  rep(i,n)
  cin >> w[i] >> v[i];

  rep(i,n)rep(j,maxv)
  dp[i][j]=1e12;
  dp[0][0]=0;

  rep(i,n){
    rep(j,maxv){
      if(v[i]<=j)
      dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      else 
      dp[i+1][j]=dp[i][j];
    }
  }

  ll ans=0;
  rep(i,maxv)if(dp[n][i]<=W)
  ans=i;
  cout << ans << endl;
}

Measured memory_bytes: 80128
y,x = map(int,input().split())
str = [["#" for i in range(x+2)]for i in range(y+2)]
a = [0 for i in range(y)]
for i in range(y):
    a[i] = input()
for i in range(1,y+1):
    for z in range(1,x+1):
        check = a[i-1]
        str[i][z] = a[i-1][z-1]

for i in range(y+2):
    print("".join(str[i]))

Measured memory_bytes: 3064
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    ans = 0
    for i in range(10 ** 5 + 1):
        ans = max(ans, C[i - 1] + C[i] + C[i + 1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 93388
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

int main(void){
	bool ok=true;
	ll n,m,a[100010],visited[100010]={},f=0,ans=0;
	vector<ll> v[100010],team[100010];
	cin>>n>>m;
	rep(i,n)cin>>a[i];//0-origin
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i,n){
		if(visited[i]==0){
			visited[i]=1;
			queue<ll> Q;
			Q.push(i);
			while(!Q.empty()){
				ll p=Q.front();Q.pop();
				team[f].push_back(p);
				rep(j,v[p].size()){
					ll q=v[p][j];
					if(visited[q]==0){
						visited[q]=1;
						Q.push(q);
					}
				}
			}
			f++;
		}
	}
	//連結成分はf個なので，木を作るためには少なくともf-1本の辺が必要．つまり，2(f-1)個の点が必要．
	if(f==1){
		ans=0;
	}else{
		//少なくとも１つの連結成分で１つは点を使わないといけない（これはちゃんと取ることができる）．
		//値が最も小さい点をとる
		vector<ll> left;//残った点
		rep(i,f){
			ll min_id=0;
			rep(j,team[i].size()){
				if(a[team[i][min_id]]>a[team[i][j]])min_id=j;
			}
			ans+=a[team[i][min_id]];
			team[i].erase(team[i].begin()+min_id);//使う点を抜く
			rep(j,team[i].size())left.push_back(a[team[i][j]]);//残った点をまとめる
		}
		if(left.size()<2*(f-1)-f){//点が足りなかったら
			ok=false;
		}else{
			sort(left.begin(),left.end());
			rep(i,f-2){//小さい順に2(f-1)-f個とる
				ans+=left[i];
			}
		}
	}
	if(ok){
		cout<<ans<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;
    string s;
    map<string, lint> appear;
    rep(i, N) {
        cin >> s;
        sort(s);
        if (appear.count(s)) {
            appear[s]++;
        }
        else {
            appear[s] = 1;
        }
    }
    lint ana = 0;
    for (auto x : appear) {
        ana += x.second * (x.second - 1) / 2;
    }
    cou(ana);


}

Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main(){
long i,n;
string s,t;
stringstream ss;
char c;
while(cin>>s){
ss.str("");ss.clear();t="";
ss<<s;
while(ss>>c){
if(c=='@'){
ss>>c;n=c-48;
ss>>c;
for(i=0;i<n;i++)t+=c;
}else{
t+=c;
}
}
cout<<t<<endl;
}
return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    print("ABC" + to_string(N));
}


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

int main(){
  int n,p;
  int prime[101000];

  for(int i=0;i<101000;i+=2)prime[i] = 0;
  for(int i=1;i<101000;i+=2)prime[i] = 1;
  prime[1] = 0;
  prime[2] = 1;

  int c = 3;
  while(c*c<101000){
    for(int i=3*c;i<101000;i+=c)prime[i] = 0;
    while(!prime[++c]);
  }

  while(1){
    cin >> n >> p;
    if(n<0 && p<0)break;

    vector<int> e;
    for(int i=0;i<p;i++){
      while(!prime[++n]);
      e.push_back(n);
    }

    vector<int> c;
    for(int i=0;i<(int)e.size();i++){
      for(int j=i;j<(int)e.size();j++){
	c.push_back(e[i] + e[j]);
      }
    }

    sort(c.begin(),c.end());
    cout << c[p-1] << endl;
  }
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

using Graph = vector<vector<int>>;

vector<bool> seen;

ll dfs(const Graph &G, int v, ll c) {
  seen[v] = true;

  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    int d = dfs(G, next_v, 1);
    c += d;
  }
  return c;
}

void solve(ll N, ll M, std::vector<ll> A, std::vector<ll> B) {
  Graph G(N);

  rep(i, M) {
    G.at(A.at(i)).push_back(B.at(i));
    G.at(B.at(i)).push_back(A.at(i));
  }

  seen.assign(N, false);
  ll ans = 0;
  rep(i, N) { ans = max(ans, dfs(G, i, 1)); }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  std::vector<ll> A(M);
  std::vector<ll> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    // 0-indexed
    A.at(i)--;
    B.at(i)--;
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 26548
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll u=n,d=-1;
    while(u-d>1){
        ll mid=(u+d)/2;
        bool dp[n+1][k+1];
        memset(dp,0,sizeof dp);
        dp[0][0]=true;
        rep(i,0,n){
            if(i==mid){
                rep(j,0,k+1){
                    dp[i+1][j]|=dp[i][j];
                }
                continue;
            }
            rep(j,0,k+1){
                dp[i+1][j]|=dp[i][j];
                if(j+a[i]<=k){
                    dp[i+1][j+a[i]]|=dp[i][j];
                }
            }
        }
        ll y=-1;
        rrep(i,k-1,0){
            if(dp[n][i]){
                y=i;
                break;
            }
        }
        //cout<<y<<endl;
        if(y+a[mid]>=k)u=mid;
        else d=mid;
    }
    cout<<u<<endl;
}


Measured memory_bytes: 24832
def main():
    N=int(input())
    A=list(map(int,input().split()))

    A.sort(reverse=True)

    res=A[0]

    counter=1

    while counter<=N-2:
        index = (counter + 1) // 2
        res+=A[index]
        counter+=1

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 105292
import java.util.Scanner;

public class Main {
    public static void main(String args[] ) throws Exception {
    	new Main().exec(args);
    }

    public Main() {
    }

    public void exec(String args[]) throws Exception {
    	//初期化読み込み
    	Scanner sc = new Scanner(System.in);
    	int K = sc.nextInt();
    	int T = sc.nextInt();
    	sc.nextLine();
    	String s = sc.nextLine();
    	String[] ss = s.split(" ");
    	int[] a = new int[ss.length];
    	int max=0;
    	int total=0;
    	int total_without_max=0;
    	for (int i=0; i<a.length; i++){
    		a[i] = Integer.parseInt(ss[i]);
    		if(max<a[i]) {
    			max=a[i];
    		}
    		total += a[i];
    	}
    	total_without_max = total-max;
    	int ans = 0;
    	if(total_without_max + 1 < max) {
    		ans = max - total_without_max - 1;
    	}

    	System.out.println(ans);
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  int ans = 0;
  int over = 0;
  set<int> val;
  REP(i, n){
    int now = a[i]/400;
    if (now >= 8) over++;
    else if (val.count(now) == 0){
      val.insert(now);
      ans++;
    }
  }
  int max_val = ans + over;
  int min_val = ans;
  if (ans == 0) min_val = 1;
  cout << min_val << ' ' << max_val << endl;
  return 0;
}

Measured memory_bytes: 3624
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	int n,k;
	cin>>n>>k;
	vi in(n);
	rep(i,k){
		int a;
		cin>>a;
		rep(j,a){
			int b;cin>>b;
			in[b-1]=1;
		}
	}
	int c=0;
	rep(i,n)if(in[i]==0)c++;
	cout<<c<<endl;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

enum {DOWN, STABLE, UP};

int main() {
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	fori(i, 0, n) {
		scanf("%d", &v[i]);
	}
	int ans = 1;
	int dir = STABLE;
	fori(i, 1, n) {
		if(v[i] > v[i - 1]) {
			if(dir == DOWN) {
				ans++;
				dir = STABLE;
			}
			else {
				dir = UP;
			}
		}
		else if(v[i] < v[i - 1]) {
			if(dir == UP) {
				ans++;
				dir = STABLE;
			}
			else {
				dir = DOWN;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  int count = 1;
  rep(i, n-1) {
      if (s[i] == s[i+1])
      {
          continue;
      }
      count++;
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
def dfs(index, A, B, C, X ):
    global n, ans, a, b, c
    # print(A, B, C, X)
    mp = 0
    if A and B and C:
        mp += (max(len(A) - 1, 0) + max(len(B) - 1, 0) + max(len(C) - 1, 0) ) * 10
        mp += abs(sum(A) - a) +abs(sum(B) - b) +abs(sum(C) - c) 
        ans = min(ans, mp)
    if index == n:
        return
    dfs(index+1, A + [l[index]], B, C, X)
    dfs(index+1, A, B + [l[index]], C, X)
    dfs(index+1, A, B, C + [l[index]], X)
    dfs(index+1, A, B, C, X + [l[index]])

n, a, b, c = map(int, input().split())
l = [ int(input()) for _ in range(n) ]
ans = float("inf")
dfs(0, [], [], [], [])
print(ans)


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

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;n);
    if vs.iter().any(|&v| v % 2 == 1) {
        println!("first")
    } else {
        println!("second")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 
// ========================================================
signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    int n;cin>>n;
    vector<int> a(n);
    vector<int> stool(n);
    int mx = INT_MIN;
    for0(i,n){
        cin>>a[i];
        mx = max(mx,a[i]);
        stool[i] = mx;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(a[i] < stool[i]){
            ans += stool[i] - a[i];
        }
    }
    cout<<ans<<endl;
  rr;
}



Measured memory_bytes: 4776
#include "bits/stdc++.h"
using namespace std;
class dsu{
private:
    const int default_size = 100100;
    vector<int> parent;
    int size;
    int find(int vertex){
        return (parent[vertex] < 0)?vertex:parent[vertex] = find(parent[vertex]);
    }
public:
    dsu(){
        this->size = default_size;
        parent.assign(size, -1);
    }
    dsu(int size){
        this->size = size;
        parent.assign(size, -1);
    }
    void clear(){
        parent.assign(size, -1);
    }
    bool isConnected(int u, int v){
        return find(u) == find(v);
    }
    bool connect(int u, int v){
        u = find(u);
        v = find(v);
        if(u != v){
            if(-parent[u] < -parent[v]) swap(u, v);
            parent[u] += parent[v];
            parent[v] = u;
        }
        return u != v;
    }
    int componentSize(int u){
        return - parent[find(u)];
    }
    bool isRoot(int u){
        return parent[u] < 0;
    }
};
const int maxn = 555;
void init(vector<vector<int> > & g, vector<int> & c, int cur, int p){
    if(p != -1) c[cur] = c[p] ^ 1;
    for(int nxt : g[cur]) if(nxt != p)
        init(g, c, nxt, cur);
}
int M(){
    int n, m;
    if(!(cin >> n >> m)) return 0;
    dsu solver(n);
    vector<vector<int> > g(n);
    vector<pair<int, int> > es;
    for(int e = 0; e < m; e++){
        int u, v;
        scanf("%d %d", &u, &v);u--;v--;
        if(!solver.isConnected(u, v)){
            g[u].push_back(v);
            g[v].push_back(u);
            solver.connect(u, v);
        } else {
            es.push_back({u, v});
        }
    }
    vector<int> cores(n, 0);
    init(g, cores, 0, -1);
    long long qtd_z = 0;
    long long qtd_o = 0;
    for(int e = 0; e < n; e++){
        if(cores[e] == 0) qtd_z++;
        else qtd_o++;
    }
    bool full = false;
    for(auto & u : es){
        if(cores[u.first] == cores[u.second])
            full = true;
    }
    if(full) printf("%lld\n", 1ll*n*(n-1)/2 - m);
    else printf("%lld\n", qtd_z * qtd_o - m);
    return 1;
}
int main(){
    while(M());
    return 0;
}


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

const int N=1<<20;
int n,a[N],ans[N];

int main()
{
	int i,j,x1,x2;
	scanf("%d",&n);
	n=(1<<n);
	for(i=0;i<n;i++)
	    scanf("%d",&a[i]);
	for(i=1;i<n;i++)
	{
	    ans[i]=ans[i-1];
	    for(j=i,x1=x2=0;;j=((j-1)&i))
	    {
	        if(a[j]>=x1)x2=x1,x1=a[j];
	        else if(a[j]>x2)x2=a[j];
	        if(!j)break;
	    }
	    ans[i]=max(ans[i],x1+x2);
	}
	for(i=1;i<n;i++)
	    printf("%d\n",ans[i]);
}


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

count = 0
difference = []

for i in range(len(A)):
    difference.append(A[i] - B[i])

if min(difference) >= 0:
    print(count)
    quit()


difference.sort()
minussum = 0
for d in difference:
    if d < 0:
        count = count + 1
        minussum = minussum + d
difference.reverse()

plussum = 0
for d in difference:
    plussum = plussum + d
    count = count + 1
    if plussum + minussum >= 0:
        print(count)
        quit()

print(-1)


Measured memory_bytes: 18524
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ull N;
    cin >> N;
    ull power = 1;
    ull m = 1000000007;
    for (ull i = 1; i <= N; ++i)
    {
        ull p = power * i;
        power = p % m;
    }
    cout << power << endl;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int ans;
	cin >> i >> j;
	if (i < j)
		ans = 0;
	else
		ans = 10;
	cout << ans << endl;

	return 0;
}

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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    inp(n);
    inps(a, b);
    ll x = min(a, b);
    ll y = max(a, b);
    ll diff = y-x;
    if(diff%2==0){
        cout << diff/2 << endl;
    }
    else{
        ll xx = x;
        ll yy = y;
        ll ans = x-1;
        y = y-ans;
        ans++;
        y--;
        x = 1;
        ll diff1 = y-x;
        ans += diff1/2;
        ll ans1 = n-yy;
        xx+=ans1;
        xx++;
        ans1++;
        yy = n;
        diff1 = yy-xx;
        ans1+=diff1/2;
        ll res = min(ans, ans1);
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n;
  int s;
  int x=0;
  cin >> n;
  s=n;
  for(int i;i<12;i++)
  {
    x=x+s%10;
    s=s/10;
  }
  if(n%x==0)
  {
    cout << "Yes" <<endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//int _(){
//    int n;
//    cin >> n;
//    vi p(n);
//    cin >> p;
//    int ans = 0;
//    int last = -1;
//    rep(i,1,n)
//        if(p[i-1] == i){
//            ++ans;
//            if(last == i-1){
//                --ans;
//                last = -1;
//            }
//            else
//                last = i;
//        }
//    return ans;
//}
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
int _(){
    int n;
    cin >> n;
    vi p(n);
    cin >> p;
    int ans = 0;
    int last = -1;
    rep(i,1,n)
        if(p[i-1] == i){
            ++ans;
            if(last == i-1){
                --ans;
                last = -1;
            }
            else
                last = i;
        }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 640
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

ll sq2(ll n){
	ll L=0,R=2e9+5,ans=0;
	while(L<=R){
		ll mid=(L+R)/2;
		if(mid*mid<=4*n){
			ans=mid;
			L=mid+1;
		}
		else R=mid-1;
	}
	//watch(ans);
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a,b,c; cin>>a>>b>>c;
	
	if(a+b+sq2(a*b)<c) cout<<"Yes\n";
	else cout<<"No\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  if(n <= k) cout << 0 << endl;
  else {
    sort(h.begin(), h.end());
    rep(i, k) {
      h.pop_back();
    }
    ll ans = 0;
    rep(i, h.size()) ans+=h[i];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    string s;
    int n;
    cin >> n >> s;
    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }
    map<char,ll> mp;
    rep(i,n) {
        mp[s[i]]++;
    }
    ll count = 0;
    ll c, l, r;
    rep(i,n) {
        c = i;
        rep(j,n) {
            l = i-1-j;
            r = i+1+j;
            if (l < 0 || r > n-1) break;
            if (s[c] != s[l] && s[l] != s[r] && s[r] != s[c]) count++;
        }
    }
    cout << ((mp['R'] * mp['G'] * mp['B']) - count) << endl;
    return 0;
}

Measured memory_bytes: 3604
def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38644
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] ar = new int[N];
		int cnt = 0;
		
		for (int i = 0; i < N; i++) {
			ar[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			boolean swapFlag = false;
			int minIndex = i;
			for (int j = i + 1,min = ar[minIndex]; j < N; j++) {
				if ( ar[j] < min ){
					min = ar[j];
					minIndex = j;
					swapFlag = true;
				}
			}
			if (swapFlag) {
				int temp = ar[i];
				ar[i] = ar[minIndex];
				ar[minIndex] = temp;
				cnt++;
			}
		}
	
	for (int i = 0; i < N; i++) {
		System.out.print(ar[i]);
		if (i + 1 < N) {
			System.out.print(" ");
		} else {
			System.out.println();
		}
	}
	
	System.out.println(cnt);
	}
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6+1;
const ld pi = acos(-1);
int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

template <class T1, class T2>
ostream &operator<<(ostream &out, map<T1, T2> &A) {
    for (auto x : A) cout << x.ff << " # " << x.ss << endl;
    return out;
}

int fastmod(int e, int x) {
    int res = 1;
    e %= mod;
    if (e == 0) return 0;
    while (x > 0) {
        if (x & 1) res = (res * e) % mod;
        x >>= 1;
        e = (e * e) % mod;
    }
    return res;
}


int32_t main() {
    IOS
    int n, ans = 0;  cin>>n;
    mod = n;
    set<int>sy;
    int i=0,x=1;
    if(n % 2 == 0){
        cout << -1 << endl;
        return 0;
    }
    bool flag = true;
    while(1){
        ans += 7*fastmod(10,i++);
        ans %= mod;
        // //cout << ans << "ok" << endl;
        if(sy.count(ans)){
            flag = false;
            break;
        }
        sy.insert(ans);
        if(ans == 0)  break;  
    }
    if(flag)    cout << i << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 50428
x = int(input())
sam = [j*100+j*10+j for j in range(1,10)]

for k in range(len(sam)):
  if x>sam[k] and x<sam[k+1]:
    print(sam[k+1])
    break
  elif x==sam[k]:
    print(sam[k])
    break
  elif x<sam[0]:
    print(sam[0])
    break

Measured memory_bytes: 3064