akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  cout << (n + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

int main(){	
	ll s;
	cin>>s;
	ll xa=0,ya=0,xb=1e9,yb,xc=1,yc;
	//xb*yc-xc*yb=s
	yc=s/INF;//INFで割るため
	yb=INF*yc-s;
	if(yb<0){
		yc++;
		yb=INF*yc-s;
	}
	cout<<xa<<" "<<ya<<" "<<xb<<" "<<yb<<" "<<xc<<" "<<yc<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

ll ans = 0;
int n,m,q;
vi a,b,c,d;

void dfs(vi A) {
  if(A.size() == n+1) {
    ll point = 0;
    rep(i,q) if(A.at(b.at(i))-A.at(a.at(i))==c.at(i)) point+=d.at(i);
    ans = max(ans,point);
    return;
  }
  int t = A.back();
  srep(i,t,m+1) {
    A.eb(i);
    dfs(A);
    A.pop_back();
  }

}

int main() {
  cin >> n >> m >> q;
  a=b=c=d=vi(q,0);
  rep(i,q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);

  dfs(vi(1,1));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s; cin>>s;
	int n = (int)s.size();
	if(s[n-1]!='s'){
		cout<<s<<"s"<<"\n";
	}
	else{
		cout<<s<<"es"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3656
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) throws IOException {
        int num = receiveInt();
        BigInteger[] inputs = new BigInteger[num];
        for(int i = 0; i < num; i++) {
            inputs[i] = receiveBigInteger();
        }
        BigInteger ans = lcm(inputs);
        println(ans);
        flush();
    }

    // 数学関連
    static BigInteger gcd(BigInteger x, BigInteger y) {
        if (y.subtract(x).signum() > 0) {
            return gcd(y, x);
        }
        if (y.equals(BigInteger.ZERO)) {
            return x;
        }
        return gcd(y, x.remainder(y));
    }

    static BigInteger gcd(int x, int y) {
        return gcd(BigInteger.valueOf(x), BigInteger.valueOf(y));
    }

    static BigInteger lcm(int x, int y) {
        return lcm(BigInteger.valueOf(x), BigInteger.valueOf(y));
    }

    static BigInteger lcm(BigInteger x, BigInteger y) {
        return x.multiply(y).divide(gcd(x, y));
    }

    static BigInteger lcm(BigInteger[] arr) {
        BigInteger lcm = BigInteger.ONE;
        for (BigInteger i : arr) {
            lcm = lcm(lcm, i);
        }
        return lcm;
    }
    static BigInteger lcm(int[] arr) {
        BigInteger lcm = BigInteger.ONE;
        for (int i : arr) {
            lcm = lcm(lcm, BigInteger.valueOf(i));
        }
        return lcm;
    }

    static int powerOf2(int x) {
        int ret = 0;
        while (true) {
            if (x % 2 != 0)
                break;
            x /= 2;
            ret++;
        }
        return ret;
    }

    // 入出力関連
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);

    enum Delimiter {
        NONE(""), SPACE(" "), DOT("\\."), COMMA(",");

        private String regex;

        private Delimiter(String regex) {
            this.regex = regex;
        }

        public String getRegex() {
            return regex;
        }
    }

    static String receive() throws IOException {
        return br.readLine();
    }

    static int receiveInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }
    static BigInteger receiveBigInteger() throws IOException {
        return new BigInteger(br.readLine());
    }

    static char receiveChar() throws IOException {
        return br.readLine().charAt(0);
    }

    static char[] receiveCharArray() throws IOException {
        return br.readLine().toCharArray();
    }

    static int[] receiveIntArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).mapToInt(Integer::parseInt).toArray();
    }

    static String[] receiveStringArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).toArray(String[]::new);
    }

    static void print(Object obj) {
        pw.print(obj);
    }

    static void println(Object obj) {
        pw.println(obj);
    }

    static void flush() {
        pw.flush();
    }
}

