akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
class Flow {
public:
    static constexpr int INF = 1E9;
    int n;
    vector<pair<int, int>> e;
    vector<vector<int>> g;
    vector<int> cur, h;
    bool bfs(int s, int t) {
        h.assign(n, -1);
        queue<int> que;
        h[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (int i : g[u]) {
                int v, c;
                tie(v, c) = e[i];
                if (c > 0 && h[v] == -1) {
                    h[v] = h[u] + 1;
                    if (v == t)
                        return true;
                    que.push(v);
                }
            }
        }
        return false;
    }
    int dfs(int u, int t, int f) {
        if (u == t)
            return f;
        int r = f;
        for (int &i = cur[u]; i < g[u].size(); ++i) {
            int j = g[u][i];
            int v, c;
            tie(v, c) = e[j];
            if (c > 0 && h[v] == h[u] + 1) {
                int a = dfs(v, t, min(r, c));
                e[j].second -= a;
                e[j ^ 1].second += a;
                r -= a;
                if (r == 0)
                    return f;
            }
        }
        return f - r;
    }
    Flow(int n) : n(n) {g.resize(n);}
    void addEdge(int u, int v, int c) {
        g[u].push_back(e.size());
        e.emplace_back(v, c);
        g[v].push_back(e.size());
        e.emplace_back(u, 0);
    }
    int maxFlow(int s, int t) {
        int ans = 0;
        while (bfs(s, t)) {
            cur.assign(n, 0);
            ans += dfs(s, t, INF);
        }
        return ans;
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> e(n - 1);
    Flow f(2 * n);
    int s = 0, t = 2 * n - 1;
    for (int i = 0; i < n - 1; ++i) {
        f.addEdge(s, i + 1, 1);
        f.addEdge(i + n, t, 1);
    }
    for (int i = 0; i < n - 1; ++i) {
        int c;
        cin >> c;
        e[i].resize(c);
        for (int &j : e[i]) {
            cin >> j;
            --j;
            if (j != 0)
                f.addEdge(j, i + n, 1);
        }
    }
    if (f.maxFlow(s, t) != n - 1) {
        cout << -1 << "\n";
        return 0;
    }
    vector<int> match(n);
    for (int i = 1; i < n; ++i) {
        for (int j : f.g[i]) {
            int v, c;
            tie(v, c) = f.e[j];
            if (v >= n && c == 0) {
                match[i] = v - n;
                break;
            }
        }
    }
    vector<int> u(n - 1), v(n - 1, -1);
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        for (int j : e[match[i]])
            if (i != j)
                g[j].push_back(i);
        u[match[i]] = i;
    }
    function<void(int)> dfs = [&](int u) {
        for (int _v : g[u]) {
            if (v[match[_v]] == -1) {
                v[match[_v]] = u;
                dfs(_v);
            }
        }
    };
    dfs(0);
    for (int i = 0; i < n - 1; ++i)
        cout << u[i] + 1 << " " << v[i] + 1 << "\n";
    return 0;
}

Measured memory_bytes: 38632
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}
inline long mod_inv(long x, long p=MOD){ return mod_pow(x%p, p-2, p); }

vector<int> g[5003];

int dfs(int v, int from){
  int ret = 1;
  for(auto to : g[v]) if(to != from) ret += dfs(to, v);
  return ret;
}

