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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int n;cin >> n;
	cout << ((n >= 30) ? "Yes" : "No");
}

//Coded by LoliThief

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

string aaa(string t) {
	string l = t; SORT(l); REVE(l);
	string s = t; SORT(s);
	int ans = stoi(l) - stoi(s);
	string sans = to_string(ans);
	string ret; ret.assign(4 - sz(sans), '0');
	ret += to_string(ans);
	return ret;
}

int main() {
	while (true) {
		string s; cin >> s;
		if (s == "0000")break;

		bool flag = (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]);
		int ans = 0;
		while (s != "6174" && !flag) {
			s = aaa(s);
			ans++;
		}
		if (flag)puts("NA");
		else cout << ans << endl;
	}
}


Measured memory_bytes: 3308
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a > 0 && a < 10 && b > 0 && b < 10) {
      System.out.println(a * b);
    } else {
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 23892
/*
*  author: mkbaloch
*  time:   2019-12-31 14:27:34
*/

#include<bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define repn(i, n) for(int i=0; i<(int)n; i++)

using namespace std;

int main()
{
 ll a, b, k;
 cin >> a >> b >> k;
 ll new_a = min(a, k);
 a -= new_a;
 k -= new_a;
 b -= min(k, b);
 cout << a << " " << b << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

int main() {
  string S,T;

  cin >> S>>T;
  
  int r=0;
  REP(i,S.length()){
  if (S[i]==T[i])r++;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int i, j, k, l;
    char p[100], s[100];
    scanf("%s", s);
    scanf("%s", p);
    for ( i = 0; i < strlen(s); i++ ) {
        if ( s[i] == p[0] ) {
            for (j = 1; j < strlen(p); j++ ) {
                if ( i + j < strlen(s)) {
                    if ( s[i + j] != p[j]) break;
                }
                else {
                    if ( s[i + j - strlen(s)] != p[j]) break;
                }
            }
        }
        if ( j == strlen(p)) {
            printf("Yes\n");
            break;
        }
    }
    if ( i == strlen(s)) printf("No\n");

    return 0;
}

Measured memory_bytes: 1820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int a[][] = new int[100010][3];

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");
			a[i][0] = Integer.parseInt(str[0]);
			a[i][1] = Integer.parseInt(str[1]);
			a[i][2] = Integer.parseInt(str[2]);
		}

		int dp[][] = new int[100010][3];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k)
						continue;
					dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + a[i][k]);
				}
			}
		}

		int max = 0;
		for (int i = 0; i < 3; i++) {
			max = Math.max(max, dp[n][i]);
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 48544
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int N;cin >> N;
  int i,ans=0;
  REP(i,N){
    int x;
    cin >> x;
    ans += x-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long ans=0;
int main()
{
    long N,A[5]={0};
    char S[1000000];

    scanf("%ld",&N);
    for(int i=0; i<N; i++){
        scanf("%s",S);
        if(S[0] == 'M'){
            A[0]++;
        }else if(S[0] == 'A'){
            A[1]++;
        }else if(S[0] == 'R'){
            A[2]++;
        }else if(S[0] == 'C'){
            A[3]++;
        }else if(S[0] == 'H'){
            A[4]++;
        }
    }

    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans += A[i] * A[j] * A[k];
            }
        }
    }
    printf("%ld",ans);
    return 0;
}

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

