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

using namespace std;

typedef long long ll;
#define int ll

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1e9;

signed main(void){
    for(int n, m; cin >> n >> m;){
        vi s(n), t(n);
        rep(i, n) cin >> s[i] >> t[i];

        m += 2;
        vi p(m);
        p[0] = 0, p[m - 1] = inf;
        range(i, 1, m - 1) cin >> p[i];

        sort(all(p));
        
        int res = 0;
        vi cnt_lb(m, 0), cnt_ub(m, 0);

        rep(i, n){
            auto p_lb = p.begin(), p_ub = p.begin();

            if(s[i] < t[i]){
                p_lb = lower_bound(all(p), s[i]) - 1;
                p_ub = lower_bound(all(p), t[i]);

                if((p_ub - p_lb - 1) % 2 == 1){
                    p_ub--;
                }
                else {
                    res -= (*p_ub - t[i]);
                }
                
                res -= (s[i] - *p_lb);
            }
            else {
                p_lb = lower_bound(all(p), t[i]) - 1;
                p_ub = lower_bound(all(p), s[i]);

                if((p_ub - p_lb - 1) % 2 == 1){
                    p_lb++;
                }
                else {
                    res -= (t[i] - *p_lb);
                }

                res -= (*p_ub - s[i]);
            }

            cnt_lb[p_lb - p.begin()]++;
            cnt_ub[p_ub - p.begin()]++;
        }

        int cur_cnt = cnt_lb[0], pre_cnt = 0;

        range(i, 1, m){
            res += cur_cnt * (p[i] - p[i - 1]);

            cur_cnt -= cnt_ub[i];
            swap(cur_cnt, pre_cnt);
            cur_cnt += cnt_lb[i];
        }

        cout << res << endl;
    }

	return 0;
}

Measured memory_bytes: 4956
import java.util.Scanner;
public class Main {
	
	public static void main(String [] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		
		int [] arr = new int [n];
		
		
		int maxVal = Integer.MIN_VALUE;
		
		
		
		for(int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		
		int biggestNum = arr[n - 1];
		
		for(int j = n - 1; j > 0; j--) {
			
			 biggestNum = Math.max(arr[j], biggestNum);
			
			 
			 if(biggestNum - arr[j - 1] > maxVal) {
				 maxVal = biggestNum - arr[j - 1];
			 }
			 	
	}
		
		System.out.println(maxVal);
		
		

	}
}



Measured memory_bytes: 70388
import java.util.ArrayDeque;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Deque;
    import java.util.List;
    import java.util.Scanner;

    //
    public class Main {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int M = sc.nextInt();
            int cnt = 0;
            int count = 0;
            int ans = 0;
            int input[][]=new int[M+1][N+1];
            int input_p[]=new int[M+1];

            for(int i=1;i<=M;i++){
                int K = sc.nextInt();
                input[i][0]= K;
                for(int j=1;j<=K;j++){
                    input[i][j]=sc.nextInt();
                }
            }

            for(int k=1;k<=M;k++){
                input_p[k]=sc.nextInt();
            }



            for(int bit=0;bit<(1<<N);bit++){
                count=0;
                for(int i=1;i<=M;i++){
                    cnt=0;
                    for(int j=1;j<=input[i][0];j++){
                        if(((((1<<(input[i][j]-1))&bit)>>(input[i][j]-1)))==1){
                        cnt=cnt+1;
                        }
                    }
                    if(input_p[i]==cnt%2){
                        count=count+1;
                    }
                }
                if(count==M){
                    ans=ans+1;
                }
            }
        System.out.println(ans);
        }
    }







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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 100011;

