akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
inline double distance(double y1, double x1, double y2, double x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

class TopologicalSort {
    const unsigned int N;               // ノード数
    const vector<vector<int>> graph;    // グラフ
    vector<bool> used;                  // 使用済みノード
    vector<int> indeg;                  // 入次数

public:
    vector<int> result;

public:
    TopologicalSort(unsigned int num_node, const vector<vector<int>> &graph) : N(num_node), graph(graph){
        this->indeg.assign(num_node, 0);
        this->used.assign(num_node, false);
    }

    bool sort() {
        for (int u = 0; u < N; ++u) {
            for (int v : graph[u]) {
                indeg[v]++;
            }
        }

        for (int u = 0; u < N; ++u) {
            if (indeg[u] == 0 and not used[u]) {
                bfs(u);
            }
        }

        return this->result.size() == N;
    }

private:
    void bfs(int s) {
        queue<int> que;
        que.push(s);
        used[s] = true;
        while (not que.empty()) {
            int u = que.front();
            que.pop();
            result.emplace_back(u);

            for (int v : graph[u]) {
                indeg[v]--;
                if (indeg[v] == 0 and not used[v]) {
                    used[v] = true;
                    que.push(v);
                }
            }
        }
    }
};


int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> graph(V);
    FOR(_, 0, E) {
        int s, t;
        cin >> s >> t;
        graph[s].emplace_back(t);
    }

    TopologicalSort ts(V, graph);
    ts.sort();
    FOE(v, ts.result) {
        print(v);
    }

    return 0;
}


Measured memory_bytes: 4448
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int d[26];
	for(int i = 0; i < 26; i++) d[i] = 0;
	for(int i = 0; i < S.size(); i++) {
		d[S[i] - 'a']++;
	}

	for(int i = 0; i < 26; i++) {
		if(d[i] == 0) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}


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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int n; cin >> n;

    vector<vector<bool>> M(n, vector<bool>(n));

    for (int i = 0; i < n; ++i){
        string s; cin >> s;

        for (int j = 0; j < n; ++j)
            M[i][j] = s[j] == '1';
    }

    vector<int> color(n);
    vector<int> xconj(n, -1);

    for (int i = 0; i < n; ++i){
        if (color[i]) continue;

        queue<int> q; q.push(i);
        color[i] = 1;

        while (!q.empty()){
            int u = q.front(); q.pop();
            xconj[u] = i;

            for (int j = 0; j < n; ++j){
                if (M[u][j]) {
                    if (color[j]){
                        if (color[j] == color[u]){
                            cout << -1 << endl;
                            exit(0);
                        }
                    } else {
                        color[j] = -color[u];
                        q.push(j);
                    }
                }
            }
        }
    }

    vector<vector<int>> dist(n, vi(n, oo));

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            if (i == j) dist[i][j] = 0;
            else if (M[i][j]) dist[i][j] = 1;
        }
    }

    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    vector<int> answer(n, 0);

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            if (xconj[i] == xconj[j]){
                answer[xconj[i]] = max(answer[xconj[i]], dist[i][j]);
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < n; ++i){
        if (i == xconj[i])
            ans += answer[i] + 1;
    }

    cout << ans << endl;

    return 0;
}

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

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        long ans = 0;
        long[] b = new long[n];
        for (int i = n - 1; i >= 0; i--) {
            if (i < n - 1) {
                b[i] = b[i + 1] - 1;
            }
            if (a[i] < b[i]) {
                System.out.println(-1);
                return;
            } else if (a[i] > b[i]) {
                ans += a[i];
                b[i] = a[i];
            }
        }
        if (b[0] > 0) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 43140