int main() {
    long n, a, b;
    cin >> n >> a >> b;
    long h[n], diff = a - b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    long lb = -1, ub = (h[max_element(h, h + n) - h] - 1) / b + 1;
    long ans = ub;
    while (ub - lb > 1) {
        long mid = (lb + ub) / 2, count = 0;
        for (int i = 0; i < n; i++) {
            if (mid * b < h[i])
                count += (h[i] - mid * b - 1) / diff + 1;
        }
        if (count <= mid) {
            ans = mid;
            ub = mid;
        } else {
            lb = mid;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> H >> W >> K;
	vector<string> S(H);
	vll Ans(H, vl(W, 0));
	vl noS(H);
	for (i = 0; i < H; i++) {
		cin >> S[i];
		ll count = 0;
		for (j = 0; j < W; j++) {
			if (S[i][j] == '#') count++;
		}
		if (count == 0) noS[i] = 1;
	}
	ll id = 0;
	for (i = 0; i < H; i++) {
		if (noS[i] == 0) {
			id++;
			ll count = 0;
			for (j = 0; j < W; j++) {
				if (S[i][j] == '#' && count >= 1) {
					count++; id++;
				}
				else if(S[i][j] == '#'){
					count++;
				}
				Ans[i][j] = id;
			}
			for (k = i-1; k >= 0; k--) {
				if (noS[k] != 1) break;
				for (j = 0; j < W; j++) {
					Ans[k][j] = Ans[i][j];
				}
			}
			for (k = i + 1; k < H; k++) {
				if (noS[k] != 1) break;
				for (j = 0; j < W; j++) {
					Ans[k][j] = Ans[i][j];
				}
			}
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cout << Ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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(){
  int i,j;
  int n,r;
  cin>>n>>r;
  if(n<10) r+=100*(10-n);
  cout<<r<<endl;

}

Measured memory_bytes: 256
def binom(n, r, mod):
    if n < r or n < 0 or r < 0: return 0
    
    if n - r < r: r = n - r
    if r == 0: return 1
    elif r == 1: return n

    X = 1; Y = 1
    for k in range(r):
        X = (X * ((n - r + 1 + k) % mod)) % mod
        Y = (Y * ((1 + k) % mod)) % mod
    return X * pow(Y, mod-2, mod)

MOD = 10**9 + 7
n, a, b = map(int, input().split())
ans = (pow(2, n, MOD) - 1 - ((binom(n, a, MOD) + binom(n, b, MOD)) % MOD)) % MOD
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,v[100005];
long long ans,x[100005],x1[100005],f[100005][2],C;
deque<int>q,p;
int main(){
    scanf("%d%lld",&n,&C);
    for(int i=1;i<=n;i++){
    	scanf("%lld%d",&x[i],&v[i]);
    	x1[i]=C-x[i];
    }
    for(int i=1;i<=n;i++){
    	f[i][0]=f[i-1][0]+v[i]-x[i]+x[i-1];
    	f[n-i+1][1]=f[n-i+2][1]+v[n-i+1]-x1[n-i+1]+x1[n-i+2];
    	ans=max(ans,max(f[i][0],f[n-i+1][1]));
    	if(i==n)break;
    	if(i==1)q.push_back(n-i+1);
    	else if(f[q.front()][1]<f[n-i+1][1]){
    		q.push_front(n-i+1);
    	}
    	if(i==1)p.push_back(i);
    	else if(f[p.front()][0]<f[i][0]){
    		p.push_front(i);
    	}
    }
    for(int i=1;i<n;i++){
    	if(i>=q.front())q.pop_front();
    	ans=max(ans,f[i][0]-x[i]+f[q.front()][1]);
    }
    for(int i=n;i>1;i--){
    	if(i<=p.front())p.pop_front();
    	ans=max(ans,f[i][1]-x1[i]+f[p.front()][0]);
    }
    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	string s;
	cin >> s;
	bool bw = false;
	if (s[0] == 'W')bw = true;
	int res=0;
	FOR(i, 1, size(s) - 1) {
		if ((bw&&s[i]=='B')||(!bw&&s[i] == 'W')) {
			bw = !bw;
			res++;
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back

int vx[4] = { 1,-1,0,0 };
int vy[4] = { 0,0,-1,1 };
char grid[100][100]; 
int ret(int x, int y, bool passed[100][100]) {
	if (passed[x][y]) { cout << "LOOP" << endl; return 0; }
	char now = grid[x][y];
	int move = 0;
	if (now == '<') {
		move = 1;
	}
	else if (now == '^') {
		move = 2;
	}
	else if (now == 'v') {
		move = 3;
	}
	else if (now == '.') {
		cout << x << " " << y<<endl;
		return 0;
	}
	passed[x][y] = true;
	return ret(x+vx[move],y+vy[move],passed);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	while (cin >> a >> b) {
		if (a == b&&b == 0) { break; }
		rep(i, a) {
			rep(j, b) {
				cin >> grid[j][i];
			}
		}
		bool hadgone[100][100];
		for (int i = 0; i < 100; i++) {
			rep(j, 100) {
				hadgone[i][j] = false;
			}
		}
		ret(0, 0, hadgone);
	}
	return 0;
}


Measured memory_bytes: 3040
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize,mut  l: [usize; n]);

    let mut count = 0;
    for i in 0..n {
        for j in i + 1..n {
            if l[i] == l[j] {
                continue;
            }
            for k in j + 1..n {
                if l[i] == l[k] || l[j] == l[k] {
                    continue;
                }
                if l[i] + l[j] <= l[k] || l[k] + l[i] <= l[j] || l[j] + l[k] <= l[i] {
                    continue;
                }
                count += 1;
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=300001 ;
int main()
{
   fast ;
   string s ;
   cin>>s ;
   ll f=0 ;
   for(char c:s)
   {
       if(c=='7')
       {
           f=1 ;
       }
   }
   if(f)
    cout<<"Yes"<<endl ;
   else
    cout<<"No"<<endl ;


}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    int n; cin>>n;
    V t(n);
    rep(i,0,n) cin>>t[i];
    int m; cin>>m;
    V p(m),x(m);
    cinf(m,p,x);

    rep(i,0,m){
        V u(n);
        u=t;
        u[p[i]-1]=x[i];
        int ans=0;
        rep(j,0,n){
            ans+=u[j];
        }
        cout<<ans<<"\n";
    }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  vi s(n); rep(i, n) std::cin >> s[i];
  sort(rng(s));
  int ans = accumulate(rng(s), 0);
  if (ans % 10 == 0) {
    bool ok = false;
    rep(i, n) {
      if ((ans-s[i]) % 10 == 0) continue;
      ans -= s[i];
      ok = true;
      break;
    }
    if (!ok) ans = 0;
  }
  std::cout << ans << "\n";
}


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

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> field(H);
    for (int h = 0; h < H; h++) {
        cin >> field[h];
    }

    // 全黒マスからの距離
    int dist[1000][1000];
    memset(dist, -1, sizeof(dist));

    // 探索対象のキュー
    queue<pair<int, int>> que;

    // とりあえず黒マスを全部キューに入れる
    for (int h = 0; h < H; h++) {
        for ( int w = 0; w < W; w++) {
            if (field[h][w] == '#'){
                que.push(make_pair(h, w));
                dist[h][w] = 0;
            }
        }
    }

    // 探索開始！
    while (!que.empty()) {
        pair<int, int> p = que.front();
        que.pop();

        // cout << p.first << " " << p.second << endl;

        for (int i = 0; i < 4; i++) {
            int nh = p.first + dy[i];
            int nw = p.second + dx[i];

            // cout << "nh, nw = " << nh << " " << nw << endl;

            // 範囲外だったらスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            // cout << "here?1" << endl;
            // 黒だったらスルー
            if (field[nh][nw] == '#') continue;
            // cout << "here?2" << endl;
            // 探索ずみならスルー
            if (dist[nh][nw] != -1) continue;
            // cout << "here?3" << endl;

            // cout << "here?" << endl;

            dist[nh][nw] = dist[p.first][p.second] + 1;
            que.push(make_pair(nh, nw));
        }
    }

    int max_dist = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            // cout << dist[h][w] << endl;
            max_dist = max(max_dist, dist[h][w]);
        }
    }

    cout << max_dist << endl;
}


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

int main(){
	int p[3], j[2];
	
	for(int i=0; i<3; ++i) scanf(" %d", &p[i]);
	for(int i=0; i<2; ++i) scanf(" %d", &j[i]);
	sort(p, p+3);
	sort(j, j+2);
	
	printf("%d\n", p[0]+j[0]-50);
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>

using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;

ll a = 100;
ll x;
int cnt = 0;
int main(){
	scanf("%lld", &x);
	while(a < x){
		cnt++;
		a += (a / 100);
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i <= (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i <= (int)(b); i++)
#define repl(i,list) for(int i : list)
#define INF 1e+12
typedef long long int lli;
using namespace std;

int main()
{
    lli N;
    cin >> N;
    lli m;
    lli walk = INF;
    repi(n,1,sqrt(N)) {
        if (N % n == 0) {
            m = N / n;
            walk = min((m-1)+(n-1), walk);
            //cout << walk << endl;
        }
    }
    cout << walk << endl;
}

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

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;

ll dp[100010];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = INF;
  }
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 < n) {
      dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1] - a[i]));
    }
    if (i + 2 < n) {
      dp[i+2] = min(dp[i+2], dp[i] + abs(a[i+2] - a[i]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fast;
    ll n;
    cin >> n;
    ld ans = 2*n*3.14;
    cout << ans;
    return 0;
}
//                                     #!!{*[$um1t_Kum@r]*}!!#


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s, p;
  cin >> s >> p;
  s += s;
  if (s.find(p) == string::npos)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<algorithm>
using namespace std;
int z[20000];
int num[20000];
int a,b;
pair<int,int> dfs(int d,int l,int r){
	int L=upper_bound(z,z+b+1,l)-z-1;
	int R=upper_bound(z,z+b+1,r)-z-1;
	//printf("%d %d %d: %d %d\n",d,l,r,L,R);
	if(l==r){
		return make_pair(0,1<<num[L]);
	}
	if(L==R){
		if(num[L]<=d){
			return make_pair(r-l,1<<num[L]);
		}
		int ad=0;
		for(int i=0;i<=d;i++)ad+=(1<<i);
	//	printf("%d %d %d: %d %d %d\n",d,l,r,num[L],(r-l+1)-(r-l+1)/(1<<(1+a-num[L])),ad);
		return make_pair((r-l+1)-(r-l+1)/(1<<(1+a-num[L])),ad);
	}
	pair<int,int>lv=dfs(d+1,l,(l+r)/2);
	pair<int,int>rv=dfs(d+1,(l+r)/2+1,r);
	int can=0;
	if(lv.second&(1<<(d+1))){
		can|=rv.second;
	}
	if(rv.second&(1<<(d+1))){
		can|=lv.second;
	}
	if(can&(1<<(d+1)))can-=(1<<(d+1));
	if(can){
	//	printf("%d %d %d: %d %d\n",d,l,r,lv.first+rv.first,can);
		return make_pair(lv.first+rv.first,can);
	}
	int ad=lv.second|rv.second;
	for(int i=d+1;i<=a;i++)if(ad&(1<<i))ad-=(1<<i);
	if(ad){
		//printf("%d %d %d: %d %d\n",d,l,r,lv.first+rv.first+1,ad);
		return make_pair(lv.first+rv.first+1,ad);
	}
	ad=0;
	for(int i=0;i<=d;i++)ad+=(1<<i);
//	printf("%d %d %d: %d %d\n",d,l,r,lv.first+rv.first+2,ad);
	return make_pair(lv.first+rv.first+1,ad);
}
int main(){
	scanf("%d%d",&a,&b);
	for(int i=0;i<b+1;i++){
		scanf("%d",z+i);
	}
	for(int i=0;i<b;i++)scanf("%d",num+i);
	/*for(int i=0;i<=a;i++){
		int len=1<<(a-i);
		for(int j=0;j<=a;j++){
			
		}
	}*/
	printf("%d\n",dfs(0,0,(1<<a)-1).first);
}

Measured memory_bytes: 1108
import sys
x = int(input())
def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for xi in range(x,10000000):
    if is_prime(xi):
        print(xi)
        sys.exit()
    else:
        continue

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

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

    int s, w;
    cin >> s >> w;

    if(w >= s) puts("unsafe");
    else puts("safe");

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int k;
    cin >> k;
    int ans = -1;
    while(k--) {
        sort(a,a+3);
        a[2] *= 2;
    }
    cout << accumulate(a,a + 3, 0) << endl;
}

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

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res *= a;
		a *= a;
		pw >>= 1;
	}
	return res;
}
mat mul(mat &a,mat &b, ll mod){ //a*bなのでn*mとm*l→n*l
    mat c(a.size(),vec(b.at(0).size(),0));
    rep(i,a.size()){
        rep(k,b.size()){
            rep(j,b.at(0).size()){
                //ll ab = (a.at(i).at(k)*b.at(k).at(j))%mod;
                ll aa = a.at(i).at(k),bb =b.at(k).at(j);
                if(aa<0 || bb<0){
                    cout<<"abover"<<endl;
                    cout<<i<<' '<<k<<' '<<j<<endl;
                    cout<<aa<<' '<<bb<<endl;
                }
                (aa+=mod)%=mod;
                (bb+=mod)%=mod;
                (aa*=bb)%=mod; 
                (c.at(i).at(j) += aa)%=mod;
                if(c.at(i).at(j)<0){
                    cout<<"over"<<endl;
                    cout<<aa<<' '<<bb<<endl;
                }
            }
        }
    }
    return c;
}

mat matpow(mat a, ll pow, ll mod){
    mat b(a.size(),vec(a.size(),0));
    rep(i,a.size()) b.at(i).at(i) = 1;
    while(pow>0){
        if(pow&1) b = mul(b,a,mod);
        a = mul(a,a,mod);
        pow >>= 1;
    }
    return b;
}

int main() {
    ll L,A,B,M;
    cin>>L>>A>>B>>M;
    vector<ll> numd(19,0);//1-indexedでd桁の要素を保存
    ll last = 0;
    reps(i,1,19){
        ll next = fastpow(10,i)-(A+1);
        if(next<0) continue;
        (next+=B) /= B; //i桁までの要素数
        numd.at(i) = min(next-last,L-last);
        if(L <= next) break;
        last += numd.at(i);
    }   
    /*cout<<"numd"<<endl;
    rep(i,19) cout<<numd.at(i) << ' ';
    cout<<endl;*/
    mat cd(3,vec(3,0));
    ll X = 0, s = A;
    mat ans(1,vec{X,s,1});
    //rep(i,3) cout<<ans[0][i]<<' ';
    //cout<<endl;
    reps(i,1,19){
        if(numd.at(i) == 0) continue;
        rep(p,3) rep(q,3) cd[p][q] = 0;
        cd[1][0] = cd[1][1] = cd[2][2] = 1;
        (cd[2][1] += B)%=M;
        (cd[0][0] += fastpow(10,i))%=M;
        ll num = numd.at(i);
        cd = matpow(cd,num,M);
        rep(p,3) rep(q,3) if(cd[p][q]<0)cout<<"cdover"<<endl;
        rep(p,3) if(ans[0][p]<0)cout<<"ans "<<p<<' '<<i<<' '<<ans[0][p]<<endl;
        ans = mul(ans,cd,M);
        //ans.at(0).at(1) -= B;
        while(ans.at(0).at(1) < 0){
            ans.at(0).at(1) += M;
        }
        (ans.at(0).at(1)+=M)%=M;
        //cout<<ans.at(0).at(0)<<' '<<ans[0][1]<<endl;
    }
    cout<<ans.at(0).at(0)<<endl;
    //cout<<M<<endl;    
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int p[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
        p[i]--;
    }
    int ans=-1*INF;
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        ans=max(ans, c[i]);
    }
    for(int i=0;i<n;i++)
    {
        vi temp;
        int cur=p[i];
        while(cur!=i)
        {
            temp.pb(c[cur]);
            cur=p[cur];
        }
        temp.pb(c[cur]);
        int l=temp.size();
        int s=0;
        for(int i=0;i<l;i++)
        s+=temp[i];
        int pre=0;
        for(int i=0;i<l;i++)
        {
            pre+=temp[i];
            if((k-1)<i)
            break;
            ans=max({ans, (((k-i-1)/l)*s)+pre, pre});
        }
    }
    cout<<ans;
}

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

ans='APPROVED'

for i in range(N):
  if A[i]%2==0:
    #print(A[i])
    if A[i]%3==0:
      pass
    elif A[i]%5==0:
      pass
    else:
      ans='DENIED'
      break
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
 
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;
 
typedef pair<long long int, long long int> P;
 
long long int INF = 1e18;
long long int MOD = 1e9 + 7;
 
int main(){
    long long int N;
    cin >> N;
    long long int ans = 0;
    for(long long int i = 1; i * i < N - i; i++){
        if((N - i) % i == 0){
            ans += (N - i) / i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]

def get_candidate(K):
    l = []
    b = 0
    for i in range(30)[::-1]:
        if (K&(1<<i)):
            l.append(b + (1<<i) - 1)
            b += (1<<i)
    return l+[K]

def get_ans(K):
    bit = [None]*30
    for i in range(30):
        bit[i] = (K&(1<<i))>>i

    ans = 0
    for i, j in l:
        for k in range(30):
            b = (i&(1<<k))>>k
            if not ((bit[k]==1) or (b==0 and bit[k]==0)):
                break
        else:
            ans += j
    return ans

ans = 0
for k in get_candidate(K):
    ans = max(ans, get_ans(k))
print(ans)


Measured memory_bytes: 88452
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e8)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 1e6+5;
int main()
{
	ll n;
	ll k;
	cin>>n>>k;
	vector<ll>a(n+1);
	for(int i=0;i<n;i++)cin>>a[i];
	auto get = [&](ld x){
		int cnt = 0;
		for(int i=0;i<n;i++)cnt+=ceil(a[i]/x)-1;
		return cnt;
	};
	ll l = 0,r = 1e9;
	while(r-l>1){
        auto mid = (l+r)/2;
        if(get(mid) <= k)r=mid;
        else l = mid;
    }
	cout<<r;
}


Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int D, G; cin >> D >> G;
  G = G / 100;

  vector <pair<int, int> > PC(D);
  int ans = 0;
  for (int i = 0; i < D; i++){
    int P, C; cin >> P >> C;
    ans += P; C = C / 100;
    PC[i].first = P; PC[i].second = C;  
  }
  
  int times = pow(2, D);
  bool flag[times][D];
  for (int i = 0; i < times; i++){
    int num = i;
    for (int j = 0; j < D; j++){
      if(num % 2 == 0) flag[i][j] = false;
      else flag[i][j] = true;
      num = num / 2;
    }
  }
  
  for (int i = 0; i < times; i++){
    int sum = 0, cnt = 0;
    for (int j = 0; j < D; j++){
      if (flag[i][j] == true){
        sum += PC[j].first * (j + 1) + PC[j].second;
        cnt += PC[j].first;
      }
    }

    if (sum >= G){
      if(ans > cnt) ans = cnt;
    }else{
      int rest = G - sum;
      for (int j = 0; j < D; j++){
        if (flag[i][j] == false){
          int cnt2 = rest / (j + 1);
          if (rest % (j + 1) != 0) cnt2++;

          if (cnt2 <= PC[j].first){
            if (ans > cnt + cnt2) ans = cnt + cnt2;
          }
        }
      }
    }
  }
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
const int mod(1e9+7),maxn(405);
int n,c;
ll sum[maxn],f[maxn][maxn];
int a[maxn],b[maxn];
void init(){
	n=read(),c=read();
	for (int i(1);i<=n;++i) a[i]=read();
	for (int i(1);i<=n;++i) b[i]=read();
	f[0][0]=1;
}

void calc(int a,int b){
	memset(sum,0,sizeof(sum));
	for (int i(a);i<=b;++i){
		ll t=1;
		for (int j(0);j<=c;++j){
			sum[j]=sum[j]+t,sum[j]%=mod;
			t=t*i%mod;
		}
	}
}

signed main(){
	init();
	for (int i(1);i<=n;++i){
		calc(a[i],b[i]);
		for (int j(0);j<=c;++j)
			for (int k(0);k<=j;++k)
				f[i][j]=(f[i][j]+f[i-1][j-k]*sum[k])%mod;
	}
	printf("%d\n",f[n][c]);					 
	return 0; 
}


Measured memory_bytes: 1408
x,y=map(int,input().split())
if y==0:
    if 0>=x:
        print(-x)
    else:
        print(x+1)
elif x==0:
    if y>0:
        print(y)
    else:
        print(-y+1)
elif x*y>0:
    if y>=x:
        print(abs(abs(y)-abs(x)))
    else:
        print(abs(abs(y)-abs(x))+2)
else:
    if y<x:
        print(abs(abs(y)-abs(x))+1)
    else:
        print(abs(abs(y)-abs(x))+1)


Measured memory_bytes: 3064
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
import bisect #二部探索
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
mod = 10**9 + 7
INF = 10**9 + 7

def main():
    n = int(input())
    if n == 0:
        print('1')
        return 0
    print('0')
    
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27148
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        if ((g * 10 + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

string S;
ll dp[100010][14]{};

int main(int argc, char **argv)
{
	cin >> S;
	ll N = S.size();
	**dp = 1;

	REP(n, N)
	{
		REP(j, 13)
		{
			if (S[n] == '?')
			{
				REP(k, 10)
				{
					(dp[n+1][(j*10+k)%13] += dp[n][j]) %= MOD;
				}
			}
			else
			{
				ll k = S[n] - '0';
				(dp[n+1][(j*10+k)%13] += dp[n][j]) %= MOD;
			}
		}
	}

	std::cout << dp[N][5] << std::endl;
}


Measured memory_bytes: 11392
S = input()
N = len(S)
if 2 == N:
    S_0 = "01" * (N // 2)
    S_1 = "10" * (N // 2)
else:
    S_0 = "01" * (N // 2) + "0"
    S_1 = "10" * (N // 2) + "1"

cnt_0 = 0
cnt_1 = 0
for i in range(N):
    if S[i] != S_0[i]:
        cnt_0 += 1
    if S[i] != S_1[i]:
        cnt_1 += 1

print(min(cnt_0, cnt_1))

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
const int MAX_M = 100005;

int N, M;
struct S{
  int p, y, index;
  string str;
  bool operator < (const S& s) const {
    return y < s.y;
  }
};

vector<S> SS[MAX_N];
string ans[MAX_M];

signed main()
{
  cin >> N >> M;
  REP(m,M) {
    S s; cin >> s.p >> s.y;
    s.index = m;
    SS[s.p].push_back(s);
  }

  FOR(n,1,N+1) {
    sort(begin(SS[n]), end(SS[n]));
    REP(i,SS[n].size()) {
      std::ostringstream sout1,sout2;
      sout1 << std::setfill('0') << std::setw(6) << SS[n][i].p;
      std::string s = sout1.str();
      sout2 << std::setfill('0') << std::setw(6) << i+1;
      ans[SS[n][i].index] = s + sout2.str();
      // cerr << s << " " << sout2.str() << endl;
    }
  }

  REP(i,M) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

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

    int N, T, A;
    cin >> N >> T >> A;
    vector<float> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    for(int i = 0; i < N; i++){
        H[i] = abs(T - H[i] * 0.006 - A);
    }

    vector<float>::iterator minIt = min_element(H.begin(), H.end());
    size_t minIndex = distance(H.begin(), minIt);

    cout << (minIndex + 1) << "\n";

    return 0;
}

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

#define INF 1145141919

int R, C;
bool S[10][10000];

void invertR(int k) {
  for (int i=0; i<10; i++) {
    if (k & (1<<i)) {
      for (int j=0; j<10000; j++) {
        S[i][j] = !S[i][j];
      }
    }
  }
}

int main() {
  while (cin >> R >> C) {
    if (R == 0 && C == 0) break;
    for (int i=0; i<R; i++) {
      for (int j=0; j<C; j++) {
        cin >> S[i][j];
      }
    }
    int ans = INF;
    for (int k=0; k<1024; k++) {
      invertR(k);
      int t = 0;
      for (int j=0; j<C; j++) {
        int c = 0;
        for (int i=0; i<R; i++) {
          if (S[i][j]) c++;
        }
        t += min(c, R-c);
      }
      ans = min(ans, t);
      invertR(k);
    }
    cout << R*C - ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3116
S = list(input())
T = list(input())
import copy
ans = []
for i in reversed(range((len(S)-len(T))+1)):
    R = copy.deepcopy(S)
    for j in range(len(T)):
        if S[i+j] != "?" and S[i+j] != T[j]:
            break
    else:
        for j in range(len(T)):
            R[i+j] = T[j]
        for j in range(len(S)):
            R[j] = "a" if R[j] == "?" else R[j]
        ans.append("".join(R))
if ans:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 9180
//test!!!!!!!!!!!!!!!!!

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

// 1 <= k <= n <= 10^7
#define CNKMAX 100003
class CNK1 {
    std::vector<long long> fac, finv, inv;
    int MOD;
public:
    CNK1(int mod = 1000000007): MOD(mod), fac(CNKMAX), finv(CNKMAX), inv(CNKMAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < CNKMAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    int get(const int &n, const int &k) const {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

long long power(long long x, long long n, long long mod = 1000000007) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

void solve() {
    string l;
    cin >> l;
    int len = l.size();
    CNK1 cnk;
    VI cs(100000+2);
    LL ans = 0;
    int c1 = 0;
    REP(i,0,len) {
        if (l[i] == '0') continue;
        LL sum = power(3, len - i - 1);
        sum = (sum * power(2, c1)) % MOD;
        ans = (ans + sum) % MOD;
        ++c1;
    }
    ans = (ans + power(2, c1)) % MOD;

    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}


Measured memory_bytes: 6160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

#define int long long

const int INF = 1e15;

int n, m, l;
int sm[100001];
int cost(int a, int b) {
	if (a > b)swap(a, b);
	return (sm[b + 1] - sm[a]) / l;
}

int dp[2001][2001];
signed main() {
	cin >> n >> m >> l;
	vector<int> k(n), s(m);
	rep(i, n) {
		cin >> k[i];
		k[i]--;
	}
	sort(all(k));
	rep(i, n)rep(j, n) {
		dp[i][j] = -1;
	}

	rep(i, m) {
		cin >> s[i];
	}
	for (int i = 1; i <= m; i++) {
		sm[i] = sm[i - 1] + s[i - 1];
	}
	function<int(int, int)> solve = [&](int a, int b) {
		if (dp[a][b] != -1)return dp[a][b];
		int next = max(a, b) + 1;
		if (next == n) {
			return cost(k[max(a, b)], k[min(a, b)]);
		}
		int t0 = solve(next, b) + cost(k[next], k[a]);
		int t1 = solve(a, next) + cost(k[next], k[b]);
		return dp[a][b] = min(t0, t1);
	};
	cout << solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    map<pair<string, string>, ll> m;
    for (int bit = 0; bit < (1 << N); bit++) {
        string A, B;
        for (int i = 0; i < N; i++) {
            int mask = 1 << i;
            if (bit & mask) {
                A.push_back(S[2 * N - 1 - i]);
            } else {
                B.push_back(S[2 * N - 1 - i]);
            }
        }
        //cout << A << " " << B << endl;
        m[make_pair(A, B)]++;
    }

    ll ans = 0;
    for (int bit = 0; bit < 1 << N; bit++) {
        string A, B;
        for (int i = 0; i < N; i++) {
            int mask = 1 << i;
            if (bit & mask) {
                A.push_back(S[i]);
            } else {
                B.push_back(S[i]);
            }
        }
        auto it = m.find(make_pair(A, B));
        if (it != m.end()) {
            ans += it->second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 46080
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);

        int N;
        cin >> N;

        if (N % 2 == 0) {
                cout << N << endl;
        } else {
                cout << N * 2 << endl;
        }
        return 0;
}


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

int main()
{
  string o, e;
  cin >> o >> e;
  if (o.size() == e.size()) {
    for (int i=0; i<o.size(); i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << endl;
  }
  else {
    for (int i=0; i<o.size()-1; i++) {
      cout << o.at(i) << e.at(i);
    }
    cout << o.at(o.size()-1) << endl;
  }
}

Measured memory_bytes: 256