akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define MAX_N 500
#define MAX_M 200000
#define MAX_Q 100000
int main(void){
    int N,M,Q;
    cin >> N >> M >> Q;
    int L[MAX_M];
    int R[MAX_M];
    int p[MAX_Q];
    int q[MAX_Q];
    for (int i=0;i<M;i++){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    for(int i=0;i<Q;i++){
        cin >> p[i]>> q[i];
        p[i]--;
        q[i]--;
    }
    int B[MAX_N+1][MAX_N+1];
    int C[MAX_N+1][MAX_N+1];
    int D[MAX_N+1][MAX_N+1];
    for(int i=0;i<M;i++){
        B[R[i]][0]++;
        B[R[i]][L[i]+1]--;
        B[N][0]--;
        B[N][L[i]+1]++;
    }
    for (int i=0;i<N+1;i++){
        for (int j=0;j<N+1;j++){
            if (i==0){
                C[i][j]=B[i][j];
            }
            else{
                C[i][j]=B[i][j]+C[i-1][j];
            }
        }
    }
    for(int i=0;i<N+1;i++){
        for(int j=0;j<N+1;j++){
            if (j==0){
                D[i][j]=C[i][j];
            }
            else{
                D[i][j]=C[i][j]+D[i][j-1];
            }
        }
    }
    for (int i=0;i<Q;i++){
        cout << D[q[i]][p[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 6272
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A2 = [0] * (N + 1)
for i in range(1, N + 1):
  A2[i] = A2[i - 1] + A[i - 1]

B2 = [0] * (M + 1)
for i in range(1, M + 1):
  B2[i] = B2[i - 1] + B[i - 1]

#print(A2, B2)
#print(bisect.bisect_left(B2, 300))
ans = 0
for i in range(N + 1):
  time = K - A2[i]
  if time < 0:
    print(ans)
    quit()
  else:
    index = bisect.bisect_right(B2, time) - 1
    #print(index, time, B2)
    ans = max(ans, i + index)
    
print(ans)    
  
  
  
  

Measured memory_bytes: 110620
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

typedef pair<pii, int> ppi;

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

void solve() {
  int h, w, n;
  cin >> h >> w >> n;
  vs s(h);
  vpii v(n + 1);
  rep(i, h) {
    cin >> s[i];
    rep(j, w) {
      if (s[i][j] == 'S') v[0]                               = mp(i, j);
      if ('1' <= s[i][j] && s[i][j] <= '9') v[s[i][j] - '0'] = mp(i, j);
    }
  }
  int c    = 0;
  auto bfs = [&](vs s, pii f, pii t) {
    queue<ppi> q;
    q.push(mp(f, 0));
    while (q.size()) {
      int i = q.front().fi.fi, j = q.front().fi.se, d = q.front().se;
      q.pop();
      if (i < 0 || j < 0 || i >= h || j >= w || s[i][j] == 'X') continue;
      if (i == t.fi && j == t.se) return d;
      s[i][j] = 'X';
      d++;
      rep(k, 4) q.push(mp(mp(i + di[k], j + dj[k]), d));
    }
  };
  loop(i, 1, v.size()) c += bfs(s, v[i - 1], v[i]);
  cout << c << endl;
}

Measured memory_bytes: 4912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		
		int count=1;
		int coord=0;
		for (int i=0; i<N; i++){
			coord+=sc.nextInt();
			if (coord>X)
				break;
			count++;
		}
		//System.out.println(coord);
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
# Problem A - A+...+B Problem

# input
N, A, B = map(int, input().split())

# corner case
if A>B:
    print(0)
elif N==1 and A!=B:
    print(0)
elif N==1 and A==B:
    print(1)
else:
    ans = (N-2)*(B-A) + 1
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 3636
N, X, M = map(int, input().split())
NN = N
li = []
isused = [False] * M
while isused[X] == False and N != 0:
    li.append(X)
    isused[X] = True
    X = (X ** 2) % M
    N -= 1
    
if N == 0:
    print(sum(li))

elif N != 0 and X in li:
    l = len(li)
    s = li.index(X)
    T = l - s
    q = (NN - s) // T
    r = (NN - s) % T
    print(sum(li) + sum(li[i] for i in range(s, len(li))) * (q-1) + sum(li[i] for i in range(s, s + r)))

Measured memory_bytes: 11516
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  9 22:12:40 2017

@author: kitagenbakurou
"""
import numpy as np
import copy

def insert(pos, s, x):
  return x.join([s[:pos], s[pos:] ])

s = input()
N = len(s)

i = 0
j = N - 1
cnt = 0
flag = True
while i < j : 
    if s[i] != s[j] : 
        if s[i] == "x" : 
            cnt += 1
            #s = insert(N - i  , s , "x")
            i += 1
            j += 0
        elif s[j] == "x" : 
            cnt += 1
            #s = insert(i , s , "x")
            i +=0
            j -= 1
        else : 
            flag = False
            break
    else : 
        i += 1
        j -= 1

if flag : 
    print(cnt)
else : 
    print(-1)

Measured memory_bytes: 12724
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    string str;
    cin  >> str;
    if(str.back() == '2' || str.back() == '4'
       || str.back() == '5' || str.back() == '7'
       ||str.back() == '9'){
        cout << "hon\n";
    }else if(str.back() == '0' || str.back() == '1'
             || str.back() == '6' || str.back() == '8'){
        cout << "pon\n";
    }else{
        cout << "bon\n";
    }
}






Measured memory_bytes: 3596
fun main(args: Array<String>) {
    val mod = 1000000007

    val s = readInputLine().toCharArray()
    
    val dp = Array(s.size, {IntArray(13)})
    
    if (s[0] == '?') {
        for (i in 0..9) {
            dp[0][i] = 1
        }
    } else {
        dp[0][(s[0] - '0').toInt()] = 1
    }

    for (i in 1 until s.size) {
        val num = if (s[i] == '?') -1 else (s[i] - '0').toInt()

        if (num != -1) {
            for (j in 0 until 13) {
                dp[i][(j * 10 + num) % 13] = dp[i - 1][j]
            }
        } else {
            for (k in 0..9) {
                for (j in 0 until 13) {
                    dp[i][(j * 10 + k) % 13] += dp[i - 1][j]
                    dp[i][(j * 10 + k) % 13] %= mod
                }
            }
        }
    }
    
    println(dp[s.size - 1][5])
}

fun readInputLine(): String {
    return readLine()!!
}


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

#define INF 12345678900
#define ll long long

ll a, b, c, d;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> a >> b >> c >> d;
	cout << max({a*c,a*d,b*c,b*d});
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int sum=0;
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++){
		if(i%3==0||i%5==0) continue;
		else sum+=i;
	}
	printf("%lld",sum);
	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    if (K >= accumulate(A.begin(), A.end(), 0LL) - N) {
        cout << 1 << endl;
        return 0;
    }

    int l = 1; // NG
    int r = 1e9 + 5; // OK
    while (r - l > 1) {
        int mid = (l + r) / 2;

        int cut = 0;
        for (int i=0; i<N; ++i) {
            cut += (A[i] - 1) / mid;
        }
        if (cut <= K) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    vector<int> W;
    rep(i,N){
        int Wi; cin >> Wi;
        W.push_back(Wi);
    }
    int minS1_S2 = pow(10,5);
    rep(T, N){
        int S1 = 0;
        int S2 = 0;
        for(int i=0; i<=T; i++){
            S1 += W[i];
        }
        for(int i=T+1; i<N; i++){
            S2 += W[i];
        }
        int S1_S2 = abs(S1-S2);
        if(minS1_S2 > S1_S2) minS1_S2 = S1_S2;
    }
    cout << minS1_S2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1e9 + 7

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

const int INF = 1e9 + 5;

int main() {
	int n;
	scanf ("%d", &n);
	vector < int > dp (3);
	vector < int > h (3);
	while (n--) {
		for (int & x : h) scanf ("%d", &x);
		vector < int > new_dp (3);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != j){
					new_dp[i] = max (new_dp[i], dp[j] + h[i]);
				}
			}
		}
		dp = new_dp;
	}
	printf ("%d\n", max ({dp[0], dp[1], dp[2]}));
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var wd=arr.shift();
   if(wd=="0 0")break;
   var W=arr.shift().split(" ").map(Number);
   var D=arr.shift().split(" ").map(Number);
   var sum=W.reduce(function(a,b){return a+b;});
   D.forEach(function(v){
      var index=W.indexOf(v);
      if(index!=-1)W[index]="";
      else sum+=v;
   });
   console.log(sum);
}

Measured memory_bytes: 16648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
ll a[1000], b[1000], c[1000];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 1; i <= n; i++)
    {
        long long sum = 0;
        for(int j = i; j < n; j++)
        {
            if(sum <= b[j])sum = b[j];
            else
            {
                long long temp = sum;
                sum += c[j]-(sum-b[j])%(c[j]);
                if((temp-b[j])%(c[j]) == 0)sum -= c[j];
            }
            sum += a[j];
        }
        if(i ==  n)sum = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,p,s=0,pmax=0;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> p;
    s+=p;
    pmax=max(pmax,p);
  }
  cout << s-pmax/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int X, i = 0, j = 0;
    scanf("%d", &X);
    while (X >= 500 * i)
    {
        i++;
    }
    i--;
    X = X - 500 * i;
    while (X >= 5 * j)
    {
        j++;
    }
    j--;
    printf("%d\n", 1000 * i + 5 * j);

    return 0;
}

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

const int N_MAX = 100100;

int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> L(N_MAX), R(N_MAX);
    for (int i = 0; i < q; i++) {
        cin >> L[i] >> R[i];
    }

    vector<int> v(N_MAX);   // 0からi文字目までに含まれる"AC"の数
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            v[i] = v[i - 1] + 1;
        }
        else {
            v[i] = v[i - 1];
        }
    }

    int ans;
    for (int i = 0; i < q; i++) {
        ans = v[R[i] - 1] - v[L[i] - 1];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll int n, a[200010], ans[200010];
    cin >> n;
    ans[0] = 0;
    rep(i, n) {
        cin >> a[i];
        ans[i+1] = ans[i] + a[i];
    }
    sort(ans, ans+n+1);

    ll int cnt = 0;  // 求める部分列の数
    // startとans[i]が異なる数になったとき，長さlの部分列があるということだからl(l+1)/2をcntに足す
    // 最後の部分列の分も数える
    ll int start = ans[0], l = 0;
    rep(i, n+1){
        if (ans[i] != start) {
            start = ans[i];
            cnt += l * (l-1) / 2;
            l = 0;
        }
        l++;
        if (i == n) {
            cnt += l * (l-1) / 2;
        }
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    ll x,b,a;
    cin>>x>>a>>b;
    ll y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    ll r=1e9,l=0,mid;
    while (l<=r){
        mid=(r+l)/2;
        ll cnt=0;
        for (int i=0;i<x;i++){
            ll m=y[i]-b*mid;
            if (m>0)
                cnt+=m/(a-b)+(m%(a-b)!=0);
        }
        if (cnt<=mid)
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N), ans;
  long flag;
  for(int i = 0; i < N; i++)cin >> data.at(i);
  for(int i = 0; i < N; i++){
    flag = 0;
    for(long j = data.size() - 1; j >= 0; j--){
      if(data.at(j) == j + 1){
        data.erase(data.begin() + j);
        ans.push_back(j + 1);
        flag = 1;
        break;
      }
    }
    if(flag == 0)break;
  }
  if(flag == 0)cout << -1 << endl;
  else {
    for(int i = ans.size() - 1; i >= 0; i--){
      cout << ans.at(i) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define for_(i,n) for(int i=0;i<n;++i)
#define for_1(i,n) for(int i=1;i<=n;++i)
const int mod= 1e9 +7;
const int inf=1e7;
int n;
int d;string k;
int len;
int dp[10000][100][2];
/*
digit dp:
indx 0 to len-1,

flag =1, already smaller possile digits  0 to 9 
flag = 0,not already smaller, possile digits 0 to k[indx] 
sum= sum till now

rem= sum%D, can have value from 0 to D-1

recurrence
dp[indx][rem][flag] += dp[indx-1][newRem][newFlag]
--> range = flag==1 ? 9 : k[indx];
we put 0 to i at ans[indx-1]
    for i in 0 to range    
        --> newFlag = (!flag && k[indx]>i )|| flag ? 1: 0;
        
        --> newRem  =  (oldsum+i)%D = (rem+i%D)%D 
*/
int solve(int indx, int rem, int flag){
    if(indx==-1) return (rem%d==0);
    //else if(indx<0) {cout<<"in1 \n";return 0;}     
    else if(dp[indx][rem][flag]!=-1) {//cout<<"in \n";
    return dp[indx][rem][flag];}

    else{
        int val=0;
        int range =(flag==1)?9:(k[len-1-indx]-'0');
       // cout<<indx<<" "<<range<<" "<<flag<<endl;
        for_(i,range+1)
        {   int newRem = (rem+i%d)%d;
            int newFlag= ((!flag && (k[len-1-indx]-'0')>i )|| flag )? 1: 0;;
            val= (val + solve(indx-1,newRem,newFlag))%mod;
        }
        dp[indx][rem][flag] = val;
        return dp[indx][rem][flag];
    }
    
}
main()
{
  //int m,d,a,b; cin>>m>>d>>a>>b;
    cin>>k; cin>>d;
    len=k.length();
    memset(dp, -1, sizeof(dp));
   // for_(i,len) for_(k,d) for_(j,2) cout<<dp[i][k][j]<<" ";
   int ans= solve(len-1, 0, 0);
   ans = (ans+mod-1)%mod;
    cout<<ans<<endl;
    
}










/*
typedef struct structure{
    int x,y;
} pt;
pt p0;
bool cmp(pt a, pt b)
{
    return cw(p0,a,b);
}
bool cw(pt a, pt b, pt c){
    return ((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x))>=0
}



convex_hull(vector<pt>& points)
{
   // sort(points.begin(),points.end, cmp);// sorted according to y cordinate
    p0=points[0];
    sort(points.begin(),points.end, cmp);
    vector<pt> convexHull;
    stack<pt> temp;
    convexHull.push_back(points[0]);
    
    temp.push(points[0]);temp.push(points[1]);//temp.push(points[2]);
    pt top,top0;
    for(int it=2;it<points.size();++it)
    {   
        top=temp.top(); temp.pop(); top0=temp.top();
        pt next=points[it];
        if(cw(top0,top,next))
        {
            convexHull.push_back(top);
            temp.push(top);
            top0=top;
            top=next;
        }
        else
        {
          temp.push(next);  
        }
        
    }
    
}*/












Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 3e5 + 233;
int n, m, one[N], zero[N], ans;
map <int, int> mp;

int main(void) {
    read(n); read(m);
    rep (i, n) {
	int x; read(x); mp[x]++;
    }
    for (auto i : mp) {
	int res = i.first % m;
	one[res] += i.second & 1;
	zero[res] += i.second - (i.second & 1);
    }
    ans += one[0] / 2 + zero[0] / 2;
    for (int i = 1; i < m - i; i++) {
	int one1 = one[i];
	int zero1 = zero[i];
	int one2 = one[m - i];
	int zero2 = zero[m - i];
	if (one1 < one2) swap(one1, one2), swap(zero1, zero2);
	ans += one2; one1 -= one2; one2 = 0;
	if (zero2 < one1) {
	    ans += zero2;
	} else {
	    ans += one1 + (zero2 - one1) / 2;
	}
	ans += zero1 / 2;	
    }
    if (m % 2 == 0) {
	ans += one[m / 2] / 2 + zero[m / 2] / 2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int m, d; cin>>m>>d;
    int ans = 0;
    for(int i=1; i<=m; i++){
        for(int j=10; j<=d; j++){
            int d1 = j % 10;
            int d10 = (j / 10) % 10;

            if(1 < d1 && 1 < d10 && d1 * d10 == i) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> R(N);

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

    int maxBenefit = R[1] - R[0];
    int minNum = R[0];
    for (int i = 1; i < N; ++i) {

        if (R[i-1] < minNum) {
            minNum = R[i-1];
        }

        int benefit = R[i] - minNum;
        if (benefit > maxBenefit) {
            maxBenefit = benefit;
        }

    }

    cout << maxBenefit << endl;
}




Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, j, l, n, m, k, ans=0;
int a[201][201];

int gcd(int i0, int i1) {
  if(i0 < i1) return gcd(i1, i0);
  int r;
  while ((r=i0%i1)) {
    i0 = i1;
    i1 = r;
  }
  return i1;
}

int main() {
    scanf(" %d", &k);
    rep(1, k+1) for (j=1;j<k+1;j++) a[i][j] = gcd(i, j);
    rep(1, k+1) for (j=1;j<k+1;j++) for (l=1;l<k+1;l++) {
        ans = ans + a[a[i][j]][l];
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 3884
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		long ans = 0;
		if(n>=m/2) {
			ans = m/2;
		}else {
			long x = (m-2*n)/4;
			ans = n+x;
		}
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 35500
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a.at(i);
    bool ans = true;
    rep(i, n){
        if(a.at(i) % 2 == 0 && a.at(i) % 3 != 0 && a.at(i) % 5 != 0)ans = false;
    }
    if(ans)cout << "APPROVED";
    else cout << "DENIED";
}

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

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

    int at = 0, mini = 0;
    for (char c : S) {
        if (c == '(')
            at++;
        else
            at--;
        mini = min(mini, at);
    }

    cout << string(-mini, '(') + S + string(at - mini, ')') << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,max,sum=1,H[30];
    cin>>N>>H[0];
    max=H[0];
    for(int i=1;i<N;++i){
        cin>>H[i];
        if(H[i]>=max){
            sum+=1;
            max=H[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,ma,mi;
  cin>>x>>y;
  ma=max(x,y);
  mi=min(x,y);
  while(1){
    if(ma%mi==0){
      cout<<mi<<endl;
      break;
    }
    swap(ma,mi);
    mi=mi%ma;
  }
  return 0;
}

Measured memory_bytes: 3076
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

#define MAX_V 1000
#define INF (1 << 29)

using namespace std;

struct edge{
	int to, cap, rev; // 行き先、容量、逆辺
};

vector<edge> G[MAX_V] = {};
bool used[MAX_V];

// from から to へ向かう容量 cap の辺を張る
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	// G[to].push_back((edge){from, 0, G[from].size() - 1}); // 有向辺
	G[to].push_back((edge){from, cap, G[from].size() - 1}); // 無向辺
}

// 増加パスを dfs で探す
int dfs(int v, int t, int f){
	if(v == t){
		return f;
	}
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s から t への最大流を求める
int max_flow(int s, int t){
	int flow = 0;
	while(true){
		fill(used, used + MAX_V, 0);
		int f = dfs(s, t, INF);
		if(f == 0){
			return flow;
		}
		flow += f;
	}
}

int main(){
	
	int H, W;
	cin >> H >> W;
	
	for(int i = 0; i < H; i++){
		string str;
		cin >> str;
		for(int j = 0; j < W; j++){
			if(str[j] == 'S'){
				add_edge(H + W, i, INF);
				add_edge(H + W, H + j, INF);
			}else if(str[j] == 'T'){
				add_edge(H + W + 1, i, INF);
				add_edge(H + W + 1, H + j, INF);
			}else if(str[j] == 'o'){
				add_edge(i, H + j, 1);
			}
		}
	}
	
	int ans = max_flow(H + W, H + W + 1);
	
	if(ans >= INF){
		ans = -1;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

bool solve(){
    char s[500],t[500];
    ll n,m,i,j;
    cin >> s;
    n = strlen(s);
    if(n == 1 && s[0] == '.')return false;
    cin >> t;
    m = strlen(t);
    ll check = 0;
    ll reads = 0,readt = 0;
    ll sums = 0,sumt = 0;
    ll semicount = 0;
    while(1){
        while(s[reads + sums] != '"' && reads + sums < n){
            reads ++;
        }
        while(t[readt + sumt] != '"' && readt + sumt < m){
            readt ++;
        }
        if(reads == readt){
            bool dame = false;
            for(ll i=0;i<reads;i++){
                if(s[i + sums] != t[i + sumt]){
                    dame = true;
                }
            }
            if(dame && semicount % 2 == 1){
                check ++;
            }else if(dame && semicount % 2 == 0){
                check += 100;
            }
        }else{
            if(semicount % 2 == 1){
                check ++;
            }else{
                check += 100;
            }
        }

        semicount ++;
        
        if(reads + sums >= n && readt + sumt >= m)break;
        sums += reads;
        sumt += readt;
        reads = 1;
        readt = 1;

    }
    ll a=0,b = 0;
    for(i=0;i<n;i++){
        if(s[i] == '"')a++;
    }
    for(i=0;i<m;i++){
        if(t[i] == '"')b++;
    }
    if(a != b)check += 100;
    if(check == 0){
        cout << "IDENTICAL" << endl;
    }else if(check == 1){
        cout << "CLOSE" << endl;
    }else{
        cout << "DIFFERENT" << endl;
    }
    return true;
}



int main(){
    while(solve()){}
}


Measured memory_bytes: 3100
import os, sys, re, math, heapq

N, M = [int(s) for s in input().split(' ')]

dic = {}
cards =  [int(s) for s in input().split(' ')]
for c in cards:
    if c in dic:
        dic[c] += 1
    else:
        dic[c] = 1

for i in range(M):
    b,c = [int(s) for s in input().split(' ')]
    if c in dic:
        dic[c] += b
    else:
        dic[c] = b

keys = sorted(list(dic.keys()), reverse=True)

ret = 0
for k in keys:
    ret += min(N, dic[k]) * k
    N = N - dic[k]
    if N <= 0:
        break

print(ret)


Measured memory_bytes: 87380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n, d ,a;
  cin >> n >> d;
  a = 0;
  vector<long long int> x(n);
  vector<long long int> y(n);
 
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
    
  }
  
  for (int i = 0; i < n; i++) {
    if ((x.at(i) * x.at(i)) + (y.at(i) * y.at(i)) > d * d) {
    a++;
    }
  }

    cout << n - a << endl;
  }
  

Measured memory_bytes: 6352
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun



int main() {
	

	for (int i = 0; i < 5; ++i) {
		int x;
		cin >> x;
		if (x == 0) cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c,x;
  int y[101]={};
  int i,j,k;
  cin >> n >> a >> b >> c >> x;
  while(n!=0){
    for(i=0;i<n;i++) cin >> y[i];
    int s=-1,f=x,p=0;
    while(p!=n&&s<=10000){
      if(f==y[p]) p++;
      s++;
      f=(a*f+b)%c;
    }
    if(s>10000) cout << -1 << endl;
    else cout << s << endl;
    cin >> n >> a >> b >> c >> x;
  }
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  ll D, T, S; cin >> D >> T >> S;
  if (S * T >= D) Yes();
  else No();

  return 0;
}


Measured memory_bytes: 3632
x = gets.chomp.split("")
if x.size == 1
  puts 0
  exit
end
left_half = left_half = x[0..x.size/2 - 1]
mid = 0
if x.size.even?
  mid = x.size/2 - 1 + 1
else
  mid = x.size/2 - 1 + 2
end
right_half = x[mid..-1].reverse

res = 0
left_half.each_with_index do |i, idx|
  res += 1 unless right_half[idx] == i
end

puts res

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

const int N=int(2e5)+10;
int n,dim,d[N],sg[N];
std::vector<int> e[N];
void dfs(int x,int fa) {
	int a=1,b=0;
	for (auto p:e[x]) if (p!=fa) {
		dfs(p,x);
		if (a<d[p]+1) {
			b=a;
			a=d[p]+1;
		} else if (b<d[p]+1) b=d[p]+1;
	}
	dim=std::max(dim,std::max(a+b-1,a));
	d[x]=a;
}
int main() {
	scanf("%d",&n);
	for (int i=1;i<n;++i) {
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].emplace_back(y);
		e[y].emplace_back(x);
	}
	dfs(1,0);
	sg[1]=1;
	sg[2]=0;
	for (int i=3;i<=n;++i) {
		if (sg[i-1]==0||sg[i-2]==0) sg[i]=1;
		else sg[i]=0;
	}
	puts(sg[dim]?"First":"Second");
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, x, m;
  cin >> n >> x >> m;
  vector<ll> rep(m, -1LL);
  vector<ll> sum;
  ll sum_all = 0;

  ll lp = 0;
  while(rep[x] == -1)
  {
    rep[x] = lp;
    lp++;
    sum.emplace_back(x);
    sum_all += x;
    x = (x * x) % m;
  }


  ll loop_cnt = lp - rep[x];
  ll sum_loop = 0;
  for(int i = rep[x]; i < lp; ++i) sum_loop += sum[i];

  ll ans = 0;
  if (n <= lp)
  {
    for(int i = 0; i < n; ++i) ans += sum[i];
  }
  else
  {
    ans += sum_all;
    n -= lp;
    ans += sum_loop * (n / loop_cnt);
    n %= loop_cnt;
    for(int i = 0; i < n; ++i) ans += sum[rep[x] + i];
  }  
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4644
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  long long N;
  cin >> N;
  int ans = (int)log10(N)+1;

  for (long long i = 1; i * i <= N; i++){
    if (N%i != 0) continue;
    long long M = N/i;
    int tmp=max((int)log10(i)+1, (int)log10(M)+1);
    if(ans > tmp) ans = tmp;
  }
  printf("%d\n",ans);
}


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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans = 0;
  int now = 0;
  for (int i=1; i<N; i++) {
    if (s[i] == 'E') {
      now++;
    }
  }
  ans = now;
  for (int i=0; i<N-1; i++) {
    if (s[i] != s[i+1]) {
      continue;
    }
    if (s[i] == 'E') {
      now--;
    }
    else {
      now++;
    }
    ans = min(ans,now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using i64 = long long;

i64 gcd(i64 a, i64 b) {
    if (b > a) std::swap(a, b);
    return a % b ? gcd(b, a % b) : b;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &el : a) std::cin >> el;
    std::deque<int> pre, suf;
    pre.push_back(a.front()), suf.push_back(a.back());
    for (int i = 1; i < n; i++) {
        pre.push_back(gcd(pre.back(), a[i]));
        suf.push_front(gcd(suf.front(), a[n - 1 - i]));
    }
    i64 ret = std::max(suf[1], pre[n - 2]);
    for (int i = 1; i < n - 1; i++) {
        ret = std::max(ret, gcd(pre[i - 1], suf[i + 1]));
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        HashMap<String, Integer> HM = new HashMap();
        Iterator IT = HM.entrySet().iterator();
        for (int I = 0; I < N; I++) {
            String S = Input.next();
            if (!HM.containsKey(S)) {
                HM.put(S, 1);
            } else {
                HM.replace(S, HM.get(S) + 1);
            }
        }
        int C = 0;
        for (int Values : HM.values()) {
            if (Values % 2 == 1) {
                C++;
            }
        }
        System.out.println(C);
    }
}


Measured memory_bytes: 51824
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	string s = "";
	int i;
	int dx = tx-sx;
	int dy = ty-sy;
	for(i=0;i<dx;i++){
		s += "R";
	}
	for(i=0;i<dy;i++){
		s += "U";
	}
	for(i=0;i<dx;i++){
		s += "L";
	}
	for(i=0;i<=dy;i++){
		s += "D";
	}
	for(i=0;i<=dx;i++){
		s += "R";
	}
	for(i=0;i<=dy;i++){
		s += "U";
	}
	s +="LU";
	for(i=0;i<=dx;i++){
		s += "L";
	}
	for(i=0;i<=dy;i++){
		s += "D";
	}
	s+="R";
	cout <<s;
}

Measured memory_bytes: 256
// Aizu Vol-3 0346: Rectangle Made with Bars
// 2017.8.25

#include <stdio.h>

int e[12], f[12];

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

	for (i = 0; i < 12; i++) e[i] = -10000, f[i] = 0;
	for (i = 0; i < 12; i++) { 
		scanf("%d", &k);
		for (j = 0; j < 12; j++) {
			if (k == e[j]) { f[j]++; break; } 
			else if (e[j] < 0) { e[j] = k, f[j] = 1; break; }
		}
	}
	for (i = 0; i < 6; i++) if (f[i] & 1) break;
	puts(i >= 6 ? "yes" : "no");
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
void print_array(int[], int);
int main(void){
    int N, v, i = 0, j;
    int A[100];

    scanf("%d", &N);
    while(i < N){
        scanf("%d", &A[i]);
        i++;
    }
    print_array(A, N);
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print_array(A, N);
    }
    return 0;
}
void print_array(int a[], int n){
    int i = 1;
    printf("%d", a[0]);
    while(i < n){
        printf(" %d", a[i]);
        i++;
    }
    printf("\n");
    return;
}


Measured memory_bytes: 2112
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  while(1){
    int n; rd(n); if(n==0) break;
    auto a=readln.split.to!(int[]);
    sort(a);
    int mn=1_000_000_000;
    foreach(i; 0..(n-1)) mn=min(mn, a[i+1]-a[i]);
    writeln(mn);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

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

now_char = '1'
cnt = 0
cnt_list = []

# cnt_listを[1が何連続したか、0が何連続したか、1が何連続したか...]にする
# cnt_listは1に始まり1で終えたいので、例えば0100なら
# [1が0回、0が1回、1が1回、0が2回、1が0回]とカウントしたい
for i, s in enumerate(S):
    # これまで連続していた文字とs[i]が異なるとき
    # 結果をリストに加えてリセット
    if s != now_char:
        cnt_list.append(cnt)
        cnt = 1
        now_char = s
    # 同じ文字ならカウントアップ
    else:
        cnt += 1
else:
    # 最後の文字についてのカウントを追加
    cnt_list.append(cnt)
    # 最後が1なら補正する
    if S[-1] == '0':
        cnt_list.append(0)

# cnt_list = [1, 1, 2, 3, 5](つまりS = 101100011111), K = 1なら
# 最初の0を反転させたときの(左側の)1が連続する区間の長さは 
# [1, 1, 2] を抜き出したときの合計に対応
# これをもとに [[1, 1, 2], 3, 5] → [1, 1, [2, 3, 5]] と走査していけばいい
# ※真ん中の [1, 2, 3] は K = 1 の場合意味がない (両端が0の並ぶ数)
if 2 * K + 1 >= len(cnt_list):
    ans = sum(cnt_list)  # 全部 1 にできる
else:
    l = 0
    r = 2 * K
    tmp_sum = sum(cnt_list[l:r+1])
    max_sum = 0
    while r < len(cnt_list):
        if tmp_sum > max_sum:
            max_sum = tmp_sum
        tmp_sum = tmp_sum + sum(cnt_list[r+1:r+3]) - sum(cnt_list[l:l+2])
        l += 2
        r += 2
    ans = max_sum

print(ans) 

Measured memory_bytes: 4468
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <cmath>

using namespace std;

typedef long long LL;

string s;
int main() {
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << ' ' << -1 << endl;
}

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

using namespace std ;
using ll = long long;
using p = pair <int , int >;
using V = vector <int> ;
using S = vector <string>;

int main()
{
	string S ,T;
	cin >> S;
	cin >> T;
	int m = S.size();
	if(S.size() == 0 && T.size()== 0 && T.size() <= S.size()){
		return 0;
	}
	else{
	string j = S.substr(0,m);
	string i = T.substr(0,m);
	if ( j == i ){cout << "Yes";}
	else {cout << "No";}
		}



	return 0;
	}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	long long a,b,c,d,i,x,n,m,e,f,y;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{long long f(int x,int y);
	e=c*d/f(c,d);
	 x=b/c-a/c+b/d-a/d-(b/e-a/e);
	 if(a%c==0)x+=1;
	 if(a%d==0)x+=1;
	 if(a%e==0)x-=1;
	 printf("%lld\n",b-a+1-x);
	}
}
long long f(int a,int b)
{if(a%b==0)return b;
 else return f(b,a%b);
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	r := nextFloat64()
	var pi = math.Pi
	fmt.Fprintf(out, "%.6f %.6f\n", r*r*pi, 2*r*pi)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}



Measured memory_bytes: 1212
n,e,t=gets.split.map &:to_i
x=gets.split.map{|x|x.to_i*2}
x.push(e*2)
w=10**15
j=0
y=Array.new(n+1,0)
0.upto(n-1){|i|
while j<i&&t<x[i]-x[j] do
w=[w,y[j]+x[i]-x[j]].min
j+=1
end
y[i+1]=[w,y[j]+[t, x[i]-x[j]].max].min
w+=x[i+1]-x[i]}
puts y[n]+e

Measured memory_bytes: 11916
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =2*1e5+5;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) {
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3856
#include<iostream>
#include<vector>

using namespace std;

signed main(){

   while(1){
      int N;
      cin>> N;
      if(!N) break;

      int data[N][N];
      fill((int*)data, (int*)data+N*N, 0);
      for(int i=0; i<N; i++){
         int M;
         cin>> M;
         for(int j=0; j<M; j++){
            int p;
            cin>> p;
            data[i][p-1]=1;
         }
      }
      int K;
      cin>> K;
      int l[K];
      for(int i=0; i<K; i++){
         cin>> l[i];
         l[i]--;
      }
      int tada[N]={0};
      for(int i=0; i<K; i++){
         tada[l[i]]=1;
      }

      vector<int> ans;
      for(int i=0; i<N; i++){
         int f=1;
         for(int j=0; j<N; j++){
            f&=(data[i][j]==tada[j]||data[i][j]);
         }
         if(f) ans.push_back(i+1);
      }

      if(ans.size()!=1){
         cout<< -1<< endl;
      }else{
         cout<< ans[0]<< endl;
      }

   }

   return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int INF = 1e9 + 239;

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

	int n;
	cin >> n;
	vector<int> t(n);
	vector<int> v(n);
	int st = 0;
	for (auto &x : t) {
		cin >> x;
		x *= 2;
		st += x;
	}
	for (auto &x : v) {
		cin >> x;
		x *= 2;
	}
	vector<int> mv(st + 1, INF);
	mv.front() = 0;
	mv.back() = 0;
	int p = 0;
	for (int i = 0; i < n; i++) {
		for (int j = p; j <= p + t[i]; j++) {
			mv[j] = min(mv[j], v[i]);
		}
		p += t[i];
	}
	vector<int> lv = mv;
	vector<int> rv = mv;
	for (int i = 1; i <= p; i++) {
		lv[i] = min(lv[i], lv[i - 1] + 1);
	}
	for (int i = p - 1; i >= 0; i--) {
		rv[i] = min(rv[i], rv[i + 1] + 1);
	}
	int ans = 0;
	for (int i = 0; i < p; i++) {
		ans += min(lv[i], rv[i]) + min(lv[i + 1], rv[i + 1]);
	}
	double rs = (double)ans / 8;
	cout << fixed << setprecision(16);
	cout << rs << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int A;
    ll B, N;
    cin >> A >> B >> N;
    ll x = min(B-1, N);
    ll ans = (A*x) / B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vi a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	cout << a[0] + a[1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int n,a,b,ans;
signed main(){
	Rd(n),Rd(a),Rd(b);
	ans=n/(a+b)*a,ans+=min(n%(a+b),a);
	wr(ans),exit(0);
}

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

int main()
{
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a,a+5);
	cout<<a[4]<< " "
		<<a[3]<< " "
		<<a[2]<< " "
		<<a[1]<< " "
		<<a[0]<<endl;
	return 0;

	
}

Measured memory_bytes: 0