akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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



	string S, T;
	cin >> S >> T;

	int nagasaS = S.size();
	int nagasaT = T.size();

	int dekita = 0;

	for (int i = nagasaS - nagasaT; i >= 0; i--) {
		
		int dekiru = 1;
		rep(ii, nagasaT) {
			if (S[i + ii] != T[ii] && S[i + ii] != '?') {
				dekiru = 0;
			}
		}
		if (dekiru) {
			rep(ii, nagasaT) {
				S[i + ii] = T[ii];
			}
			dekita = 1;
			break;
		}
	}

	rep(i, nagasaS) {
		if (S[i] == '?') S[i] = 'a';
	}

	if(dekita) co(S);
	else co("UNRESTORABLE");

	Would you please return 0;
}

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

int main(){
  int l,r;
  for(;;){
    cin>>l>>r;
    if(l+r==0)break;

    set<unsigned int> pass;
    unsigned int t,max=0;

    pass.insert(0);

    for(int i=0;i<l+r;i++)
      cin>>t,pass.insert(t);

    set<unsigned int>::iterator it;
    for(it=pass.begin();it!=--pass.end();++it)
      if(*(++it)-*(--it)>max)max=*(++it)-*(--it);

    //if(l+r==1)max=*(pass.begin());
    cout<<max<<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int I1= sc.nextInt();
		String S2 = sc.next();
		sc.close();

		if(S2.length() <= I1) {
			System.out.println(S2);
		}else{
			System.out.println(S2.substring(0, I1)+"...");
		}
	}
}



Measured memory_bytes: 27048
n,m = gets.split.map(&:to_i)
pref = Array.new(n+1){[]}
ans = Array.new(m,nil)
m.times do |i|
  pi,yi = gets.split.map(&:to_i)
  pref[pi] << [i,yi]
end
pref.each_with_index do |arr,j|
  arr.sort_by!{|a| a[1]}
  arr.each_with_index do |a,i|
    ans[a[0]] = "%06d" % j  + "%06d" % (i+1)
  end
end

ans.each do |s|
  puts s
end


Measured memory_bytes: 34552
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        b[i] -= a[i]
        a[i] = 0
    else:
        count += b[i]
        a[i] -= b[i]
        b[i] = 0
    if a[i+1] < b[i]:
        count += a[i+1]
        b[i] -= a[i+1]
        a[i+1] = 0
    else:
        count += b[i]
        a[i+1] -= b[i]
        b[i] = 0
print(count)

Measured memory_bytes: 19004
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
  
  int n;
  cin>>n;
  n--;
  cout<<(n*(n+1))/2;



}

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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll,ll>> vii;
typedef vector<vii> vvii;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define iter(i,c) for (auto i:c)
#define ss second
#define ff first
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define DEBUG2(x,a) cout << '>' << #x << ':' << x << " >" << #a << ':' << a <<  endl;
#define DEBUG3(x,a,b) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << endl;
#define DEBUG4(x,a,b,c) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << " >" << #c << ':' << c << endl;
#define printstr(a,st,e,s) if (st<e) {cout<<s<<a[st];rep(noname,st+1,e) cout<<""<<a[noname];}cout<<"\n"
#define printarr1(a,st,e,s) if (st<e) {cout<<s<<a[st];rep(noname,st+1,e) cout<<" "<<a[noname];}cout<<'\n'
#define printarr(a,st,e,s) cout<<s<<": [";if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<", "<<a[noname];}cout<<"]\n"
#define printus(c,s) cout<<s<<": {";for (auto noname:c) cout<<noname<<",";cout<<"}\n"
#define printum(c,s) cout<<s<<": {";for (auto noname:c) cout<<noname.first<<":"<<noname.second<<", ";cout<<"}\n"
#define MAXN 102
#define mod 1000000007
 
ll n, m, k, a[MAXN];
string s,s1;
char c;