Measured memory_bytes: 22740
<?php
list($n,$m)=explode(" ",trim(fgets(STDIN)));
$l=1;
$r=$n;
$i=0;
while($i<$m){
  list($a,$b)=explode(" ",trim(fgets(STDIN)));
  $l=max($l,$a);
  $r=min($r,$b);
  ++$i;
}
echo max($r-$l+1,0);


Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main()
{
	int a[12]={0,111,222,333,444,555,666,777,888,999};
	int x;
	scanf("%d",&x);
	int b=x/100;
//	cout<<"b"<<b<<endl;
	if(x<=a[b])cout<<a[b]<<endl;
	else
	{
		cout<<a[b+1]<<endl;
	}
}

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

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const int DAY = 86400;

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  REP(i,N) cin >> a[i] >> b[i];

  vector<int> awake;
  int tmp = a[0] % DAY;
  REP(i,N) {
    if(i) tmp = (tmp + b[i - 1] + a[i]) % DAY;
    awake.push_back(tmp);
    awake.push_back(tmp + DAY);
  }
  sort(ALL(awake));
  int res = 0;
  REP(i,N) {
    int tmp = upper_bound(ALL(awake), awake[i] + 10800) - awake.begin() - i;
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (int i = 0; i < k; i++)
        {
            cout << s.at(i);
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextLine();
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(scanner.nextInt());
			}
			scanner.nextLine();
			List<Integer> resultList = new LinkedList<>();
			if (check(list, resultList)) {
				for (int i = resultList.size() - 1; i >= 0; i--) {
					System.out.println(resultList.get(i));
				}
			} else {
				System.out.println(-1);
			}
		}
	}

	private static boolean check(List<Integer> list, List<Integer> resultList) {
		// System.out.println("list=" + toString(list) + ", resultList=" + toString(resultList));
		if (list.isEmpty()) {
			return true;
		}
		for (int i = list.size() - 1; i >= 0; i--) {
			if (list.get(i) == (i + 1)) {
				resultList.add(i + 1);
				list.remove(i);
				if (check(list, resultList)) {
					return true;
				} else {
					return false;
				}
			}
		}
		return false;
	}
}


Measured memory_bytes: 25172
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        res = 0
        for a, b, c, d in X:
            if x[b] - x[a] == c:
                res += d
        return res

    res = 0
    x.append(x[-1])
    while x[-1] <= M:
        res = max(res, dfs(x))
        x[-1] += 1
    x.pop()

    return res

print(dfs([1]))


