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

int main() {
  int cnt = 0;
  string s,t;
  
  cin >> s >> t;
  
  for(int i = 0; i < 3; i++){
    if(s.at(i) == t.at(i)) cnt++;
  }
  
  cout << cnt;
}


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

using namespace std;

int main()
{
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0; i<n; i++)
    cin >> a.at(i);

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

    int cnt=0;
   
    for(int i=0; i<n; i++){
        if(x - a.at(i) >0 && i==n-1){
            break;
        }
        else if(x - a.at(i) >= 0){
            cnt++;
            x -= a.at(i);
        }
        else{
            break;
        }

    }
    cout << cnt << endl;

}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();

        int c , ti;

        int min_cost = 1001;

        for(int i = 0;i < n;i++){
            c = sc.nextInt();
            ti = sc.nextInt();

            if(ti <= t && c <min_cost){
                min_cost = c;
            }
        }

        if(min_cost == 1001){
            System.out.println("TLE");
        }else{
            System.out.println(min_cost);
        }

    }
}

Measured memory_bytes: 21844
import math
n, a, b = map(int, input().split())
h = []
spread = b
attack = a - b
count = 0
for i in range(n):
    h.append(int(input()))
h.sort()
h.reverse()
def binary_search(left, right):
    if right - left <= 1:
        return right
    middle = (right + left)//2
    count = 0
    for i in range(n):
        if h[i] - (middle * spread) <= 0:
            break
        else:
            count += math.ceil((h[i] - (middle * spread)) / attack)
    if count > middle:
        return binary_search(middle, right)
    elif count < middle:
        return binary_search(left, middle)
    else:
        return middle
print(binary_search(0,10**10))



Measured memory_bytes: 7404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
ll Mod = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll fact[200003];
ll ifact[200003];
ll Combination(ll a,ll b) {
  ll s = (fact[a] * ifact[b]) % Mod;
  return (s * ifact[a-b]) % Mod;
}

int main() {
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i <= 200003; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= Mod;
    ifact[i] = modinv(fact[i],Mod);
  }
  ll N,K;
  cin >> N >> K;
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A,A+N);
  ll ans = 0;
  for (ll i = 0; i < N - K + 1; i++) {
    ans += (Combination(K-1+i,K-1) * A[K-1+i]);
    ans %= Mod;
  }
  for (int i = 0; i < N - K + 1; i++) {
    ans -= (Combination(N-1-i,K-1) * A[i]);
    ans %= Mod; 
  }
  if (ans < 0) ans += Mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4096
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

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

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String n;
		ArrayList<String> S = new ArrayList<>();
		for(int i = 0; i<N; i++) {
			n = scan.next();
//			if(S.contains(n)==false) {
				S.add(n);
//			}
		}
		 Set<String> linkedHashSet = new LinkedHashSet<String>();

		    // 配列の要素を順にLinkedHashSetオブジェクトへ追加
		    for (int i = 0; i < S.size(); i++) {
		    linkedHashSet.add(S.get(i));
		    }

		    // LinkedHashSetオブジェクトを配列に変換
		    Object[] strings_after = linkedHashSet.toArray();

		    System.out.println(strings_after.length);
//		System.out.println(S.size());

	}
}

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

int main()
{
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0)
      break;

    vector<int> t(n+m);
    for (int i = 0; i < n+m; ++i)
      cin >> t[i];

    t.push_back(0);
    sort(t.begin(), t.end());

    int ans = 0;
    for (unsigned int i = 0; i < t.size()-1; ++i)
      ans = max(ans, t[i+1]-t[i]);

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1004
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), x = sc.nextInt();
		sc.close();
		String ans[] = {"YES", "NO"};
		int an = 0;
		if(a > x)an = 1;
		if(a + b < x)an = 1;
		System.out.println(ans[an]);
	}

}


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

int ans;
int H, W;

char C[330][330];
int dp[330][330];
int g[330][330];