void solve() {
	cin>>s>>s1;
	ll ans = 0;
	rep(i,0,sz(s)) {
		if (s[i]!=s1[i]) ans++;
	}
	cout<<ans<<endl;
}
 
void aux() {
}
 
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    int direction = 1;
    vector<char> A, B;
    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            direction *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (direction == 1) {
                    A.push_back(c);
                } else {
                    B.push_back(c);
                }
            } else {
                if (direction == 1) {
                    B.push_back(c);
                } else {
                    A.push_back(c);
                }
            }
        }
    }

    if (direction == 1) {
        reverse(A.begin(), A.end());
        string s1 = string(A.begin(), A.end());
        string s2 = string(B.begin(), B.end());
        cout << s1 << S << s2 << endl;
    } else {
        reverse(B.begin(), B.end());
        reverse(S.begin(), S.end());
        string s1 = string(B.begin(), B.end());
        string s2 = string(A.begin(), A.end());
        cout << s1 << S << s2 << endl;
    }

    return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int INF = 1e9;
const int MAX = 100001;

int Q;

int main(){
    
    vector<bool> is_prime(MAX,true);
    is_prime[0] = false; is_prime[1] = false;
    for(int i = 2;i < MAX; ++i){
        if(is_prime[i]){
            for(int j = i * 2; j < MAX; j += i) is_prime[j] = false;
        }
    }

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

    for(int i = 0; i < MAX; ++i){
        s[i+1] = s[i] + a[i];
    }

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

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer n = scan.nextInt();
        Integer l = scan.nextInt();
        Integer taste = IntStream.range(l, l + n).sum();

        Integer result;
        if(l >= 0) {
            result = taste - l;
        }
        else if(Math.abs(l) < n) {
            result = taste;
        }
        else {
            Integer tmp = IntStream.range(l, l + n)
                    .reduce(n + Math.abs(l), (i1,i2) ->
                            Math.abs(i1) > Math.abs(i2) ? i2 : i1);
            result = taste - tmp;
        }
        System.out.println(result);
        scan.close();
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

// TODO: write
int main() {
  string s,t;cin>>s>>t;
  print(t+s);
  return 0; 
}


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

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}


Measured memory_bytes: 2920
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define mod 1000000007
#define infinity (ll)1e8+1
#define PI 3.14159265358979

#define ll long long
#define pdd pair<double,double>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>//ll
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define vch vector<char>
#define vb vector<bool>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()
#define X first
#define Y second


int main()
{
	ios_base::sync_with_stdio(false);
	//ifstream in("In.txt");

	ll power[31];
	power[0] = 1;
	FOR(i, 1, 31)
		power[i] = 2 * power[i - 1];
	
	int a, b, c;
	cin >> a >> b >> c;
	int a1, b1, c1;
	FOR(i,0,1000000)
	{
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
		{
			cout << i;
			return 0;
		}

		a1 = b / 2 + c / 2;
		b1 = a / 2 + c / 2;
		c1 = a / 2 + b / 2;
		a = a1;
		b = b1;
		c = c1;
	}

	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t="keyence";cin>>s;
  bool isok=false;
  ll l=s.length();
  rep(i,8) {
    if(s.substr(0,i)==t.substr(0,i)&&s.substr(l-(7-i),7-i)==t.substr(i,7-i)) {
      isok=true;
      break;
    }
  }
  print(isok?"YES":"NO");
  return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [input() for x in range(H)]
output = [[0 for a in range(W)] for b in range(H)]

count = 0

for i in range(H):
  for j in range(W):
    s = S[i][j]
    if s == '#':
      count += 1
      output[i][j] = count
      left = '.'
      right = '.'
      
      sw = 0
      while left == '.':
        sw += 1
        if j - sw < 0 or S[i][j-sw] == '#':
          left = ''
        else:
          left = S[i][j-sw]
        if left == '.':
          output[i][j-sw] = count
      sw = 0
      while right == '.':
        sw += 1
        if j + sw > W-1 or S[i][j+sw] == '#':
          right = ''
        else:
          right = S[i][j+sw]
        if right == '.':
          output[i][j+sw] = count

last = 0
for i in range(H):
  if 0 in output[i]:
      output[i] = output[last]
  else:
    last = i


for i in range(H):
  revi = H-i-1
  if 0 in output[revi]:
      output[revi] = output[last]
  else:
    last = revi

for i in range(H):
  print(' '.join(map(str, output[i])))

Measured memory_bytes: 7224
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
const int MAXN=101;
int A[MAXN],B[MAXN],C[MAXN];
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
struct node
{
	int ma;
	int x,y;
	node(int m,int xx,int yy)
	{
		ma=m;x=xx;y=yy;
	}
	bool operator < (const node& a) const
	{
		return ma<a.ma;
	}
};
string str;
int main()
{
	int n=read(),k=read();
	cin>>str;
	int ans=0;
	for(int i=1;i<n;++i) if(str[i]==str[i-1]) ans++;
	ans=min(ans+2*k,n-1);
	cout<<ans<<endl;
}	


Measured memory_bytes: 512
//package atcoder.beginner179;

import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            String s = in.next();
            if(s.charAt(s.length() - 1) == 's') {
                out.println(s + "es");
            }
            else {
                out.println(s + "s");
            }
        }
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
}