Measured memory_bytes: 73340
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int x = a + b;
	if (x == 24)
		x = 00 ;
	if (x > 24)
		x = x - 24;
	cout << x ;
	return 0 ;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  vector<int> cnt;
  cnt.assign(26, 0);

  string s;
  cin >> s;
  rep(i, s.length()) {
    cnt[s[i] - 'a']++;
  }

  rep(i, 26) {
    if(cnt[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }

  cout << "None" << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void) {
	int N;
	string s;
	int p, max=0;
	int count = 0;
	int count_a['z' - 'a' + 1] = { 0 };
	int count_b['z' - 'a' + 1] = { 0 };
	cin >> N>>s;
	for (p = 1;p < N - 1;p++) {
		count = 0;
		for (int i = 0; i < p;i++) {
			count_a[s[i] - 'a']++;
		}
		for (int i = p; i < N;i++) {
			count_b[s[i] - 'a']++;
		}
		for (int i = 0;i < 'z' - 'a' + 1;i++) {
			if (count_a[i] > 0 && count_b[i] > 0)
				count++;
			count_a[i] = 0;
			count_b[i] = 0;
		}
		if (count > max)
			max = count;
	}
	cout << max << endl;
	return 0;
}


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

int main()
{
    int n, m; cin >> n >> m;
    vector<int> p(m), y(m);
    for (int i = 0; i < m; i++) cin >> p[i] >> y[i];

    vector<vector<int>> cor(n+1); // cor[p[i]] = 県p[i]に属する市の誕生年の配列
    for (int i = 0; i < m; i++) cor[p[i]].push_back(y[i]);
    for (int i = 1; i <= n; i++) sort(cor[i].begin(), cor[i].end());
    for (int i = 0; i < m; i++) {
        int num = lower_bound(cor[p[i]].begin(), cor[p[i]].end(), y[i]) - cor[p[i]].begin() + 1;
        printf("%06d%06d\n", p[i], num);
    }
    return 0;
}

Measured memory_bytes: 7808
s=input()
q=int(input())
t1counter=0
s1=''
for i in range(q):
    tfc=input().split()
    if(tfc[0]=='1'):
        t1counter+=1
    else:
        if(t1counter%2==0 and tfc[1]=='1'):
            s1=s1+tfc[2]
        elif(t1counter%2==1 and tfc[1]=='2'):
            s1=s1+tfc[2]
        elif(t1counter%2==0 and tfc[1]=='2'):
            s=s+tfc[2]
        elif(t1counter%2==1 and tfc[1]=='1'):
            s=s+tfc[2]
        else:
            print('error')
s=s1[::-1]+s
if(t1counter%2==0):
    print(s)
elif(t1counter%2==1):
    print(s[::-1])

Measured memory_bytes: 4496
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n,K;
    scanf("%d%d", &n, &K);
    vector<int> s(n+1);
    int i;
    for(i=0; i<n; i++) {
        int a;
        scanf("%d", &a); a--;
        s[i+1]=(s[i]+a)%K;
    }

    ll sum=0;
    map<int,int> cnt;
    for(i=0; i<=n; i++) {
        if(i>=K) {
            cnt[s[i-K]]--;
        }
        if(cnt[s[i]]>0) {
            sum+=cnt[s[i]];
        }
        cnt[s[i]]++;
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int end = 0;
	int n, T;
	cin >> n >> T;
	int sum = 0;
	int tmp;
	for(int i = 0; i < n; ++i){
		std::cin >> tmp;
		if(tmp > end){
			sum -= tmp - end;
		}
		end = tmp + T;
	}
	sum += end;
	cout << sum << '\n';
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;


        y = y>>1;
        x = x*x;
    }
    return res;
}

