akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<random>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int num=130000;
int koho=5;
int calc(vector<int>const& t,vector<vector<int>>& last_list){
  int res=0;
  vector<int> last(30,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    last_list[i]=last;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    //cout<<res<<"\n";
  }
  return res;
}
int change(int nd,int nq,int& res,vector<int>& t,vector<vector<int>>& last_list){
  int flag_t=false;
  int flag_q=false;
  int x=t[nd];
  t[nd]=0;
  res+=s[nd][nq];res-=s[nd][x];
  for(int i=nd;i<=d;++i){
    if(flag_t&&flag_q)break;
    if(t[i]==x||flag_t)flag_t=true;
    else{
      res+=c[x]*(i-last_list[i][x]);
      last_list[i][x]=last_list[i-1][x];
      res-=c[x]*(i-last_list[i][x]);
    }
    if(t[i]==nq||flag_q)flag_q=true;
    else{
      res+=c[nq]*(i-last_list[i][nq]);
      last_list[i][nq]=nd;
      res-=c[nq]*(i-last_list[i][nq]);
    }
  }
  t[nd]=nq;
  return res;
}
vector<int> greedy(int d,vector<vector<int>>& t_koho){
  vector<int> res(d+1,0);
  vector<int> last(30,0);
  rep1(i,d){
    int mx=-inf;
    int mx_ind=0;
    vector<P> kouho(26);
    rep1(j,26){
      int tmp=s[i][j];
      rep1(k,26){
        if(k==j)continue;
        tmp-=c[k]*(i-last[k]);
      }
      if(mx<tmp){
        mx=tmp;
        mx_ind=j;
      }
      kouho[j-1]={tmp,j};
    }
    sort(kouho.begin(),kouho.end());
    reverse(ALL(kouho));
    rep(x,koho){
      t_koho[i][x]=kouho[x].second;
    }
    last[mx_ind]=i;
    res[i]=mx_ind;
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<vector<int>> t_koho(d+5,vector<int>(koho+5,0));
  vector<int> t=greedy(d,t_koho);
  vector<vector<int>> last_list(d+1,vector<int>(30,0));
  int res=calc(t,last_list);
  //cout<<res<<"\n";
  int param=2;
  rep(xx,num){
    random_device rand;
    mt19937 mt(rand());
    vector<int> nd(param);rep(i,param)nd[i]=mt()%d+1;
    vector<int> nq(param);rep(i,param)nq[i]=t_koho[nd[i]][mt()%koho];
    vector<int> bq(param);rep(i,param)bq[i]=t[nd[i]];
    int bval=res;
    rep(i,param){
      change(nd[i],nq[i],res,t,last_list);
    }
    int yakinamasi=mt()%100;
    if(yakinamasi<(10-(xx*10)/num)&&res+res/10000>bval)continue;
    if(bval>res){
      rep(i,param){
        change(nd[i],bq[i],res,t,last_list);
      }
    }
  }
  rep(xx,num){
    random_device rnd;
    mt19937 mt(rnd());
    int nd=mt()%d+1;
    int nq=mt()%26+1;
    int bq=t[nd];
    int bval=res;
    int hoge=change(nd,nq,res,t,last_list);
    if(hoge<bval){
      change(nd,bq,res,t,last_list);
    }
  }
  rep1(i,d){
    cout<<t[i]<<"\n";
  }
  //cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if (s[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
const int N = 1e5+10;
typedef long long LL;
int a[N];

int main()
{
    int cnt=0, sum=0;
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==i)
        {
            a[i+1]=i;
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}





Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    ll ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n; cin >> n;
    vector<int> p(n), q(n);
    FOR(i, 0, n) cin >> p[i];
    FOR(i, 0, n) cin >> q[i];

    bool isp = false;
    FOR(i, 0, n) {
        if (p[i] < q[i]) {
            isp = true; break;
        } else if (p[i] > q[i]) {
            isp = false; break;
        }
    }
    
    int count = 0;
    do {
        bool match = true;
        FOR(i, 0, n) {
            if (p[i] != q[i]) match = false;
        }
        if (match) break;
        ++count;
    } while (
        isp 
        ? std::next_permutation(p.begin(), p.end())
        : std::next_permutation(q.begin(), q.end())
        );
    cout << count << endl;
}

signed main() {
    solve();
    return 0;
}

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

using namespace std;
typedef long long Int;

int n;
int a[108000];
int b[108000];
int c[108000];



int main(){
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	for(int i = 0;i < n;i++)cin >> b[i];
	for(int i = 0;i < n;i++){
		cin >> c[i];
		c[i] = -c[i];
	}

	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	Int res = 0;
	for(int i = 0;i < n;i++){
		Int acnt = lower_bound(a, a + n, b[i]) - a;
		acnt = max(acnt, 0LL);

		Int ccnt = lower_bound(c, c + n, -b[i]) - c;
		ccnt = max(ccnt, 0LL);
		
		res += acnt * ccnt;
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2040
N,M,C = map(int, input().split())
li_b = list(map(int, input().split()))
li_a = []
ans = 0
for i in range(N):
    li = list(map(int, input().split()))
    li_a.append(li)
for i in range(N):
    num_sum = 0
    for t in range(M):
        num_sum += li_a[i][t]*li_b[t]
    if num_sum + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 9076
using System;
namespace Program_0152 {
	class Program {
		static void Main(string[] args) {
			while(true) {
				int n = int.Parse(Console.ReadLine());
				if (n == 0) break;
				int[] d = new int[n];
				for(int i = 0; i < n; i++) {
					string[] sc = Console.ReadLine().Split();
					int id = int.Parse(sc[0]);
					int[] a = new int[sc.Length - 1];
					for (int j = 0; j < sc.Length - 1; j++) a[j] = int.Parse(sc[j + 1]);
					int ret = 0, ptr = 0;
					for(int j = 0; j < 9; j++) {
						if (a[ptr] == 10) { ret += 10 + a[ptr + 1] + a[ptr + 2]; ptr++; }
						else if (a[ptr] + a[ptr + 1] == 10) { ret += 10 + a[ptr + 2]; ptr += 2; }
						else { ret += a[ptr] + a[ptr + 1]; ptr += 2; }
					}
					for (int j = ptr; j < a.Length; j++) ret += a[j];
					d[i] = (300 - ret) * 10000 + id;
				}
				Array.Sort(d);
				for(int i = 0; i < n; i++) Console.WriteLine((d[i] % 10000) + " " + (300 - (d[i] - d[i] % 300) / 10000));
			}
		}
	}
}

Measured memory_bytes: 9428
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 100010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

const double INF=1e18;

int n;
int a[N],cnt[N];

int Solve1()
{
	int res=1;
	if (cnt[0]!=1) return 0;

	for (int i=2;i<n;i+=2)
	{
		if (cnt[i]!=2) return 0;
		res=1ll*res*2%Mod;
	}
	return res;
}

int Solve2()
{
	int res=1;
	for (int i=1;i<n;i+=2)
	{
		if (cnt[i]!=2) return 0;
		res=1ll*res*2%Mod;
	}
	return res;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++;
	
	if (n&1) printf("%d\n",Solve1());
	else printf("%d\n",Solve2());
	
	return 0;

}


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

int main() {
  int x;
  cin >> x;
  int X = x;
  int sum = 0;
  
  for(; X != 0; X /= 10) {
    sum += X % 10;
  }
  if(x % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n,x,m = inp
x = x%m
t = na(m+m,0)
mem = na(m+m,false)
anss = 0
ans = x
now = x
i = 1
t[i] = x 
mem[x] = i;
nk = 0
(n-1).times do
  i += 1
  now = (now * now) % m
  ans += now
  t[i] = ans
  if(mem[now])
    rt = (n-i) / (i-mem[now])
    anss = ans + (rt) * (ans - t[mem[now]])
    nk = n - i - rt *  (i-mem[now])
    anss += t[mem[now]+nk] - t[mem[now]]
    break
  end
  mem[now] = i
end
puts (anss==0)? ans : anss

Measured memory_bytes: 17640
from collections import defaultdict
def main():
    v, e = map(int, input().split())
    g = defaultdict(set)
    residual = [[0] * v for _ in range(v)]
    source, sink = 0, v - 1

    for _ in range(e):
        s, t, c = map(int, input().split())
        if 0 < c and s != sink and t != source:
            g[s] |= {t}
            g[t] |= {s}
            residual[s][t] = c

    while True:
        route, flow = search(g, residual, source, sink)
        if not route:
            break
        for s, t in zip(route, route[1:]):
            residual[s][t] -= flow
            residual[t][s] += flow

    print(sum(residual[sink][i] for i in g[sink]))

def search(g, residual, source, sink):
    dfs_stack = [(source, None, float('inf'))]
    route = [None]
    visited = set()
    while dfs_stack:
        u, prev, flow = dfs_stack.pop()
        while route[-1] != prev:
            route.pop()
        route.append(u)
        visited |= {u}
        if u == sink:
            return route[1:], flow
        for v in g[u]:
            if v not in visited and 0 < residual[u][v]:
                dfs_stack.append((v, u, min(residual[u][v], flow)))
    return [], 0

main()


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool a = true;
  for (int i = 0; i <= B - A; i++){
     if ((A + i) % K == 0){
    cout << "OK" << endl;
       a = false;
       break;
     }
  }
  if(a){
    cout << "NG" << endl;
  }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int alice = 0;
    int bob = 0;
    for (int i=0; i<n; i+=2) {
        alice += a[i];
        if (i+1 < n) bob += a[i+1];
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX 100000

int partition(int *, int, int);

int main() {
  int i, n, data[MAX], k;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &data[i]);
  }

  k = partition(data, 0, n-1);

  for (i = 0; i < n; i++) {
    if (i == k) {
      printf("[%d] ", data[i]);
    }
    else if (i == n-1) {
      printf("%d\n", data[i]);
    }
    else {
      printf("%d ", data[i]);
    }
  }

  return 0;
}


int partition(int *a, int p, int r) {
  int x, i, j, temp;

  x = a[r];
  i = p-1;

  for (j = p; j < r; j++) {
    if (a[j] <= x) {
      i++;
      temp = a[i];
      a[i] = a[j];
      a[j] = temp;
    }
  }
  temp = a[i+1];
  a[i+1] = a[r];
  a[r] = temp;
  
  return i+1;
}



Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];

  int flag=0;
  for(int i=1; i<n-1; i++){
    if(p[i-1]<p[i] && p[i]<p[i+1]) flag++;
    if(p[i-1]>p[i] && p[i]>p[i+1]) flag++;
  }
  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef pair<long, long> PAIR;
typedef unsigned long long ULL;
const int MOD=1e9+7;
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }
ULL gcd(ULL a, ULL b){ return b?gcd(b, a%b):a; }
int main(){
int N; cin >> N; long A[N], B[N], z=0, ans=1;
map <PAIR, long> K; vector<PAIR> nw;
REP(i, N){ 
  cin >> A[i] >> B[i];
  if(A[i]==0&&B[i]==0){ z++; continue; }
  long f=((A[i]>=0&&B[i]>=0)||(A[i]<0&&B[i]<0))?1:-1;
  long g=gcd(abs(A[i]), abs(B[i]));
  PAIR p=make_pair(f*abs(A[i])/g, abs(B[i])/g);
  if(K[p]==0){ nw.push_back(p); } K[p]++;
}
map<PAIR, bool> ksht;
REP(i, nw.size()){ 
  PAIR p=nw[i]; long h=(p.first>0)?-1:1;
  if(ksht[p]){ continue; }
  PAIR q=make_pair(h*p.second, abs(p.first)); ksht[q]=true;
  long t=(pw(2, K[p])+pw(2, K[q])+MOD-1)%MOD;
  ans=(ans*t)%MOD;
}
ans=(ans+z+MOD-1)%MOD;
cout << ans << "\n";
}

Measured memory_bytes: 59364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int num[100005];

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	if(n%2==1){
		num[0]=1;
		for(i=2;i<n;i+=2){
			num[i]=2;
		}
	}else{
		for(i=1;i<n;i+=2){
			num[i]=2;
		}
	}
	for(i=0;i<n;i++){
		cin>>a;
		num[a]--;
		if(num[a]<0){
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<pow_mod(2,n/2)<<endl;
}

Measured memory_bytes: 640
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


n,x=input_list()
a=input_list()
ans=1
n=0
for each in a:
    n=n+each
    if n<=x:
        ans+=1
print(ans)

Measured memory_bytes: 12508
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
int main(){
  std::string s;
  std::cin >> s;
  std::map<char, int > mp;
  for (int i=0; i<s.length(); i++){
    mp[s[i]]++;
  }

  int ans = 1e7;
  for (auto &entry : mp){
    int temp = 0;
    std::vector<int > pos;
    pos.push_back(-1);
    for (int i=0; i<s.length(); i++){
      if (s[i]==entry.first){
        pos.push_back(i);
      }
    }
    for (int j=0; j<pos.size()-1; j++){
      temp = std::max(temp, pos[j+1]-pos[j]-1);
    }
    temp = std::max(int(s.length())-pos[pos.size()-1]-1, temp);
    ans = std::min(ans, temp);
  }
  
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

#define ll long long

void solve(){
    int n;
    cin>>n;
    set<string> st;
    string s;
    while(n--){
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
}

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


Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  int left = A+B;
  int right = C+D;
  if (left > right) {
    cout << "Left" << endl;
  } else if (right > left) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;




int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    int min = 1000000;
    for (int i=2; i<n; i++) {
        int v = 100*(s[i-2]-'0') + 10*(s[i-1]-'0') + (s[i]-'0');
        if (abs(v-753)<min) {
            min = abs(v-753);
            ans = v;
        }
    }
    
    
    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int x,y,r,g,c; 
    cin>>x>>y>>r>>g>>c; 
    int R[r],G[g],C[c];
    for (int i=0;i<r;i++) cin>>R[i];
    for (int i=0;i<g;i++) cin>>G[i];
    for (int i=0;i<c;i++) cin>>C[i];
    sort(R, R+r, greater<int> ()); 
    sort(G, G+g, greater<int> ()); 
    sort(C, C+c, greater<int> ()); 
    priority_queue<int> pq;
    for (int i=0;i<min(r,x);i++) pq.push(R[i]);
    for (int i=0;i<min(g,y);i++) pq.push(G[i]);
    for (int i=0;i<min(c,x+y);i++) pq.push(C[i]);
    int sum=0,i=0;
    while (pq.size() && i<(x+y)){
        sum += pq.top();
        i++; pq.pop(); 
    }
    printf("%lld\n",sum);
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 9796
/*input
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
map<char,indexed_set> mp;
char asd[]={'R','G','B'};
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    REP(i,n) mp[s[i]].insert(i);
    ll ans=0;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j]) continue;
            char nd='Z';
            REP(k,3){
                if(asd[k]!=s[i] and asd[k]!=s[j]) nd=asd[k];
            }
            assert(nd!='Z');
            int cnt=mp[nd].size()-mp[nd].order_of_key(j);
            if(mp[nd].find(j+(j-i))!=mp[nd].end()) --cnt;
            ans+=cnt;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3880
import sys
import io

f = sys.stdin.buffer
n = int(f.readline())
h = list(map(int, f.readline().split()))
p0, p1 = 0, abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
    p0, p1 = p1, p2
print(p1)


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

int kaijyou(int a, int b){
  int i,sum;
  sum = 1;
  if(b == 0) return 1;
  else if(b == 1) return a;
  else{
   for(i=0;i<b;i++){
     sum = sum * a; 
   }
   return sum;
  }
}
int main(){
  int N,a,b,i,j;
  j = 8;
  cin >> N;
  b = N;
  for(i=0;i<8;i++){
    if(N<10) {
      a = N;
      break;
    }
    else{
     a += b / kaijyou(10,j);
     b -= (b/kaijyou(10,j))*kaijyou(10,j);
     if(b<10) {
       a += b;
       break;
     }
     j--;
    }
  }
  if((N % a) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]
edge = {tmp}

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in edge:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        edge.add(tmp)
        continue
else:
    print(tmp)

Measured memory_bytes: 32404
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn calc_temp(t:f32, x: f32) -> f32 {
    return t - x * 0.006;
}

fn main() {
    input!{
        n: usize,
        t: isize,
        a: isize,
        hs: [isize; n],
    }
    let mut min = 9999.0;
    let mut ans = 0;

    for i in 0..n {
        let tmp = (calc_temp(t as f32, hs[i] as f32) - a as f32).abs();
        if tmp < min {
            min = tmp;
            ans = i + 1;
        }
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 4352
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>

int count(int x)
{
	int ans=0;
	while(!(x%2)){
		x/=2;
		ans++;
	}
	return ans;
}

int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		ans+=count(x);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <stack>
#include <utility>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::stack<int> st;
  for (size_t i = 0; i < n; ++i) {
    char p;
    int x;
    scanf(" %c %d", &p, &x);

    if (p == '(') {
      if (st.empty()) {
        st.push(x);
      } else {
        st.top() += x;
      }
    } else {
      while (x && !st.empty()) {
        if (st.top() <= x) {
          x -= st.top();
          st.pop();
        } else {
          st.top() -= x;
          x = 0;
        }
      }
      if (x) return puts("NO"), 0;
    }
  }
  puts(st.empty()? "YES": "NO");
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n;
int A[N];
int B[N];
int a[N];
int b[N];

inline int get(int l, int r)
{
	auto it1 = upper_bound(b, b + n, r) - b;
	auto it2 = lower_bound(b, b + n, l) - b;
	return it1 - it2;
}

inline bool ok(int bit)
{
	FOR(i, 0, n) a[i] = A[i] & ((1 << (bit + 1)) - 1);
	FOR(i, 0, n) b[i] = B[i] & ((1 << (bit + 1)) - 1);
	
	sort(b, b + n);
	int ans = 0;
	
	FOR(i, 0, n)
	{
		if (!(a[i] & (1 << bit)))
		{
			int l = (1 << bit) - a[i];
			int r = l + (1 << bit) - 1;
			ans ^= (get(l, r) & 1);
		}
		else
		{
			int l = 0;
			int r = (1 << (bit + 1)) - a[i] - 1;
			ans ^= (get(l, r) & 1);
			
			l = 3 * (1 << bit) - a[i];
			r = (1 << (bit + 1)) - 1;
			ans ^= (get(l, r) & 1);
		}
	}
	
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) cin >> A[i];
	FOR(i, 0, n) cin >> B[i];
	
	LL ans = 0;
	FOR(i, 0, 30) if (ok(i)) ans |= (1 << i);
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 3840
b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
#初めi=0で固定しリストの先頭削除をしていたが計算時間がそれなりにかかる
#i+=1でiを増やしていく方向で行かないといけない
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]


Measured memory_bytes: 27760
using System;

public class Class1
	{
		public static void Main()
		{
		 string ab=Console.ReadLine();
		 string[] abArray=ab.Split();
		 int a=int.Parse(abArray[0]);
		 int b=int.Parse(abArray[1]);
		 if(a<b)
		 {
		 	Console.WriteLine("a < b");
		 }
		 else if(a>b)
		 {
		 	Console.WriteLine("a > b");
		 }
		 else if(a==b)
		 {
		 	Console.WriteLine("a == b");
		 	                 
		 }
		}
	}

Measured memory_bytes: 8728
#include<stdio.h>
long int gcd(long int a,long int b)
{
    long int n=1,tm;
    while(n)
    {
        if(!(a%b))return b;
        tm=b;
        b=a%b;
        a=tm;
    }
}
int main()
{

    long int a,b;
    while(scanf("%ld%ld",&a,&b)!=EOF)
    {
        printf("%ld\n",gcd(a,b));
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

int n,k;

int main() {

	n=read(),k=read();
	if (k==1) puts("0"); else printf("%d\n",n-k);

	return 0;
	
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
int n;
db d,x,ans;
void solve(int n,db d,db x){
	ans+=d+(2*n-1)*x/2;
	if(n==1)return;
	db d1=((2*n+2)*d+5*x)/(2*n);
	db d2n=(d+(2*n-3)*x+3*d+(6*n-6)*x+(2*n-2)*(d+(2*n-1)*x))/(2*n);
	solve(n-1,d1,(d2n-d1)/(2*n-3));
}
int main(){
	cin>>n>>d>>x;
	solve(n,d,x);
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;

int main(){
    
    int n;
    int a[maxn];
    int ans=INF;
    int sum=0,sm=0;
    cin >> n;
    
    rep(i,n){
        cin>> a[i];
        sum+=a[i];
    }
    
    rep(i,n-1){
        sm+=a[i];
        //cout << sum<<' '<<sm<<endl;
        ans=min(ans,abs(sum-sm-sm));
    }
    
    cout << ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//~ ifstream f(".in");
//~ ofstream g(".out");

const int NMAX = 1e5 + 5;

int n, MOD;
vector<int> adj[NMAX];
int down[NMAX];
int up[NMAX];

void mul(int &a, int b) {
  a = (1LL * a * b) % MOD;
}

void add(int &a, int b) {
  a = (a + b) % MOD;
}

int prev(const vector<int> &v, int i) {
  return (i == 0) ? 1 : v[i - 1];
}

int next(const vector<int> &v, int i) {
  return (i == (int)v.size() - 1) ? 1 : v[i + 1];
}

void dfs(int node, int parent, int type) {
  if (type == 0) {
    down[node] = up[node] = 1;
    for (int &x : adj[node]) {
      if (x == parent) {
        continue;
      }
      dfs(x, node, type);
      mul(down[node], down[x] + 1);
    }
    return;
  }
  vector<int> pref_prod(adj[node].size() - 1, 1);
  vector<int> suff_prod(adj[node].size() - 1, 1);
  for (int i = 0, idx = 0; i < (int)adj[node].size(); ++i) {
    int x = adj[node][i];
    if (x != parent) {
      pref_prod[idx] = 1LL * prev(pref_prod, idx) * (down[x] + 1) % MOD;
      ++idx;
    }
  }
  for (int i = adj[node].size() - 1, idx = i - 1; i >= 0; --i) {
    int x = adj[node][i];
    if (x != parent) {
      suff_prod[idx] = 1LL * next(suff_prod, idx) * (down[x] + 1) % MOD;
      --idx;
    }
  }
  for (int i = 0, idx = 0; i < (int)adj[node].size(); ++i) {
    int x = adj[node][i];
    if (x != parent) {
      add(up[x], (1LL * up[node] * prev(pref_prod, idx) % MOD) * next(suff_prod, idx) % MOD);
      ++idx;
      dfs(x, node, type);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif

  cin >> n >> MOD;
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  adj[1].push_back(0);
  dfs(1, 0, 0);
  dfs(1, 0, 1);

  for (int i = 1; i <= n; ++i) {
    cout << 1LL * down[i] * up[i] % MOD << '\n';
  }

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	int n;
	cin>>n;
	ll ans = 0;
	int last = 0;
	while(n--) {
		int val;
		cin>>val;
		if(val<last) {
			ans+=last-val;
		} else {
			last = val;
		}
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
LL A[200001];
LL B[200001];
LL L[200001];
LL R[200001];
typedef pair<LL,int> P;
vector<P>v;
vector<int>G[200011];
int C[200001];
int NL[200001];
int NR[200001];
bool check[200001];
bool used[200011];

int dfs(int x, int p){
	//cout<<x<<endl;
	used[x]=true;
	int now=C[x];
	REP(i,G[x].size()){
		int y=NL[G[x][i]]^NR[G[x][i]]^x;
		//cout<<NL[G[x][i]]<<" "<<NR[G[x][i]]<<" "<<y<<endl;
		if(used[y]==false){
			now+=dfs(y,G[x][i]);
		}
	}
	//cout<<x<<" "<<now<<" "<<p<<" "<<endl;
	now%=2;
	if(p!=-1&&now==1){
		//cout<<p<<"p"<<endl;
		check[p]=true;
	}
	return  now;
}

int binary_search(LL x){
	int lb=-1;
	int ub=v.size();
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		if(v[mid].first<=x){
			lb=mid;
		}else{
			ub=mid;
		}
	}
	return lb;
}

int binary_search2(LL x){
	int lb=-1;
	int ub=v.size();
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		if(v[mid].first<x){
			lb=mid;
		}else{
			ub=mid;
		}
	}
	return ub;
}

void add_edge(LL x, LL y, int i){
	int a=binary_search2(x);
	//if(x==v[a].first)a--;
	int b=binary_search2(y);
	//if(y==v[a].first)b++;
	G[a].push_back(i);
	G[b].push_back(i);
	NL[i]=a;
	NR[i]=b;
}

int main(){
	cin>>N>>M;
	v.push_back(P(0,0));
	v.push_back(P(1e10+1,0));
	REP(i,N){
		cin>>A[i]>>B[i];
		A[i]*=2;
		v.push_back(P(A[i],B[i]));
	}
	sort(v.begin(),v.end());
	REP(i,v.size()){
		if(i==0){
			C[i]=0;
		}else{
			C[i]=v[i].second^v[i-1].second;
		}
		used[i]=false;
	}
	REP(i,M){
		cin>>L[i]>>R[i];
		L[i]*=2;
		L[i]--;
		R[i]*=2;
		R[i]++;
		add_edge(L[i],R[i],i);
		check[i]=false;
	}
	/*cout<<"check"<<endl;
	REP(i,v.size()){
		cout<<C[i]<<" aaa"<<v[i].first<<endl;
	}
	cout<<"checker"<<endl;
	REP(i,M){
		cout<<NL[i]<<" "<<NR[i]<<endl;
	}*/
	
	REP(i,v.size()){
		if(used[i]==false){
			int a=dfs(i,-1);
			if(a==1){
				cout<<-1<<endl;
				return 0;
			}
		}
	}

	
	int cnt=0;
	REP(i,M){
		if(check[i]==true)cnt++;
	}
	cout<<cnt<<endl;
	REP(i,M){
		if(check[i]==true){
			cout<<i+1;
			cnt--;
			if(cnt!=0){
				cout<<" ";
			}
		}
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 23536
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());

        var ans = new string(n.ToString().Select(c => c == '1' ? '9' : c == '9' ? '1' : c).ToArray());


        WriteLine(ans);
    }
}


Measured memory_bytes: 28176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z')
    {
        cout << 'a' << endl;
    }
    else
    {
        cout << 'A' << endl; 
    }
    
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/16  Problem: ABC 130 C / Link: http://abc130.contest.atcoder.jp/tasks/abc130_c  ----- */


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

	LL W, H, X, Y;
	cin >> W >> H >> X >> Y;
	bool c = 0;
	if (W == 2 * X && H == 2 * Y)c = 1;

	cout << H * W / 2.0 << " ";
	cout << c << endl;

	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int keta_sum(int num)
{
    int ret = 0;
    while(num>0)
    {
        ret += num%10;
        num /=10;
    }
    return ret;
}
int main()
{
    int n;cin >> n;
    int mn = INF;
    for (int i = 1; i <=n-1; i++)
    {
        int temp = 0;
        temp += keta_sum(i);
        temp += keta_sum(n-i);
        mn = min(mn, temp);
    }
    cout << mn << endl;
}

Measured memory_bytes: 3580
n, m = map(int, input().split())
X = list(map(int, input().split()))
 
ans = 0
if n < m:
    X.sort()
    L = sorted([X[i + 1] - X[i] for i in range(m - 1)], reverse=True)
    ans = sum(L[n - 1: ])
 
print(ans)                


Measured memory_bytes: 20836
#include <iostream>

int main(int argc, char const *argv[]) {
  int a=0,b=0,c=0;
  int count=0;
  std::cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if((c % i)==0) count++;
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 3108
import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import accumulate

N, K = map(int, input().split())

S = input()


num = []

if S[0] == '0':
    num.append(0)

if S[-1] == '1':
    S += '0'
else:
    S += '1'    

cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        num.append(cnt)
        cnt = 1 
if S[-2] == '0':
    num.append(0)

num = [0] + num
cum_sum = list(accumulate(num))

ans = 0

for i in range(0, len(cum_sum), 2):
    right = i + K * 2 + 1
    if i + K * 2 >= len(cum_sum): 
        right = len(cum_sum) - 1

    ans = max(ans, cum_sum[right] - cum_sum[i])
print(ans)        


Measured memory_bytes: 8804
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @k = gets.to_s.to_i
    @a = Array.new(50, 49 + k/50)
  end

  def solve
    (k % 50).times do |i|
      a[i] += 50
      50.times do |j|
        next if i == j
        a[j] -= 1
      end
    end
    a
  end

  def show(ans)
    puts 50
    puts ans.join(" ")
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 1;
    for (int i = 0; i < 26; i++) {
        ll k = 1;
        for (int j = 0; j < n; j++) {
            if (s[j] - 'a' == i)k++;
        }
        ans *= k;
        ans %= 1000000007;
    }
    cout << (ans + 1000000006) % 1000000007 << endl;
}

Measured memory_bytes: 3260
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static int N;
	public static Map<String, Integer> wordCount = new TreeMap<String, Integer>();

	public static void main(String[] args) {
		init();
		int max = 0;
		for (int v : wordCount.values()) {
			if (v > max) {
				max = v;
			}
		}
		for (String w : wordCount.keySet()) {
			if (wordCount.get(w) == max) {
				System.out.println(w);
			}
		}
	}

	public static void init() {
		Scanner sc = new Scanner(System.in);
		try {
			N = sc.nextInt();
			for (int i = 0; i < N; i++) {
				String w = sc.next();
				if (wordCount.containsKey(w)) {
					int count = wordCount.get(w);
					wordCount.put(w, ++count);
				} else {
					wordCount.put(w, 1);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}


Measured memory_bytes: 85724