vector<int> calc_ch(int root){
  vector<int> ret;
  for(auto to : g[root]) ret.pb(dfs(to, root));
  return ret;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  vector<pair<int,int>> v;
  rep(i,n){
    auto rv = calc_ch(i);
    v.pb(mp(*max_element(all(rv)), i));
  }
  sort(all(v));

  vector<long> fact(n+1,1);
  vector<long> inv(n+1,1);
  rep(i,n) fact[i+1] = fact[i]*(i+1) %MOD;
  rep(i,1,n+1) inv[i] = mod_inv(i);

  if(v[0].fi == v[1].fi){
    assert(v[0].fi == n/2 && v[1].fi == n/2);
    cout << fact[n/2] * fact[n/2] %MOD << endl;
    return 0;
  }
  else {
    auto a = calc_ch(v[0].se);
    int m = a.size();
    sort(all(a));
    vector<long> sel(1,1);
    rep(i,m){
      vector<long> nxt(sel.size() + a[i], 0);
      rep(j,sel.size()){
        long comb = 1;
        rep(k,a[i]+1){
          nxt[j+k] += sel[j]*(comb*comb%MOD *fact[k]%MOD);
          nxt[j+k] %= MOD;
          comb = comb * (a[i]-k) %MOD * inv[k+1] %MOD;
        }
      }
      swap(nxt, sel);
    }
    assert(sel.size() == n);
    // dbg(a);dbg(sel);

    long ans = 0;
    long sgn = 1;
    rep(k,n){
      ans += sel[k] * fact[n-k] * sgn %MOD;
      sgn *= -1;
    }
    ans %= MOD;
    if(ans < 0) ans += MOD;

    cout << ans %MOD << endl;
  }

  return 0;
}


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

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

    vector<long long> a(n);
    long long minus_cnt = 0;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] < 0){
            minus_cnt++;
        }
    }

    long long ans = 0;
    if(minus_cnt % 2 == 0){
        for(long long i = 0; i < n; i++) ans += abs(a[i]);
    }
    else{
        long long minv = 1e15;
        for(long long i = 0; i < n; i++) minv = min(minv, abs(a[i])), ans += abs(a[i]);
        ans -= 2*minv;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int k,n;
string s;

int main(){
	cin>>n;
	cout<<n+n*n+n*n*n<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

bool dfs(const vector<vecint>& g, vecint& clr, int i, int c) {
  clr[i] = c;
  bool ok = true;
  for (auto&& to : g[i]) {
    if (clr[to] == c) ok = false;
    if (clr[to] >= 0) continue;
    if (!dfs(g, clr, to, 1-c)) ok = false;
  }
  return ok;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;
  cin>>n>>m;
  vector<vecint> g(n);
  REP(i,m) {
    int u,v;
    cin>>u>>v;
    --u;--v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vecint clr(n, -1);
  ll alone = 0;
  ll bipartite = 0;
  ll other = 0;
  REP(i,n) {
    if (clr[i] == -1) {
      if (g[i].empty()) ++alone;
      else if (dfs(g, clr, i, 0)) ++bipartite;
      else ++other;
    }
  }
  ll ans = 2 * n * alone - alone * alone;
  ll total = bipartite + other;
  ans += 2 * total * other - other * other;
  ans += 2 * bipartite * bipartite;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11776
import queue

N = int(input())
ab = []
deg = [0 for i in range(N)]
child = [[] for _ in range(N)]
edge = {}
color = [0 for _ in range(N-1)]
for i in range(N-1):
  tmp = list(map(int, input().split()))
  deg[tmp[0]-1] += 1
  deg[tmp[1]-1] += 1
 
  child[tmp[0]-1].append(tmp[1]-1)
  child[tmp[1]-1].append(tmp[0]-1)
  tmp = [tmp[0]-1, tmp[1]-1]
  edge[tuple(tmp)] = i
  
q = queue.Queue()
q.put([None, 0, None])
used = [0]
# parent, self, color
while not q.empty():
  current = q.get()
  if current[0] is not None:
    cnt = 1
    for c in child[current[1]]:
  #    if c in used:
  #      continue
      used.append(c)
      if cnt == current[2]:
        cnt += 1
      q.put([current[1], c, cnt])
      ind = [current[1], c] if current[1] < c else [c, current[1]]
      
      color[edge[tuple(ind)]] = cnt
      child[c].remove(current[1])
      cnt += 1
  else:
    for i, c in enumerate(child[current[1]]):
      used.append(c)
      q.put([current[1], c, i+1])
      ind = [current[1], c] if current[1] < c else [c, current[1]]
      #print(edge[tuple(ind)], i+1)
      color[edge[tuple(ind)]] = i+1
      child[c].remove(current[1])

print(max(deg))
for c in color:
  print(c)

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

int H, W;
vector<string> fi;

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

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];

    // 多点をスタートとして扱う
    vector<vector<int> > dist(H, vector<int>(W, -1));
    using pint = pair<int,int>;
    queue<pint> que;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') {
                dist[i][j] = 0;
                que.push(pint(i, j));
            }
        }
    }

    // BFS
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        for (int dir = 0; dir < 4; ++dir) {
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            res = max(res, dist[i][j]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 13456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main(){

    int a,b;

    cin >> a;
    cin >> b;

    bool f = true;

    f = a <= 8 && b <= 8;

    cout << ((f)? "Yay!" : ":(") << endl;

    return 0;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    int cnt = 0;
    map<int, int> a;
    int key;
    for (int i = 0; i < n-1; i++) {
        cin >> key;
        a[key]++;
    }

    int size = a.size();
    for (int i = 1; i < n; i++ ) {
        cout << a[i] << endl;
    }

    cout << 0 << endl;
}



Measured memory_bytes: 13016
#include <stdio.h>
int main(void){
    int i, j;
    int n;
    scanf("%d", &n);
    for(i = 3; i <= n; i++){
        if(i%3 == 0)
            printf(" %d", i);
        else if(i%10 == 3)
                printf(" %d", i);
        else{
            j = i;
            while((j%10 != 3)&&(j != 0)){
                j /= 10;
                if(j%10 == 3)
                    printf(" %d", i);
            }
        }
    }
    putchar('\n');
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL x, y;

int main() {
    cin >> x >> y;
    int ans = 1;
    while (x * 2 <= y) {
        ++ans;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto T = RD!string;
	bool ans;
	foreach (i; 0..S.length)
	{
		bool ok = true;
		foreach (j; 0..T.length)
		{
			if (S[(i+j)%S.length] != T[j])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			ans = ok;
			break;
		}
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int bfs(int h,int w,const bool B[99][99],int sy,int sx,int ty,int tx){
	int d[99][99];
	rep(i,h) rep(j,w) d[i][j]=INF;
	d[sy][sx]=0;

	queue<int> Q; Q.push(sy*w+sx);
	while(!Q.empty()){
		int y=Q.front()/w,x=Q.front()%w; Q.pop();
		rep(k,4){
			int yy=y+dy[k],xx=x+dx[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && !B[yy][xx] && d[yy][xx]>d[y][x]+1){
				d[yy][xx]=d[y][x]+1;
				Q.push(yy*w+xx);
			}
		}
	}
	return d[ty][tx];
}

int main(){
	int w,h,n; scanf("%d%d%d",&w,&h,&n);
	int wall[1000][4];
	rep(i,n) rep(j,4) scanf("%d",wall[i]+j);
	int sx,sy,tx,ty; scanf("%d%d%d%d",&sx,&sy,&tx,&ty); sx*=2; sy*=2; tx*=2; ty*=2;

	bool B[99][99]={};
	rep(i,h-1) rep(j,w-1) B[2*i+1][2*j+1]=true;
	rep(i,n){
		if(wall[i][0]==wall[i][2]){ // 縦の壁
			for(int y=min(wall[i][1],wall[i][3]);y<max(wall[i][1],wall[i][3]);y++){
				if(0<wall[i][0] && wall[i][0]<w){
					B[2*y][2*wall[i][0]-1]=true;
				}
			}
		}
		else{ // 横の壁
			for(int x=min(wall[i][0],wall[i][2]);x<max(wall[i][0],wall[i][2]);x++){
				if(0<wall[i][1] && wall[i][1]<h){
					B[2*wall[i][1]-1][2*x]=true;
				}
			}
		}
	}
	h=2*h-1;
	w=2*w-1;

	int d0=bfs(h,w,B,sy,sx,ty,tx),d=d0;
	rep(i,h) rep(j,w) if((i%2==1 || j%2==1) && !B[i][j]) {
		B[i][j]=true;
		int tmp=bfs(h,w,B,sy,sx,ty,tx);
		if(tmp<INF) d=max(d,tmp);
		B[i][j]=false;
	}
	printf("%d\n",(d-d0)/2);

	return 0;
}

Measured memory_bytes: 1120
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool visited[100100];
int prev[100100];
std::queue<int> que;
std::vector<int> g[100100];

int main(void){
	int n,m,u,v,i;
	std::cin >> n >> m;
	for(i=0; i<m; ++i){
		std::cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	que.push(0); visited[0] = true;
	while(!que.empty()){
		v = que.front();
		que.pop();
		for(i=(g[v].l_ength()-1); i>=0; --i){
			u = g[v][i];
			if(visited[u]){
				continue;
			}
			visited[u] = true;
			prev[u] = v+1;
			que.push(u);
		}
	}
	std::cout << "Yes" << std::endl;
	for(i=1; i<n; ++i){
		std::cout << prev[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 10456
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, M, K) = Scanner.Scan<int, int, int>();
            var A = Scanner.ScanEnumerable<long>().ToArray();
            var B = Scanner.ScanEnumerable<long>().ToArray();
            var aggA = CumulativeItems(A).ToArray();
            var aggB = CumulativeItems(B).ToArray();

            var answer = 0;
            var j = M;
            for (var i = 0; i <= N; i++)
            {
                if (aggA[i] > K) break;
                while (aggB[j] > K - aggA[i]) j -= 1;
                answer = Math.Max(answer, i + j);
            }
            Console.WriteLine(answer);
        }

        public static IEnumerable<long> CumulativeItems(IEnumerable<long> items)
        {
            var arr = items.ToArray();
            var ret = new long[arr.Length + 1];
            for (var i = 0; i < arr.Length; i++) ret[i + 1] = arr[i] + ret[i];
            return ret;
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 88868
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<int>> c(3, vector<int>(3));
    rep (i, 3) rep (j, 3) cin >> c[i][j];
    bool ok = true;
    rep (i1, 3) {
        rep (i2, 3) {
            rep (j1, 3) {
                rep (j2, 3) {
                    if (i1 == i2 || j1 == j2) continue;
                    int p = c[i1][j1], q = c[i1][j2],
                        r = c[i2][j1], s = c[i2][j2];
                    if (q - p != s - r || r - p != s - q) ok = false;
                }
            }
        }
    }
    cout << (ok ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include<queue>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int N, A[100];

int main() {
	S(N);
	R(i, N) {
		S(A[i]);
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				printf("DENIED");
				return 0;
			}
		}
	}
	printf("APPROVED");
}



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

int main() {
	int n, m,all=0;
	scanf("%d %d",&n,&m);
	std::vector<int> a;
	for (int i = 0; i < n; i++) {
		int ai;
		scanf("%d",&ai);
		all += ai;
		a.push_back(ai);
	}
	double th = double(all) / (4.0 * m);
	int num = 0;
	for (auto e : a) {
		if (!(double (e) < th)) {
			num++;
			if (num >= m) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

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

int main(){
        int h,n,i,j,a,b;
        cin >> h >> n;
        vector<int> dp(h+1,1000000000);
        dp.at(0) = 0;
        for(i=0;i<n;++i){
                cin >> a >> b;
                for(j=0;j<h+1;++j){
                        if(j-a<0) dp.at(j) = min(dp.at(j), b);
                        else dp.at(j) = min(dp.at(j-a)+b,dp.at(j));
                }
        }
        cout << dp.at(h) << endl;
        return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
/*I love Korosensei forever.*/
/**/
int main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	int n, ans = 1;
	read(n);
	for(int i =1; i <=3; i++) ans*=n;
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 3005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using  namespace std;
ll dp[mxn][mxn][4],a[mxn][mxn];
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll r,c,k,i,j,x,y,v;
	cin>>r>>c>>k;
	for(i=0;i<k;i++){
		cin>>x>>y>>v;
		a[x][y]=v;
	}
	for(i=0;i<=r;i++){
		dp[i][0][1]=-inf;
		dp[i][0][2]=-inf;
		dp[i][0][3]=-inf;
	}
	for(i=1;i<=r;i++){
		for(j=1;j<=c;j++){
			dp[i][j][0]=max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3],dp[i][j-1][0]});
			dp[i][j][1]=max({dp[i][j][1],dp[i-1][j][0]+a[i][j],dp[i][j-1][0]+a[i][j],dp[i-1][j][0]+a[i][j],dp[i-1][j][1]+a[i][j],dp[i-1][j][2]+a[i][j],dp[i-1][j][3]+a[i][j]});
			dp[i][j][2]=max({dp[i][j][2],dp[i-1][j][1]+a[i][j],dp[i][j-1][1]+a[i][j]});
			dp[i][j][3]=max({dp[i][j][3],dp[i-1][j][2]+a[i][j],dp[i][j-1][2]+a[i][j]});
			dp[i][j][1]=max({dp[i][j][1],dp[i-1][j][1],dp[i][j-1][1]});
			dp[i][j][2]=max({dp[i][j][2],dp[i-1][j][2],dp[i][j-1][2]});
			dp[i][j][3]=max({dp[i][j][3],dp[i-1][j][3],dp[i][j-1][3]});
		}
	}
	cout<<max({dp[r][c][0],dp[r][c][1],dp[r][c][2],dp[r][c][3]});
}


Measured memory_bytes: 355600
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int d[1000]={0},a,b,s,t,n,ans=0;
	cin>>a>>b>>n;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		for(int j=s;j<t;j++) d[j]=1;
	}
  
	for(int i=a;i<b;i++){
		if(d[i]==1){
          
			ans=1;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];
    stable_sort(d, d+n);
    int count = 0;
    for (int i = 0; i < n-1; i++) {
        if (d[i+1]-d[i]) count++;
    }
    cout << count+1 << endl;
}

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

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  REP(i, N){
    cin >> a[i];
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

void sol()
{	
	int k;
	std::cin >> k;

	std::string s;
	std::cin >> s;

	std::vector<char> v;

	if(s.length()>k)
	{
		for(int i=0;i<k;++i)
		{
			v.push_back(s[i]);
		}

		v.push_back('.');
		v.push_back('.');
		v.push_back('.');

		for(int i=0;i<v.size();++i)
		{
			std::cout << v[i] ;
		}
	}

	else
	{
		std::cout << s << std::endl;
	}
}

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

	sol();

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

bool test(string s) {
    return s == string(s.rbegin(), s.rend());
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if (test(s) && test(s.substr(0, (n - 1) / 2)) && test(s.substr((n + 3) / 2 - 1, n))) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    int c =0;
    while(t--){
        int n; cin>>n;
        bool flag = false;
        for(int i=2; i<=sqrt(n); i++){
            if(n%i==0){
                flag = true;
                break;
            }
        }
        if(!flag) c++;
    }
    cout<<c<<endl;
    
     return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    string s; cin >> s;
    int len = (int)s.size();
    rep(i, len) cout << 'x';
    cout << endl;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 82;
int a[N][N], b[N][N], n, m, dp[N][N][N*N*2];

bool val(int x, int y) {
    return 1 <= x && x <= n && 1 <= y && y <= m;
}

int rec(int x, int y, int bal) {
    if (x == n && y == m) {
        return min(bal + abs(a[x][y] - b[x][y]), abs(bal - abs(a[x][y] - b[x][y])));
    }
    int &ret = dp[x][y][bal];
    if (ret != -1) return ret;
    ret = 1e9;
    if (val(x + 1, y)) {
        ret = min(ret, rec(x + 1, y, bal + abs(a[x][y] - b[x][y])));
        ret = min(ret, rec(x + 1, y, abs(bal - abs(a[x][y] - b[x][y]))));
    }
    if (val(x, y + 1)) {
        ret = min(ret, rec(x, y + 1, bal + abs(a[x][y] - b[x][y])));
        ret = min(ret, rec(x, y + 1, abs(bal - abs(a[x][y] - b[x][y]))));
    }
    return ret;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &b[i][j]);
        }
    }
    memset(dp, -1, sizeof dp);
    printf("%d", rec(1, 1, 0));
    return 0;
}


Measured memory_bytes: 357056
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include <algorithm>
using namespace std;
using ll = long long;

typedef pair<int,int> P;
 
int main(void){
    int N;
    cin >> N;
    vector<ll> vec(N);
    ll ans=0;
    ll X=1000000007;
    ll fix=0;
    for(int k=0;k<N;k++){
        cin >> vec[k];
    }
    for(int m=0;m<N;m++){
        fix+=vec[m];
        fix%=X;
    }
    for(int m=0;m<N;m++){
        ll preans=0;
        fix-=vec[m];
        if(fix<0)fix+=X;
        preans=vec[m]*fix;
        preans%=X;
        ans+=preans;
        ans%=X;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 4776
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    string s; cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(ri, 2){
        int cnt = 0;
        rep(i, n){
            if(s[i]=='R')cnt++;
            else{
                ans[i] += cnt/2;
                ans[i-1] += (cnt+1)/2;//cntが奇数なら1増える
                cnt = 0;
            }
        }

        reverse(all(ans));
        reverse(all(s));
        rep(i, n){
            if(s[i]=='L')s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i, n)cout << ans[i] << " ";
    cout << ln;
}



Measured memory_bytes: 3844
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    //string a,b;
    //cin>>a>>b;
    ll a[n];
    ll b[n];
    rep(i,0,n)
    cin>>a[i];
    rep(i,0,n)
    cin>>b[i];
    ll aa=0,bb=0;
    ll fact[9];
    fact[0]=1;
    fact[1]=1;
    fact[2]=2;
    fact[3]=6;
    fact[4]=24;
    fact[5]=120;
    fact[6]=720;
    fact[7]=5040;
    fact[8]=40320;
    ll cnt[9]={};
    cnt[0]=-9999;
    rep(i,0,n)
    {
        ll var= a[ i ];
        ll y=0;
        //rev(j,var,1)
        for( ll j=var-1;j>=1;j-- )
        {
            if( cnt[ j ] == 0 )
            y++;
        }
        cnt[ a[i] ]=1;
        aa+= y*fact[n-i-1];
        //cout<<"y.."<<" "<<y<<" ";
    }
    ll cnt2[9]={};
    cnt2[0]=-9999;
    rep(i,0,n)
    {
        ll var= b[ i ];//-48;
        ll y=0;
        rev(j,var,1)
        {
            if( cnt2[ j ]==0 )
            y++;
        }
        cnt2[ b[i] ]=1;
        bb+= y*fact[n-i-1];
     //   cout<<"y.."<<" "<<y<<" ";
    }
   // cout<<"aa.."<<aa<<"bb.."<<bb<<endl;
    cout<<abs(aa-bb)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    int n;
    int ans = 1;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	int mx = 0;
	for(int i = 1; i <= n; i++) {
	    int cnt = 0, m = i;
	    
	    while(m % 2 == 0) {
		cnt++;
		m /= 2;
	    }

	    if(mx < cnt) {
		mx = cnt;
		ans = i;
	    }
	}
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fastio ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define all(a) (a).begin() , (a).end()
typedef long long  int ll;
#define rep(i , a , b) for(int i=a;i<b;i++)
using namespace std;




void solve(){
    int n , k;
    cin >> k >> n;

    int arr[n];
    vector<int>seg;
    for(int i=0;i<n;i++){
        cin >> arr[i];
        if(i > 0)seg.push_back(arr[i] - arr[i-1]);
    }
    seg.push_back(k - (arr[n-1] - arr[0]));
    int ans = INT_MAX;

    for(auto i : seg){
        ans = min(ans , k - i);
    }
    cout << ans << endl;
}



int  main(){
    fastio
    int test;
    test = 1;
    while(test--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1912
#include<algorithm>
#include<iostream>
#include<vector>

int main(){
    int n;
    std::cin>>n;
    std::vector<int> an(n,0);//?????
 

    for(int i=0;i<n;i++){
        std::cin>>an[i];//いつもpush_backを使っていた
    }

    int q,b,e;
    std::cin>>q;
    for(int i=0;i<q;i++){
        std::cin>>b>>e;
        std::reverse(&an[b],&an[e]);//an.begin[]+iみたいな書き方がいい？
    }

    for(int i=0;i<n;i++){std::cout<<(i? " ":"")<<an[i];}
    std::cout<<std::endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
const int mod = (int) 1e9 + 7;

using namespace std;

signed main() {

    int n, k; cin >> n >> k;

    vector<int> h(n), dp(n, INF);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }

    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = max(0LL, i - k); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }

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


    return 0;
}

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

typedef long long ll;

const int INF = 1e9 + 10;
const ll INFLL = 3e18;

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	int cnta = 0;
	int cntb = 0;
	int a;
	cin >> a;
	if(a == 5)cnta++;
	else if(a == 7) cntb++;
	cin >> a;
	if(a == 5)cnta++;
	else if(a == 7) cntb++;
	cin >> a;
	if(a == 5)cnta++;
	else if(a == 7) cntb++;
	
	if(cnta == 2 && cntb == 1) cout << "YES\n";
	else cout << "NO\n";
	
	return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n;
    cin >> n;
    vector<string> v(n);
    for(auto& i : v) cin >> i;
    unordered_map<string, lli> mp;
    for(auto& i : v) sort(i.begin(), i.end());
    for(auto i : v) mp[i]++;
    lli sum = 0;
    for(auto i : mp){
        if(i.second >= 2){
            sum+=i.second*(i.second-1)/2;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 17700
#include <stdio.h>

int main(){

	int x, y;

	while(1){
		scanf("%d %d", &x, &y);
			if(x==0 && y==0)break;
				if(x<y){
			printf("%d %d\n", x, y);
			}

		else{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.util.regex.Matcher;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        HashMap<Character,Integer> counters = new HashMap<>();
        HashMap<Character,Integer> indexes = new HashMap<>();
        boolean flag = false;
        String s;
        s = in.nextLine();
        int length = s.length();
        if(s.length() > 1 && (s.charAt(0) == s.charAt(1))){
            System.out.print(1);
            System.out.print(" ");
            System.out.print(2);
        }
        else if(s.length() == 2 || s.length() == 1){
            System.out.print(-1);
            System.out.print(" ");
            System.out.print(-1);
        }
        else {
            for (int i = 0; i<s.length();i++){
                if(!counters.containsKey(s.charAt(i))){
                    counters.put(s.charAt(i),1);
                    indexes.put(s.charAt(i),i);
                }else{
                    counters.replace(s.charAt(i),counters.get(s.charAt(i)) + 1);
                    int count = counters.get(s.charAt(i));
                    int index = indexes.get(s.charAt(i));
                    double diff = (double) i- (double) index;
                    int differnece = (int) (Math.round(diff/2));

                    if(count > differnece){
                        System.out.print(index+1);
                        System.out.print(" ");
                        System.out.print(i+1);
                        flag = true;
                        break;
                    }
                    else {
                            indexes.replace(s.charAt(i),i);
                            counters.replace(s.charAt(i),1);
                    }

                }
            }
            if(flag == false){
                System.out.print(-1);
                System.out.print(" ");
                System.out.print(-1);
            }
        }


    }
}


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

int main() {
  const int N = 6;
  const vector<int> v = {100, 101, 102, 103, 104, 105};

  int X;
  cin >> X;

  if (X < 100) {
    cout << 0 << endl;
    return 0;
  } else if (X < 106) {
    cout << 1 << endl;
    return 0;
  }

  vector<bool> dp(X + 1, false);
  dp.at(0) = true;
  rep(i, N) dp.at(v.at(i)) = true;

  for (int i = 200; i <= X; i++) {
    if (any_of(v.begin(), v.end(), [&dp, &i](int y) { return dp.at(i - y); }))
      dp.at(i) = true;
  }

  cout << (dp.at(X) ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String[] line=sc.nextLine().split(" ");
		
		int a=Integer.parseInt(line[0]);//赤
		int b=Integer.parseInt(line[1]);//緑
		int c=Integer.parseInt(line[2]);//青
		
		String line1=sc.nextLine();
		int k=Integer.parseInt(line1);
		
		for(int i=0;i<k;i++) {
			if(b<=a) {
				b=b*2;
			}else {
				c=c*2;
			}
		}
		
		if(a<b&&b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	
		
		
	}

}


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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    for (int i = 1; i <= 5; ++i) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3584
import itertools

n, m, x = map(int, input().split())
c = [None] * n
a = [None] * n
for i in range(n):
    aa = list(map(int, input().split()))
    c[i] = aa[0]
    a[i] = aa[1:]

ans = 100000000000
for k in range(1, n + 1):
    for cmb in itertools.combinations(range(n), k):
        d = [0] * m
        cost = 0
        for cm in cmb:
            cost += c[cm]
            for i in range(m):
                d[i] += a[cm][i]

        f = True
        for i in range(m):
            if d[i] < x:
                f = False
                break
        if f:
            ans = min(ans, cost)

if ans == 100000000000:
    ans = -1
print(ans)


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

int main(){
	int i = 0, j = 0;
	char S[51];
	scanf("%s", S);
	while(S[j] == 'A'){
		j++;
	}
	if(j > 1){
		printf("NO\n");
		return 0;
	}
	i += j;
	if(S[i] != 'K' || S[i + 1] != 'I' || S[i + 2] != 'H'){
		printf("NO\n");
		return 0;
	}
	i += 3;
	j = 0;
	while(S[i + j] == 'A'){
		j++;
	}
	if(j > 1){
		printf("NO\n");
		return 0;
	}
	i += j;
	if(S[i] != 'B'){
		printf("NO\n");
		return 0;
	}
	i++;
	j = 0;
	while(S[i + j] == 'A'){
		j++;
	}
	if(j > 1){
		printf("NO\n");
		return 0;
	}
	i += j;
	if(S[i] != 'R'){
		printf("NO\n");
		return 0;
	}
	i++;
	j = 0;
	while(S[i + j] == 'A'){
		j++;
	}
	if(j > 1){
		printf("NO\n");
		return 0;
	}
	i += j;
	if(S[i] == '\0'){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
map<string,int>dp;
int solve(string s)
{
    int n=s.size();
    if(n==0)return 1;
    if(n==1)return s[0]-'0'+1;
    if(dp[s])return dp[s];
    string x,y;
    x="",y="";
    x.push_back(s[0]);
    for(int i=1;i<n;++i)y.push_back(s[i]);
    int res=1ll*solve(x)*solve(y)%mod;
    for(int i=1;i<=n;++i)
    {
        x="";
        for(int j=0;j<i;++j)x.push_back(s[j]);
        for(int j=i+i-1;j<n;j+=i)
        {
            for(int k=j-i+1,p=0;k<=j;++k,++p)x[p]=min(x[p],s[k]);
            y="";
            for(int k=j+1;k<n;++k)y.push_back(s[k]);
            ade(res,1ll*solve(x)*solve(y)%mod);
        }
    }
    dp[s]=res;
    return res;
}
int main()
{
    string(s);
    cin>>s;
    printf("%d\n",solve(s));
    return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main()
{
  int A1,A2,A3;
  scanf("%d" "%d" "%d",&A1,&A2,&A3);
  
  int Z = 0;
  Z = A1 + A2 + A3;
  
  if(Z >= 22){
    printf("bust");
  }else{
    printf("win");
  }
}

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

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

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

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (w * h) * 0.5 << " ";
    if(x*2 == w && y*2==h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;

  vector<tuple<int, int, int>> pref_year_id(M);
  for (int i = 0; i < M; i++) {
    int pid, year;
    cin >> pid >> year;
    pref_year_id.at(i) = make_tuple(pid, year, i);
  }

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

  vector<int> pref_id(M), city_id(M), cnt(N + 1);
  for (auto& pyi : pref_year_id) {
    int pid, id;
    tie(pid, ignore, id) = pyi;
    pref_id.at(id) = pid;
    cnt[pid]++;
    city_id.at(id) = cnt[pid];
  }

  rep(i, M) {
    cout << setfill('0') << setw(6) << pref_id.at(i);
    cout << setfill('0') << setw(6) << city_id.at(i) << "\n";
  }
  return 0;
}


Measured memory_bytes: 3840