#include <stdio.h>
#include <math.h>
int main() {
	int  i, j, k, n, d, c = 0;
	double x[10][10], s = 0, r;
	scanf("%d%d", &n, &d);
	for (i = 0; i < n; i++)for (j = 0; j < d; j++) scanf("%lf", &x[i][j]);
	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			s = 0;
			for (k = 0; k < d; k++)s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			r = sqrt(s);
			if (ceil(r) == floor(r))c++;
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 128
#define M'   '
char*s,T[M],*r=T;U[M*35];i;k;main(n){for(;gets(r+1);k=0)for(--n;*++r&=31;)U[r-T]=k|=!!n<<*r;for(;i++-2;)for(s=r;s-->T;k=U[k]=U[k-=~-~*s*M]?:*s?s-T:0)n+=__builtin_popcount(U[s-T]&(U[k+M]^=!s[-1]<<*s));printf("%d",n);}

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

using namespace std;

int main(){
    int N,A,B,C; cin>>N>>A>>B>>C;
    int l[9],SWI[9],Atmp=0,Btmp=0,Ctmp=0;
    int cost=1000000;

    for(int i=1;i<=N;i++) cin>>l[i];

    for(int i=0;i<pow(4,N);i++){
        int rem=i;
        for(int j=N-1;j>=0;j--){//4^jの位をSWI[j+1]
            SWI[j+1]=rem/(int)pow(4,j);
            rem=rem%(int)pow(4,j);
        }//1つのスイッチの状態完成
      
        int gosei=-3;
        //SWI[1]~SWI[N] 0:A,1:B,2:C,3:x
        for(int j=1;j<=N;j++){
            if(SWI[j]==0){
                Atmp+=l[j];
                gosei++;
            }else if(SWI[j]==1){
                Btmp+=l[j];
                gosei++;
            }else if(SWI[j]==2){
                Ctmp+=l[j];
                gosei++;
            }
            if(Atmp>0 && Btmp>0 && Ctmp>0) cost=min(cost,abs(Atmp-A)+abs(Btmp-B)+abs(Ctmp-C)+gosei*10);
        }

        //次に行くので初期化
        Atmp=0;
        Btmp=0;
        Ctmp=0;
    }
    printf("%d",cost);
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] t = new int[n];
    String[] str = in.readLine().split(" ");
    int t_sum = 0;
    for(int i=0; i<n; i++) {
      t[i] = Integer.parseInt(str[i]);
      t_sum += t[i];
    }
    
    int m = Integer.parseInt(in.readLine());
    int[] p = new int[m];
    int[] x = new int[m];
    for(int i=0; i<m; i++) {
      str = in.readLine().split(" ");
      p[i] = Integer.parseInt(str[0]);
      x[i] = Integer.parseInt(str[1]);
      System.out.println(t_sum - (t[p[i]-1]-x[i]));
    }
  }
}

Measured memory_bytes: 32828
N,K = map(int,input().split())
S = list(input())

li = []

for i in range(N):
    if i != K-1:
        li.append(S[i])
    else:
        if S[i] =="A":
            li.append("a")
        if S[i] =="B":
            li.append("b")
        if S[i] == "C":
            li.append("c")
print(''.join(li))

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int n, q, temp, i, j;
  int a[2001] = {1};
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &temp);
    for(j=2000-temp;j>=0;j--){
      if(a[j]) a[j + temp] = 1;
    }
  }
 
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &temp);
    if(a[temp]) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
        



