akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N; cin >> N;
  priority_queue<pair<int, int>> q;
  for (int i = 0; i < N; i++) {
    int x; cin >> x; q.emplace(x, i);
  }
  q.emplace(0, -1);
  priority_queue<int, vector<int>, greater<int>> index;
  vector<ll> res(N);
  while (q.top().first) {
    ll c = q.top().first;
    while (q.top().first == c) {
      index.push(q.top().second);
      q.pop();
    }
    res[index.top()] += (c - q.top().first) * ll(index.size());
  }
  for (int i = 0; i < N; i++) cout << res[i] << endl;
}


Measured memory_bytes: 3572
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> x,y;
    for(int i=0;i<n;i++){
        ll k;
        cin>>k;
        x.push_back(k);
    }
    for(int i=0;i<m;i++){
        ll k;
        cin>>k;
        y.push_back(k);
    }
    ll xsum=0;
    ll ysum=0;
    for(int i=1;i<n;i++){
        ll k=x[i]-x[i-1];
        k%=MOD;
        k*=i;
        k%=MOD;
        k*=n-i;
        k%=MOD;
        xsum+=k;
        xsum%=MOD;
    }
    for(int i=1;i<m;i++){
        ll k=y[i]-y[i-1];
        k%=MOD;
        k*=i;
        k%=MOD;
        k*=m-i;
        k%=MOD;
        ysum+=k;
        ysum%=MOD;
    }
    ll ans=xsum*ysum;
    ans%=MOD;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 2548
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, X = MAP()

a, p = [1]*N, [1]*N
for i in range(N-1):
	a[i+1] = a[i]*2+3
	p[i+1] = p[i]*2+1

def f(N, X):
	if N == 0:
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1]+1+f(N-1, X-2-a[N-1])

print(f(N, X))


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 924844033;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K; cin >> N >> K;
  ll len[K*2] = {}; rep(i,K) { len[i] = (N-i+(K-1))/K-1; len[i+K] = len[i]; }
  // debug(len,len+K*2);

  ll l = 0; rep(i,2*K) l += len[i];
  bool st[l] = {}; ll np = 0; rep(i,2*K) { st[np] = true; np += len[i]; }
  // debug(st,st+l);

  ll dp[l+1][N+1] = {}; dp[0][0] = 1;
  rep(i,l) rep(j,N+1) {
    dp[i+1][j] = (dp[i+1][j]+dp[i][j]) % MOD;
    if (j) {
      if (st[i]) dp[i+1][j] = (dp[i+1][j]+dp[i][j-1]) % MOD;
      else dp[i+1][j] = (dp[i+1][j]+dp[i-1][j-1]) % MOD;
    }
  }
  // rep(i,l+1) debug(dp[i],dp[i]+(N+1));

  c_fac();
  ll result = 0;
  rep(i,N+1) result = (result+(i%2?-1ll:1ll)*fac[N-i]*dp[l][i]%MOD+MOD) % MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 73400
#include<cstdio>
#include<algorithm>
#include<cstring>
const int N=200017;
inline int read()
{
	int ans=0,f=1;char t=getchar();
	while(t<'0'||t>'9')	f=(t=='-'?-1:1),t=getchar();
	while(t>='0'&&t<='9')	ans=ans*10+t-'0',t=getchar();
	return ans*f;
}
int a[N];
struct node
{
	int val,c,next;
}e[N];
const int mod=1e5+3;
int first[mod+7];
int cnt;
void add(int val)
{
	int x=val%mod;
	for(int k=first[x];k;k=e[k].next)
	if(e[k].val==val)
	{
		e[k].c++;
		return;
	}
	e[++cnt]=(node){val,1,first[x]};first[x]=cnt;
}
bool check(int val)
{
	int x=val%mod;
	for(int k=first[x];k;k=e[k].next)
	if(e[k].val==val&&e[k].c>0)
	{
		e[k].c--;
		return 1;
	}
	return 0;
}
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	a[i]=read(),add(a[i]);
	scanf("%d",&m);
	int u;
	for(int i=1;i<=m;i++)
	{
		u=read();
		if(!check(u))	
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

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

#define INFTY 100000

void bfs(int s, vector<vector<int>> &M) {
    int n = M.size();
    queue<int> q;
    q.push(s);

    int d[n];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
    }
    d[s] = 0;

    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0)
                continue;
            
            if (d[v] != INFTY)
                continue;

            d[v] = d[u] + 1;
            q.push(v);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i + 1 << " ";
        if (d[i] == INFTY)
            cout << -1;
        else
        {
            cout << d[i];
        }
        cout << endl;
    }
}

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

    vector<vector<int>> M(n, vector<int>(n, 0));
    int u, k, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0, M);
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
using namespace std;
#define ll long long