int main(){
	cin >> H >> W;
	for(int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++){
            cin >> C[i][j];
        }
	}

    ans = 0;

    for (int i = 1; i < W; i++){
        memset(dp, 0x3f, sizeof(dp));
        memset(g, 0, sizeof(g));
        for (int j = 1; j <= H; j++){
            for(int k = 1; k <= H; k++){
                g[j][k] = g[j - 1][k - 1];
                if(C[j][i] == C[k][i + 1]){
                    g[j][k]++;
                }
            }
        }
        dp[H][H] = 0;
        for(int j = H; j >= 0; j--){
            for(int k = H; k >= 0; k--){
                if(j > 0) dp[j - 1][k] = min(dp[j - 1][k], dp[j][k] + g[j][k]);
                if(k > 0)dp[j][k - 1] = min(dp[j][k - 1], dp[j][k] + g[j][k]);
            }
        }
        ans += dp[0][0];
    }
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

constexpr int MAX_N = 303030;

//[1,n],size
int  n, m, l[303030], r[303030];

struct BIT {
	int s[1 << 18];
	void init() {
		REP(i, (1 << 18))s[i] = 0;
	}
	void add(int k, int x) {
		while (k > 0) {
			s[k] += x;
			k -= k&-k;
		}
	}
	int sum(int k) {
		int ret = 0;
		while (k < (1 << 18)) {
			ret += s[k];
			k += k&-k;
		}
		return ret;
	}
}bit;