Measured memory_bytes: 25476
#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int N=2e5+5;
char s[N];
int n;
string t[N];
int top=0;
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	scanf("%s",s+1),n=strlen(s+1);
	int ans=n;
	for(ri i=1;i<=n;++i)if(s[i]==s[i-1])s[i+1]='0',--ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,A[2010],B[2010];
int h[2010],nxt[40010],to[40010],K=0;
int aa=0,bb=0;
void ins(int u,int v){nxt[++K]=h[u];h[u]=K;to[K]=v;}
int dfs(int x,int fa,int dep)
{
	int siz=0;
	for(int i=h[x];i;i=nxt[i])
		if(x==aa&&to[i]==bb||x==bb&&to[i]==aa||to[i]==fa)continue;
		else siz+=dfs(to[i],x,dep+1);
	if(dep>k/2)siz++;return siz;
 } 
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)scanf("%d%d",&A[i],&B[i]),ins(A[i],B[i]),ins(B[i],A[i]);
	int ans=1e9;
	if(k&1)
	{
		for(int i=1;i<n;i++)
		{
			aa=A[i],bb=B[i];
			ans=min(ans,dfs(A[i],0,0)+dfs(B[i],0,0));
		}
	}
	else
	{
		for(int i=1;i<=n;i++)ans=min(ans,dfs(i,0,0));
	}
	printf("%d",ans);return 0;
 } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e6 + 5;
int arr[MAX_N];

void solve()
{
}

int main()
{
    char d;
    cin >> d;
    if (d - 'A' < 26)
    {
        cout << 'A' << "\n";
    }
    else
    {
        cout << 'a' << "\n";
    }
}

Measured memory_bytes: 3584
N = int(input())
count = 0

N -= 1 if len(str(N)) == 6 else 0