int main () {
  ll n, k;
  cin >> n >> k;
  ll p[n];
  for (ll i = 0; i < n; i++) {
    cin >> p[i];  
  }
  sort(p, p + n);
  ll min = -1;
  for (ll i = 0; i < n; i++) {
    if (i + k - 1 < n) {
      if (min == -1 || min > p[i + k - 1] - p[i]) {
        min = p[i + k - 1] - p[i];  
      }  
    }  
  }
  cout << min << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int n;
int memo[101][100005];
int a[105];
int w[105];
int solve(int i,int sum)
{
    if(i == n)
    {
        if(sum > 0)
            return 1e9+7;
        return 0;
    }
    int &ret = memo[i][sum];
    if(ret != -1)
        return ret;
    ret = min(solve(i+1,sum) , w[i]+solve(i+1,max(0 , sum-a[i])));
    return ret;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    int W;
   cin>>n>>W;
   for(int i=0;i<n;i++)
   {
       cin>>w[i]>>a[i];
   }
   int ans = 0;
   for(int i=0;i<=100000;i++)
   {
       int x = solve(0,i);
       if(x <= W)
       {
           ans = i;
       }
   }
   cout<<ans;
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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 nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//素因数分解
vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N,M,K; cin >> N >> M >> K;
    vector<int> A(N),B(M);
    REP(i,N) cin >> A[i];
    REP(i,M) cin >> B[i];

    vector<ll> Asum(N+1,0), Bsum(M+1,0);
    REP(i,N) Asum[i+1] = A[i]+Asum[i];
    REP(i,M) Bsum[i+1] = B[i]+Bsum[i];

    ll ans = 0, j = M;
    REP(i,N+1){
        if(Asum[i] > K) break;
        while(Bsum[j] > K - Asum[i]) j--;
        ans = max(ans, i+j);
    }

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


Measured memory_bytes: 7928
#include <iostream>
using namespace std;
int main(void){
    
    string N;
    
    cin >> N;
    
    if(N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
    else if(N[1] == N[2] && N[2] == N[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d&&abs(b-c)<=d)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	cout << (s[0] == '+' ? 1 : -1) + (s[1] == '+' ? 1 : -1) + (s[2] == '+' ? 1 : -1) + (s[3] == '+' ? 1 : -1) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
using Data=pair<long long,vector<int> >;

int main(){
    vector<long long>N(3);
    int K;
    for(int i=0;i<3;i++)cin>>N[i]; cin>>K;
    vector<vector<long long> >v(3);
    for(int iter=0;iter<3;iter++){
        v[iter].resize((N[iter]));
        for(int i=0;i<N[iter];i++)cin>>v[iter][i];
        sort(v[iter].begin(),v[iter].end(),greater<long long >());

    }
    priority_queue<Data> que;
    set<Data> se;
    que.push(Data(v[0][0]+v[1][0]+v[2][0],vector<int>({0,0,0})));
    for(int k=0;k<K;k++){
        auto c=que.top();que.pop();
        cout<<c.first<<endl;

        for(int iter=0;iter<3;iter++){
            if(c.second[iter]+1<N[iter]){
                long long sum=c.first-v[iter][c.second[iter]]+v[iter][c.second[iter]+1];
                auto num=c.second; num[iter]++;
                auto d=Data(sum,num);
                
                if(!se.count(d))se.insert(d),que.push(d);            }
        }
    }
}

Measured memory_bytes: 1408
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

sum = 0
for i in 0..A do
    for j in 0..B do
        for k in 0..C do
            sum += 1 if 500*i+100*j+50*k==X
        end
    end
end
print sum

Measured memory_bytes: 1788
import sys,queue,math,copy,itertools,bisect,collections,heapq
INF = 10**18
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

N,C = LI()
D = [LI() for _ in range(C)]
p = [LI() for _ in range(N)]
q = [[0] * (C+1) for _ in range(3)]
for i in range(N):
    for j in range(N):
        k = (i + j) % 3
        q[k][p[i][j]] += 1

ans = INF
for col in itertools.permutations(range(1,C+1),3):
    iwa = 0
    for i in range(3):
        for j in range(1,C+1):
            iwa += D[j-1][col[i]-1] * q[i][j]
    ans = min(ans,iwa)
print (ans)


Measured memory_bytes: 44216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int yy = 10 * (S[0] - '0') + S[1] - '0';
    int mm = 10 * (S[2] - '0') + S[3] - '0';
    if (yy >= 1 && yy <= 12)
    {
        if (mm >= 1 && mm <= 12)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else
        {
            cout << "MMYY" << endl;
        }
    }
    else if (mm >= 1 && mm <= 12)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def merge(A, B):
    res = [[inf]*26 for _ in range(26)]
    for i in range(26):
        for j1 in range(26):
            for j2 in range(26):
                if j1 == j2:
                    continue
                for k in range(26):
                    res[i][k] = min(res[i][k], A[i][j1]+B[j2][k])
    return res
S = list(map(lambda x: ord(x) - 97, readline().strip()))
K = int(readline())
inf = 10**18+13
dp = [None]*26

for st in range(26):
    Dp = [inf]*26
    if st == S[0]:
        Dp[st] = 0
    else:
        Dp[st] = 1
    for s in S[1:]:
        Dp2 = [inf]*26
        for i in range(26):
            for j in range(26):
                if i == j:
                    continue
                if s != i:
                    Dp2[i] = min(Dp2[i], Dp[j] + 1)
                else:
                    Dp2[i] = min(Dp2[i], Dp[j])
        Dp = Dp2[:]
    dp[st] = Dp[:]

stack = [dp]

for _ in range(32):
    stack.append(merge(stack[-1], stack[-1]))

E = [[0]*26 for _ in range(26)]
for i in range(32):
    if (1<<i) & K:
        E = merge(E, stack[i])
print(min(min(d) for d in E))


Measured memory_bytes: 53340
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN maxn

using namespace std;

int N;
set<int> s;
long long mx, mx2;

signed main()
{
  IO;
  cin >> N;
  for (int i = 0, t; i < N; i++) {
    cin >> t;
    if (s.find(t) != s.end()) {
      if (t > mx)
        mx2 = mx, mx = t;
      else if (t > mx2) 
        mx2 = t;
      s.erase(t);
    }
    else 
      s.insert(t);
  }
  cout << mx * mx2 << endl;
  return 0;
}



Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int[] height = new int[N];
            for (int i = 0; i < N; i++)
            {
                height[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(height);

            int answer=0;

            for (int i = 0; i < N-K+1; i++)
            {
                int X = height[i + K - 1] - height[i];

                if (i == 0)
                {
                    answer = X;
                }
                else if (answer > X)
                {
                    answer = X;
                }
            }

            Console.WriteLine(answer);

        }
    }
}


Measured memory_bytes: 15452
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
bool used[3][3];
void solve(){
    int a[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b[n];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < n; ++k) {
                if (a[i][j] == b[k]) used[i][j] = true;
            }
        }
    }
    for (int i = 0; i < 3; ++i) {
        bool q = true;
        for (int j = 0; j < 3; ++j) {
            if (!used[i][j]) q = false;
        }
        if (q) {
            cout << "Yes";
            return;
        }
    }
    for (int j = 0; j < 3; ++j) {
        bool q = true;
        for (int i = 0; i < 3; ++i) {
            if (!used[i][j]) q = false;
        }
        if (q) {
            cout << "Yes";
            return;
        }
    }
    bool q = true;
    for (int i = 0; i < 3; ++i) {
        if (!used[i][i]) q = false;
    }
    if (q) cout << "Yes";
    else 
    if (used[0][2] && used[1][1] && used[2][0]) cout << "Yes";
    else cout << "No";
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int x;

void input() {
  cin >> x;
}

void solve() {
  int ans = 1;

  while (ans * (ans + 1) / 2 < x)
    ++ans;

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/
int main() {
	map<ll, ll> mp;
	ll N; cin >> N;
	ll a[100000] = {};
	rep(i, 0, N) {
		cin >> a[i];
		mp[a[i]]++;
	}

	ll cnt = 0;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->first < it->second) {
			cnt += it->second - it->first;
		}
		else if (it->second < it->first) {
			cnt += it->second;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 7040
#include <stdio.h>
 
int main(void)
{
  int a , b ,c;
  scanf("%d %d %d",&a,&b,&c);
  
  for(int i = 1; i <= b; i++){
    if((a*i)%b==c){
      printf("YES");
      return 0;
    }}
 
  printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;
using pii = pair<int, int>;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int n, k;
    cin >> n >> k;
    int *a;
    a = new int[MAX];
    rep(i, n){
        cin >> a[i];
    }

    ll *dp;
    dp = new ll[MAX];
    dp[0] = 0;
    fill(dp+1, dp+MAX, LLINF);
    rep2(i, 1, n){
        if(i-k>=0){
            rep2(j, i-k, i){
                dp[i] = min(dp[i] ,dp[j] + abs(a[j] - a[i]));
            }
        }
        else{
            rep2(j, 0, i){
                dp[i] = min(dp[i] ,dp[j] + abs(a[j] - a[i]));
            }
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int x[520][520];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>x[i][j];
		}
	}
	vector<int> a;
	vector<int> b;
	vector<int> c;
	vector<int> d;
	for(int i=0;i<n;i++){
		for(int j=0;j<m-1;j++){
			if(x[i][j]%2==1){
				x[i][j]--;
				x[i][j+1]++;
				a.push_back(i);
				b.push_back(j);
				c.push_back(i);
				d.push_back(j+1);
			}
		}
	}
	for(int i=0;i<n-1;i++){
		if(x[i][m-1]%2==1){
			x[i][m-1]--;
			x[i+1][m-1]++;
			a.push_back(i);
			b.push_back(m-1);
			c.push_back(i+1);
			d.push_back(m-1);
		}
	}
	cout<<a.size()<<endl;
	for(int i=0;i<a.size();i++){
		cout<<a[i]+1<<" "<<b[i]+1<<" "<<c[i]+1<<" "<<d[i]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 5220
package main

import (
	"fmt"
)

func main() {
	var n, a, b int32
	fmt.Scanf("%d%d%d", &n, &a, &b)
	c := a * n
	var r int32
	if c < b {
		r = c
	} else {
		r = b
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
        
	long n_customer;
	scanf("%ld",&n_customer);
	
	long long sold;
	scanf("%lld",&sold);
	sold -= 1;
	
	if(n_customer == 1){
		printf("%lld",sold);
		return 0;
	}
	
	long i = 1;
	long price = 2;
	
	while(1){
		long money;
		scanf("%ld",&money);
		if(money < price)
			i++;
		else if(money == price){
			price++;
			i++;
		}else{
			if(money % price == 0){
				sold += money / price -1;
			}else{
				sold += money / price;
			}
			i++;
		}
		if(i == n_customer)
			break;
	}
	printf("%lld",sold);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

char s[111111];

int main(void) {
  scanf("%s", s);
  int z = 0, o = 0;
  for (int i = 0; s[i]; i++) {
    if (s[i] == '0') ++z;
    if (s[i] == '1') ++o;
  }
  printf("%d\n", (z > o ? o : z) * 2);
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N, M, X, Y; cin >> N >> M >> X >> Y;
    Int maxX = LLONG_MIN, minY = LLONG_MAX;

    rep(i, 0, N) {
        Int x; cin >> x;
        maxX = max(maxX, x);
    }

    rep(i, 0, M) {
        Int y; cin >> y;
        minY = min(minY, y);
    }

    if (X<Y and maxX < minY) {
        rep(z, maxX, minY+1) {
            if (!(X<z and z<=Y)) {
                cout << "War" << endl;
                return 0;
            }
        }
        cout << "No War" << endl;
        return 0;
    }
    else cout << "War" << endl;
}


Measured memory_bytes: 256
def add(a, w, d)
  while a <= d.size - 1
    d[a] += w
    a += a & -a
  end
end

def sum(i, d)
  ret = 0
  x = i
  while x > 0
    ret += d[x]
    x -= x & -x
  end
  return ret
end

n = gets.split.map(&:to_i)[0]

time = {}
customer = Array.new(n){[]}
n.times{|i|
  l, r = gets.split.map(&:to_i)
  time[l] = 1
  time[r] = 1
  customer[i] = [l, r]
}
#p customer

st = time.keys.sort
#p st
ti = {}
st.each_with_index{|v, i|
  ti[v] = i+1
}
#p ti

d = Array.new(ti.size+1){0}

n.times{|i|
  add(ti[customer[i][0]], 1, d)
  add(ti[customer[i][1]], -1, d)
}

max = 0
st.size.times{|i|
  s = sum(i+1, d)
  max = s if s > max
}
p max

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

int main(){
   int n;
   cin >> n;
   cout << 800*n-(n/15)*200 << endl;
   
   
   return 0;
}

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

typedef long long ll;

ll N;
typedef pair<ll, ll> Pair;
vector<Pair> B;
const ll INF = 1ll << 60;
ll Res = -INF;

Pair meet(Pair a, Pair b) {
  return Pair(max(a.first, b.first), min(a.second, b.second));
}
ll size(Pair a) { return max(0ll, a.second + 1 - a.first); }
int main() {
  cin >> N;
  B.resize(N);
  Pair r_min = Pair(INF, -1);
  for (ll i = 0; i < N; ++i) {
    ll l, r;
    cin >> l >> r;
    B[i] = Pair(l, r);
    r_min = min(r_min, Pair(r, i));
  }
  Pair base = B[r_min.second];
  B.erase(B.begin() + r_min.second);
  sort(B.begin(), B.end());
  for (ll i = 0; i < N - 1; ++i) {
    Res = max(Res, size(meet(base, B[N - 2])) + size(B[i]));
  }
  Pair rest = Pair(-INF, INF);
  for (ll i = N - 2; i >= 0; --i) {
    rest = meet(rest, B[i]);
    Res = max(Res, size(i == 0 ? base : meet(base, B[i - 1])) + size(rest));
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    llint n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    llint anum=0, bnum=0;
    REP(i,n){
        if(s[i]=='a'&&anum+bnum<a+b){
            anum++;
            cout << "Yes" << endl;
        }else if(s[i]=='b'&&anum+bnum<a+b&&bnum<b){
            bnum++;
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
import kotlin.math.abs

fun main(args: Array<String>) {
    var (n, s) = readIntList()
    val x = readLongList()

    var ans = abs(x[0] - s)
    for (i in 1 until n) {
        ans = gcd(ans, abs(x[i] - s))
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

// 最大公約数
fun gcd(p: Long, q: Long): Long = if (p % q == 0L) q else gcd(q, p % q)

Measured memory_bytes: 52632
from itertools import starmap


def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for s in starmap(lambda *x: x.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 73316
N=int(input())
dp=[i for i in range(N+1)]
n=1
while n<=N:
  n*=6
  for j in range(N-n+1):
    dp[j+n]=min(dp[j+n],dp[j]+1)
    
n=1
while n<=N:
  n*=9
  for j in range(N-n+1):
    dp[j+n]=min(dp[j+n],dp[j]+1)

print(dp[N])

Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);
const ll MOD=1e9l+7;
ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
	{
        if(e & 1) ans = (((ans%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        base = (((base%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        e >>= 1;
	}
	return (ans+MOD) %MOD;
}

int main(){
	IOS
	string s;
	cin>>s;
	ll n=sz(s);
	ll ans=0;
	ll cnt=0;
	fo(i,n){
		if(s[i]=='0'){
			continue;
		}
		else{
			ans=(ans+Power(2,cnt)*Power(3,n-1-i))%MOD;
			cnt++;
			
		}

	}
	ans=(ans+Power(2,cnt))%MOD;
	cout<<ans<<endl;


}

Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<iterator>
using namespace std;

int main()
{
    long long int n,temp;
    cin>>n;
    multiset <int, greater<int> > mset;
    multiset <int, greater<int> > :: iterator itr;
    long long arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        mset.insert(arr[i]);
    }
    for(int i=0;i<n;i++)
    {
        temp=*mset.begin();
        if(arr[i]==temp)
            {
                mset.erase(mset.find(arr[i]));
                cout<<*mset.begin()<<endl;
                mset.insert(arr[i]);
            }
        else
            cout<<temp<<endl;
    }
	return 0;
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}


typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef pair<int, int> PII;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;

		vector<PII> team(n);
		REP(i, n) {
			int m, s;
			scanf("%d", &team[i].second);
			team[i].first = 0;
			REP(j, 4) {
				scanf("%d %d", &m, &s);
				team[i].first += m * 60 + s;
			}
		}
		sort(team.begin(), team.end());
		printf("%d\n%d\n%d\n", team[0].second, team[1].second, team[team.size()-2].second);
	}
	return 0;
}

Measured memory_bytes: 1268
N = int(input())
a = list(map(int,input().split()))
sumA = 0
sumB = 0
for i in range(1,N+1):
    m = max(a)
    if i%2 == 1:
        sumA += m
    else:
        sumB += m
    a.remove(m)

print(sumA-sumB)



Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
using UnweightedGraph = vector<vector<T>>;

int N;
UnweightedGraph<int> G;
vector<bool> visited;
vector<char> color;

void bfs()
{
    queue<pair<int, char>> que;
    que.emplace(0, 'B');
    que.emplace(N - 1, 'W');
    while (!que.empty())
    {
        auto p = que.front();
        int now = p.first;
        char c = p.second;
        que.pop();
        if (visited[now] == true)
            continue;
        visited[now] = true, color[now] = c;
        for (auto &e : G[now])
        {
            if (visited[e] == false)
                que.emplace(e, c);
        }
    }
}

int main()
{
    cin >> N;
    G = vector<vector<int>>(N), visited = vector<bool>(N, false), color = vector<char>(N);
    color[0] = 'B', color[N - 1] = 'W';
    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);
    }
    bfs();
    int b = 0, w = 0;
    for (int i = 0; i < N; i++)
    {
        if (color[i] == 'B')
            b++;
        else
            w++;
    }
    cout << (w >= b ? "Snuke" : "Fennec") << endl;
}

Measured memory_bytes: 6016
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  vector<vector<P>> graph_yen(n);
  vector<vector<P>> graph_sunuke(n);
  for(int i = 0; i < m; i++)
  {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    //円の無向グラフの構成
    graph_yen[u - 1].push_back({a, v - 1});
    graph_yen[v - 1].push_back({a, u - 1});
    //スヌケの無向グラフの構成
    graph_sunuke[u - 1].push_back({b, v - 1});
    graph_sunuke[v - 1].push_back({b, u - 1});
  }

  //グラフダンプ関数
  auto dump = [n](vector<vector<P>> &graph){
    for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < graph[i].size(); j++)
      {
        cout << graph[i][j].second << " ";
      }
      cout << endl;
    }
  };

  //ダイクストラ
  auto dijkstra = [n](vector<vector<P>> &graph, int s, int t){
    //到達済みフラグと結果
    vector<bool> flag(n, false);
    vector<ll> result(n, -1);
    //優先度付きキュー
    priority_queue<P, vector<P>, greater<P>> q;
    //初期化
    result[s] = 0;
    q.push({0, s});
    //メインアルゴリズム
    while(!q.empty())
    {
      const P current = q.top();
      if(!flag[current.second])
      {
        flag[current.second] = true;
      }else{
        q.pop();
      }
      for(int i = 0; i < graph[current.second].size(); i++)
      {
        const P target = graph[current.second][i];
        ll temp_len = result[current.second] + target.first;
        if(result[target.second] == -1 || temp_len < result[target.second])
        {
          result[target.second] = temp_len;
          flag[target.second] = true;
          q.push({temp_len, target.second});
        }
      }
    }
    return result;
  };
  vector<ll> result_yen = dijkstra(graph_yen, s - 1, t  - 1);
  vector<ll> result_sunuke = dijkstra(graph_sunuke, t - 1, s  - 1);
  vector<ll> optimal_sunuke(n + 1, 0);
  for(int i = n - 1; i >= 0; i--)
  {
    ll rest = 1000000000000000 - (result_yen[i] + result_sunuke[i]);
    optimal_sunuke[i] = max(optimal_sunuke[i + 1], rest);
  }
  for(int i = 0; i < n; i++)
  {
    cout << optimal_sunuke[i] << endl;
  }
	return 0;
}


Measured memory_bytes: 19012
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
signed main()
{
    fast
    int n,k; cin>>n>>k;
    int arr[n],dp[n+5];
    rep(i,0,n) cin>>arr[i];
    dp[0]=0;
    rep(i,1,n)dp[i]=1000000000;
    rep(i,1,n){
        repp(j,1,k){
            if(i>=j)
            dp[i]=min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i]);
        }
        // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1]<<endl;
}

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

int main(){
    
    int N,A;
    cin>>N>>A;
    vector<int> S(N);
    vector<long long int>T(600000,0);
    for(int i=0;i<N;i++){
        cin>>S[i];
        S[i]-=A;
    }
    int cnt=0;
    T[300000]=1;
    for(int i=0;i<N;i++){
        if(S[i]<0){
        for(int j=0;j<600000;j++){
            if(T[j]!=0) T[j+S[i]]+=T[j];
        }
        }
        if(S[i]>0){
            for(int j=599999;j>=0;j--){
                if(T[j]!=0) T[j+S[i]]+=T[j];
            }
        }
        if(S[i]==0) cnt++;
    }
    long long int ans=T[300000];
    for(int i=0;i<cnt;i++){
        ans*=2;
    }
    cout<<ans-1<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

string s;

signed main()
{
    cin >> s;
    int s0 = s[0] - '0';
    int s1 = s[1] - '0';
    int s2 = s[2] - '0';
    int s3 = s[3] - '0';
    REP(i, 2) REP(j, 2) REP(k, 2)
    {
        int ans = 0;
        ans = i == 0 ? s0 + s1 : s0 - s1;
        ans = j == 0 ? ans + s2 : ans - s2;
        ans = k == 0 ? ans + s3 : ans - s3;
        if (ans == 7)
        {
            string str = "";
            str += s[0];
            str += i == 0 ? "+" : "-";
            str += s[1];
            str += j == 0 ? "+" : "-";
            str += s[2];
            str += k == 0 ? "+" : "-";
            str += s[3];
            str += "=7";
            cout << str << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
        #include<iostream>
        using namespace std;
        int main()
        {
          double n,m,d;
          cin >> n >> m >> d;
          if(d == 0)
            printf("%.10lf\n",(1/n)*(m-1));
          else
            printf("%.10lf\n",(2*(n-d)*(m-1))/(n*n));
          return 0;
        }

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

char s[101021],t[101023];

int main(){

	scanf("%s%s",s,t);
	char*p=s;
	while(p = strstr(p,t)){
		//正直何やってのかわからんｗ
		printf("%d\n",p-s);
		p = p + 1;
	}
	return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int LINF=1e18;
const int MOD=1e9+7;
//
int main(){
    int n,x; cin>>n>>x;
    int m=INF,sum=0;
    FOR(i,0,n){
        int c; cin>>c;
        m=min(c,m);
        sum+=c;
    }
    cout<<n+(x-sum)/m<<endl;
}

Measured memory_bytes: 256
from collections import Counter

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

check = [0] * (M + 1)

answer = []
for _ in range(M):
  tmp = []
  for ai in A:
    for aij in ai:
      if check[aij] == 0:
        tmp.append(aij)
        break
  counter = list(Counter(tmp).items())
  counter.sort(key = lambda x: -x[1])  
  max_kind, max_cnt = counter[0][0], counter[0][1]
  check[max_kind] = 1
  answer.append(max_cnt)
  
print(min(answer))

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

int main() {
	long long X;
	cin >> X;
	for (long long A = 0; A <= 1000; A++) {
		for (long long B = -1000; B < A; B++) {
			if (A * A * A * A * A - B * B * B * B * B == X) {
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    bool f = false;
    if(s.size() > 2){
        for(int i = 0; i < s.size() - 2; i++){
            if(s[i] == s[i + 1] and s[i] != s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
            if(s[i] == s[i + 2] and s[i] != s[i + 1]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
            if(s[i + 1] == s[i + 2] and s[i] != s[i + 1]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }else{
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    cout << -1 << " " <<  -1 << endl;

    return 0;
}

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

int main() {
  ll h;
  cin >> h;
  ll k=1;
  rep(i,100){
    if(h/k>=2){
      k*=2;
    }else{
      break;
    }
  }
  
  cout << k*2-1 << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100+10;
typedef unsigned long long ll;
const double eps=1e-9;

ll f[maxn][maxn],a[maxn],dp[maxn][maxn];

int main()
{
    int n,l,r;cin>>n>>l>>r;

    for(int i=0;i<maxn;++i) 
        for(int j=0;j<maxn;++j)
            dp[i][j]=(ll)-1e17;

    dp[0][0]=0;f[0][0]=1;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=n;++i)
    {
        dp[i][0]=0;f[i][0]=1;
        for(int j=1;j<=i&&j<=r;++j)
        {
            ll t1=dp[i-1][j];
            ll t2=dp[i-1][j-1]+a[i];

            if(t1==t2) dp[i][j]=t1,f[i][j]=f[i-1][j]+f[i-1][j-1];
            else if(t1>t2) dp[i][j]=t1,f[i][j]=f[i-1][j];
            else dp[i][j]=t2,f[i][j]=f[i-1][j-1];
        }
    }

    int pos=0;ll cnt=0;
    for(int i=l;i<=r&&i<=n;++i)
        if(pos==0||dp[n][i]*pos > dp[n][pos]*i) pos=i,cnt=f[n][i];
        else if(dp[n][i]*pos==dp[n][pos]*i) cnt+=f[n][i];

    printf("%.6f\n%lld\n",(double)dp[n][pos]/pos,cnt);
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int L[200001], R[200001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	rep(i, N) {
		int l, r;
		cin >> l >> r;
		L[l + 100000]++;
		R[r + 100000]++;
	}

	ll kotae = 0, kotae2 = 0;
	int l = 200000;
	int r = 0;

	while (1) {
		int l2 = l, r2 = r;
		while (r <= 200000 && !R[r]) r++;
		while (l >= 0 && !L[l]) l--;
		if (kotae2 < kotae + max(2 * (100000 - r), 2 * (l - 100000))) {
			kotae2 = kotae + max(2 * (100000 - r), 2 * (l - 100000));
		}

		if (l > r) kotae += 2 * (l - r);
		else break;

		R[r]--;
		L[l]--;
	}

	co(max(kotae, kotae2));

	Would you please return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
 
char change(char a,string str,int i){
  int t=0;
  for(int j=i-1;j>=0;j--){
    if(str[j]=='+') t++;
    else if(str[j]=='-')t--;
    else break;
  }
  a=(a+26*10-'A'+t)%26+'A';
    return a;
}
 
 
void ja(string str){
  string anstr;
  for(int i=0;i<(int)str.size();i++){
    if(str[i]>='A' && str[i]<='Z')anstr+=change(str[i],str,i);
    else if(str[i]=='?') anstr+='A';
    else if(str[i]=='[')anstr+='[';
    else if(str[i]==']') anstr+=']';
  }
  for(int i=0;i<(int)anstr.size();i++){
    if(anstr[i]=='['){
      int cnt=1;
      int j;
      for(j=i+1;cnt>0;j++){
    if(anstr[j]=='[')cnt++,anstr[j]=']';
    else if(anstr[j]==']')cnt--,anstr[j]='[';
      }
anstr[j-1]=']';
      
    reverse(anstr.begin()+i+1,anstr.begin()+j-1);
      }
    }
  for(int i=0;i<(int)anstr.size();i++)if(anstr[i]>='A' && anstr[i]<='Z')cout<<anstr[i];
  cout<<endl;
}
 
int main(){
  while(1){
    string str;
    cin>>str;
    if(str==".")break;
    ja(str);
  }
  return 0;
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int main()
{
    string s;
    getline(cin, s);
    if( s == "ABC")
    {
        cout << "ARC";
    }
    else
    {
        cout << "ABC";
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int dp[2][5010];

int main() {
	int n, m, a[5010], b[5010];

	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= m; ++i) {
		cin >> b[i];
	}

	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			dp[i % 2][j] = max(dp[!(i % 2)][j], a[i] == b[j] ? dp[!(i % 2)][j - 1] + 1 : 0);
		}
	}

	cout << *max_element(dp[0], dp[2]) << endl;

	return 0;
}

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

int main()
{
	int a;
	cin >> a;

	int cnt = 0;

	if( a & 0x01 ) cnt ++;
	if( a & 0x02 ) cnt ++;
	if( a & 0x04 ) cnt ++;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int S,h,m,s;//设出时分秒 
	scanf("%d",&S);//输入秒数数值 
	h=S/3600;//小时数 
	m=(S-3600*h)/60;//分钟数 
	s=S-3600*h-60*m;//秒数 
	printf("%d:%d:%d\n",h,m,s);//打印结果 
	return 0;
}




Measured memory_bytes: 2064
#!/usr/bin python3
# -*- coding: utf-8 -*-

# ループを検索して計算量圧縮
# 0->1->...->st->st+1->...->st+lp-1-┐
#             └─────────────────────┘
#                       lp


n, x, m = map(int, input().split())

seen = set([])
seqs = []
for i in range(m+1):
    seen.add(x)
    seqs.append(x)
    x = pow(x,2,m)
    if x in seen:
        break
start = seqs.index(x)
lp = len(seqs) - start

lpsum = sum(seqs[start:])
lptimes = (n-(start+lp)+(lp-1))//lp
ret_sum = lpsum * lptimes
n -= lp * lptimes
ret_sum += sum(seqs[:n])
ret_val = seqs[n-1]

print(ret_sum)
#print(ret_val)

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);

    sort(h.begin(), h.end());

    int answer = INT_MAX;
    for (int index_min = 0; index_min <= n - k; index_min++)
    {
        int index_max = index_min + k - 1;
        answer = min(answer, h.at(index_max) - h.at(index_min));
    }

    cout << answer << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ios std::ios::sync_with_stdio(false);
int main(){
    ios;
     
     int a[4];
     cin>>a[1]>>a[2]>>a[3];
     if(    (a[1]==a[2]&&a[3]!=a[1])||(  a[1]==a[3]&&a[3]!=a[2]   )||( a[2]==a[3]&&a[1]!=a[2] )            )
     cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 998244353;

int a;
ii ar[maxn];

void solve() {
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&ar[i].fi), ar[i].se = i;
		sort( ar+1, ar+1+a );
	for(int i=1;i<=a;i++) printf("%d ",ar[i].se); printf("\n");
}

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}

Measured memory_bytes: 1536