int main() {
    int n, h, mx = 0;
    cin>>n>>h;
    vector<LL> data;
    for(int i = 0; i < n; ++i) {
        int a, b;
        cin>>a>>b;
        mx = max(mx, a);
        data.PB(b);
    }
    
    sort(ALL(data));
    reverse(ALL(data));
    
    for(int i = 1; i < SZ(data); ++i)
        data[i] += data[i-1];
    
    LL cur, ans = 1e15;
    for(LL i = 0; i < SZ(data); ++i) {
        cur = h;
        cur -= data[i];
        cur = max(0LL, cur);
        ans = min(ans, i+1 + cur/mx + ((cur % mx) ? 1LL : 0LL) );
        cur = 0;
    }
    PL(ans);
    return 0;
}

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

bool PN(int i){
	if(i == 2 || i == 3) return true;
	if(i <= 4 || i%2 == 0 || i%3 == 0) return false;
	for(int j = 6; (j-1)*(j-1) <= i; j+= 6) if((i%(j-1) == 0) || i%(j+1) == 0) return false;
	return true;
}

int main(){
	int N, P;
	while(1){
		int count = 0, PrimeNum[110] = {};
		vector <int> temp; 
		cin>>N>>P;
		if(N == -1 && P == -1) break;
		
		for(int i = N+1; count <= P; i++)
			if(PN(i)) PrimeNum[count++] = i;
		
		for(int i = 0; i <= P; i++)
			for(int j = i; j <= P; j++)
				temp.push_back(PrimeNum[i]+PrimeNum[j]);
		sort(temp.begin(), temp.end());
		cout<<temp[P-1]<<endl;
	}
		
	return 0;
}


Measured memory_bytes: 3164
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using Value = std::int64_t;