signed main()
{
int a,b,c;
cin>>a>>b>>c;
if((a+b)>c)
    cout<<"No"<<endl;
else
{
    int x=c-(a+b);
    int y=power(x,2);
    if(y>(4*a*b))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
}










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

#define MAXN 2005

using namespace std;

int n, a[MAXN], deg[MAXN];
bool visit[MAXN];
vector<int> g[MAXN], h[MAXN], ans;

struct node {
	int u, v;
	node(int u = 0, int v = 0):u(u), v(v) {}

	bool operator < (const node b) const {
		return v < b.v;
	}
};

int gcd(int a, int b) {
	return !b ? a : gcd(b, a % b);
}

int read() {
	char c = getchar();
	int x = 0;
	while (!isdigit(c))
		c = getchar();
	while (isdigit(c)) {
		x = (x << 3) + (x << 1) + c - '0';
		c = getchar();
	}
	return x;
}

void DFS(int u) {
	visit[u] = true;
	for (int i = 0; i < (int)g[u].size(); ++i) {
		int v = g[u][i];
		if (visit[v])
			continue;
		h[u].push_back(v);
		++deg[v];
		DFS(v);
	}
}

void toposort() {
	priority_queue<node> q;
	for (int i = 1; i <= n; ++i)
		if (!deg[i])
			q.push(node(i, a[i]));
	while (!q.empty()) {
		int u = q.top().u;
		ans.push_back(a[u]);
		q.pop();
		for (int i = 0; i < (int)h[u].size(); ++i) {
			int v = h[u][i];
			if (--deg[v] == 0)
				q.push(node(v, a[v]));
		}
	}
}

int main() {
	n = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (gcd(a[i], a[j]) != 1) {
				g[i].push_back(j);
				g[j].push_back(i);
				// cout << i << " " << j << endl;
				// ++deg[j];
			}
	for (int i = 1; i <= n; ++i)
		if (!visit[i])
			DFS(i);
	toposort();
	// bool isreverse = false;
	for (int i = 0; i < n; ++i)
		printf("%d ", ans[i]);
	// for (int i = 1; i < n; ++i)
		// if (!isreverse && gcd(ans[i], ans[i - 1]) == 1 && ans[i] < ans[i - 1])
			// swap(ans[i], ans[i - 1]);
}

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);

	for(int i = 0; i < n; i++){
		cin >> p.at(i);
	}
	for(int i = 0; i < n; i++){
		cin >> q.at(i);
	}

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		a.at(i) = i+1;
	}

	map<vector<int>, int> mp;

	do{
		mp[a] = mp.size();
	}while(next_permutation(a.begin(), a.end()));

	int ans = abs(mp[p] - mp[q]);
	cout << ans << endl;

}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"H"<<"\n";
  }
  else{
    cout<<"D"<<"\n";
  }
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int k;
	cin >> k;
	int rem = 7;
	rep(i, 10101010) {
		if (rem % k == 0) {
			cout << i + 1 << endl;
			return 0;
		}
		rem *= 10;
		rem += 7;
		rem %= k;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    string s, t;    cin >> s >> t;
    ll res=0;
    REP(i, s.size()){
        res += s[i]!=t[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 3912
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}



Measured memory_bytes: 1080
import sys
import collections
from collections import Counter
# from collections import deque
# from collections import defaultdict
import itertools
# from itertools import accumulate
# from itertools import permutations
# from itertools import combinations
# from itertools import takewhile
from itertools import compress
# import functools
# from functools import reduce
import math
# from math import gcd
# from math import inf
# from math import ceil
# from math import floor
# from math import log10
# from math import log2
# from math import log
from math import factorial

# import re

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

S = set()
for i in range(N):
    for j in range(i, N):
        b = A[i:j + 1]
        S.add(sum(b))

S = list(S)

ans = 0
for i in range(40, -1, -1):
    A = [s & (1 << i) for s in S]
    newS = list(compress(S, A))
    if len(newS) >= K:
        ans += (1 << i)
        S = newS

print(ans)


Measured memory_bytes: 120168
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int N, Q;
	cin >> N;
	vector<int> par(N, 0);
	for(int i = 1; i < N; i++) par[i] = (i-1)/2;
	vector<cat> V(N);
	vector<int> W(N);
	for(int i = 0; i < N; i++) cin >> V[i] >> W[i];
	int X = min(N, 1<<9), MX = 100000;
	vector< vector<cat> > kn(X, vector<cat>(MX+1, 0));
	kn[0][W[0]] = V[0];
	for(int j = 1; j <= MX; j++) kn[0][j] = max(kn[0][j], kn[0][j-1]);
	for(int i = 1; i < X; i++) {
		kn[i] = kn[par[i]];
		for(int j = 0; j <= MX-W[i]; j++) kn[i][j+W[i]] = max(kn[i][j+W[i]], kn[par[i]][j]+V[i]);
		for(int j = 1; j <= MX; j++) kn[i][j] = max(kn[i][j], kn[i][j-1]);
	}
	cin >> Q;
	for(int q = 0; q < Q; q++) {
		int v, L;
		cin >> v >> L;
		v--;
		vector< pair<cat, int> > items;
		while(v >= X) {
			items.push_back({V[v], W[v]});
			v = par[v];
		}
		int sz = items.size();
		static cat sum_V[1<<10];
		static int sum_W[1<<10];
		cat ans = 0;
		for(int i = 0, b = 0; i < (1<<sz); i++) {
			while((1<<b) <= i) b++;
			for(int j = b; j < sz; j++) sum_V[i+(1<<j)] = sum_V[i]+items[j].ff;
			for(int j = b; j < sz; j++) sum_W[i+(1<<j)] = sum_W[i]+items[j].ss;
			if(sum_W[i] <= L) ans = max(ans, kn[v][L-sum_W[i]]+sum_V[i]);
		}
		cout << ans << "\n";
	}
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 409496
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<tuple<string, int, int>> A;
    for (int i = 0; i < N; i++) {
        string S; int P; cin >> S >> P;
        A.emplace_back(S, -P, i+1);
    }
    sort(begin(A), end(A));
    for (auto &t : A) cout << get<2>(t) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],dp[100010];
int main(){
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for (int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
#define ABS(x) ((x<0)?(-x):(x))
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

int abs(int x){
	if(x<0)	return -x;
	else return x;
}

int cost(int a, int b){
	return ((a>b)?(a-b):(b-a));
}

int main(){
	int n, h1, h2, h3;
	cin >> n;
	int curr, prev, pprev;
	cin >> h1 >> h2;
	pprev = 0;
	prev = abs(h1-h2);
	for(int i=2; i<n; i++){
		cin >> h3;
		curr = min(prev + abs(h2-h3), pprev + abs(h1-h3));
		pprev = prev;
		prev = curr;
		h1 = h2;
		h2 = h3;
	}
	if(n == 2)
		cout << prev;
	else
		cout << curr;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<map>
#include<string>
#include<cmath>

using namespace std;

const double eps=1e-9;
typedef complex<double> P;
typedef vector<P> Polygon;
typedef vector<Polygon> Country;

double cross(P a,P b){
  return (conj(a)*b).imag();
}

double dot(P a,P b){
  return (conj(a)*b).real();
}

bool d[100][100];
int color[10];
int nv;

int dfs(int x,int n){
  if(x==nv){
    return n;
  }else{
    int m=99;
    for(int i=0;i<n+1;i++){
      bool f=false;
      for(int j=0;j<x;j++){
	f|=d[x][j]&&i==color[j];
      }
      if(!f){
	color[x]=i;
	m=min(m,dfs(x+1,max(n,i+1)));
      }
    }
    return m;
  }
}

int main(){
  for(int n;cin>>n,n;){
    map<string,Country> m;
    while(n--){
      string s;
      cin>>s;
      Polygon p;
      for(int x,y;cin>>x,x>=0;){
	cin>>y;
	p.push_back(P(x,y));
      }
      m[s].push_back(p);
    }
    vector<Country> c;
    for(auto e:m){
      c.push_back(e.second);
    }
    nv=c.size();
    fill(d[0],d[10],false);
    for(int i=0;i<c.size();i++){
      for(auto e:c[i]){
	for(int j=0;j<e.size();j++){
	  for(int k=0;k<i;k++){
	    for(auto f:c[k]){
	      for(int l=0;l<f.size();l++){
		P a=e[j],b=e[(j+1)%e.size()];
		P x=f[l],y=f[(l+1)%f.size()];
		if(fabs(cross(a-b,x-b))<eps&&fabs(cross(a-b,y-b))<eps){
		  double pa,pb,pc,pd;
		  if(fabs(a.real()-b.real())<eps){
		    pa=min(a.imag(),b.imag());
		    pb=max(a.imag(),b.imag());
		    pc=min(x.imag(),y.imag());
		    pd=max(x.imag(),y.imag());
		  }else{
		    pa=min(a.real(),b.real());
		    pb=max(a.real(),b.real());
		    pc=min(x.real(),y.real());
		    pd=max(x.real(),y.real());
		  }
		  if(max(pa,pc)<min(pb,pd)-eps){
		    d[i][k]=d[k][i]=true;
		  }
		}
	      }
	    }
	  }
	}
      }
    }
    cout<<dfs(0,0)<<endl;
  }
}

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

int main(){
  int a,b,c,d;
  int i=1;
  cin >> a >> b >> c >> d;
  
  while(1){
    if(i%2==1){
      c -= b;
      if(c <= 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
    else{
       a -= d;
       if(a <= 0){
         cout << "No" << endl;
         return 0;
       }
    }
    i++;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 2000;
ll n,sum;
void solve(){
  for(int i=0 ; i<=n ; i++){
    for(int j=0 ; j<=n-i ; j++){
        if(10000*i + 5000*j + 1000*(n-i-j) == sum){
          cout << i << ' ' << j << ' ' << n-i-j << endl;
          return;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}
int main(){
  cin >> n >> sum;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;cin>>n;
  long long int a=500;
  long long int d=n/a;
  long long int ans=d*(long long int)1000;
  n-=(ans)/2;ans+=(n/5)*5;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    cnt = {}
    for a in ai:
        if a in cnt:
            cnt[a] += 1
        else:
            cnt[a] = 1

    ais = sorted(list(set(ai)), reverse=True)
    longer = 0
    shorter = 0
    for a in ais:
        if cnt[a] >= 2:
            longer = a
            cnt[a] -= 2
            break
    for a in ais:
        if cnt[a] >= 2:
            shorter = a
            cnt[a] -= 2
            break
    print(longer * shorter)

main()


Measured memory_bytes: 20748
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using ld= long double;
using vi= vector<int>;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvi= vector<vector<int>>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N,F;
    cin >> N >> F;
    vl L(N);
    REP(i,N)L[i] = F + i;
    ll sum = 0;
    REP(i,N)sum += L[i];
    ll ans = 0;
    ll diff = 1000000000000;
    REP(i,N){
        if(diff > abs(L[i])){
            chmin(diff,abs(L[i]));
            ans = i;
        }
    }
    cout << sum - L[ans]<< "\n";
}

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

vector<int> G[200000];
vector<int> cnt;
vector<bool> visited(200000);

void dfs(int u) {
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (visited[v]) continue;
        cnt[v] += cnt[u];
        visited[v] = true;
        dfs(v);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cnt.resize(N);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    visited[0] = true;
    dfs(0);

    for (int i = 0; i < N; i++) {
        cout << cnt[i] << " ";
    }
    cout << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    priority_queue<pair<ll, int>> pq;
    rep(i, M){
        ll val; int c;
        cin >> c >> val;
        pq.push(make_pair(val, c));
    }
    int idx = 0;
    while(!pq.empty()){
        pair<ll, int> op = pq.top();
        pq.pop();
        if(idx < N){
            int cnt = 0;
            while(idx < N && cnt < op.second && A[idx] < op.first){
                A[idx] = op.first;
                cnt++;
                idx++;
            }
        }
    }
    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
import java.util.*;
class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = 0;
		b = a / 3600;
    	int h = a % 3600 / 60;	
		int t = a % 60;  
		System.out.println(b + ":" + h + ":" + t);
	}
}



Measured memory_bytes: 26232
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> p = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }

        p = p.stream().sorted().collect(Collectors.toList());

        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += p.get(i);
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 39404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

class segtree{
public:
    int n;
    vector<ll> dat;
    segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,0);
    }
    void update(int k,ll a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[k*2+1],dat[k*2+2]);
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return 0;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};
ll a[200001],h[200001];
int main(){
    int n;
    cin>>n;
    segtree seg(200001);
    rep(i,n) cin>>h[i];
    rep(i,n) cin>>a[i];
    rep(i,n){
        ll nx1=seg.query(h[i],h[i]+1);
        ll nx2=seg.query(0,h[i])+a[i];
        seg.update(h[i],max(nx1,nx2));

    }
    cout<<seg.query(0,200001)<<endl;
    return 0;
}


Measured memory_bytes: 7424
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n,k = m()

a = l()

ans = 0

for i in range(n):
    if a[i] >= k:
        ans += 1
print(ans)








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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  vector<string> candi;
  for (int i = 0; i <= int(s.length() - t.length()); i++)
  {
    bool equal_check = true;
    rep(j, t.length())
    {
      if (s[i + j] != '?' && s[i + j] != t[j])
      {
        equal_check = false;
      }
    }
    if (equal_check)
    {
      string tmp;
      rep(j, s.length())
      {
        if (j >= i && j < (i + int(t.length())))
        {
          tmp.push_back(t[j - i]);
        }
        else
        {
          if (s[j] == '?')
          {
            tmp.push_back('a');
          }
          else
          {
            tmp.push_back(s[j]);
          }
        }
      }
      candi.push_back(tmp);
    }
  }
  if (candi.empty())
  {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  sort(candi.begin(), candi.end());
  cout << candi[0] << endl;
  return 0;
}

Measured memory_bytes: 3556
def ispalindrome(str): return 1 if str == str[::-1] else 0

i = input()
l = len(i)
x = int((l-1)/2)
y = int((l+3)/2-1)
ii = i[0:x]
iii = i[y:l]

if (ispalindrome(i) == 1) and (ispalindrome(ii) == 1) and (ispalindrome(iii) == 1):
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 3060
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
//#define int long long
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
//mt19937 rnd(time(0));
typedef long double ld;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
signed main(void){
    int x;cin >> x;cout << (x==0?1:0) << endl;;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //nab
  int n,a,b,x,z;
  cin >>n>>a>>b;
  x=n*a;
  if(x>b){
    z=b;
  }else{
  	z=x;
  }
  cout << z << endl;
	
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        map<int, int> cnt;
        rep(i, N) {
            rep(j, 3) {
                cnt[A[i] - 1 + j]++;
            }
        }
        pii ans;
        for(auto p : cnt) {
            if(p.second > ans.second) ans = p;
        }
        cout << ans.second << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	string s1, s2;
	cin >> s1 >> s2;
	int l1 = s1.length();
	int l2 = s2.length();
	vector<vector<int>> DP(l1 + 1, vector<int>(l2 + 1));
	for (int i = 1; i <= l1; i++){
		for (int j = 1; j <= l2; j++){
			if (s1.at(i - 1) == s2.at(j - 1)){
				DP.at(i).at(j) = DP.at(i - 1).at(j - 1) + 1;
			} else {
				DP.at(i).at(j) = max(DP.at(i - 1).at(j), DP.at(i).at(j - 1));
			}
		}
	}
	int i = l1, j = l2;
	string ans = "";
	while (i > 0 && j > 0){
		if (DP.at(i).at(j) == DP.at(i - 1).at(j - 1) + 1 && s1.at(i - 1) == s2.at(j - 1)){
			ans += s1.at(i - 1);
			i--;
			j--;
		} else if (DP.at(i).at(j - 1) > DP.at(i - 1).at(j)){
			j--;
		} else {
			i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);     
     int n;
     cin>>n;
     map<int,int>m;
     for(int i=0;i<n;i++)
     {
        int x;
        cin>>x;
        m[x]++;
     }
     int res=0;
     for(auto &x:m)
     {
           if(x.second>=x.first)
            res+=x.second-x.first;
           else
            res+=x.second;
     }
     cout<<res<<endl;
     time();
     return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int l, n;
	cin >> l >> n;
	vector<int> x(n), w(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> w[i];
	}
	int left = 0, right = 0;
	for(int i = 0; i < n; ++i){
		if(x[i] < 0){
			left += -x[i] * w[i];
		}else{
			right += x[i] * w[i];
		}
	}
	if(left < right){
		cout << 1 << endl;
		cout << -1 << " " << (right - left) << endl;
	}else if(left > right){
		cout << 1 << endl;
		cout << 1 << " " << (left - right) << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
N, K, C = gets.split.map(&:to_i)
S = gets.strip.chars.map { |char| char == 'o' ? 0 : nil }
ss = S.size

# Justify the numbers to the right
dates_from_left = S
# Justify the numbers to the left
dates_from_right = S.reverse
ans = []

i = 0
plan = 1
while i < N
  break if plan > K
  if dates_from_left[i] == 0
    dates_from_left[i] = plan
    plan += 1
    i += C + 1
  else
    i += 1
  end
end

i = 0
plan = K
while  i < N
  break if plan < 1
  if dates_from_right[i] == 0
    dates_from_right[i] = plan
    plan -= 1
    i += C + 1
  else
    i += 1
  end
end

dates_from_left.each_with_index do |date, i|
  unless date.nil? || date == 0
    ans << i + 1 if date == dates_from_right[ss-i-1]
  end
end
if ans.nil?
  puts "\n"
else
  ans.each do |a|
    puts a
  end
end


Measured memory_bytes: 22780
import Control.Applicative

main :: IO ()
main = solve <$> getLine >>= print

solve :: String -> Int
solve w
  | w == "SUN" = 7
  | w == "MON" = 6
  | w == "TUE" = 5
  | w == "WED" = 4
  | w == "THU" = 3
  | w == "FRI" = 2
  | otherwise = 1


Measured memory_bytes: 380
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for i in range(N)]

ans = float('inf')
for b in range(1<<N):
    arr = [0] * (M+1)
    for i in range(N):
        if b&(1<<i)==0: continue
        for j,v in enumerate(CA[i]):
            arr[j] += v
    if all(v >= X for v in arr[1:]):
        ans = min(ans,arr[0])
print(-1 if ans==float('inf') else ans)

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

long long gcm(long long a,long long b) {
  if(a < b) return gcm(b,a);
  long long r;
  while(r = a%b) {
    a = b;
    b = r;
  }
  return b;
}

long long lcm(long long a,long long b) {
  return b / gcm(a,b) * a;
}

int main() {
	int n;
  long long ans = 1;
  long long in;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> in;
    ans = lcm(in,ans);
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
//#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+ 5;
#define ll long long
#define inf 0x3f3f
#define mod 1000000007
#define endl '\n'
int fa[maxn];
int find1(int x)
{
	if(fa[x]==x)return x;
  else return fa[x]=find1(fa[x]);
}
void Union(int x, int y)
{
	int fx = find1(x), fy = find1(y);
	fa[fy] = fx;
}
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	for (int i = 1; i < maxn; i++)fa[i] = i;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int x, y; cin >> x >> y;
		Union(x, y);
	}
	map<int, int>mp;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int t = find1(i);
		mp[t]++;
		ans = max(ans, mp[t]);
	}cout << ans << endl;

}
	 


Measured memory_bytes: 13756
N = int(input())
light_rule = {n:int(input())-1 for n in range(N)}

light = ["1"]+["0"]*(N-1)

flag = 0
num = 0
bottun = 0
for _ in range(N):
    if light[1] == "1":
        flag = 1
        break
    num += 1
    # print(bottun, light_rule[bottun])
    light[bottun] = "0"
    light[light_rule[bottun]] = "1"
    bottun = light_rule[bottun]
    # print(light)
    
if flag:
    print(num)
else:
    print(-1)

Measured memory_bytes: 17892
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string shuffle(string str, int h ){
    string head = str.substr(0, h);
    string tail = str.substr(h, str.size()-h);
    return tail + head;
}

int main(){
    string cards;
    int m, h;
    
    while(1){
        cin >> cards;
        if ( cards == "-" ) break;
        
        cin >> m;
        for ( int i = 0; i < m; i++ ){
            cin >> h;
            cards = shuffle(cards, h);
        }
        cout << cards << endl;;
    }
    
    return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		
		int sum = n*a < b ? n*a : b;
		System.out.println(sum);
		in.close();
	}
}

Measured memory_bytes: 21972
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static int J, Y;
  static List<string> lst = new List<string>();
  static void Dfs(int j, int y, string s) {
    if (J == j && Y == y) {
      lst.Add(s);
      return;
    }
    if (J < j || Y < y) return;
    if (j == 5 && y <= 3) return;
    if (y == 5 && j <= 3) return;
    Dfs(j + 1, y, s + "A");
    Dfs(j, y + 1, s + "B");
  }

  static void Main() {
    var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    J = a[0];
    Y = a[1];
    Dfs(0, 0, "");
    lst.ForEach(Console.WriteLine);
  }
}


Measured memory_bytes: 18364