Measured memory_bytes: 2104
N = int(input())
A = sorted([int(_) for _ in input().split()], reverse=1)
#0+ a + b + b + c + c + d + d + e + e + f + f
#1   2   3   4   5   6   7  8   9  10  11 12
if N % 2:
    print(2 * sum(A[:N // 2]) - A[0] + A[N // 2])
else:
    print(2 * sum(A[:N // 2]) - A[0])


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    vector<vi> A(N, vi(M));
    rep(i,N)rep(j,M) cin>>A[i][j], A[i][j]--;

    auto check_front = [&](queue<int> &que){
        vi vec(M);
        rep(i,N) vec[A[i].front()]++;
        int ret = *max_element(all(vec));
        rep(i,M)if(vec[i]==ret) que.push(i);
        return ret;
    };

    auto remove = [&](int x){
        rep(i,N){
            ITR(itr,A[i]){
                if (*itr==x){
                    A[i].erase(itr);
                    break;
                }
            }
        }
    };

    int ans = N;
    queue<int> que;
    while(!A[0].empty()){
        chmin(ans,check_front(que));
        while(!que.empty()){
            int s = que.front(); que.pop();
            remove(s);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3760
from math import fsum, sqrt
from itertools import permutations
N = int(input())
towns = [tuple(map(int, input().split())) for _ in range(N)]
distances = []
num = 0
for rt in permutations(range(N), N):
    num += 1
    for i in range(1, N):
        x1, y1 = towns[rt[i-1]]
        x2, y2 = towns[rt[i]]
        distance = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
        distances.append(distance)
print(fsum(distances) / num)

Measured memory_bytes: 12080
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    int H[N];
    bool ans = true;
    for(int i=0;i<N;i++)cin >> H[i];
    
    for(int i=0 ;i<N;i++){
        if(H[i]-H[i-1]==1)H[i]= H[i-1];
        else if(H[i] < H[i-1])ans = false;
        else {
            if(H[i] != H[i-1])H[i] = H[i]-1;
        }
            


    }
    if(ans)cout << "Yes" << endl;
    else cout<< "No" << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * @author david yepes buitrago
 * @date 21-01-2017
 * @time 0.000 ms
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = in.readLine()) != null;) {
			int n = Integer.parseInt(line.trim());
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(in.readLine().trim());
			if (n == 1) {
				out.println(arr[0] / 2);
				continue;
			}
			long x = arr[0], cont = 0;

			for (int i = 1; i < arr.length; i++) {
				x += arr[i];
				cont += x / 2;
				if ((x & 1) == 1 && arr[i] != 0) {
					x = 1;
				} else {
					x = 0;
				}
			}
			out.println(cont);
		}
		out.close();
	}
}


Measured memory_bytes: 31244
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(void){
    int n; cin >> n;n++;
    vector<ll>L(n);
    L[0]=2,L[1]=1;
    for(int i=2;i<n;i++) L[i]=L[i-1]+L[i-2];
    cout << L[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#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>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
//        Int N;
//        cin >> N;
//        vector<Int> A(N);
//        set<Int> B;
//        for (int i = 0; i < N; ++i) {
//            Int tmp;
//            cin >> tmp;
//            A[i] = tmp;
//            B.insert(tmp);
//        }
//        if (A.size() == B.size()) {
//            cout << "YES" << endl;
//        } else {
//            cout << "NO" << endl;
//        }
//

        string S, T;
        cin >> S >> T;
        Int A, B;
        cin >> A >> B;
        string U;
        cin >> U;

        if (S == U) A--;
        if (T == U) B--;
        cout << A << " " << B << endl;
    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    //int n;cin >> n;
    string s;cin >> s;
    
    if(s[0]=='7' or s[1]=='7' or s[2]=='7')
    cout << "Yes";
    else
    cout << "No";
    
    
    
	return 0;
    
}


Measured memory_bytes: 10636
import os

def main():
  args = list(map(int, input().split()))
  nb = args[0]
  nl = args[1]
  if nb == 0 or (nl % 2 == 1) or nl == 0 or nb > nl or (nl / 4.0) > nb:
    print('No')
    return
  for i in range(nb + 1):
    if ((nb - i) * 4 + i * 2) == nl:
      print('Yes')
      return
  print('No')

if __name__ == '__main__':
  main()


Measured memory_bytes: 9196
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char x;
    int t=0;
    for(int s=0;s<=1000;s++){
        for(int i=0;i<=1000;i++){
            scanf("%c",&x);
            if(x=='\n') break;
            t +=(int)(x-'0');
        }
    if(t==0) break;
    printf("%d\n",t);
    t=0;
    }
}


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

int main() {
    string S; cin >> S;
    string Y, M;
    for (int i = 0; i < 4; i++) {
        Y += S.at(i);
    }
    for (int i = 0; i < 2; i++) {
        M += S.at(5 + i);
    }
    int y = stoi(Y), m = stoi(M);
    if (y >= 2019 && m >= 5) {
        cout << "TBD" << endl;
    }
    else {
        cout << "Heisei" << endl;
    }
}

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

int main() {
	string s,t;
	cin >> s>>t;
	int p = 0;
	rep(i, 3)if (s.at(i) == t.at(i))p++;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  long ans = 0;
  map<int, int> m;
  rep(i,0,N-1) {
    int tmp;
    cin >> tmp;
    int a = i - tmp;
    int b = i + tmp;
    ans += m[a];
    m[b]++;
  }

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


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

int main() {
  string str;
  int q;
  string order, p;
  int a, b;
  string substr;

  cin >> str >> q;
  for (int i = 0; i < q; i++) {
    cin >> order >> a >> b;
    if (order == "print") {
      cout << str.substr(a, b - a + 1) << endl;
    } else if (order == "reverse") {
      substr = str.substr(a, b - a + 1);
      reverse(substr.begin(), substr.end());
      str = str.replace(a, b - a + 1, substr);
    } else {
      cin >> p;
      str = str.replace(a, b - a + 1, p);
    }
  }

  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

int n, R;

int main() {
    cin >> n >> R;
    if (n >= 10) {
        printf("%d\n", R);
    } else {
        printf("%d\n", R + 100 * (10 - n));
    }
    return 0;
}


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

int main(void)
{
    int i, j;
    int n, k, m, r;
    long long syou, amari;
    static int farray[10021], sum[10021];
    
    while (1){
        scanf("%d%d%d%d", &n, &k, &m, &r);
        
        if (n + k + m + r == 0){
            break;
        }
        
        if (m == 0){
            amari = 1;
            syou = n;
            printf("%d.", amari / syou);
            amari %= syou;
            amari *= 10;
            for (i = 0; i < r; i++){
                printf("%lld", amari / syou);
                amari %= syou;
                amari *= 10;
            }
        }
        else {
            memset(sum, 0, sizeof(sum));
            
            for (i = 0; i < n; i++){
                amari = 1;
                syou = (i == 0 ? n : n * i);
                memset(farray, 0, sizeof(farray));
                for (j = 0; j <= 10020; j++){
                    farray[j] = amari / syou;
                    amari %= syou;
                    amari *= 10;
                }
                if (i == 0){
                    memcpy(sum, farray, sizeof(farray));
                }
                else {
                    for (j = 10020; j >= 0; j--){
                        sum[j] += farray[j];
                        if (sum[j] > 9){
                            sum[j] -= 10;
                            sum[j - 1] += 1;
                        }
                    }
                }
            }
            
            printf("%d.", sum[0]);
            for (i = 1; i <= r; i++){
                printf("%d", sum[i]);
            }
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 496
l = [int(input()),int(input()),int(input()),int(input()),int(input())]
k = int(input())
i = 4
j = 0
y = 1
while i+1 :
  j = i-1
  while j+1 :
    if l[j-1]-l[i-1] > k : y = 0
    j -= 1
  i -= 1
if y == 1 : print('Yay!')
else : print(':(')

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

using namespace std;

const int INF = 1<<29;
const int MAX_N = 100;
const int MAX_M = 100;

int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

double width(int* X, int* Y, int n, double x) {
  double lb = INF, ub = -INF;
  for(int i=0; i<n; i++) {
    double x1 = X[i], y1 = Y[i], x2 = X[(i+1)%n], y2 = Y[(i+1) % n];
    
    if((x1-x)*(x2-x) <= 0 && x1 != x2) {
      double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
      
      lb = min(lb, y);
      ub = max(ub, y);
    }
  }
  
  return max(0.0, ub - lb);
}

void solve() {
  int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
  int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
  
  vector<int> xs;
  
  for(int i=0; i<M; i++) xs.push_back(X1[i]);
  for(int i=0; i<N; i++) xs.push_back(X2[i]);
  
  sort(xs.begin(), xs.end());
  
  double res = 0;
  for(int i=0; i+1<xs.size(); i++) {
    double a = xs[i], b = xs[i+1], c = (a+b) / 2;
    if(min1 <= c && c <= max1 && min2 <= c && c <= max2) {
      double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
      double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
      double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
      res += (b - a) / 6 * (fa + 4 * fc + fb);
    }
  }
  
  printf("%.10f\n", res);
}

int main() {
  
  while(cin >> M >> N && (M|N)) {
    for(int i=0; i<M; i++) cin >> X1[i] >> Y1[i];
    for(int i=0; i<N; i++) cin >> X2[i] >> Z2[i];
    
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<string.h>

int main(void) {
    char s[12];
    int i = 0;

    scanf("%s", s);

    while(i < 4) {
        printf("%c", s[i]);
        i++;
    }
    printf(" ");
    while(i < 12) {
        printf("%c", s[i]);
        i++;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    vi v(3);
    rep0(i,3){
        cin>>v[i];
    }
    sort(all(v));
    cout<<v[0]*v[1]/2<<endl;
}

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

const int N = 110000;
const long long INF = 1LL << 60;

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 0; i <= n; i++) cin >> a[i];
	
	auto calc = [&]() {
		long long ans = 0;
		vector<long long> val(n + 2, 0);
		val[0] = 1;
		for (int i = 0; i <= n; i++) {
			if (val[i] > INF) val[i] = INF;
			if (val[i] < a[i]) return -1LL;
			val[i + 1] = (val[i] - a[i]) * 2;
		}
		long long tot = 0;
		for (int i = n; i >= 0; i--) {
			tot += a[i];
			ans += tot;
			tot = min(tot, val[i] / 2);
		}
		return ans;
	};
	
	cout << calc() << "\n";
	
	return 0;
}


Measured memory_bytes: 4520
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

X,Y= MAP()
n=X
cnt=1
while True:
	if n*2 <= Y:
		n *= 2
		cnt += 1
	else:
		break

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <vector>

int main() {
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  int i,j,k,c;
  int d;
  int e;
  int count = 0;
  int ans = 0;
  for(i=1;i<n;i++) {
    count = 0;
    for(k=0;k<27;k++) {
      d = 0;
      e = 0;
      for(j=0;j<i;j++) {
        if(s[j]==k+97) {
          d++;
        }
      }
      for(j=i;j<n;j++) {
        if(s[j]==k+97) {
          e++;
        }
      }
      if(d*e>0){
        count++;
      }
    }
    if(ans < count) {
      ans = count;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
int H,W;
V<string> s;
mint dp[1001][1001];
int main(){
	cin>>H>>W;
	s.resize(H);
	rep(i,H) cin>>s[i];
	dp[0][0] = 1;
	rep(i,H) rep(j,W) if(s[i][j]=='.'){
		if(j!=W-1 && s[i][j+1]=='.') dp[i][j+1] += dp[i][j];
		if(i!=H-1 && s[i+1][j]=='.') dp[i+1][j] += dp[i][j];
	}
	cout<<dp[H-1][W-1]<<endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int k = n / 2;
  string res = "No";
  if (n % 2 == 0 && s.substr(0, k) == s.substr(k, k)) {
    res = "Yes";
  }
  cout << res << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 3e3+10;

int a[N];
ll dp[N][N][2];
int main(){
fast;
int n;
cin>>n;

fill(dp,0);

for(int i=0;i<n;i++) {
    cin>>a[i];
}
for(int i=0;i<n;i++) {
    dp[i][i][0]=a[i];
    dp[i][i][1]=-1*a[i];
}

for(int len=2;len<=n;len++) {
    for(int i=0;i<n-len+1;i++) {
        dp[i][i+len-1][0]=max(dp[i+1][i+len-1][1]+a[i], dp[i][i+len-2][1]+a[i+len-1]);
        dp[i][i+len-1][1]=min(dp[i+1][i+len-1][0]-a[i], dp[i][i+len-2][0]-a[i+len-1]);
    }
}

cout<<dp[0][n-1][0]<<endl;
return 0;
}

Measured memory_bytes: 145144
#include <stdio.h>
#define MAX 100000
static int n, a, as[MAX + 2], i, max;
int main(void) {
    scanf("%d", &n);
    while (n--) {
        scanf("%d", &a);
        ++as[a];
        ++as[a + 1];
        ++as[a + 2];
    }
    for (i = 0; i < MAX + 2; ++i)
        if (as[i] > max)
            max = as[i];
    printf("%d\n", max);
    return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    rep(i, n) {
        char t = (i%2==1)?'1':'0';
        if (s[i] != t) ++ans;
    }
    cout << min(ans, n-ans) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int x, a, b;
  cin >> x >> a >> b;
  int da = abs(x-a);
  int db = abs(x-b);
  
  if(da > db) cout << "B" << endl;
  else cout << "A" << endl;
 
 
}

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

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

		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		// System.out.prlongln(S);
		long x1 =0;
		int x2 =1000000000;
		long x3 =(x2-S%x2)%x2;
		long y1 =0;
		long y2 =1;
		long y3 =((S-1)/x2+1);
		// System.out.println(S % 2);

		// y2 = S / x1;
		// if (y2 == 0){
		// 	y2 = 1;
		// }
		// y1 = (x1 * (int)y2) - S;
		// System.out.println(y1);
		// System.out.println(y2);
		System.out.println(x1 + " " + y1 + " " + x2 + " " + (int)y2 + " " + x3 + " " + y3);

	}
}

// import java.util.*;
// public class Main{
// 	public static void main(String[]i){
// 		long s=Long.parseLong(new Scanner(System.in).next());
// 		int a=1000000000;
// 		System.out.println("0 0 "+a+" 1 "+(a-s%a)%a+" "+((s-1)/a+1));
// 	}
// }


Measured memory_bytes: 23892
N = int(input())
A = []
for i in range(2):
    Ai = list(map(int,input().split()))
    A.append(Ai)
ans = 0
for i in range(N):
    can = sum(A[0][0:i+1]) + sum(A[1][i:])
    ans = max(ans,can)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 323456;
ll a[N],l[N],r[N];

int main()
{
	int n;
	cin>>n;	
	priority_queue<int,vector<int>,greater<int> > pq1;
	priority_queue<int>pq2;
	for(int i=1;i<=3*n;i++)
	{
		cin>>a[i];
	}

	ll sum=0;
	for(int i=1;i<=3*n;i++)
	{
		sum+=a[i];
		pq1.push(a[i]);
		if(pq1.size()>n)
		{
			sum-=pq1.top();
			pq1.pop();
		}
		l[i]=sum;
	}
	sum=0;
	for(int i=3*n;i>=0;i--)
	{
		sum+=a[i];
		pq2.push(a[i]);
		if(pq2.size()>n)
		{
			sum-=pq2.top();
			pq2.pop();
		}
		r[i]=sum;
	}
	ll ans =-1e18;
	for(int i=n;i<=2*n;i++)
	{
		ans=max(ans,l[i]-r[i+1]);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
void rle(string &s, vector<pair<char,int>> &t){
    int j=0;
    t={make_pair(s[0],1)};
    for(int i=1; i<s.size(); ++i){
        if(s[i]==s[i-1]){
            ++t[j].second;
        }else{
            t.push_back(make_pair(s[i],1));
            ++j;
        }
    }
}
int main(){
	string s; cin >> s;
    vector<pair<char,int>> t;
    rle(s,t);

    int n=t.size();
    vector<int> v;
    for(int i=0; i<n; i+=2){
        int nt=t[i].second+t[i+1].second;
        v.assign(nt,0);
        v[t[i].second-1]=nt/2; //second-1が偶数と仮定
        v[t[i].second]=(nt+1)/2;
        if(t[i].second%2==1){
            swap(v[t[i].second-1],v[t[i].second]);
        }
        for(int k : v) cout << k << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=5+1e6;
int pw[25];
struct RevOp{
	int d[MAX_N];
	bool flag;
	void init(int n){
		flag=0;
		for(int i=0;i<n;++i){
			for(int j=pw[i];j<pw[i]*2;++j)
				d[j]=1;
			for(int j=pw[i]*2;j<pw[i+1];++j)
				d[j]=2;
		}
	}
	int operator[](int x){ return flag?(d[x]==0?0:3-d[x]):d[x]; }
	void add(int x){ 
		if(!flag){
			d[x]++; 
			if(d[x]>=3) d[x]-=3; 
		}else{
			d[x]--;
			if(d[x]<0) d[x]+=3;
		}
	}
	void rev(){ flag^=1; }
}d;

inline void mo(int& x){x>=3?x-=3:0;}
int gbit(int x,int i){ return x/pw[i]%3; }
int gbit2(int x,int i){
	if(gbit(x,i)!=0) return d[x%pw[i+1]];
	int y=x%pw[i];
	return 3-d[y+pw[i]]-d[y+pw[i]*2];
}
void print(int n){
	for(int x=0;x<pw[n];++x){
		int ret=0;
		for(int i=0;i<n;++i)
			ret+=gbit2(x,i)*pw[i];
		printf("%d ",ret);
	}
	puts("");
}
int main(){
	string s;
	int n,T; scanf("%d",&n); cin>>s;
	pw[0]=1; for(int i=1;i<=n;++i) pw[i]=pw[i-1]*3;
	d.init(n);
//	for(int j=0;j<pw[n];++j) printf("|%d|",d[j]);
//	print(n);
	for(int i=0;i<s.length();++i)
		if(s[i]=='S'){
			d.rev();
		}else{
			int x=0;
			for(int t=0;t<n;++t){
				d.add(x+pw[t]);
				d.add(x+pw[t]*2);
				if(gbit2(x,t)==0) x+=0;
				else if(gbit2(x+pw[t],t)==0) x+=pw[t];
				else if(gbit2(x+pw[t]*2,t)==0) x+=pw[t]*2;
			}
		}
	print(n);
	return 0;
}
	
					
			

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e18 + 7;
ll tc, n, m, q, a, b, c, d, i, j, k, ans;
ll mp[N], cnt[N];
string s;
vector < ll > vec;

int main()
{
    faster_io;
    cin >> n >> m;
    while(m--)
    {
        cin >> a >> s;
        if(mp[a])
            continue;
        if(s == "AC")
            mp[a] = 1, ans++, i += cnt[a];
        else cnt[a]++;
    }
    cout << ans << ' ' << i << endl;
}


Measured memory_bytes: 5120
#include <cstdio>

int cross[101];

int main(){
  for(;;){
    for(int i=1; i<=100; i++) cross[i] = 0;
    for(;;){
      int from,to;
      if(!~scanf("%d %d",&from,&to))
	goto hoge;
      if(from==0)
	break;

      cross[from]++; cross[to]++;
    }

    if(!((cross[1]&1)&&(cross[2]&1))){
      printf("NG\n");
      goto foo;
    }
      
    for(int i=3; i<=100; i++){
      if(cross[i]&1){
	printf("NG\n");
	goto foo;
      }
    }
    printf("OK\n");
  foo: ;
  }
 hoge: ;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";
#define mod 1000000007
int power(int x, int y)
{
	int res = 1; x %= mod;
	while(y > 0)
	{
		if(y & 1) res = res * x % mod;
		y >>= 1;
		x = x * x % mod;
	}
	return res % mod;
}
signed main()
{
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, k;
	cin >> n >> k;
	int ans = 0;
	int cnt[k+1];
	for(int i = k; i > 0; i--)
	{
		int total_divisors = k/i;
		cnt[i] = power(total_divisors, n);
		for(int j = i+i; j <= k; j += i)
			cnt[i] += mod - cnt[j];
		cnt[i] %= mod;
		ans += cnt[i] * i;
		ans %= mod; 
	}
	cout << ans << "\n";
}


Measured memory_bytes: 4344
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    string s1,s2;
    cin>>s1>>s2;
    n=s1.size();
    m=s2.size();
    ll ans=INT_MAX;
    for(i=0;i<n-m+1;i++)
    {
        string check=s1.substr(i,m);
        ll count=0;
        for(j=0;j<m;j++) if(s2[j]!=check[j]) count++;
        ans=min(count,ans);
    }
    cout<<ans;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	ll a,b,c;
	ll k;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	ll ans;
	if(k%2==0){
		ans = a-b;
	}else{
		ans = b-a;
	}
	printf("%lld\n",ans);
	return 0;
};

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if (A >= B && A >= C) {
    printf("%d\n", (A * 10) + B + C);
  } else if (B >= A && B >= C) {
    printf("%d\n", A + (B * 10) + C);
  } else {
    printf("%d\n", A + B + (C * 10));
  }
  return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

S = readline().rstrip().decode()
T = readline().rstrip().decode()

s = [ S[i] for i in range(len(S))]
t = [ T[i] for i in range(len(T))]

s.sort()
t.sort()
t.reverse()

for i in range(min(len(S),len(T))):
    if ord(s[i]) < ord(t[i]):
        print("Yes")
        exit(0)
    if ord(s[i]) > ord(t[i]):
        print("No")
        exit(0)

if len(S) < len(T):
    print("Yes")
    exit(0)
else:
    print("No")
    exit(0)

Measured memory_bytes: 38256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, H = li_input()
    S = [li_input() for _ in range(N)]

    ans = 0
    strong_throw = []

    maxcut = -1
    for s in S:
        if s[0] > maxcut:
            maxcut = s[0]

    for s in S:
        if s[1] > maxcut:
            strong_throw.append(s[1])

    strong_throw.sort(reverse=True)

    for st in strong_throw:
        H -= st
        ans += 1

        if H <= 0:
            break

    if H > 0:
        ans += math.ceil(H / maxcut)

    print(ans)


main()


Measured memory_bytes: 23904
#include <stdio.h>
int main(){
  int H,W,i,j,x;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(i=1; i<=H; i++){
      for(j=1; j<=W; j++){
	x=i+j;
	if(x%2==0)printf("#");
	else if(x%2==1)printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	i64 N;

	scanf("%lld", &N);

	if (N % 2 == 0)
	{
		printf("%lld %lld %lld", N, N, N / 2);
		return 0;
	}

	for (i64 h = 1 + N / 4; h <= 3500; h++)
	{
		for (i64 w = 1 + N / 4; w <= 3500; w++)
		{
			if (w*N + h*N >= 4 * h*w)
				continue;

			if (N*h*w % (4 * h*w - w*N - h*N) == 0)
			{
				i64 n = N*h*w / (4 * h*w - w*N - h*N);
				printf("%lld %lld %lld", h, w, n);
				return 0;
			}
		}
	}

	return 0;
}

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

int main(void){
  int c, i, j, k;
  long int a, b, d;
  char tmp[8];
  c = 'a';
  for(j = 0; j < 200; j++){
    i = 0;
    while((c = getchar()) != EOF){
      if(c == '\n') break;
      tmp[i] = c;
      if(c == ' '){
        tmp[i] = '\0';
        a = atol(tmp);
        i = 0;
        continue;
      }
      i++;
    }
    if(c == EOF) break;
    tmp[i] = '\0';
    b = atol(tmp);

    d = a + b;
    for(i = 0; d > 0; i++){
      d /= 10;
    }
    printf("%d\n", i);
  }
  return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

/////////////////////////////////////////////////////////////////////

struct StronglyConnectedComponent {
    vector<vector<int>> G,R,T,C;
    vector<int> vs,used,blg;
    StronglyConnectedComponent() {}
    StronglyConnectedComponent(int N) : G(N), R(N), used(N), blg(N) {}

    void add_edge(int u,int v){
        G[u].emplace_back(v);
        R[v].emplace_back(u);
    }

    void dfs(int v){
        used[v] = 1;
        for(int u:G[v]) {
            if(!used[u]) dfs(u);
        }
        vs.emplace_back(v);
    }

    void rdfs(int v, int k) {
        used[v] = 1;
        blg[v] = k;
        C[k].emplace_back(v);
        for(int u:R[v]) {
            if(!used[u]) rdfs(u,k);
        }
    }

    int build() {
        int N = G.size();
        for(int v = 0; v < N; v++) {
            if(!used[v]) dfs(v);
        }

        fill(used.begin(),used.end(),0);
        int k = 0;
        for(int i = N-1; i >= 0; i--) {
            if(!used[vs[i]]) {
                T.emplace_back();
                C.emplace_back();
                rdfs(vs[i], k++);
            }
        }

        for(int v = 0; v < N; v++) {
            for(int u:G[v]) {
                if(blg[v] != blg[u]) T[blg[v]].emplace_back(blg[u]);
            }
        }

        for(int i = 0; i < k; i++) {
            sort(T[i].begin(),T[i].end());
            T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
        }
        return k;
    }

    int operator[](int k) const{return blg[k];}
};

/////////////////////////////////////////////////////////////////

void GRL_3_C() {
    int N,M; cin >> N >> M;
    StronglyConnectedComponent SCC(N);
    for (int i = 0; i < M; i++) {
        int u,v; cin >> u >> v;
        SCC.add_edge(u,v);
    }
    SCC.build();
    int Q; cin >> Q;
    while (Q--) {
        int u,v; cin >> u >> v;
        cout << (SCC[u]==SCC[v]) << endl;
    }
} 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    GRL_3_C();
}


Measured memory_bytes: 4596
"use strict";
const lines = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
const hs = lines[1].split(" ");
let h = [];
for(let i = 0; i < hs.length; i++){
  h.push(parseInt(hs[i]));
}

const n = h.length;
let i;
for(let j = 0; ; j++){
  for(i = 0; h[i] === 0 && i < n; i++){}
  if(i === n){
    console.log(j);
    break;
  }
  for(; i < n; i++){
    if(h[i] > 0){
      h[i]--;
    }else{
      break;
    }
  }
}




Measured memory_bytes: 7372