Value solve(std::vector<Value> array)
{
  int count_of_negative = 0;
  for (auto& v : array) {
    if (v < 0) {
      ++count_of_negative;
      v = -v;
    }
  }
  auto result = std::accumulate(array.begin(), array.end(), Value{0});
  if (count_of_negative % 2) {
    result -= 2 * *std::min_element(array.begin(), array.end());
  }
  return result;
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<Value> longs(n);
  for (auto& a : longs) {
    std::cin >> a;
  }

  std::cout << solve(longs) << std::endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    int cnt = A[0];
    for(int i = 1; i < N; i++) {
        if(INF%A[i] == 0) {
            if(INF/A[i] < cnt) {
                cout << -1 << endl;
                return 0;
            }
            cnt *= A[i];
        }
        else {
            if(INF/A[i] <= cnt) {
                cout << -1 << endl;
                return 0;
            }
            cnt *= A[i];
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4008
n, k = map(int, input().split())
sec = [list(map(int, input().split())) for _ in range(k)]
sec.sort()
    
mod = 998244353
    
dp = [0] * n
dp[0] = 1
sum_dp = [0, 1]
for i in range(1, n):
    for l, r in sec:
        if i - l < 0:
            break
        elif i - r > 0:
            dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod
        else:
            dp[i] = (dp[i] + sum_dp[i-l+1]) % mod
    
    sum_dp.append((sum_dp[-1] + dp[i]) % mod)
    
print(dp[n-1])


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

using namespace std;

int main()
{
	int n;
	int a[100];
	cin>>n;
	int t,ans=0;
	int min=10000000;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		min=i;
		for(int j=i;j<n;j++)
			if(a[j]<a[min])
				min=j;
		t=a[i];
		a[i]=a[min];
		a[min]=t;
		if(i!=min)
			ans++;
	}
	for(int i=0;i<n-1;i++)
		cout<<a[i]<<' ';
	cout<<a[n-1]<<endl;
	cout<<ans<<endl;
}


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

long int comb(long int);

int main(void){
    int n;
    cin >> n;
    vector<string> sv(n);
    for(int i = 0; i < n; i++) cin >> sv.at(i);
    unordered_map<string, int> hash;
    for(auto s : sv){
        sort(s.begin(), s.end());
        if(hash[s] == 0){
            hash[s]++;
        }else{
            hash[s] += 1;
        }
    }
    long int cnt = 0;
    for(auto i = hash.begin(); i != hash.end(); i++){
        cnt += comb(i->second);
    }
    cout << cnt << endl;
    return 0;
}

long int comb(long int x){
    return x*(x-1)/2;
}

Measured memory_bytes: 17700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int i = 0; i <= A; i++) {
			for(int j = 0; j <= B; j++) {
				for(int k = 0; k <= C; k++) {
					int t = 500 * i + 100 * j + 50 * k;
					if(t == X) cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

using i64 = long long;

int main() {
#ifdef HOME
	freopen("agc8c.in", "r", stdin);
	freopen("agc8c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant, i, o, t, j, l, s, z;

	cin >> i >> o >> t >> j >> l >> s >> z;

	ant = 2 * o;
	ant+= max(
		(i > 0 && j > 0 && l > 0) ? 6 + 4 * ((i - 1) / 2 + (l - 1) / 2 + (j - 1) / 2) : 0, /// ha ha ha ha, I'm such an idiot :<
		4 * (i / 2 + j / 2 + l / 2)
	);

	cout << ant / 2 << endl;

	return 0; }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) rep2(i,0,n)

using namespace std;


main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int ans=0;
    a[0]+=a[2]-a[1];
    ans+=a[2]-a[1];
    if((a[2]-a[0])%2==0) ans+=(a[2]-a[0])/2;
    else ans+=1+(a[2]-a[0]+1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	char s[4];
	cin >> s;
	int n = atoi(s);
	if(1 <= n / 100 && n / 100 <= 12 && 1 <= n % 100 && n % 100 <= 12) cout << "AMBIGUOUS" << endl;
	else if(1 <= n % 100 && n % 100 <= 12) cout << "YYMM" << endl;
	else if(1 <= n / 100 && n / 100 <= 12) cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
  string a;
  cin >> a;
  char b=a[5]; char c=a[6];
  if(b=='0' && c <'5') cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
上から順に決めれる
O(NlogN)版
*/

bool ok=true;
ll n,a[200010];
vector<ll> ans;

void init(){
	cin>>n;
	reg(i,1,n)cin>>a[i];
}

int main(void){
	init();
	ireg(i,1,n){
		for(int j=2;i*j<=n;j++)a[i]^=a[j*i];
		if(a[i]==1){
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<endl;
	rep(i,ans.size())cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 3009, MOD = 1e9 + 7;

int dp[N][N];
int sum[N][N];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    s = "pu" + s;
    dp[1][1] = 1;
    for (int i = 1; i <= n; ++i)
        sum[1][i] = sum[1][i - 1] + dp[1][i];
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= i; ++j) {
            if (s[i] == '<') {
                dp[i][j] = sum[i - 1][j - 1];
            }else{
                dp[i][j] = sum[i - 1][i - 1] - sum[i - 1][j - 1];
                if (dp[i][j] < 0)
                    dp[i][j] += MOD;
            }
            sum[i][j] = sum[i][j - 1] + dp[i][j];
            if (sum[i][j] >= MOD)
                sum[i][j] -= MOD;
        }
    }
    cout << sum[n][n];
    return 0;
}


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

set<string> st;
string s[100];

int main(){
  int n, i;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> s[i];
    st.insert(s[i]);
    if(i && s[i][0] != s[i-1][s[i-1].length()-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(st.size() == n){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, ans = 0;
    int a[100000] = {};
    cin >> n;
    rep(i, n){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}



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

int main(){
char x;
cin >> x;
if(x=='A'||x=='B'||x=='C'||x=='D'||x=='E'||x=='F'||x=='G'||x=='H'||x=='I'||x=='J'||x=='K'||x=='L'||x=='M'||x=='N'||x=='O'||x=='P'||x=='Q'||x=='R'||x=='S'||x=='T'||x=='U'||x=='V'||x=='W'||x=='X'||x=='Y'||x=='Z') cout << "A" << endl;
else cout << "a" << endl;


}

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

int main(){
	int n,m,max,tmp,a[1000];
	while(1){
		cin >> n >> m;
		if(n==0&&m==0)break;
		max = 0;

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

		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(max<a[i]+a[j]&&m>=a[i]+a[j]){
					max = a[i]+a[j];
				}
			}
		}
		if(max==0){
			cout << "NONE" << endl;
			continue;
		}
		cout << max << endl;
	}
}


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

using namespace std;

vector<int> answer(int n, vector<bool> e) {
  vector<int> ans;
  int curr = 1;
  while (ans.size() < n) {
    while (!e[++curr]);
    if (curr % 10 != 1) {
      continue;
    }
    ans.push_back(curr);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<bool> e(10000, true);
  e[1] = false;
  for (int i = 2; i < 10000;) {
    for (int j = i * 2; j < 10000; j += i) {
      e[j] = false;
    }
    while (i < 10000 && !e[++i]);
  }
  int n;
  cin >> n;
  auto ans = answer(n, e);
  for (int i = 0; i < n - 1; i++) {
    cout << ans[i] << " ";
  }
  cout << ans[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		UL X; cin >> X;
		UL ans = 0;
		ans += X / 500 * 1000;
		ans += X % 500 / 5 * 5;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int N = sc.nextInt();
        Integer[] a = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int[] ans = solve(N, a);

        for (int i=0; i<N; i++) {
            System.out.println(ans[i]);
        }
    }

    private static int[] solve(int N, Integer[] a) {
        int[] ans = new int[N];
        List<Integer> list = Arrays.asList(a.clone());

        Collections.sort(list);

        for (int i=0; i<N; i++) {
            ans[i] = a[i] <= list.get(N/2 - 1) ? list.get(N/2) : list.get(N/2 - 1);
        }

        return ans;
    }
}

Measured memory_bytes: 97608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n;
    string s;
    cin >> n >> s;

    ll r = 0, g = 0, b = 0;
    for(auto &&i : s) {
        if(i == 'R')
            r++;
        else if(i == 'G')
            g++;
        else
            b++;
    }
    ll all = r * g * b;

    ll cnt = 0;

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(s[i] == s[j])
                continue;
            ll k = 2 * j - i;
            if(k >= n || s[k] == s[i] || s[k] == s[j])
                continue;
            ++cnt;
        }
    }
    cout << all - cnt << endl;
}


Measured memory_bytes: 3628
N, D = map(int, input().split())
X = []
ans = 0

for i in range(N):
    Xi = list(map(int, input().split()))
    X.append(Xi)
    
for i in range(N-1):
    for j in range(i+1, N):
        dis_sq = 0
        for d in range(D):
            dis_sq += (X[i][d]-X[j][d]) ** 2
        dis = dis_sq ** 0.5
#         print(dis)
        if dis.is_integer():
            ans += 1
print(ans)
        

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>H(15);

	int N;
	cin >> N;
	vector<int>A(N);
	vector<vector<P>>V(N, vector<P>(N));
	int cnt = 0;
	int ans = 0;
	int sum = 0;
	rep(i, N) {
		cin >> A[i];
		rep(j, A[i]) {
			cin >> V[i][j].first >> V[i][j].second;
		}
	}
	rep(i1, 2) {
		rep(i2, 2) {
			rep(i3, 2) {
				rep(i4, 2) {
					rep(i5, 2) {
						rep(i6, 2) {
							rep(i7, 2) {
								rep(i8, 2) {
									rep(i9, 2) {
										rep(i10, 2) {
											rep(i11, 2) {
												rep(i12, 2) {
													rep(i13, 2) {
														rep(i14, 2) {
															rep(i15, 2) {
																H = { i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15 };

																rep(i, N) {
																	rep(j, N) {
																		if (V[i][j].first != 0) {
																			if (H[i] == 1 && H[V[i][j].first - 1] != V[i][j].second) {
																				cnt++;
																			}
																		}
																}
																}

																rep(i, N) {
																	if (H[i] == 1) {
																		sum++;
																	}
																}

																if (cnt == 0) {
																	ans = max(ans, sum);
																}

																cnt = 0;
																
																sum = 0;


															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int N = fs.nextInt(), M = fs.nextInt();
		int maxL = -1, minR = N;
		for(int i = 0; i < M; i++) {
			int L = fs.nextInt(), R = fs.nextInt();
			maxL = Math.max(maxL, L);
			minR = Math.min(minR, R);
		}
		out.println(Math.max(0, minR-maxL+1));
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

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

	}

}

Measured memory_bytes: 24148
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

typedef long long LL;
const int MAXN = 1e5;
int w ,h, ans,k;
char a[105][105];
int MAX;
int main(){
	cin >> h >> w;
	for(int i = 1;i <= w;i++){
		for(int j = 1;j <= h;j++){
			cin >> a[i][j];
		}
	}
	int flag = 0;
	for(int i = 1;i <= w;i++){
		for(int j = 1;j <= h;j++){
			if(a[i][j] == '#'){
			if(a[i][j+1] == '#' || a[i][j-1] == '#' || a[i+1][j] =='#' || a[i-1][j] =='#'){
				flag = 1;
			}
			if(flag == 0){
				cout << "No" << endl;
				return 0;
			}
			else{
				flag = 0;
			}
		}
		}
	}
	cout << "Yes" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
map<long long,int>mm;
int main()
{
    long long num;
    int n;
    cin >> n;
    long long ans =0 ;
    for(long long i=0;i<n;i++){
        cin >> num ;
        ans += mm[i-num];
        mm[i+num]++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i; i<n; i++) {
    cin >> a.at(i);
    b.at(i)=a.at(i);
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  for (int i; i<n; i++) {
    if (a.at(i)==b.at(0)) {
      cout << b.at(1) << endl;
    }
    else {
      cout << b.at(0) << endl;
    }
  }
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

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

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	int H, W;
	cin >> H >> W;
	cin.ignore();
	std::vector<bool> A(W * H);
	vector<bool> checked(W * H, false);
	deque<pair<int, int>> q;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			char c;
			cin >> c;
			A[i * W + j] = c == '.';
			if (!A[i * W + j])
			{
				q.push_back(make_pair(i * W + j, 0));
			}
		}
		cin.ignore();
	}

	int count = 0;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop_front();
		if (checked[p.first])	continue;
		checked[p.first] = true;
		count = max(count, p.second);
		if (p.first / W != 0)		q.push_back(make_pair(p.first - W, p.second + 1));
		if (p.first / W != H - 1)	q.push_back(make_pair(p.first + W, p.second + 1));
		if (p.first % W != 0)		q.push_back(make_pair(p.first - 1, p.second + 1));
		if (p.first % W != W - 1)	q.push_back(make_pair(p.first + 1, p.second + 1));
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 33168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0;
		switch(a) {
		case 1:
			sum += 300000;
			break;
		case 2:
			sum += 200000;
			break;
		case 3:
			sum += 100000;
			break;
		}
		switch(b) {
		case 1:
			sum += 300000;
			break;
		case 2:
			sum += 200000;
			break;
		case 3:
			sum += 100000;
			break;
	}
		if(a == 1 && b == 1) {
			sum += 400000;}
		System.out.println(sum);
		}
	
}


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

int main() {
  int a,b;cin>>a>>b;
  cout<<(a*b-a-b+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    int i;
    cin>>n;
    int val;
    string s;
    vector<pair < pair<string,int> ,int> > vec;
    rep(i,n){
    	cin>>s>>val;
    	vec.pb(mp(mp(s,-1*val),i));
    }
    sort(all(vec));
    rep(i,n){
    	cout<<vec[i].ss+1<<endl;
    }
    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	if(A1*T1+A2*T2==B1*T1+B2*T2){
		cout << "infinity" << endl;
		return 0;
	}
	if(A1*T1+A2*T2>B1*T1+B2*T2){
		swap(A1, B1);
		swap(A2, B2);
	}
	if(A1<B1){
		cout << 0 << endl;
		return 0;
	}
	ll d=(B1*T1+B2*T2)-(A1*T1+A2*T2);
	ll f=((A1-B1)*T1+d-1)/d;
	if(((A1-B1)*T1)%d==0) cout << f*2 << endl;
	else cout << f*2-1 << endl;
	return 0;
}

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

int main(){
   int K;
   string S;
   cin >> K;
   cin >> S;
    int len = S.length();
   if(len <=K){
       cout << S;
   }

   else{
       for(int i=0;i<K;i++){
           cout << S[i];
       }
       cout <<"..."<< endl;
   }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

inline bool domain(int i, int j){
  if(i < 8 && j < 8 && 0 <= i && 0 <= j) return true;
  else return false;
}

int main(){
  int i,j,k,n;
  vector<string> in(8);

  while(cin >> in[0] >> in[1] >> in[2] >> in[3] >> in[4] >> in[5] >> in[6] >> in[7]){
    rep(i,in.size()) rep(j,in[i].size()){
      if(in[i][j] == '1'){
        if(domain(i+1,j) && in[i+1][j] == '1' &&
           domain(i,j+1) && in[i][j+1] == '1' &&
           domain(i+1,j+1) && in[i+1][j+1] == '1'){
          cout << "A" << endl;
        }

        if(domain(i+1,j) && in[i+1][j]  == '1' &&
           domain(i+2,j) && in[i+2][j] == '1' &&
           domain(i+3,j) && in[i+3][j] == '1' ){
          cout << "B" << endl;
        }

        if(domain(i,j+1) && in[i][j+1] == '1' &&
           domain(i,j+2) && in[i][j+2] == '1' &&
           domain(i,j+3) && in[i][j+3] == '1' ){
          cout << "C" << endl;
        }

        if(domain(i+1,j) && in[i+1][j] == '1' &&
           domain(i+1,j-1) && in[i+1][j-1] == '1' &&
           domain(i+2,j-1) && in[i+2][j-1] == '1' ){
          cout << "D" << endl;
        }

        if(domain(i,j+1) && in[i][j+1] == '1' &&
           domain(i+1,j+1) && in[i+1][j+1] == '1' &&
           domain(i+1,j+2) && in[i+1][j+2] == '1' ){
          cout << "E" << endl;
        }

        if(domain(i+1,j) && in[i+1][j] == '1' &&
           domain(i+1,j+1) && in[i+1][j+1] == '1' &&
           domain(i+2,j+1) && in[i+2][j+1] == '1' ){
          cout << "F" << endl;
        }

        if(domain(i,j+1) && in[i][j+1] == '1' &&
           domain(i+1,j) && in[i+1][j] == '1' &&
           domain(i+1,j-1) && in[i+1][j-1] == '1' ){
          cout << "G" << endl;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


int N,K,ans = 1;
string S;

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

  cin >> N >> K >> S;

  int cnt=0,len=0;

  REP(i,N){
    if(S[i] =='0'){
      if(i == 0 || S[i - 1] == '1'){
        cnt++;
      }
    }
    if(cnt > K){
      while(S[len] == '1'){
        len++;
      }
      while(S[len] == '0'){
        len++;
      }
      cnt--;
    }
    ans = max(ans,i - len + 1);
  }


  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    if((a*b) % 2 == 0) {
        cout << "Even\n";
    } else {
        cout << "Odd\n";
    }
    
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

deque<ll> dq;
ll a[200001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll sum = 0;
	for(int i = 0; i < n - 1; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for(int i = 0; i <= sum-a[0]-a[1]; i++)
	{
		dq.pb(i);
	}
	for(int i = 2; i < n - 1; i++)
	{
		ll v = a[i];
		for(int j = 1; j <= v*2-1; j+=2)
		{
			dq.push_front(dq[j]);
		}	
	}
	int m; cin >> m;
	for(int i = 0; i < m; i++)
	{
		int x; cin >> x;
		if(x>sum-a[0]-a[1])
		{
			cout<<x-sum+2*a[0]<<'\n';
		}
		else
		{
			cout<<dq[x]+a[0]-a[1]<<'\n';
		}
	}
}


Measured memory_bytes: 20136
def solve(n,x,k):
  ans=-10**20
  s=0
  sx=sum(x)
  for i in range(n):
    if (i+1)>k:break
    s+=x[i]
    d=((k-i-1)//n)*sx
    ans=max(ans,s+d,s)
  return ans

n,k=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
ans=-10**20
for i in range(n):
  x=[c[i]]
  j=p[i]
  while i!=j:
    x.append(c[j])
    j=p[j]
  x=x[1:]+[x[0]]
  ans=max(ans,solve(len(x),x,k))
print(ans)

Measured memory_bytes: 87640
#include <iostream>
#include<stdio.h>
int main()
{
    int n,i,s=0,a;
    scanf("%d",&n);
    a=n;
    while(n!=0)
    {   s+=n%10;
        n=n/10;
    }
    if(a%s==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

struct ModInt {
    ll v;
    static unsigned M;
    ModInt() : v(0) {}
    ModInt(ll x) : v((x % M + M) % M) {}

    ModInt& operator+=(const ModInt& r) {
        v = (v + r.v) % M;
        return *this;
    }
    ModInt& operator-=(const ModInt& r) {
        v = (v - r.v + M) % M;
        return *this;
    }
    ModInt& operator*=(const ModInt& r) {
        v = (v * r.v) % M;
        return *this;
    }
    ModInt operator-() const { return (M - v % M); }

    friend ModInt operator+(ModInt l, const ModInt& r) { return l += r; }
    friend ModInt operator-(ModInt l, const ModInt& r) { return l -= r; }
    friend ModInt operator*(ModInt l, const ModInt& r) { return l *= r; }
    friend bool operator==(ModInt l, const ModInt& r) { return l.v == r.v; }
    friend bool operator!=(ModInt l, const ModInt& r) { return !(l == r); }

    ModInt pow(ll n) const {
        ModInt base = *this, ans = 1;
        while (n) {
            if (n & 1) ans *= base;
            base *= base;
            n /= 2;
        }
        return ans;
    }
};
unsigned ModInt::M;
ostream& operator<<(ostream& o, const ModInt& r) {
    o << r.v;
    return o;
}

const int SMAX = 32000;
ModInt dp[110][SMAX][2] = {};
int main() {
    ModInt::M = 1000000007;
    ll n, k; cin >> n >> k;
    loop1 (32000 - 1, j) {
        dp[0][j][0] = 1;
        dp[0][j][1] = 1;
    }

    int sqn = 0;
    while (sqn * sqn <= n) sqn++;

    loop1 (k, i) {
        loop1 (sqn, j) {
            dp[i][j][0] = dp[i][j - 1][0] + dp[i - 1][j][1];
        }

        dp[i][sqn][1] = dp[i][n / sqn][0];
        for (int j = sqn - 1; j >= 1; j--) {
            ModInt cnt = n / j - n / (j + 1);
            dp[i][j][1] = dp[i][j + 1][1] + dp[i - 1][j][0] * cnt;
        }
    }

    cout << dp[k][1][1] << endl;
    return 0;
}



Measured memory_bytes: 55296
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  string ans = "";
  while (N != 0) {
    ans += (char)('a' + (N - 1) % 26);
    N = (N - 1) / 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
}


Measured memory_bytes: 3612
import java.util.Scanner;

class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String s = scan.next();
        scan.close();
        int ans = (1 << 16);
        for (int i = 0; i <= s.length() - 3; i++)
        {
            String tmp = s.substring(i, i + 3);
            ans = Math.min(Math.abs(753 - Integer.parseInt(tmp)), ans);
        }
        System.out.println(ans);
    }
}

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

//|\\---------------//|\\
//|\\RISE FROM ASHES//|\\
//|\\---------------//|\\

// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 

    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 

    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 

        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 

        // If i is equal to r of any query store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                    query(queries[query_counter].r + 1, bit, n)- 
                    query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 

    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
    int n;
    cin>>n;
    int q;
    cin>>q;

    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    //int n = sizeof(a)/sizeof(a[0]); 
    Query queries[q]; 
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        queries[i].l=a-1;
        queries[i].r=b-1;
        queries[i].idx=i;
    }
    
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 


Measured memory_bytes: 19308
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

#ifdef __GNUC__
#define popcount __builtin_popcount
#elif _MSC_VER >= 1400
#include <intrin.h>
#define popcount __popcnt
#else
static inline int popcount(unsigned int b) {
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
}
#endif

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> sw(m), p(m);
	for (int i = 0; i < m; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int s;
			cin >> s;
			sw[i] |= 1 << (s - 1);
		}
	}
	for (int i = 0; i < m; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); ++i) {
		int j;
		for (j = 0; j < m; ++j) {
			if ((popcount(i & sw[j]) & 1) != p[j]) {
				break;
			}
		}
		ans += j >= m;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	
	int n, h;
	cin >>n >>h;
	VI a(n), b(n);
	rep(i, n) cin >>a[i] >>b[i];
	sort(b.rbegin(), b.rend());
	int ga = *max_element(all(a));
	int cr=0;
	rep(i, n){
		if(b[i] > ga){
			h -= b[i]; cr++;
			if(h <=0) break;
		}else break;
	}
	if(h > 0){
		cr += (h + ga -1)/ga;
	}
	cout << cr <<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

    int N, R, G, B;

    cin >> R >> G >> B >> N;


    int cou, iN;

    for (int ri = 0; ri <= N; ri++)
    {
        for(int gi = 0; gi <= N; gi++)
        {
            iN = N - R * ri - G * gi;
            if(iN % B == 0 && iN >= 0)
            {
                cou++;
            }
        }
    }
    
    cout << cou << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin >> N;
   int K;
   cin >> K;
   vector<int> h(N);
   for(int i=0; i<N; i++){
       cin >> h.at(i);
   }
   int count=0;
   for(int i=0; i<N; i++){
       if(h.at(i)>=K){
           count++;
       }
   }
   cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const int INF = 1e9;
const double EPS = 1e-9;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}


int main() {
  static int dp[101][101]; // ??????????????? = ?\???????????????°
  
  while (true) {
    int N, M, L;
    cin >> N >> M >> L;
    if (N + M + L == 0) {
      break;
    }
    
    struct Edge {
      int to;
      int length;
      int threat;

      Edge(int to, int length, int threat):
        to(to), length(length), threat(threat) { }
    };

    vector<Edge> G[101];
    for (int i = 0; i < M; i++) {
      int A, B, D, E;
      cin >> A >> B >> D >> E;
      G[A].push_back(Edge(B, D, E));
      G[B].push_back(Edge(A, D, E));
    }

    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= L; j++) {
        dp[i][j] = INF;
      }
    }
    dp[1][0] = 0;
    
    struct Search {
      int v;
      int cost;
      Search(int v, int cost): v(v), cost(cost) { }
    };

    queue<Search> que;
    que.push(Search(1, 0));
    
    while (!que.empty()) {
      Search s = que.front();
      que.pop();
      for (Edge e : G[s.v]) {
        int u = e.to;
        // ????????????
        if (dp[u][s.cost] > dp[s.v][s.cost] + e.threat) { 
          dp[u][s.cost] = dp[s.v][s.cost] + e.threat;
          que.push(Search(u, s.cost));
        }
        // ??????
        if (s.cost + e.length <= L) { 
          if (dp[u][s.cost + e.length] > dp[s.v][s.cost]) {
            dp[u][s.cost + e.length] = dp[s.v][s.cost];
            que.push(Search(u, s.cost + e.length));
          }
        }
      }
    }

    int ans = INF;
    for (int i = 0; i <= L; i++) {
      ans = min(ans, dp[N][i]);
    }
    cout << ans << endl;
   

  }
  return 0;
}

Measured memory_bytes: 3312