count += N - 10000 + 1 if len(str(N)) == 5 else 0
count += min(900, N - 100 + 1) if len(str(N)) >= 3 else 0
count += min(9, N) if len(str(N)) >= 1 else 0

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    if(s<b&&a<f){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;   
  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const int INF = 1 << 30;
const LL LLINF = 1LL << 60;
using namespace std;


int main(void){
    int N;
    cin >> N;

    vector<int> s(N);
    rep(i, N) cin >> s[i];

    int s_sum = accumulate(ALL(s), 0);
    if(s_sum % 10 != 0) {
        cout << s_sum << endl;
        return 0;
    }

    int min_num = INF;
    rep(i,N){
        if(s[i]%10 != 0) chmin(min_num, s[i]);
    }
    cout << max(s_sum - min_num, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0

for i in range(N):
    if A[i] < B[i]:
        ans += A[i]
        B[i] -= A[i]
        A[i] = 0
        if A[i+1] < B[i]:
            ans += A[i+1]
            A[i+1] = 0
        else:
            ans += B[i]
            A[i+1] -= B[i]
            B[i] = 0
    else: # A[i] >= B[i]
        ans += B[i]
        
print(ans)

Measured memory_bytes: 19156
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	const int Te=1;
	#include<De>
#else 
	const int Te=0;
#endif
using namespace std;
#define IF if(Te)
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	freopen("E.in","r",stdin);
#endif
	try{
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
		IF printf("%s","exception");
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 1e5+5;
int n,m;
int a[N];
int mod;
//ll cal(int x){
//	ll ans = 0;
//	for(int i=2;i<=n;i++){
//		ans+=min((a[i]-a[i-1]+mod)%mod,(a[i]-x+mod)%mod+1);
//	}
//	return ans;
//}
ll p[3*N];
void inp(){
	scanf("%d%d",&n,&m);
	mod=m;
	for(int i =1;i<=n;i++){
		scanf("%d",&a[i]);
	}
#ifdef XS
//	for(int i = 0;i<m;i++){
//		printf("%d ->fav:%lld\n",i,cal(i));
//	}
#endif
	MS(p);
	ll all = 0;
	for(int i = 2;i<=n;i++){
		int l = a[i-1];
		int r = a[i];
		if(r<l)r+=m;
		all += r - l;
		if(r-l==1);
		else {
			p[l+2]+=1;
			p[r+1]+=l-r;
			p[r+2]+=r-l-1;
		}
	}
	for(int i = 1;i<=2*m+5;i++)p[i]+=p[i-1];
	for(int i = 1;i<=2*m+5;i++)p[i]+=p[i-1];
	
	ll ans = -1;
	for(int i = 1;i<=m;i++)ans=max(ans,p[i]+p[i+m]);
	printf("%lld\n", all - ans);
}
//E.cc by xsthunder at Fri Jul 14 16:37:25 2017


Measured memory_bytes: 2944
//NEVER LOSE HOPE 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define si set<int>
#define mi map<int,int>
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(),v.end()
#define gi greater<int>()
#define mp make_pair
#define endl "\n"

//to count no of digits //floor(log10(n) + 1)

#define lb lower_bound //a,a+n,4 -a==index of 4  // returns pointer to the "first position of num" if number is present in the container. Returns pointer to the "position of next higher number greater than num" if num is not present.   
#define ub upper_bound // returns pointer to the "first position of the next higher number than last occurence of num" if num is present in the container. Returns pointer to the position of next higher number than num if container does not contain occurence of num.
#define REP(i,n) for(int i=0;i<n;i++)
#define REPE(i,n) for(int i=n-1;i>=0;i--)
#define REPA(i,a,n) for(int i=a;i<=n;i++)
 
//next_permutation(s.begin(),s.end())
//*max_element(a,a+n)
#define mod 1000000007
int N=INT_MAX;
using namespace std;

bool isPrime(int n)
{if(n==1)return false;
for(int i=2;i*i<=n;i++)
{if(n%i==0)return false;}
return true;
} 

int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
 
}

  
 //JAI SHREE RAM  //JAI SHREE RAM //JAI SHREE RAM  //JAI SHREE RAM
///////////////// MAIN FUNCTION ////////////////////////

 void CSK()
 {
  string s;
  cin>>s;
  int sm=0,x=0;;
  for(int i=0;s[i];i++){
  	int x=abs(48-s[i]);
    sm+=x;
  }

  if(sm%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
    

  





   



    




  




    

















}
///////////////////////// END //////////////////////////////////////  
  
 

 
 
 
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    fastio;
    cout<<fixed;
    cout.precision(10);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    CSK();  
}
 
}

Measured memory_bytes: 3716
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$al = range("a","z");
$r = 1;
$q = $N;
$res=array();
while($q > 0) {
  if ($q==0) break;
  $r = $q % 26;
  if ($r==0) {$r=26;$q-=26;};
  $res[] = $al[$r-1];
  $q = intdiv($q , 26);
}
krsort($res);
printf("%s\n",implode("",$res));


Measured memory_bytes: 16112
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
pair<ld,ll> a[4];
int main(){
    ld n,tmp;
    rep(i,0,4){cin>>tmp;a[i]F=tmp*8/powl(2,i);a[i]S=pow(2,i);}
    cin>>n;
    n*=4;
    sort(a,a+4);
    ll cnt=n,ans=0,t;
    rep(i,0,4){ans+=(cnt/a[i]S)*(a[i]F*a[i]S/8);cnt%=a[i]S;}
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
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 Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
int main(void){
    string S;cin>>S;
    if(S[0]=='S')cout<<"Cloudy";
    else if(S[0]=='C')cout<<"Rainy";
    else cout<<"Sunny";
    cout<<"\n";
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        int count = 0;
        for (int i = 0; i < 3; i++)
        {
            if (s[i] == t[i])
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
int A[100007], B[100007];
int main() {
	int n; cin >> n;
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < n; i++) {
		cin >> B[i];
	}

	for (int i = 0; i < n; i++) {
		int left = min(A[i], B[i]);
		ans += left;
		A[i] -= left;
		B[i] -= left;

		int right = min(A[i + 1], B[i]);
		ans += right;
		A[i + 1] -= right;
		B[i] -= right;

	}

	cout << ans;
	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int x, y;
    cin >> x >> y;

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

    vector<string> board(x);
    rep(i, x) cin >> board[i];

    rep(i, x)
    {
        rep(j, y)
        {
            if (board[i][j] == '#')
            {
                int cnt = 0;
                rep(k, 4)
                {
                    int xx = i + dx[k];
                    int yy = j + dy[k];

                    if (0 <= xx && xx < x && 0 <= yy && yy < y && board[xx][yy] == '#')
                    {
                        cnt++;
                    }
                }
                if (!cnt)
                {
                    cout << "No" << '\n';
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 3656
#a
x=int(input())
x=x/100
if x<12:
    if x<8:
        if x<6:
            a=8
        else:
            a=7
    else:
        if x<10:
            a=6
        else:
            a=5
else:
    if x<16:
        if x<14:
            a=4
        else:
            a=3
    else:
        if x<18:
            a=2
        else:
            a=1
        
print(a)

Measured memory_bytes: 9208
N = int(input())

count = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        #print("FizzBuzz")
        pass
    elif i % 3 == 0:
        #print("Fizz")
        pass
    elif i % 5 == 0:
        #print("Buzz")
        pass
    else:
        count += i
print(count)

Measured memory_bytes: 9168
import java.util.*;

import static java.lang.System.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();

    static  class P{
    	int x;
    	int y;
    	public P(int x,int y){
    		this.x=x;this.y=y;
    	}

    	@Override
    	public boolean equals(Object obj) {
    		if(!(obj instanceof P))return false;
    		P p=(P)obj;
    		return p.x==x && p.y==y;
    	}
    	@Override
    	public String toString() {
    		return "("+x+","+y+")";
    	}
    }

    public void run() {
        Test:while(true){
        	int W=sc.nextInt();
        	int H=sc.nextInt();
        	if(W==0 && H==0)return;
        	boolean[][] map=new boolean[H][W];

        	int[][] wall=new int[2*H-1][W];
        	for(int h=0;h<2*H-1;h++){
        		for(int w=0;w<(h%2==0?(W-1):W);w++){
            		wall[h][w]=sc.nextInt();
        		}
        	}

        	Queue<P> plist=new LinkedList<P>();
        	plist.add(new P(0,0));
        	map[0][0]=true;
        	int l=1;
        	while(!plist.isEmpty()){
        		Queue<P> next=new LinkedList<P>();

        		while(!plist.isEmpty()){
	        		P p=plist.poll();
	        		if(p.x ==W-1 &&p.y ==H-1){
	        			ln(l);continue Test;
	        		}
	        		//N
	        		if(p.y-1>=0){
		        		if(wall[2*p.y-1][p.x]==0 && !map[p.y-1][p.x]){
		        			map[p.y-1][p.x]=true;
		        			next.add(new P(p.x,p.y-1));
		        		}
	        		}
	        		//S
	        		if(p.y+1<H){
		        		if(wall[2*p.y+1][p.x]==0 && !map[p.y+1][p.x]){
		        			map[p.y+1][p.x]=true;
		        			next.add(new P(p.x,p.y+1));
		        		}
	        		}
	        		//E
	        		if(p.x+1<W){
		        		if(wall[2*p.y][p.x]==0 && !map[p.y][p.x+1]){
		        			map[p.y][p.x+1]=true;
		        			next.add(new P(p.x+1,p.y));
		        		}
	        		}
	        		//W
	        		if(p.x-1>=0){
		        		if(wall[2*p.y][p.x-1]==0 && !map[p.y][p.x-1]){
		        			map[p.y][p.x-1]=true;
		        			next.add(new P(p.x-1,p.y));
		        		}
	        		}
        		}
        		l++;
        		plist=next;
        	}
        	ln(0);
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, d;
	while (cin >> n >> d) {
		if (n == 0 && d == 0) break;
		vector< stack< int > > vq(n, stack< int >());
		vector< int > sum(n, 0);
		for_(i,0,n) {
			int m; cin >> m;
			for_(j,0,m) {
				int c; cin >> c;
				vq[i].push(c);
				sum[i] += c;
			}
		}
		
		bool end = false;
		while (!end) {
			end = true;
			for_(i,0,n) {
				if (vq[i].empty()) continue;
				sum[i] -= vq[i].top();
				if (*max_element(sum.begin(), sum.end()) - *min_element(sum.begin(), sum.end()) <= d) { vq[i].pop(); end = false; }
				else sum[i] += vq[i].top();
			}
		}
		
		cout << (*max_element(sum.begin(), sum.end()) == 0 ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(min(B, D) - max(A, C), 0) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    N = ir()
    P = lr()
    P = [((p-1)//N, (p-1)%N) for p in P]
    dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]
    people = [[True] * N for i in range(N)]

    answer = 0
    for i, j in P:
        answer += dp[i][j]
        people[i][j] = False
        que = deque([(i, j, dp[i][j])])
        popleft = que.popleft; append = que.append
        while que:
            y, x, cur = popleft()
            cur += people[y][x]
            if x > 0:
                if dp[y][x-1] > cur:
                    dp[y][x-1] = cur
                    append((y, x-1, cur))
            if x < N-1:
                if dp[y][x+1] > cur:
                    dp[y][x+1] = cur
                    append((y, x+1, cur))
            if y > 0:
                if dp[y-1][x] > cur:
                    dp[y-1][x] = cur
                    append((y-1, x, cur))
            if y < N-1:
                if dp[y+1][x] > cur:
                    dp[y+1][x] = cur
                    append((y+1, x, cur))

    print(answer)
    
if __name__ == "__main__":
    main()


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

const ll mod = 1000000007;

ll power(ll x, ll y) {
    if(y == 1) {
        return x;
    }
    
    ll ans;
    if(y % 2 == 1) {
        ll r = power(x,(y-1)/2);
        ans = r * r % mod;
        ans = ans * x % mod;
    }
    else {
        ll r = power(x,y/2);
        ans = r * r % mod;
    }
    
    return ans;
}

ll comb(ll x, ll y) {
    ll c, p;
    c = p = 1;
    
    while(y >= 1) {
        c *= x;
        p *= y;
        c %= mod;
        p %= mod;
        x--;
        y--;
    }
    
    return c * power(p,mod-2) % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    
    cout << comb(n-k+1,1) << endl;
    for(int i = 2; i <= k; i++) {
        ll b = comb(k-i+(i-1),i-1);
        ll r = comb((n-k)-(i-1)+i,i);
        
        //cout << b << " " << r << endl;
        cout << (b * r) % mod << endl;
    }
    
    
    return 0;
}




Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
	int h, w,a=0;
	char s[52][52];
	cin >> h >> w;
	for (int i = 1;i <= h;i++)
		for (int j = 1;j <= w;j++)
			cin >> s[i][j];
	for (int i = 0;i <= h + 1;i++) {
		s[i][0] = '.'; s[i][w + 1] = '.';
	}
	for (int j = 1;j <= w + 1;j++) {
		s[0][j] = '.'; s[h + 1][j] = '.';
	}

	for (int i = 1;i <= h;i++)
		for (int j = 1;j <= w;j++) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] == '.'&&s[i + 1][j] == '.'&&s[i][j - 1] == '.'&&s[i][j + 1] == '.') a = 1;
			}
		
		}

	if (a == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
n,y = map(int, input().split())
count = 0
for i in range(0,n+1):
    for j in range(0,n-i+1):
        a = 10000*i + 5000*j + 1000*(n-i-j)
        if (a == y):
            ans = [i,j,n-i-j]
            print(*ans)
            sys.exit()
ans = [-1,-1,-1]
print(*ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int n=sc.nextInt();
        int ph=sc.nextInt();
        int pw=sc.nextInt();
        String s[]=sc.next().split("",0);
        String s2[]=sc.next().split("",0);
        boolean po=true;
        int pcopyw=pw;
        for(int i=0;i<n;i++){
            if(s[i].equals("R")){
                pcopyw++;
            }
            if(pcopyw>w){po=false;
                break;
            }
            if(s2[i].equals("L")&&pcopyw>1){
                pcopyw--;
            }
        }
        pcopyw=pw;
        for(int i=0;i<n&&po;i++){
            if(s[i].equals("L")){
                pcopyw--;
            }
            if(pcopyw<=0){po=false;
                break;
            }
            if(s2[i].equals("R")&&pcopyw<w){
                pcopyw++;
            }
        }
        int pcopyh=ph;
        for(int i=0;i<n&&po;i++){
            if(s[i].equals("D")){
                pcopyh++;
            }
            if(pcopyh>h){po=false;
                break;
            }
            if(s2[i].equals("U")&&pcopyh>1){
                pcopyh--;
            }
        }
        pcopyh=ph;
        for(int i=0;i<n&&po;i++){
            if(s[i].equals("U")){
                pcopyh--;
            }
            if(pcopyh<=0){po=false;
                break;
            }
            if(s2[i].equals("D")&&pcopyh<h){
                pcopyh++;
            }
        }
        System.out.println(po?"YES":"NO");
    }
}


Measured memory_bytes: 54472
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>
#include<iomanip>

using namespace std;

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

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;


int main(){
	ll n,m,d;cin>>n>>m>>d;
	double ans = 0.0;

	if(d == 0)
		ans = 1.0*(m-1)/n;
	else{
		ans = double((n - d) * 2) / (n*n)*(m - 1);
	}

	cout << setprecision(7)<< ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
        a.Add(0);
        var listA = new List<int>();
        var listB = new List<int>();
        bool judge = false;
        int temp = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < a[i + 1])
            {
                if (!judge) listA.Add(i - 1);
                judge = true;
            }
            if (a[i] > a[i + 1] && judge) { listB.Add(i); judge = false; temp = 0; }
        }
        long money = 1000;
        while (listB.Count() >= 1)
        {
            int min = a.Where((f, g) => g >= listA[0] + 1 && g <= listB[0]).Min();
            int max = a.Where((f, g) => g >= listA[0] + 1 && g <= listB[0]).Max();
            long kabu = money / min;
            money = money - kabu * min + kabu * max;
            listA.RemoveAt(0);
            listB.RemoveAt(0);
        }
        Console.WriteLine(money);
    }
}

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

int main(void){
    int n,q,x,y;
    cin>>n>>q;
    stack<int> s[n];
    while(q--){
        cin>>x;
        if(x==0){
            cin>>x>>y;
            s[x].push(y);
        }else if(x==1){
            cin>>x;
            if(s[x].size()!=0)cout<<s[x].top()<<endl;
        }else{
            cin>>x;
            if(s[x].size()!=0)s[x].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4432
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
L = list(map(int, input().split()))
L.sort()

"""
短いほうから２本固定して条件に合うものをさがす（長いほうから２本固定でもOK）
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""


ans = 0
for i in range(N):
    for j in range(i+1, N):
        l = L[j] - L[i]
        r = L[j] + L[i]

        #  a < b < c（場合によっては等号を含む）で考えたときの、b - a < cを満たすもの 
        il = bisect_right(L, l, lo=j)
        #  a < b < c（場合によっては等号を含む）で考えたときの、c < a + bを満たすもの
        ir = bisect_left(L, r, lo=j)
        # b - a < cを満たすものがない場合、飛ばす
        if il == N-1:
            break
        
        ans += ir - il - 1

print(ans)


Measured memory_bytes: 46880
import sys
def input():
    return sys.stdin.readline()[:-1]

def code():
    a,b = map(int,input().split(' '))
    ans = 0
    p = 1
    while True:
        if b<=p:
            break
        ans += 1
        p += (a-1)
    print(ans)

if __name__=='__main__':
    code()

Measured memory_bytes: 3060
#include<stdio.h>
#define N 100
#define INFTY 21

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

main(){
  int  u, k, v, i, j; 

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  bfs(0);

  return 0;
}


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

long int gcd(long int a,long int b){
    if(!(a%b)) return b;
    return gcd(b,a%b);
}
int main(){
    long int x,y;
    while(cin >> x >> y)
        cout << gcd(x,y) << " " << x*y/gcd(x,y) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a + b > c + d) {
        printf("Left");
    } else if (a + b < c + d) {
        printf("Right");
    } else {
        printf("Balanced");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {

    void solve() {

        int n = io.nextInt();
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = io.nextInt();
        }

        int idx = partition(A, 0, A.length - 1);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i == idx) {
                sb.append(String.format(" [%d]", A[i]));
            } else {
                sb.append(String.format(" %d", A[i]));
            }
        }
        System.out.println(sb.toString().trim());
    }

    int partition(int[] A, int p, int r) {
        int x = A[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (A[j] <= x) {
                i += 1;
                swap(A, i, j);
            }
        }
        swap(A, i + 1, r);
        return i + 1;
    }

    void swap(int[] A, int idx1, int idx2) {
        int tmp = A[idx1];
        A[idx1] = A[idx2];
        A[idx2] = tmp;
    }

    public static void main(final String[] args) {
        new Main().solve();
    }

    IO io = new IO();

    class IO {
        private final int SIZE = 1 << 12;
        private final InputStream stream = System.in;
        private final byte[] buffer = new byte[SIZE];
        private int ptr = 0, buffLen = 0;

        private boolean hasNextByte() {
            if (ptr < buffLen) return true;
            ptr = 0;
            try {
                buffLen = stream.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return buffLen > 0;
        }

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

        private boolean isAscii(byte i) {
            return '!' <= i && i <= '~';
        }

        public char nextChar() {
            byte b = readByte();
            while (!isAscii(b)) b = readByte();
            return (char) b;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isAscii(b)) {
                sb.append((char) b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            return Integer.valueOf(next());
        }

        public long nextLong() {
            return Long.valueOf(next());
        }

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



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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind<int> UF(N);
    for(int i=0; i<M; ++i){
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if(UF.issame(l,r)){
            int diff = UF.diff(l,r);
            if(diff != d){
                cout << "No" << endl;
                return 0;
            }
        }else{
            UF.merge(l,r,d);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 1408