akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;


void solve(){
	cin >> n;
	llint a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	llint f=a[n-1];
	ld f2=f/2.0;
	ld min_dif=inf;
	llint s;
	for(int i=0;i<n;i++){
		if(abs(f2-a[i])<min_dif){
			min_dif=abs(f2-a[i]);
			s=a[i];
		}
	}

	printf("%lld %lld\n",f,s);

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
s=[0]*n
for _ in range(n):
  s[_]=input()
sd={}
for _ in s:
  sd[_]=s.count(_)
m=int(input())
t=[0]*m
for _ in range(m):
  t[_]=input()
l=sd.keys()
for _ in t:
  if _ in l:
    sd[_]-=1
if max(sd.values())<0:
  print(0)
else:
  print(max(sd.values()))

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;

namespace adaptor = boost::adaptors;

void Main()
{
	int X;
	int amari;
  	cin >> X;
	
	int gohyaku = X / 500;
	amari = X - (gohyaku * 500);
	// int hyaku = amari / 100;
	// amari = amari - (hyaku * 100);
	// int gojyu = amari / 50;
	// amari = amari - (gojyu * 50);
	// int jyu = amari / 10;
	// amari = amari - (jyu * 10);
	int go = amari / 5;

	cout << (go * 5) + (gohyaku * 1000);
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	
	Main();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long n,i,x,A[100005],St[100005],Dr[100005];
long long rez,S1[100005],S2[100005];
pair<long long,int> Max[100005];

bool cmp(pair<long long,int> a, pair<long long,int> b)
{
    return a.first>b.first;
}

bool check(long long val)
{
    long long nr=val/x;
    if(nr>=n)
        return 1;
    long long extra=val-x*nr;
    long long i;
    long long rez=-1;
    for(i=1; i<=n; i++)
    {
        long long aux=1LL*Dr[i]*(x-A[i])+1LL*St[i]*A[i];
        long long idk=0;
        if(extra>=A[i])
            idk=1LL*Dr[i]*(extra-A[i]);
        else
            idk=1LL*St[i]*(extra-A[i]);
        if(aux>=Max[nr].first && nr!=0)
            rez=max(rez,idk+S1[nr+1]-1LL*Dr[i]*(x-A[i])+S2[nr+2]);
        else
            rez=max(rez,idk+S1[nr]+1LL*St[i]*A[i]+S2[nr+1]);
    }
    return (rez>=0);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>x;
	rez=0;
	for(i=1; i<=n; i++)
    {
        cin>>A[i]>>St[i]>>Dr[i];
        Max[i]={1LL*Dr[i]*(x-A[i])+1LL*St[i]*A[i],i};
    }
    sort(Max+1,Max+n+1,cmp);
    for(i=1; i<=n; i++)
        S1[i]=S1[i-1]+1LL*Dr[Max[i].second]*(x-A[Max[i].second]);
    for(i=n; i>=1; i--)
        S2[i]=S2[i+1]-1LL*St[Max[i].second]*A[Max[i].second];
    rez=-1;
    for(i=33; i>=0; i--)
        if(!check(rez+(1LL<<i)))
            rez+=(1LL<<i);
    rez++;
	cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 5760
/******** JUST GIVE IT A TRY,COULD'NT SOLVED YOU LEARNED SOMETHING NEW 
AND IF SOLVED IT MEANS YOU GREW *********/
    
//author RKN
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pr pair<ll,ll>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);  
/*///////////////////////////////////////////////////////////////
DYNAMIC PROGRAMMING
///////////////////////////////////////////////////////////////*/
 
int main()
{
 int n,m;
 cin>>n>>m;
 int mx=1000000007;
 ll dp[n][m];
 char grid[n][m];
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++){
     cin>>grid[i][j];
     dp[i][j]=0;
     }
 }
 if(n==1)
 {
     if(grid[0][0]=='*')
     cout<<0;
     else
     cout<<1;
     return 0;
 }
 int dx[2]={0,-1};
 int dy[2]={-1,0};
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         if(i==0 && j==0){dp[i][j]=1;continue;}
         if(grid[i][j]=='*')continue;
         for(int k=0;k<2;k++)
         {
         int x1=i+dx[k];
         int y1=j+dy[k];
         if(x1>=0 && y1>=0 && x1<n && y1<m && grid[x1][y1]=='.')
         {
             (dp[i][j]+=dp[x1][y1])%=mx;
         }
         }
     }
 }
 cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define ll int