int main() {
	cin >> n >> m;
	REP(i, n)cin >> l[i] >> r[i];
	vector<pair<int, int>>v;
	bit.init();
	REP(i, n)v.emplace_back(mp(r[i] - l[i] + 1, i));
	sort(ALL(v));
	int k = 0;
	for (int i = 1; i <= m; i++) {
		while (k < v.size() && v[k].first < i) {
			bit.add(l[v[k].second] - 1, -1);
			bit.add(r[v[k].second],1);
			k++;
		}
		int ret = n - k;//区間がi以上なら必ず通る。i未満のものはBITで処理して求める。
		for (int j = 1; i*j <= m; j++) {
			ret += bit.sum(i*j);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 9840
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, a, b;
int u[101], u2[101];

inline void Solve () {
	//easy
	cin >> n >> a >> b;

	if (abs(b - a) % 2 == 0) {
		cout << "Alice\n";
		exit(0);
	}

	if (abs(b - a) & 1) {
		cout << "Borys\n";
		exit(0);
	}

	cout << "Draw\n";
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;

int main() {
	int n, k;
	int ans = 0;
	int v;
	//vector<int> a;
	cin >> n >> k;
	REP(i, n) {
		cin >> v;
	}
	ans = (n - k) / (k - 1) + 1;
	if ((n - k) % (k - 1) != 0) {
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int hill[10];
  for (int i = 0; i < 10; i++) {
    cin >> hill[i];
  }

  for (int i = 0; i < 3; i++) {
    int max = 0;
    for (int i = 0; i < 10; i++) {
      max = hill[i] > max ? hill[i] : max;
    }

    cout << max << endl;

    for (int i = 0; i < 10; i++) {
      if (hill[i] == max) {
        hill[i] = 0;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string a, b; cin >> a >> b;
    string ans;
    if(a[0]=='H'&&b[0]=='H') ans = 'H';
    else if(a[0]=='H'&&b[0]=='D') ans = 'D';
    else if(a[0]=='D'&&b[0]=='H') ans = 'D';
    else ans = 'H';
    cout << ans;
}


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

void solve () {
    int n;
    cin >> n;
    long long ans;
    long long t;
    cin >> t;
    ans += t;
    for (int i = 1; i < n - 1; i++) {
        long long x;
        cin >> x;
        ans += min (x, t);
        t = x;
    }
    ans += t;
    cout << ans;
}

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


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<ll> c(26),num(26);
    rep(i,26){
        cin >> c[i];
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    rep(i,d){
        cout << rand()%26+1 << endl;
    }
    return 0;
} 

Measured memory_bytes: 3712
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

	void East(int a[])
	{//1364 4136
		int temp = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = temp;
	}

	void Western(int a[])
	{//1364 3641
		int temp = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = temp;
	}

	void North(int a[])
	{//1562 2156
		int temp = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = temp;
	}

	void South(int a[])
	{
		//1562 5621
		int temp = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = temp;
	}

	void Right(int a[])
	{
		//1243 2431
		int temp = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = temp;
	}

	void Left(int a[])
	{
		//1243 3124
		int temp = a[1];
		a[1] = a[3];
		a[3] = a[4];
		a[4] = a[2];
		a[2] = temp;
	}
int main()
{
	int a[6],b[6];
	for (int i = 0; i < 6; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < 6; i++)
	{
		cin >> b[i];
	}

	bool isSame = false;

	for (int k = 0; k < 6; k++)
	{
		switch (k)
		{
		case 1:
			North(a);
			break;
		case 2:
			North(a);
			break;
		case 3:
			North(a);
			break;
		case 4:
			East(a);
			break;
		case 5:
			East(a);
			East(a);
			break;
		}
		int i1 = -1;
		for (int i = 0; i < 6; i++)
		{
			if (a[0] == b[i])
			{
				i1 = i;
				break;
			}
		}
		if (i1 == -1)
		{
			break;
		}

		if (i1 == 1) { North(b); }
		if (i1 == 2) { Western(b); }
		if (i1 == 3) { East(b); }
		if (i1 == 4) { South(b); }
		if (i1 == 5) { North(b); North(b); }

		int i2 = -1;
		for (int i = 1; i < 5; i++)
		{
			if (a[1] == b[i])
			{
				i2 = i;
				break;
			}
		}
		if (i2 == -1)
		{
			break;
		}

		if (i2 == 2) { Right(b); }
		if (i2 == 3) { Left(b); }
		if (i2 == 4) { Right(b); Right(b); }

		bool _isSame = true;
		for (int i = 0; i < 6; i++)
		{
			if (a[i] != b[i])
			{
				_isSame = false;
			}
		}

		if (_isSame)
		{
			isSame = true;
			break;
		}
	}

	if (isSame)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>

int main(void){
int x[5];
  for(int i=0;i<5;i++){
  scanf("%d",&x[i]);
  }
  for(int i=0;i<5;i++){
  if (x[i]==0) printf("%d",i+1);
  }
  
return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=200000 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5 ;

void work(){
  string s,t;
  cin >> s >> t;
  ll l1=s.length(),l2=t.length();
  vl m[26];
  for(ll i=0;i<l1;i++)
    m[s[i]-'a'].pb(i);
  vl d(l2);
  if(m[t[0]-'a'].size()==0){
    cout << -1;
    return;
  }
  d[0]=m[t[0]-'a'][0];
  ll prev=d[0],cycle=0;
  for(ll i=1;i<l2;i++){
//    vl v=m[t[i]-'a'];
    if(!m[t[i]-'a'].size()){
      cout << -1;
      return;
    }
    ll j=upper_bound(m[t[i]-'a'].begin(),m[t[i]-'a'].end(),prev)-m[t[i]-'a'].begin();

    // d[i]=j;
    if(j==m[t[i]-'a'].size()){
      d[i]=m[t[i]-'a'][0];
      cycle++;
      prev=d[i];
    }
    else{
      d[i]=m[t[i]-'a'][j];
      prev=d[i];
    }
  }
  // cout << cycle << " " << prev ;
  cout << l1*cycle+prev+1;
}
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 2256
N = int(input())
lst_H = list(map(int, input().split()))
lst_H = lst_H[::-1]

ans = "Yes"
for i in range(N - 1):
    if lst_H[i] + 1 == lst_H[i + 1]:
        lst_H[i + 1] -= 1
    elif lst_H[i] >= lst_H[i + 1]:
        continue
    else:
        ans = "No"
        break
print(ans)


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

using ll = long long;
const ll MOD = 998244353;

const int MAXN = 2.1e5;
int N;
pair<int, int> P[MAXN];
ll p2[MAXN];

int bit[MAXN];
void update(int a) {
  for (a++; a <= N; a += (a & (-a))) {
    bit[a] ++;
  }
}
int query(int a) {
  int r = 0;
  for (a++; a > 0; a -= (a & (-a))) {
    r += bit[a];
  }
  return r;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> P[i].first >> P[i].second;
  p2[0] = 0;
  for (int i = 1; i <= N; i++) p2[i] = (p2[i-1]*2+1)%MOD;
  
  vector<int> xs, ys;
  for (int i = 0; i < N; i++) xs.push_back(P[i].first), ys.push_back(P[i].second);
  sort(xs.begin(), xs.end());
  //xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
  sort(ys.begin(), ys.end());
  //ys.resize(unique(ys.begin(), ys.end()) - ys.begin());
  for (int i = 0; i < N; i++) {
    P[i].first = int(lower_bound(xs.begin(), xs.end(), P[i].first) - xs.begin());
    P[i].second = int(lower_bound(ys.begin(), ys.end(), P[i].second) - ys.begin());
  }
  sort(P, P + N);
  
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    int quad = query(P[i].second);
    update(P[i].second);
    ans += p2[N] - p2[P[i].first] - p2[N-1-P[i].first] - p2[P[i].second] - p2[N-1-P[i].second] + p2[quad] + p2[P[i].first - quad] + p2[P[i].second - quad] + p2[N-1-quad-(P[i].first-quad)-(P[i].second-quad)];
  }
  ans %= MOD;
  if (ans < 0) ans += MOD;
  cout << ans << '\n';
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 5 )
    {
        cout << 0 << endl;
    }
    else if (a >= 6 && a <= 12)
    {
        cout << b / 2 << endl;
    }
    else if (a >= 13)
    {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
def solve():
    S=input()
    S_len=len(S)
    T=input()
    T_len=len(T)
    if S_len<T_len:
        return 'UNRESTORABLE'
    for i in range(S_len-T_len,-1,-1):
        for j in range(T_len):
            if S[i+j]!=T[j] and S[i+j]!='?':
                break
        else:
            S = S[0:i] + T + S[i+T_len:]
            break
    else:
        return 'UNRESTORABLE'
    return S.replace('?','a')

print(solve())


Measured memory_bytes: 38384
#include <iostream>
#include <numeric>

using namespace std;

int main() {
    int n;  cin >> n;
    int sheets[100001] = { 0 };
    int l, r;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        for (int j = l; j <= r; j++) sheets[j] = 1;
    }

    int sum = accumulate(begin(sheets), end(sheets), 0);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
program e
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i
    integer(int32), allocatable:: a(:),b(:)

    read*, n
    allocate(a(n),b(n))

    do i=1,n
        read*, a(i),b(i)
    end do
    call merge_sort(a,1,n)
    call merge_sort(b,1,n)

    if (mod(n,2)==1) then
        print'(i0)', b(n/2+1) - a(n/2+1) + 1
    else
        print'(i0)', b(n/2)+b(n/2+1) - (a(n/2)+a(n/2+1))+1
    end if
        
contains
        recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program e

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

int main(){
  int n,sum=0; cin>>n;
  vector<int> s(n),t;
  for(int i=0; i<n; i++) {
    cin>>s[i];
    sum += s[i];
    if(s[i]%10 != 0) t.push_back(s[i]);
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  if(sum%10 == 0) {
    if(t.size() == 0) cout<<0;
    else cout<<sum-t[0];
  }
  else cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define N 510
#define MAX_V N
using namespace std;
typedef unordered_map<int,int> M;
M g[N];
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  
  for(M::iterator it=g[v].begin();it!=g[v].end() ;it++){
    int to=it->first;
    int &cap=it->second;
    if(!used[to] && cap > 0){
      int d = dfs(to ,t , min(f,cap));
      if(d > 0){
	cap -= d;
	g[to][v]+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

bool check(int s,int t){
  memset(used,0,sizeof(used));
  return dfs(s,t,1);
}

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;a--,b--;
    g[a][b]=g[b][a]=1;
  }
  
  int flow=max_flow(0,n-1);
  while(q--){
    int op,a,b;
    cin>>op>>a>>b;a--,b--;
    if(op==1) g[a][b]=g[b][a]=1,flow+=max_flow(0,n-1);
    if(op==2){
      if(!g[a][b]||!g[b][a]){
	if(!g[b][a])swap(a,b);
	if(!check(a,b))flow--,check(a,0),check(n-1,b);
      }
      g[a][b]=g[b][a]=0;
    }
    cout <<flow<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4928
import java.util.*;

public class Main {

    private static int N;
    private static int A[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println(solve());
    }

    static long solve() {
        Arrays.sort(A);
        int k = 0;
        int prev = -1;
        for (int i = 0; i < N; i++) {
            if( prev != A[i] ) {
                k++;
                prev = A[i];
            }
        }

        // Nは奇数+二枚づつ削る、なので
        // カードの種類が
        //   奇数 -> うまく削れる
        //   偶数 -> 一つ余計に削る
        if( k % 2 == 1 ) {
            return k;
        } else {
            return k - 1;
        }
    }
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    map<string, ll> m;
    rep(i, N) {
      string str;
      cin >> str;
      m[str]++;
    }
    ll ma = 0;
    for(auto p : m) {
      ma = max(ma, (ll)p.second);
    }
    vector<string> ans;
    for(auto p : m) {
      if (ma == p.second) {
        ans.push_back(p.first);
      }
    }
    sort(all(ans));
    for(auto p : ans) print(p);
    return 0;
}

Measured memory_bytes: 26868
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PI 3.14159265359

int main(void)
{
double R;
  

  scanf("%lf", &R);
  printf("%lf\n", R*2*(double)PI);
  
  
  return 0;
}


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

int n, a, b, c, d;
vector<vector<int>> dp;
template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

Modular<> fact[1005], inv[1005];
Modular<> ncr(int nn, int r) {
  return fact[nn] * inv[nn - r] * inv[r];
}

Modular<> groups(int nn, int g) {
  return fact[nn] * mexp(inv[g], nn/g) * inv[nn/g];
}

int solve(int rem, int cur) {
  if (cur > b) return (rem == 0);
  if (dp[rem][cur] != -1) return dp[rem][cur];
  Modular<> ret = 0;

  ret += solve(rem, cur + 1);
  for (int i = cur * c; i <= cur * d; i += cur) {
    if (i > rem)  break;
    ret += ncr(rem, i) * groups(i, cur) * solve(rem - i, cur + 1);
  }
  return (dp[rem][cur] = ret.value);
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  fact[0] = inv[0] = 1;
  for (int i = 1; i < 1005; ++i) {
    fact[i] = i * fact[i-1];
    inv[i] = 1 / fact[i];
  }

  cin >> n >> a >> b >> c >> d;
  dp.resize(n + 1, vector<int> (n + 1, -1));
  cout << solve(n, a) << '\n';
}


Measured memory_bytes: 4352
N, M = gets.chomp.split(" ").map(&:to_i)
F = []
S = []
M.times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  F << b if a == 1
  S << a if b == N
}

puts (F & S).size > 0 ? 'POSSIBLE' : 'IMPOSSIBLE'


Measured memory_bytes: 9864
import math
import sys
import itertools
import queue
from fractions import gcd
import numpy as np


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

mod = 2019

if __name__ == "__main__":
    L,R= map(int, sys.stdin.readline().split())
    if R-L>=2018:
        print(0)
    else:
        ans=2019
        for i in range(L,R):
            for j in range(i+1,R+1):
                ans=min(ans,(j*i)%mod)
        print(ans)

Measured memory_bytes: 13728
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int ch[2000010][26],fa[2000010],l[2000010],cnt,size[2000100];
int f[2000010],wb[2000010],a[2000010],last,t,k;
char s[2000010];
void Insert(int c)
{
    int p=last,np=++cnt;
    last=np,l[np]=l[p]+1;
    for(;p&&!ch[p][c];p=fa[p]) ch[p][c]=np;
    if(!p) fa[np]=1;
    else
    {
        int q=ch[p][c];
        if(l[p]+1==l[q]) fa[np]=q;
        else
        {
            int nq=++cnt;
            l[nq]=l[p]+1;
            memcpy(ch[nq],ch[q],sizeof(ch[q]));
            fa[nq]=fa[q];fa[q]=fa[np]=nq;
            for(;ch[p][c]==q;p=fa[p]) ch[p][c]=nq;
        }
    }
    size[np]=1;
}
void solve()
{
    for(int i=1;i<=cnt;i++) wb[l[i]]++;
    for(int i=1;i<=cnt;i++) wb[i]+=wb[i-1];
    for(int i=1;i<=cnt;i++) a[wb[l[i]]--]=i;
    for(int i=cnt;i;i--)
    {
        int p=a[i];
        if(t==1) size[fa[p]]+=size[p];
        else size[p]=1;
    }
    size[1]=0;
    for(int i=cnt;i;i--)
    {
        f[a[i]]=size[a[i]];
        for(int j=0;j<26;j++)
        {
            if(ch[a[i]][j]) f[a[i]]+=f[ch[a[i]][j]];
        }
    }
}
int main()
{
    t=0;
	scanf("%s%d",s+1,&k);
    int n=strlen(s+1);
    last=cnt=1;
    for(int i=1;i<=n;i++) Insert(s[i]-'a');
    solve();
    int now=1;
    while((k-=size[now])>0)
    {
        int p=0;
        while(k>f[ch[now][p]]) k-=f[ch[now][p++]];
        now=ch[now][p];
        putchar('a'+p);
    }
    return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;

int main(){

	int A,B; std::cin >> A >> B;

	int ans = 0;

	for(int i = A; i <= B; i++){
		std::string str = std::to_string(i);
		std::string reversed = str;
		std::reverse(reversed.begin(),reversed.end());
		if(str == reversed)ans++;
	}

	std::cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int unused __attribute__((unused));
  int x, a, b;
  unused = scanf("%d %d %d", &x, &a, &b);

  if(abs(x-a) < abs(x-b)) printf("A");
  else printf("B");
  return 0;
}

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

using namespace std;

#define int long long

signed main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		 cin>>a[i];
	}
	
	int cnt = 0;
	for(int i=1;i<n-1;i++){
		if((a[i] > a[i - 1] && a[i] < a[i+1]) || (a[i] > a[i+1] && a[i] < a[i-1])) cnt++;
	}
	cout<<cnt<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int x=0;
  string S,T;
  cin>>S>>T;
  if(S[0] == T[0])
    x++;
  if(S[1] == T[1])
    x++;
  if(S[2] == T[2])
    x++;
  cout<<x<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

// Modpow
int64_t modpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
  int64_t res = 1;
  for (a %= mod; b; a = a * a % mod, b >>= 1)
    if (b & 1) res = res * a % mod;
  return res;
}

// Combination
void InvInit(int64_t b, vector<int64_t>& inv) {
  inv[1] = 1;
  for (int32_t i = 2; i <= (int32_t)b; i++){
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
  }
}

//int64_t COM(int32_t n, int32_t k, vector<int64_t>& fac, vector<int64_t>& finv) {
//  if (n < k) return 0;
//  if (n < 0 || k < 0) return 0;
//  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
//}

int64_t COM(int64_t n, int64_t a, int64_t b, vector<int64_t>& inv_vect) {
  int64_t coma = n;
  for (int i = 2; i <= a; i++) {
    coma = (coma * (n - i + 1)) % MOD * inv_vect[i] % MOD; 
  }
  coma %= MOD;
  int64_t comb = coma;
  for (int i = a + 1; i <= b; i++) {
    comb = (comb * (n - i + 1)) % MOD * inv_vect[i] % MOD;
  }
  comb %= MOD;
  return (coma + comb) % MOD;
}

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

  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t res = modpow(2,n) - 1;
  if (res < 0) res += MOD;
  vector<int64_t> inv_vect(b+1);
  InvInit(b, inv_vect);
  res -= COM(n, a, b, inv_vect);
  if (res < 0) res += MOD;

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


Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
from collections import deque
def main():
    n,mod=map(int,input().split())
    Edges=[[] for _ in range(n)]
    for _ in range(n-1):
        x,y=map(int,input().split())
        x-=1; y-=1
        Edges[x].append(y)
        Edges[y].append(x)
    Stack=[0]
    Par=[-1]*n
    Order=[]
    while Stack:
        v=Stack.pop()
        Order.append(v)
        for c in Edges[v]:
            if c!=Par[v]:
                Stack.append(c)
                Par[c]=v
    child = set()
    DP=[1]*n
    for v in Order[::-1]:
        for to in Edges[v]:
            if to==Par[v]:
                continue
            DP[v]*=DP[to]+1
            DP[v]%=mod
    Ans=[0]*n
    que=deque()
    que.append((0,-1,1))
    while que:
        v,par,par_cnt=que.popleft()
        Left=[1]
        for to in Edges[v]:
            tmp=DP[to]
            if to==par:
                tmp=par_cnt
            Left.append(Left[-1]*(tmp+1)%mod)
        Right=[1]
        for to in reversed(Edges[v]):
            tmp=DP[to]
            if to==par:
                tmp=par_cnt
            Right.append(Right[-1]*(tmp+1)%mod)
        Ans[v]=Left[-1]
        m=len(Edges[v])
        for i,to in enumerate(Edges[v]):
            if to!=par:
                que.append((to,v,Left[i]*Right[m-i-1]%mod))
    print(*Ans,sep="\n")

if __name__=='__main__':
    main()

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



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string N;
    cin >> N;
    int sum = 0;
    int le = N.length();
    for (int i = 0; i < le; i++){
        sum += N[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes\n";
    else cout << "No    \n";
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *   ****      *  ****

//     ****   *****   ****         *   *  *****  *   *   ****
//    *   *    *    *             ** **    *    **  *  *
//   ****     *    * ***  *****  * * *    *    * * *  * ***
//  *   *    *    *   *         *   *    *    *  **  *   *
// ****   *****   ****         *   *  *****  *   *   ****




Measured memory_bytes: 3768
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int left,right,parent;
}tree;

void print(int);
int rec(int,int);

tree T[MAX];
int n,D[MAX];

int main()
{
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].parent=T[i].left=T[i].right=NIL;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&v,&d);
      for(j=0;j<d;j++)
	{
	  scanf("%d",&c);
	  if(j==0)
	    T[v].left=c;
	  else
	    T[l].right=c;
	  l=c;
	  T[c].parent=v;
	}
    }
  for(i=0;i<n;i++)
  {
    if(T[i].parent == NIL)
      r = i;
  }
  rec(r,0);
   for(i=0;i<n;i++)
    {
      print(i);
    }
  return 0;
}

int rec(int u,int p)
{
  D[u]=p;
  if(T[u].right != NIL)
    rec(T[u].right,p);
  if(T[u].left != NIL)
    rec(T[u].left,p+1);
}

void print(int u)
{
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);
  if(T[u].parent == NIL)
    printf("root, ");
  else if(T[u].left == NIL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0, c=T[u].left;c != NIL;i++,c = T[c].right)
    {
      if(i)
	printf(", ");
      printf("%d",c);
    }
  printf("]\n");
}



Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[400006],dp2[400006]; // dp1 : forward, dp2 : backward
int main(){
    int N; string s; cin>>N>>s;
    int mn=1e9;
    for(int i=1;i<=N;i++) dp[i]=dp[i-1]+(s[i-1]=='W');
    for(int i=1;i<=N;i++)
    {
        mn=min(mn,dp[i-1]+(N-i)-(dp[N]-dp[i]));
    }
    printf("%d",mn);
    return 0;
}


Measured memory_bytes: 1796
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());
        int x = Integer.parseInt(sc.next());
        int sum = 0;
        int ans = 1;
        for (int i = 0; i < n; i++) {
            sum += Integer.parseInt(sc.next());
            if (sum <= x) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    LL h, w;
    scanf("%lld%lld", &h, &w);
    LL x = h * w;
    if (h == 1 || w == 1) {
        printf("1\n", 1);
    } else if (x % 2 == 1) {
        printf("%lld\n", x/2 + 1);
    } else {
        printf("%lld\n", x/2);
    }
}


Measured memory_bytes: 128
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val (a, b, c) = (sc.nextInt(), sc.nextInt(), sc.nextInt())
  val k = sc.nextInt()

  val i = Seq(a, b, c)
  val ans = i.max * (math.pow(2, k) - 1) + i.sum

  println(ans.toInt)
}


Measured memory_bytes: 27204
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<int, int>;
const int INF = 1001001001;

int imos[100005];
vector<P> tv[30];

int main(void){
  int n, c;
  cin >> n >> c;
  REP(i, n){
    int s, t, ch;
    cin >> s >> t >> ch;
    ch--;
    tv[ch].emplace_back(P(s, t));
  }
  REP(ch, c){
    if(tv[ch].empty()) continue;
    sort(ALL(tv[ch]));
    int m = tv[ch].size();
    int s = tv[ch][0].first;
    int t = tv[ch][0].second;
    FOR(i, 1, m){
      if(tv[ch][i].first == t){
        t = tv[ch][i].second;
      }else{
        imos[s-1] += 1;
        imos[t] -= 1;
        s = tv[ch][i].first;
        t = tv[ch][i].second;
      }
    }
    imos[s-1] += 1;
    imos[t] -= 1;
  }
  int ans = 0;
  int sum = 0;
  REP(i, 100005){
    sum += imos[i];
    chmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

bool check(string s) {
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - 1 - i]) return 0;
	}
	return 1;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	int n = s.size();
	string a = "";
	for (int i = 0; i < (n - 1) / 2; i++) {
		a += s[i];
	}
	string b = "";
	for (int i = (n + 3) / 2 - 1; i < n; i++) {
		b += s[i];
	}

	if (check(a) and check(b) and check(s)) {
		cout << "Yes";
	} else cout << "No";


	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s; cin >> s;
    string t; cin >> t;
    ll ans = 0;
    rep(i, 3){
        if(s[i] == t[i]){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3628
/* ex 3_2
  kt125 */

#include <stdio.h>

int main(void) {
  int n;  //number
  scanf("%d", &n);
  
  switch(n % 10){ // nの一の位で場合分け
    case 2: case 4: case 5: case 7: case 9:
      printf("hon\n"); break;
    case 0: case 1: case 6: case 8:
      printf("pon\n"); break;
    case 3:
      printf("bon\n"); break;
  }
  return 0;
}



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = LINF;
    d[s] = 0;
    que.push(make_pair(0LL, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<pair<int, ll>>> g(n);
    rep(i, m) {
        int s, t;
        ll d;
        cin >> s >> t >> d;
        g[s].emplace_back(t, d);
    }
    auto d = Dijkstra(r, g);
    rep(i, n) {
        if (d[i] == LINF)
            cout << "INF" << endl;
        else
            cout << d[i] << endl;
    }
}


Measured memory_bytes: 19428
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string ss;
	int ans=0;
	while(cin >> ss){
		for(int i=0;i<ss.length();i++){
			if(ss[i]!=ss[ss.length()-1-i])goto next;
		}
		ans++;
next:;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <queue>
#include <thread>
#include<bits/extc++.h>
 
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
 
#define ll long long
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %c%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %c%d: %lld\n", ch, cs, x)
#define pcsyn(ch, cs, st) printf("Case %c%d: %s\n", ch, cs, (st) ? "Yes" : "No")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)
#define plld(x, y) printf("%lld %lld\n", x, y)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define pb(x) push_back(x)
 
inline long long max(long long x, long long y) { return x > y ? x : y; }
 
inline long long min(long long x, long long y) { return x > y ? y : x; }
 
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
 
int main(){
    std::string str;
    std::cin >> str;
    long long sav = 0;
    for (auto & it : str){
        sav += it - '0';
    }
    puts(sav % 9 == 0 ? "Yes" : "No");
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; 
  string S;
  cin >> N >> S;
  int t = S.size();
  if(t % 2 != 0) cout << "No" << endl;
  else{
    vector<char> T(t);
    for(int i = 0; i < t / 2; i++){
      T.at(i) = S.at(i);
      T.at(i + t / 2) = S.at(i);
     }
    int c = 0;
    for(int i = 0; i < t; i++){
      if(T.at(i) != S.at(i)) c = 1;
    }
    if(c == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def divisor(n):
  cd = []
  i = 1
  while i*i <= n:
    if n%i==0:
      cd.append(i)
      if i != n//i:
        cd.append(n//i)
    i += 1
  return cd

def solve():
  N, M = map(int, input().split())
  cd = divisor(M)
  cd.sort()
  for c in cd:
    if c<=M//N:
      ans = c
  return ans
print(solve())

Measured memory_bytes: 63720