int dp[1<<26]={0};
int main(){
  string s;
  cin>>s;
  vector<ll> hs;
  ll now_h=0;
  ll n=s.length();
  for(int i=0;i<n;i++){
    ll c=(ll)(s[i]-'a');
    now_h^=((ll)1<<c);
    hs.push_back(now_h);
  }
  for(int i=0;i<(1<<26);i++) dp[i]=17441744;
  dp[0]=0;
  if(now_h==0){
    cout<<1<<endl;
    return 0;
  }
  for(int i=0;i<26;i++) {
    if(now_h==(1<<i)) {
      cout<<1<<endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      dp[hs[i]]=min(dp[hs[i]],dp[hs[i]^(1<<j)]);
    }
    dp[hs[i]]++;
    dp[0]=0;
  }
  cout<<dp[hs[n-1]]<<endl;
}


Measured memory_bytes: 263544
n = gets.chomp.to_i
ac = 0
wa = 0
tle = 0
re = 0
n.times do 
    s = gets.chomp
    if s == "AC"
        ac += 1
    end
    if s == "WA"
        wa += 1
    end
    if s == "TLE"
        tle += 1
    end
    if s == "RE"
        re += 1
    end
end
print "AC"
print " "
print "x"
print " "
print ac
print "\n"

print "WA"
print " "
print "x"
print " "
print wa
print "\n"

print "TLE"
print " "
print "x"
print " "
print tle
print "\n"

print "RE"
print " "
print "x"
print " "
print re
print "\n"



Measured memory_bytes: 14312
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// 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;
const ll N = 5e5+9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<60;
const ll mod = 1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
#define BLOCK 708 // ~sqrt(N)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")



int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif                           
    ll T= 1;
    // cin >> T;
    while(T--){
    	ll n,k;cin>>n>>k;
    	ll ind[n],a[n];
    	for(int i = 0;i<n;i++){
    		cin>>a[i];a[i]--;
    	}
    	ll st = 0;
    	memset(ind,-1,sizeof(ind));
    	ll ti = 0;
    	vector<ll> v;
    	while(ind[st]==-1){
    		ind[st] = ti++;
    		v.pb(st);
    		st = a[st];
    	}
    	ll rp = 0;
    	for(int i = 0;i<v.size();i++){
    		if(v[i]==st){
    			rp = i;
    			break;
    		}
    	}
    	// for(int i = 0;i<v.size();i++){
    	// 	cout<<v[i]<<" ";
    	// }
    	// cout<<'\n';
    	ll cyc = v.size() - rp;
    	std::vector<ll> cycle;
    	for(int i = rp;i<v.size();i++){
    		cycle.pb(v[i]);
    	}

    	// for(int i = 0;i<cycle.size();i++){
    	// 	cout<<cycle[i]<<" ";
    	// }
    	// cout<<'\n';
    	// cout<<cyc<<'\n';
    	// cout<<rp<<'\n';
    	if(k<rp){
    		cout<<v[k]+1<<'\n';
    	}
    	else{
    		k-=rp;
    		k = k%cyc;
    		cout<<cycle[k]+1<<'\n';
    	}
    }
}   

Measured memory_bytes: 10780
import java.util.*;

class Main{
  public static void main(String[] args){
    int numx=0;
  //  int numx=0;
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    //String[] strArray = str.split("");
  for(int i=0; i < str.length(); i++){
    if(str.charAt(i)=='x'){
      numx++;
    }
  }
  if(numx >= 8){
    System.out.println("NO");
  }else{
    System.out.println("YES");
    }
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double MOD = 1e9+7,MAX = 1e5;

int main()
{
	double n;
	cin >> n;
	vector<double> x(n),y(n);
	for(double i = 0;i<n;i++)
	cin >> x[i];
	for(double i = 0;i<n;i++)
	cin >> y[i];
	double ans = 0;
	for(double i = 0;i<n;i++)
	{
		ans += abs(x[i]-y[i]);
	}
	printf("%.7lf\n",ans);
	ans = 0;
	for(double i = 0;i<n;i++)
	{
		ans += pow(abs(x[i]-y[i]),2.0);
	}
	ans = pow(ans,0.5);
	printf("%.7lf\n",ans);
	ans = 0;
	for(double i = 0;i<n;i++)
	{
		ans += pow(abs(x[i]-y[i]),3.0);
	}
	ans = pow(ans,1.0/3.0);
	printf("%.7lf\n",ans);
	ans = 0;
	for(double i = 0;i<n;i++)
	{
		ans = max(ans,abs(x[i]-y[i]));
	}
	printf("%.7lf\n",ans);
	return 0;
}


Measured memory_bytes: 3420
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>
#include <utility>
#define INF 9999999999
using namespace std;
typedef long long int ll;

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

	if (A + B >= C) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int main() {
  int X; cin >> X;
  int ans;
  if (X >= 400 && X <= 599) ans = 8;
  if (X >= 600 && X <= 799) ans = 7;
  if (X >= 800 && X <= 999) ans = 6;
  if (X >= 1000 && X <= 1199) ans = 5;
  if (X >= 1200 && X <= 1399) ans = 4;
  if (X >= 1400 && X <= 1599) ans = 3;
  if (X >= 1600 && X <= 1799) ans = 2;
  if (X >= 1800 && X <= 1999) ans = 1;
  cout << ans << endl; 
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
	int N;
	int s[110] = {};
	int sum = 0;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		sum += s[i];
	}

	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		ans = sum;
		int mini = 1000;
		int flag = 0;
		for (int i = 0; i < N; i++) {
			if ((ans - s[i]) % 10 != 0) {
				mini = min(s[i], mini);
				flag++;
			}
		}
		if (flag > 0) {
			ans -= mini;
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from bisect import bisect_left, bisect_right
s = input()
t = input()

n = len(s)
ds = defaultdict(list)
for i in range(n*2):
    ds[s[i%n]].append(i)

ans = 0
x = -1
for i in range(len(t)):
    if t[i] not in ds:
        ans = -1
        break

    x_next = ds[t[i]][bisect_right(ds[t[i]], x)]
    ans += x_next - x
    x = x_next % n
    # print(ans, t[i])

print(ans)


Measured memory_bytes: 53104
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    string s; cin >> s;
    int n = s.size() + 1;
    int l[n], r[n]; rep(i,n) l[i] = r[i] = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == '<') l[i+1] = l[i] + 1;
        else l[i+1] = 0;
    }
    for (int i = n - 1; i > 0; --i) {
        if (s[i-1] == '>') r[i-1] = r[i] + 1;
        else r[i-1] = 0;
    }
    ll ans = 0;
    rep(i,n) ans += max(l[i], r[i]);
    out(ans);



    return 0;
}









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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }

int dp[110][101010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    rep(i, N) reps(j, W) {
        if (j+w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
        chmax(dp[i+1][j], dp[i][j]);
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, num_2=0, num_4=0;
    cin >> n;
    vector<ll> a(n, 0);
    rep1(i, n){
        cin >> a[i];
        if (a[i]%4==0) num_4++;
        else if (a[i]%2==0) num_2++;
    }
    if (n%2==0){
        if (num_4*2+num_2>=n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if (num_4*2+num_2>=n-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    ll k = (a + b) / 2;
    if (abs(a - k) == abs(b - k)) {
        cout << k << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

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

using namespace std;

int main()
{
	string s;
	int k;
	cin >> s >> k;
	set<string> firstK;
	priority_queue<pair<string, int>, vector<pair<string, int>>, greater<pair<string, int>>> q;
	for (int i = 0; i < s.size(); i++) q.push(pair<string, int>(string() + s[i], i));
	while (firstK.size() < k)
	{
		auto p = q.top();
		q.pop();
		firstK.insert(p.first);
		if (p.second < s.size()-1) q.push(pair<string, int>(p.first + s[p.second+1], p.second+1));
	}
	cout << *firstK.rbegin() << endl;
	return 0;
}


Measured memory_bytes: 640
import numpy as np
n, m, c = map(int, input().strip().split())
bs = np.array(list(map(int, input().strip().split())))
as_ = np.array([list(map(int, input().strip().split())) for _ in range(n)])

result = np.dot(as_, bs) + c
counts = np.ones_like(result)
ans = np.sum(counts[result > 0])

print(ans)


Measured memory_bytes: 12488
a,b,c,d= input().split()
N = int(d)
R= int(a)
G = int(b)
B = int(c)

max_r = N // R
count = 0
for i in range(max_r+1):
 rest_n_r = N - R*i
 max_g = rest_n_r // G
 for j in range(max_g+1):
  rest_n_r_g = rest_n_r - G*j
  mod = rest_n_r_g % B
  if(mod == 0):
   count += 1

print(count)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() {
   int n; cin >> n;
   int res = 1000 - n%1000;
   if(res==1000)res = 0;
   cout << res << ln;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define N 400010
#define M 1000010
#define inf 2147483647
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int tot=1;
int fir[N],nex[M],got[M],tak[M];
inline void AddEdge(int x,int y,int z) { 
    nex[++tot]=fir[x],fir[x]=tot,got[tot]=y,tak[tot]=z; 
}
int dep[N],que[N];
inline int bfs(int s,int t) {
	memset(dep,0,sizeof(dep));
	int l=1,r=1;
	dep[s]=1,que[1]=s;
	while (l<=r) {
		int x=que[l++];
		for (int i=fir[x];i;i=nex[i]) {
			int y=got[i];
			if (dep[y] || !tak[i]) continue;
			dep[y]=dep[x]+1,que[++r]=y;
		}
	}
	return dep[t];
}
inline int dfs(int x,int t,int flow) {
	int rest=flow;
	if (x==t) return flow;
	for (int i=fir[x];i && rest;i=nex[i]) {
		int y=got[i];
		if (!tak[i] || dep[y]!=dep[x]+1) continue;
		int k=dfs(y,t,min(rest,tak[i]));
		if (!k) dep[y]=0;
		tak[i]-=k,tak[i^1]+=k,rest-=k;
	}
	return flow-rest;
}
inline int dinic(int s,int t) {
    int flow=0;
    while (bfs(s,t)) flow+=dfs(s,t,inf);
    return flow;
}
vector <int> v[N];
int mat[N],a[N],b[N];
inline int solve(int n) {
    int tot=0;
    queue<int> q; q.push(n);
    for (int i=1;i<=n-1;i++)
        for (int j=fir[i];j;j=nex[j])
            if (got[j]!=2*n-1 && !tak[j]) mat[i]=got[j]-n+1;
    // for (int i=1;i<=n;i++) printf("%d ",mat[i]); puts("");
    while (!q.empty()) {
        int x=q.front(); q.pop();
        // puts("qwq");
        for (auto &u:v[x]) if (mat[u]) {
            ++tot; a[u]=x,b[u]=mat[u]; q.push(mat[u]),mat[u]=0;
        }
    }
    // cout<<tot<<endl;
    return tot;
}
int main() {
    int n=read(),s=2*n-1,t=s+1;
    for (int i=1;i<n;i++) {
        AddEdge(s,i,1),AddEdge(i,s,0);
        AddEdge(t,i+n-1,0),AddEdge(i+n-1,t,1);
        int k=read();
        while (k--) {
            int x=read(); v[x].push_back(i);
            if (x==n) continue;
            AddEdge(i,x+n-1,1),AddEdge(x+n-1,i,0);
        }
    }
    // cout<<dinic(s,t)<<endl;
    if (dinic(s,t)<n-1 || solve(n)<n-1) return puts("-1"),0;
    for (int i=1;i<=n-1;i++) printf("%d %d\n",a[i],b[i]);
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  long long int before = 0;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    long long int current;
    cin >> current;
    if (before >= current) h[i] = ++count;
    else {
      count = 0;
      h[i] = count;
    }
    before = current;
  }
  cout << *max_element(h.begin(), h.end()) << endl;
}

Measured memory_bytes: 640
num = int(input())
alist = []
n = 0
while n < num:
    alist.append(int(input()))
    n += 1

def maxlist(l,r):
    temp_list =[]
    p = 0
    q = r
    while q >= 1:
        m = max(l)
        l = [t for t in l if t != m]
        temp_list.append(m)
        q = len(l)
    size = len(temp_list)
    return size

ans = maxlist(alist,num)

print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    A = LI()

    ans = 1
    index = 0
    A_set = set(A)
    if 0 in A_set:
        print(0)
        return
    while index < N:
        ans *= A[index]
        index += 1
        if ans > 10**18:
            break

    if ans <= 10**18:
        print(ans)
    else:
        print(-1)


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 102140
h,w = gets.split.map(&:to_i)
a,b = 2.times.map{(1..h).map{gets.split.map(&:to_i)}}
ab = a.zip(b).map{|ta,tb|ta.zip(tb).map{|ua,ub|(ua-ub).abs}}

max = ab.map(&:max).max
zero = 1 << (h+w)*max/2

dp = [zero]
predp = [0]*w

ab.each{|abi|
  w.times{|tw|
    d = abi[tw]
    s = predp[tw] | dp[tw-1]
    dp[tw] = (s << d) | (s >> d)
  }
  predp,dp = dp,[0]
}
ans = predp[-1]
p (0..max).find{|i|ans & ((zero << i)|(zero >> i)) > 0}

Measured memory_bytes: 21500
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
class DisjoinSet{
    public:
        vector<int> rank,p;
        DisjoinSet(){}
        DisjoinSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i=0;i<size;i++)
                makeSet(i);
        }
        void makeSet(int x){
            p[x]=x;
            rank[x]=0;

        }
        int findSet(int x){
            if(x!=p[x]) p[x]=findSet(p[x]);
            return p[x];
        }
        bool same(int x,int y){return findSet(x)==findSet(y);}

        void unite(int x,int y){link(findSet(x),findSet(y));}

        void link(int x,int y){
            if(rank[x]>rank[y]) p[y]=x;
            else{
                p[x]=y;
                if(rank[x]==rank[y]) rank[y]++;
            }
        }
};
class Edge{
    public:
        int source,target,cost;
        Edge(int source=0,int target=0,int cost=0):
            source(source),target(target),cost(cost){}
        bool operator < (const Edge &e)const{
            return cost<e.cost;
        }    
};
int kruskal(int N,vector<Edge> edges){
    int totalCost=0;
    sort(edges.begin(),edges.end());
    DisjoinSet dset=DisjoinSet(N+1);
    for(int i=0;i<N;i++)dset.makeSet(i);

    int source,taget;
    for(int i=0;i<edges.size();i++){
        Edge e=edges[i];
        if(!dset.same(e.source,e.target)){
            totalCost+=e.cost;
            dset.unite(e.source,e.target);
        }
    }
    return totalCost;

}
int main(){
    int N,M,cost,source,target;
    cin>>N>>M;
    vector<Edge> edges;
    for(int i=0;i<M;i++){
        cin>>source>>target>>cost;
        edges.push_back(Edge(source,target,cost));
    }
    cout<<kruskal(N,edges)<<"\n";
    return 0;
}



Measured memory_bytes: 5404
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let digit: u8 = buf[0..1].parse().unwrap();
    let length = buf.trim_right().len();
    writeln!(output, "{}", (length - 1) * 9 + digit as usize - if buf.trim_right()[1..].chars().all(|x| x == '9') { 0 } else { 1 }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "100
",
            "18\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "9995",
            "35\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "3141592653589793",
            "137\n",
        );
    }

    #[test]
    fn case4() {
        test("1999",
             "28\n");
    }
}

Measured memory_bytes: 4352
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
	char c;
	char next;
	int ans = 0;
	cin >> c;
	while (cin >> next) {
		if (c != next) {
			c = next;
			ans++;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const int M = 10100001;
int mod = 1e9 + 7;
#define INF 0x3f3f3f3f
int rec[N];
int main()
{

   // ios::sync_with_stdio(0);
    int n;
    while (~scanf("%d", &n))
    {
    	int a1 = 0;
    	for (int i = 0; i < n; i++)
    	{
    		scanf("%d", rec + i);
    		if (i&1)
    			a1 -= rec[i];
    		else
    			a1 += rec[i];
    	}
    	printf("%d ", a1);
    	for (int i = 0; i < n-1; i++)
    	{
    		a1 = (rec[i]<<1) - a1;
    		printf("%d%c", a1, i != n-2?' ':'\n');
    	}
    }
    return 0;
} 

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<int> h(N),dp(N,0);
  REP(i,N) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  REP2(i,2,N){
    int tmp = abs(h[i]-h[i-1]) + dp[i-1];
    int tmp2 = abs(h[i]-h[i-2]) + dp[i-2];
    dp[i] = min(tmp,tmp2);
  }
  cout << dp[N-1];
  return 0;
}

Measured memory_bytes: 1024
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long INF = 9223372036854775809;

int main(){
  
  int N,K,Q;
  cin >> N >> K >> Q;
  
  vector<int> A(Q);
  vector<int> a(N,0);
  
  rep(i,Q){
    cin >> A.at(i);
    a.at(A.at(i)-1)++;
  }
  
  rep(i,N){
   // cout << "22" << endl;
    a.at(i)=K-(Q-a.at(i));
    if(a.at(i)>0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
      
  }
  
  
  
 
}

Measured memory_bytes: 1408
import math
k = int(input())

table = [0] * k
a = math.floor(math.log10(k))

num = 7
base = 1
result = 1
for i in range(a):
  base *= 10
  result += 1
  num += base * 7
if(num < k):
  base *= 10
  result += 1
  num += base * 7

div = (num - k) % k

while(div != 0 and table[div]==0):
  table[div] = 1
  div = (div * 10 + 7) % k
  result += 1

if(div == 0):
  print(result)
else:
  print(-1)


Measured memory_bytes: 71596
H, W = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]

from collections import deque

lst = deque()

for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            lst.append((i, j, 0))


def chg(i, j):
    if i < 0 or j < 0 or H <= i or W <= j: return False
    if A[i][j] == '.':
        A[i][j] = '#'
        return True
    return False


ans = 0
while lst:
    h, w, v = lst.popleft()
    ans = max(v, ans)
    for i in range(-1, 2):
        for j in range(-1, 2):
            if i != 0 and j != 0: continue

            if chg(h + i, w + j):
                lst.append((h + i, w + j, v + 1))
print(ans)


Measured memory_bytes: 161244
/*
package com.company.practice;
*/

import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;

import static java.lang.Character.isUpperCase;

public class Main {
    public static Scanner key = new Scanner(System.in);
    public static void solveJuice()
    {
        int n = key.nextInt();
        int k = key.nextInt();
        int[] f = new int[n];
        for(int i = 0;i <= n-1;i++)
            f[i] = key.nextInt();
        Arrays.sort(f,0,n);
        int sum = 0;
        for(int j =0;j <= k-1;j++)
        {
            sum += f[j];
        }
        System.out.println(sum);
    }
    public static void main(String[] args)
    {
        solveJuice();
    }
}


Measured memory_bytes: 39160
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args){
        int a = sc.nextInt(), b = sc.nextInt();
        int ans = Math.max(2*a-1,2*b-1);
        ans = Math.max(ans,a+b);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
month, day = input().split(" ")
month = int(month)
day = int(day)

num_d = 0
for m in range(2,month+1):
    for d10 in range(2,10):
        for d1 in range(2,10):
            if d10*d1 == m and d10*10+d1 <= day:
                num_d += 1

print(num_d)

Measured memory_bytes: 3060
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



bool is(ll a, ll b) {

	ll pro = a * b;
	
	return (pro / b != a);
}

int main()
{
    ll N;
    cin >> N;
    vll A(N);
    rep(i, 0, N) cin >> A[i];

    ld sm = 0.0;
    rep(i, 0, N) {
        sm += log10(A[i]);
    }
    if (sm > 18.0000000) {
        cout << -1 << endl;
        return 0;
    }
    ll pro = 1;
    bool flg = false;
    rep(i, 0, N) {
        if (is(pro, A[i])) {
            flg = true;
            break;
        }
        pro *= A[i];
        if (pro > 1000000000000000000) {
            flg = true;
            break;
        }
    }
    if (count(all(A), 0) > 0) {
        cout << 0 << endl;
    }
    else if (flg) {
        cout << -1 << endl;
    } else 
    cout << pro << endl;
}

Measured memory_bytes: 4056
#include <iostream>

int main()
{
    std::string s, t;
    std::cin >> s;
    std::cin >> t;
    auto ans = 0;
    for(auto sitr = s.begin(),titer = t.begin(); sitr != s.end(); ++sitr, ++titer) {
        if (*sitr == *titer) {
            ++ans;
        }
    }
    std::cout << ans << std::endl;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;

int main() {
    constexpr int C_MAX = 100000;
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R), inv_r(N, -1);
    REP(i, R) {
        cin >> r[i];
        --r[i];
        inv_r[r[i]] = i;
    }
    vector<vector<pii>> g(N);
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        --A; --B;
        g[A].push_back(pii(B, C));
        g[B].push_back(pii(A, C));
    }

    const ll INF = LLONG_MAX;
    ll result = INF;
    int mask = (1 << R) - 1;
    REP(start, R) {
        vector<ll> dp(N << R, INF);
        priority_queue<pli, vector<pli>, greater<pli>> q;
        dp[(r[start] << R) ^ (1 << start)] = 0;
        q.push(pli(0, r[start] << R ^ 1 << start));
        while (!q.empty()) {
            ll d;
            int state;
            tie(d, state) = q.top();
            q.pop();
            if (dp[state] < d) {
                continue;
            }
            int u = state >> R;
            int visited = state & mask;
            if (visited == mask) {
                result = min(result, d);
                break;
            }
            for (const pii &edge: g[u]) {
                int v = edge.first;
                int cost = edge.second;
                int visited_next;
                if (inv_r[v] == -1) {
                    visited_next = visited;
                } else {
                    visited_next = visited | 1 << inv_r[v];
                }
                int state_next = v << R ^ visited_next;
                if (dp[state_next] > d + cost) {
                    dp[state_next] = d + cost;
                    q.push(pli(dp[state_next], state_next));
                }
            }
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4400
n,k=map(int,input().split())
s=input()
r=s.split('L')
r=[i for i in r if i!='']
l=s.split('R')
l=[i for i in l if i!='']
hr=s.count('R')-len(r)
hl=s.count('L')-len(l)
if k>=min(len(r),len(l)):
  print(n-1)
else:
  print(hr+hl+k*2)

Measured memory_bytes: 5372
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <deque>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  
  int main(){
    int n,ans,bans;
    ans=0;
    bans=0;
    string s;
    cin >> s;
    bool f=true;
    for (int i=0;i < s.size();i++){
      if (s[i] == 'A' && f){ 
        ans=i+1;
        f=false;
      }
      else if (s[i] == 'Z') bans=i+1;
    }
    cout << bans-ans+1 << endl;
    


    return 0;
  }


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int MAX = 100005;
int a[MAX];
int s[MAX];

int main(){
  vector<int> isprime(MAX, 1);
  isprime[0] = 0; isprime[1] = 0;
  for(int i=0;i<MAX;i++){
    if(!isprime[i]) continue;
    for(int j=i*2;j<MAX;j+=i) isprime[j] = 0;
  }

  vector<int> a(MAX,0);
  for(int i=0;i<MAX;i++){
    if(i % 2 == 0) continue;
    if(isprime[i] && isprime[(i+1)/2]) a[i] = 1;
  }

  vector<int> s(MAX+1,0);
  for(int i=0;i<MAX;i++) s[i+1] = s[i] + a[i];

  int Q; cin >> Q;
  for(int i=0;i<Q;i++){
    int l,r; cin >> l >> r; r++;
    cout << s[r] - s[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
 
 
int main(){
		
		int x,y,a,b,c;
		cin>>x>>y>>a>>b>>c;
		int ar [100000],arr[100000];
		int br [100000],brr[100000];
		int cr [100000];
		for(int i=0;i<a;i++)cin>>ar[i];
		for(int i=0;i<b;i++)cin>>br[i];
		for(int i=0;i<c;i++)cin>>cr[i];
		sort(ar,ar+a);
		sort(br,br+b);
		sort(cr,cr+c);
		int cnta=0;
		int cntb=0;
		long long ans=0;
		for(int i=0;i<100000;i++){
			arr[i]=cr[c-1];
			brr[i]=cr[c-1];
		}
		for(int i=a-x;i<a;i++){arr[i-a+x]=ar[i];ans+=ar[i];}
		for(int i=b-y;i<b;i++){brr[i-b+y]=br[i];ans+=br[i];}
		for(int i=c-1;i>=0;i--){
			if(cr[i]<=arr[cnta]&&cr[i]<=brr[cntb])break;
			if(cr[i]-arr[cnta]>=cr[i]-brr[cntb]){
				
				ans+=cr[i]-arr[cnta];
				cnta++;
			}else {ans+=cr[i]-brr[cntb];cntb++;}
		}
			
		cout<<ans<<endl;
		return 0;
}

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

struct UnionFind {
    vector<int> v;
    UnionFind(int n): v(n, -1) {}
    int root(int x) {
        if (v[x] < 0) return x;
        return v[x] = root(v[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        if(v[x] > v[y]) swap(x, y);
        v[x] += v[y];
        v[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -v[root(x)]; }
};

int deg[100005];
vector<int> to[100005];

int main() {
    int N, M, K; // SNSの利用人数, 友達関係, ブロック関係
    cin>>N>>M>>K;
    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin>>a>>b;
        --a; --b;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
    }
    rep(i, K) {
        int c, d;
        cin>>c>>d;
        --c; --d;
        to[c].push_back(d);
        to[d].push_back(c);
    }
    rep(i, N) {
        int ans = uf.size(i)-1-deg[i];
        for(int u : to[i]) {
            if(uf.same(i,u)) --ans;
        }
        printf("%d%c", ans, i==N-1?'\n':' ');
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }
    
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int d = a.at(i) - b.at(i);
        if (d < 0) {
            sum += -ceil((double)abs(d) / 2) + abs(d) % 2;
        }
        else sum += d;
    }
    if (sum <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n, a, b;
  cin >> n >> a >> b;
  if ((b-a) % 2 == 0){
    I an = (b-a)/2;
    cout << an << endl;
  }else{
    I t = min(n-a,n-b);
    I t2 = min(a-1,b-1);
    I an = min(t,t2)+(b-a)/2+1;
    cout << an << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int amin = 1000;
	string S;

	cin >> S;

	for(int i = 0; i < S.size() - 2; i++){
		amin = min(amin, abs(753 - ((S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0'))));
	}

	cout << amin << endl;

	return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ll long long
const ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  for (int i = 2; i <= N; i++) {
    int x = i;
    for (int j = 2; j <= x; j++) {
      while (x % j == 0) {
        x /= j;
        mp[j]++;
      }
    }
  }

  ll ans = 1;
  for (auto x : mp) {
    ans = ((ans % MOD) * (x.second + 1) % MOD) % MOD;
  }

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


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

int upb(int n)
{
  int ret=0;
  while(n>0) ret++, n/=2;
  return ret;
}

int main()
{
  vector<bool> close(1<<(5*5), false);
  vector<int> cls;

  for (int n; cin>>n, !(n==0); ){

    vector<vector<int> > pats(n*n+1);
    vector<vector<int> > tmp(n, vector<int>(n, 0));

    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	for (int k=i; k<n; k++){
	  for (int l=j; l<n; l++){
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=1;
	    int bd=0;
	    for (int a=0; a<n; a++){
	      for (int b=0; b<n; b++){
		bd=(bd<<1)|tmp[a][b];
	      }
	    }
	    pats[upb(bd)].push_back(bd);
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=0;
	  }
	}
      }
    }

    int bd=0;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	int t; cin>>t;
	bd=(bd<<1)|t;
      }
    }

    queue<int> mm;
    mm.push(bd);
    close[bd]=true;
    cls.push_back(bd);
    while(!mm.empty()){
      int dep=mm.front()>>25;
      int cbd=mm.front()&0x1ffffff;
      mm.pop();
      int ub=upb(cbd);
      for (int i=0; i<pats[ub].size(); i++){
	int nbd=cbd^pats[ub][i];
	if (nbd==0){
	  for (int i=0; i<=dep; i++)
	    cout<<"myon";
	  cout<<endl;
	  goto _exit;
	}
	//cout<<"*** "<<nbd<<endl;
	if (close[nbd]) continue;
	close[nbd]=true;
	cls.push_back(nbd);
	mm.push(((dep+1)<<25)|nbd);
      }
    }
  _exit:;
    for (int i=0; i<cls.size(); i++)
      close[cls[i]]=false;
    cls.clear();
  }
  return 0;
}

Measured memory_bytes: 6276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

string str, rstr;

int main() {
	cin >> str;

	rstr = "";

	int len = str.size();
	for (int i = 0; i < len; i++) {
		rstr += str[len - i - 1];
	}

	cout << rstr << endl;

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1180
def main():
    N = int(input())
    grid = []
    for i in range(N):
        grid.append(list(input()))
    res = 0
    for a in range(1,2*N):
        
        flag = True
        for i in range(N):
            for j in range(N):
                if grid[i][j] != grid[j][i]:
                    flag = False
        # print(grid)
        grid.insert(0,grid[-1])
        del grid[-1]
        if not flag:
            continue
        res+=N-abs(a-N)
    print(res)
main()

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

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

	ll N=in(),K=in();
	vector<ll> A=vecin<ll>(N);
	sort(ALL(A));
	Combination comb(N);

	ll ans=0;
	REP(i,N){
		ans += (comb.Caluclation(i,K-1)*A[i])%atcoder_mod;
		ans -= (comb.Caluclation(N-1-i,K-1)*A[i])%atcoder_mod;
		ans = (ans%atcoder_mod+atcoder_mod)%atcoder_mod;
	}
	
	out(ans);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,c=0;
    cin>>n;
    ll a[n],s[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        s[i]=a[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        if(s[i]!=a[i])
            c++;
    }
    if(c>2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
    if(c >= a && c <= b)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    xx = [0 for i in range(n)]
    for i,j in enumerate(x):
        xx[i] = j**2
    minp = 100
    for i in range(200):
        k = i*(n*i - 2*sum(x))
        if k < minp:
            minp = k
    print(sum(xx)+ minp)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  int a, b, c, ans;

  ans = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(int i = a; i <= b; i++){

    if(c%i == 0){
      ans++;
    }

  }

  printf("%d\n", ans);

}



Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,d=1000000,e=0;
  int c[10000]={};
  cin>>a>>b;
  for(int i=0;i<a;i++){
    c[i]=b+i;
    d=min(d,abs(c[i]));
    // cout<<d<<" "<<abs(c[i])<<"\n";
    e=e+c[i];
  }
  if(e>=0) cout<<e-abs(d)<<"\n";
  else cout<<e+abs(d)<<"\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	if (A == B)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define st first
#define nd second

int n, w;
int a, b;
int cev;
vector <int> weights;
vector <int> values;
int dp[105][100005];

int32_t main() {
	ios_base::sync_with_stdio(0);
    cin >> n >> w;
    weights.pb(0);
    values.pb(0);
    for(int i = 0; i < n; i++){
    	cin >> a >> b;
        weights.pb(a);
        values.pb(b);
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 100005; j++){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < 100005; j++){
            if(j >= values[i]) dp[i][j] = min(dp[i-1][j], dp[i-1][j-values[i]]+weights[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    for (int i = 0; i < 100005; i++){
        if(dp[n][i] <= w) cev = i;
    }
    cout << cev << endl;
}

Measured memory_bytes: 82440