akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
//If TLE let's use int instead of ll

string s;
bool ok, ok1;

bool isPalin(string s) {
    string s1 = "";
    REPD(i, s.length() - 1, 0)
        s1 += s[i];
    return (s1 == s);
}

void solveProblem() {
    if (!isPalin(s)) {
        cout << "No";
        return;
    }

    string temp = "", temp1 = "";
    //cout << ((s.length() - 1) / 2) - 1 << endl;
    FOR (i, 0, ((s.length() - 1) / 2)) {
        //cout << i << endl;
        temp += s[i];
    }
    ok = isPalin(temp);

    FOR(i, (s.length() + 3) / 2 - 1, s.length()) {
        temp1 += s[i];
    }
    ok1 = isPalin(temp1);

    //cout << temp << " " << temp1;

    cout << ((ok && ok1) ? "Yes" : "No");
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> s;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,k = [int(i) for i in readline().split()]

if 2*k > n+1:
    print(-1)
else:
    if n%2:
        K = (n+1)//2
        S = K + 2*n
    else:
        K = (n)//2
        S = K + 2*n-2
        
    #print(K,n,S)
    ans = []
    L = n-2
    num = n
    for i in range(2*K+n-1,K+n-1,-1):
        ans.append([i,S-i,S])
        S += 1
        num -= 1        
    
    if n%2==0:
        num -= 1
    for i in range(num):
        if n%2: P = K+2*n-1-i
        else: P = K+2*n-1-i-1
        ans.append([P,S-P,S])
        S += 1
    
    if n%2==0:
        ans.append([K+n-1,K+n-2,2*K+2*n-3+n//2])
        K-=1

    #for i in ans:
    #    print(sum(i))
    #print(ans)
    res = 0
    if n%2==0: res += 1
    
    for i in ans:
        a,b,c = i
        print(a-(K-k),b-(K-k),c-(K-k)+res)
    

Measured memory_bytes: 58840
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    string s;cin>>s;
    fol(i,s.size()-8){
        cout << s[i];
    }
    cout <<endl;
}

int main(){
//option:-std=c++0x
    solve();
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	double d, x, y;
	cin >> d;
	int ans = 0;
	rep(i, 0, n) {
		cin >> x >> y;
		if (x*x + y*y <= d*d) {
			ans++;
		}
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    rep(i,N,1000){
        if(i % 111 == 0){
            print(i);
            return 0;
        }
    }

}


Measured memory_bytes: 892
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        string s = input[0] + input[1];
        int n = int.Parse(s);
        
        for(int x = 0;x < 1000;x++){
            if(x * x == n){
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

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

using namespace std;
void solve();

long cost(long i, long j) {
  return i < j ? j - i : i - j;
}

long N;
vector<long> vec;

int main() {
  cin >> N;
  vec.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  solve();
}

void solve() {
  vector<long> dp(N);
  dp[0] = 0;
  dp[1] = cost(vec[0], vec[1]);
  if (N < 3) {
    cout << dp[1] << endl;
    return;
  }
  for (int i = 2; i < N; i++) {
    long c1 = dp[i - 2] + cost(vec[i - 2], vec[i]);
    long c2 = dp[i - 1] + cost(vec[i - 1], vec[i]);
    dp[i] = c1 < c2 ? c1 : c2;
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 1e9 + 7; const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
ll sr[112345];
vl a;
int find(int x, int y, int val) {
	if (x == y)return x;
	int mid = x + y >> 1, temp;
	if (a[mid] >= val)temp = find(mid + 1, y, val);
	else temp = find(x, mid, val);
	return temp;
}
signed main() {
	int n;
	cin >> n;
	FOR(n)cin >> sr[i];
	a.push_back(sr[0]);
	for (int i = 1; i < n; ++i) {
		if (sr[i] <= a[a.size() - 1]) {
			a.push_back(sr[i]);
		}
		else {
			int pos = find(0, a.size() - 1, sr[i]);
			a[pos] = sr[i];
		}
	}
	cout << a.size() << endl;
	return 0;
}

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

using namespace std;

int main() {
    int a, b, c;

    // input
    cin >> a >> b >> c;

    // process
    int cnt = 0;
    for (int n = a; n <= b; n++){
        if (c % n == 0) cnt++;
    }

    // output
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3112
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int a[101];

int main()
{
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    LL ans=1000000007;
    for(int i=a[0];i<=a[n-1];++i)
    {
        LL tmp=0;
        for(int j=0;j<n;++j)
            tmp+=(i-a[j])*(i-a[j]);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
B = [[0 for _ in range(3)] for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            B[i][j] = 1
c = 0
for i in range(3):       
    if B[i][0] == B[i][1] == B[i][2] == 1:
        c = 1
    if B[0][i] == B[1][i] == B[2][i] == 1:
        c = 1
if B[0][0] == B[1][1] == B[2][2] == 1:
    c = 1
if B[0][2] == B[1][1] == B[2][0] == 1:
    c = 1
if c == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	int i,j,k;
	bool s=true;
	string sa[105];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>sa[i];
		for(j=0;j<i;j++){
			if(sa[j]==sa[i])s=false;
		}
		if(i!=0 && sa[i-1].back()!=sa[i][0])s=false;
	}
	if(s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
x = b-a
if x % 2 == 0 : 
  print(x//2)
else:
  m = (a-1)+1+((b-a-1)//2)
  l = (n-b)+1+((b-a-1)//2)
  print(min(m,l))


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define int long
vector<vector<int>> adj(10001);
signed main(){
  int n,root,sum=0;
  cin>>n;
  vector<int> c(n),ans(n+1);
  for(int i=0;i<n-1;++i){
    int a,b;
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i=0;i<n;++i)cin>>c[i];
  for(int i=1;i<=n;++i){
    if(adj[i].size()>1){
      root=i;
      break;
    }
  }
  int maxdepth=0;
  vector<int> depth(n+1);
  vector<bool> visited(n+1,false);
  depth[root]=0;
  queue<int> que,empty;
  que.push(root);
  while(!que.empty()){
    int node=que.front();
    que.pop();
    visited[node]=true;
    for(auto c:adj[node]){
      if(!visited[c]){
        que.push(c);
        depth[c]=depth[node]+1;
        maxdepth=max(maxdepth,depth[c]);
      }
    }
  }
  //for(int i=1;i<=n;++i)cerr<<" "<<depth[i]; cerr<<"\n";
  int cp=0;
  sort(c.begin(),c.end());
  for(int i=1;i<=n;++i)if(depth[i]==maxdepth)que.push(i);
  while(maxdepth>=0){
    while(!que.empty()){
      //cerr<<"ans["<<que.front()<<"]<-"<<c[cp]<<"\n";
      ans[que.front()]=c[cp++];
      que.pop();
    }
    maxdepth--;
    for(int i=1;i<=n;++i)if(depth[i]==maxdepth)que.push(i);
  }
  visited=vector<bool>(n+1,false);
  que.push(root);
  while(!que.empty()){
    int node=que.front();
    que.pop();
    visited[node]=true;
    for(auto c:adj[node]){
      if(!visited[c]){
        sum+=min(ans[node],ans[c]);
        que.push(c);
      }
    }
  }
  cout<<sum<<endl;
  for(int i=1;i<=n;++i){
    if(i-1)cout<<" ";
    cout<<ans[i];
  }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n;
  st s;
  cin >> n >> s;
  ll ans = 0;
  rep(i, 0, 1000){
    st pass = to_string(i);
    if(pass.size() == 1) pass = "00" + pass;
    if(pass.size() == 2) pass = "0" + pass;
    ll now = 0;
    vrep(j, s){
      if(j == pass.at(now)) now++;
      if(now == 3) break;
    }
    if(now == 3) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import fractions

N = int(input())
arr = list(map(int, input().split()))
L = [0]
R = [0]
B = []

for i in range(N):
    L.append(fractions.gcd(arr[i], L[i]))
    R.append(fractions.gcd(arr[N - i - 1], R[i]))
for i in range(N):
    B.append(fractions.gcd(L[i],R[N - i - 1]))
print(max(B))

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

int main()
{
    int H, N;
    cin >> H >> N;
    int sum = 0;
    int a;
    for(int i=0;i<N;i++)
    {
        cin >> a;
        sum += a;
    }
    if(H <= sum)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
    
    
    return 0;
}

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

const long long POT[31]={2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

int main(){
    int n;
    std::cin>>n;
    std::vector<long long> a(n);
    std::unordered_map<long,int> cnt;

    int ans=0;
    for (int i = 0; i < n; ++i) {
        std::cin>>a[i];
        ++cnt[a[i]];
    }
    std::sort(a.begin(),a.end());
    for (int i = n-1; i >= 0; --i) {
        if(cnt[a[i]]<=0)continue;
        for (int j = 30; j >= 0; --j) {
            if(a[i]>POT[j])break;
            if (cnt[POT[j]-a[i]]>=1) {
                if(a[i]==POT[j]-a[i]&&cnt[a[i]]<=1)continue;
                ++ans;
                --cnt[a[i]];
                --cnt[POT[j]-a[i]];
                break;
            }
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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


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

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmix(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

using ll = long long;


int main() {
    int r, c;
    cin >> r >> c;

    auto input  = vvi(r, vi(c));
    auto row    = vi(r);
    auto column = vi(c);
    auto sum = 0;

    REP(i, r) {
        REP(j, c) {
            cin >> input[i][j];
            row[i] += input[i][j];
            column[j] += input[i][j];
            sum += input[i][j];
        }
    }

    REP(i, r){
        REP(j, c){
            cout << input[i][j] << " ";
        }
        cout << row[i] << "\n";
    }
    REP(j,c) cout << column[j] << " ";
    cout << sum << "\n";

    return 0;
}



Measured memory_bytes: 3196
#include<iostream>
using namespace std;
int main() {
	int money;
	while (cin >> money&&money != 0) {
		int get[12], use[12];
		for (int i = 0; i < 12; ++i) {
			cin >> get[i] >> use[i];
		}
		int ans = -1;
		int num = 0;
		for (int i = 0; i < 12; ++i) {
			num += get[i] - use[i];
			if (num >= money) {
				ans = i + 1;
				break;
			}
		}
		if (ans != -1) {
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		boolean flag=true;
		int j=s.length();
		for(int i=0;i<s.length()/2;i++) {
			if(!s.substring(i, i+1).equals(s.substring(j-1, j))) flag=false;
			j--;
		}
		j=s.length()/2;
		for(int i=0;i<s.length()/4;i++) {
			if(!s.substring(i, i+1).equals(s.substring(j-1, j))) flag=false;
			j--;
		}
		j=s.length();
		for(int i=s.length()/2+1;i<s.length()/4+s.length()/2+1;i++) {
			if(!s.substring(i, i+1).equals(s.substring(j-1, j))) flag=false;
			j--;
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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


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


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

int main(void)
{
    int n;
    cin >> n;
    if (n % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - (n % 1000) << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
#define N 5005
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,m,p;
int e_cnt=0,head[N];
int cnt[N],vis[N],dis[N],ok[N],g[N][N],g2[N][N];
queue<int> q;
struct Edge{
	int to,nxt,val;
}edge[N<<2];
void add(int a,int b,int c){
	e_cnt++;
	edge[e_cnt].to=b;
	edge[e_cnt].nxt=head[a];
	edge[e_cnt].val=c;
	head[a]=e_cnt;
}
bool SPFA(int s){
	memset(dis,-0x3f,sizeof(dis));
	dis[s]=0;
	vis[s]=1;
	q.push(s);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(!ok[v])continue;
			if(dis[v]<dis[u]+edge[i].val){
				dis[v]=dis[u]+edge[i].val;
				if(!vis[v]){
					cnt[v]++;
					vis[v]=1;
					q.push(v);
				}
				if(cnt[v]>n){
					return true;
				}
			}
		}
	}
	return false;
}
void dfs(int u){
	if(ok[u])return;
	ok[u]=1;
	for(int i=1;i<=n;i++){
		if(g[u][i]){
			dfs(i);
		}
	}
}
int main(){
	n=read(),m=read();p=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read(),w=read();
		add(u,v,w-p);
		g[v][u]=1;
	}
	dfs(n);
	if(SPFA(1)){
		cout<<-1<<endl;
	}
	else{
		cout<<max(0,dis[n])<<endl;
	}
	return 0;
}


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

using ll=long long; 

void solve(){
	ll n;cin>>n;
	vector<ll>a(n);
	for(ll i=0; i<n; i++)cin>>a[i];
	vector<ll> s(n+1);
	s[0]=0;
	for(int i=0; i<n; i++){
		s[i+1]=s[i]+a[i];
	}
	sort(s.begin(), s.end());
	ll ans=0;
	ll cnt=0;
	for(int i=1; i<n+1; i++){
		if(s[i]==s[i-1]){
			cnt=2;
			i+=1;
			while(i<n+1&&s[i]==s[i-1]){
				cnt++;
				i+=1;
			}
			ans+=cnt*(cnt-1)/2;
		}
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

int main()
{
    long long n,i,s[200005],a[200005];
     cin>>n;
     long long m;
     for(i=0;i<n;i++)
     {
         cin>>s[i];
     }
     m=0;
     map<long long ,long long >f;
     long long z;
     for(i=0;i<n;i++)
     {
        f[s[i]]++;
     }
     for(map<long long ,long long >::iterator it=f.begin();it!=f.end();it++)
         {
             z=it->second;
             m=m+((z*(z-1))/2);
         }
         for(i=0;i<n;i++)
         {
             a[i]=m-f[s[i]]+1;
             cout<<a[i]<<endl;
         }
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    // if(K==1){
    //     for (long long i = 1; i < N; i++) {
    //         judge(A[i]>A[i-1])
    //     }
    //     return 0;
    // }
    // vector<ll> v(N);
    // vector<ll> w(N);
    // v[0]=A[0];
    // for (long long i = 1; i < N; i++) {
    //     v[i]=v[i-1]+A[i];
    // }
    // w[K-1]=v[K-1];
    // for (long long i = K; i < N; i++) {
    //     w[i]=v[i]-v[i-K];
    // }
    // for (long long i = 0; i < N-K; i++) {
    //     judge(w[K+i-1]<w[K+i])
    // }
    for (long long i = K; i < N; i++) {
        judge(A[i-K]<A[i])
    }
    return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }




bool compare(pll &a, pll &b){
    if(a.fi!=b.fi) return a.fi>b.fi;
    else return a.sc<b.sc;
}


void solve(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<pll> p,q,r;
    rep(i,a){
        ll s;cin>>s;
        p.pb({s,-1});
    }
    rep(i,b){
        ll s;cin>>s;
        q.pb({s,-1});
    }
    ll d[200010];
    rep(i,c){
        cin>>d[i];
    }
    sort(d,d+c);reverse(d,d+c);
    rep(i,c){
        r.pb({d[i],i});
        p.pb({d[i],i});
        q.pb({d[i],i});
    }
    sort(all(p),compare);
    sort(all(q),compare);
    priority_queue<ll> que;
    ll ans=0;
    ll cnt[100010]={};
    rep(i,x){
        ans+=p[i].fi;
        if(p[i].sc!=-1) cnt[p[i].sc]++;
    }
    rep2(i,x,(ll)p.size()){
        if(p[i].sc==-1) que.push(p[i].fi);
    }
    rep(i,y){
        ans+=q[i].fi;
        if(q[i].sc!=-1) cnt[q[i].sc]++;
    }
    rep2(i,y,(ll)q.size()){
        // cout<<q[i].fi<<" "<<q[i].sc<<endl;
        if(q[i].sc==-1) que.push(q[i].fi);
    }
    rep(i,c){
        if(cnt[i]==0){
            que.push(d[i]);
        }
    }
    rep(i,c){
        if(cnt[i]==2){
            ans-=d[i];
            ans+=que.top();
            que.pop();
        }
    }
    cout<<ans<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    solve(); 


    return 0;
}


Measured memory_bytes: 20008
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
#define dbg_al(s, x) for(auto e:x)s+=to_string(e)+" "
#define dbg_rt(x) string s="[ ";dbg_al(s,x);s+="]";return s;
#define dbg_fd1 template<typename T>string to_string
#define dbg_fd2 template<typename U, typename V>string to_string
#define dbg_d1(c) dbg_fd1(c<T>);
#define dbg_d2(c) dbg_fd2(c<U, V>);
#define dbg_f1(c) dbg_fd1(c<T> v){dbg_rt(v);}
#define dbg_f2(c) dbg_fd2(c<U, V> v){dbg_rt(v);}
string to_string (char s) { return "\'"+string(1, s)+"\'"; }
string to_string (string s) { return "\"" + s + "\""; }
dbg_d1(vector) dbg_d1(set) dbg_d2(map)
dbg_fd2(pair<U, V> p) { return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
dbg_f1(vector) dbg_f1(set) dbg_f2(map)
/* ==================== */ 
vector<pll> p;
ll n, m;

int main() {
	
	scanf("%lld%lld", &n, &m);
	p.assign(n, pll());
	for (int i = 0; i < n; i++) scanf("%lld%lld", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (p[i].second > m) {
			ans += m * p[i].first;
			break;
		}
		ans += p[i].second * p[i].first;
		m -= p[i].second;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
# N=3
# A=[12 ,15 ,18]
l=[0]*N
r=[0]*N
l[0]=A[0]
r[0]=A[N-1]
for i in range(1,N-1):
    l[i]=gcd(l[i-1],A[i])
    r[i]=gcd(r[i-1],A[N-1-i])    
gcdlist = [1,l[N-2],r[N-2]]
for i in range(N-2):
    gcdlist.append(gcd(l[i],r[N-3-i]))
#print(gcdlist)
print(max(gcdlist))



Measured memory_bytes: 16124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int s = int.Parse(str);
        int cnt = 0;

        for(int i = 0; i <= 2; i++){
            if(s % 10 == 1){
                cnt++;
            }
            s /= 10; 
        }

        Console.WriteLine(cnt);
        
    }
}



Measured memory_bytes: 13268
#include<stdio.h>
int main(){
    int i,x[3000],y[3000];
    for(i=0;;i+=1){
        scanf("%d %d",&x[i],&y[i]);
        if(x[i]==0&&y[i]==0){
            break;
        }
    }
    for(i=0;;i+=1){
        if(x[i]==0&&y[i]==0){
            break;
        }
        else if(x[i]<=y[i]){
            printf("%d %d\n",x[i],y[i]);
        }
        else if(x[i]>=y[i]){
            printf("%d %d\n",y[i],x[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 624
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 keta setprecision(10) //10桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;

	for (int i = 0; i < a; i++)
	{
		if ('0' <= s[i] && s[i] <= '9')
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			ret;
		}
	}
	if (s[a] != '-')
	{
		cout << "No" << endl;
		ret;
	}
	for (int i = a + 1; i < a + b + 1; i++)
	{
		if ('0' <= s[i] && s[i] <= '9')
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			ret;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  bool f=true;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]!=t[i]){
      f=false;
      break;
    }
  }
  if(f) cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n,k;
        cin >> n >> k;
        double a[n+1];
        double s[n+1],t[n+1];
        int i,j;
        for(i=1; i<=n; i++){
            cin >> a[i];
            if((int)a[i]%2==1){
                t[i]=(int)a[i]/2+1;
            }
            else{
                t[i]=(a[i]+1.00)/2.00;
            }
         //   trace2(a[i],t[i]);
            
        }
        s[0]=0.0;
        double ans=0.00;
        for(i=1; i<=n; i++){
            s[i]=s[i-1]+t[i];
          //  trace(s[i]);
        }
        for(i=1;i<=n-k+1; i++){
            double r=s[i+k-1]-s[i-1];
          //  trace(r);
            ans=max(ans,r);
        }
        cout << setprecision(17) << fixed << ans << '\n';

}


Measured memory_bytes: 4992
h,w = map(int,input().split())

if h%3 == 0 or w%3 == 0:
    print(0)
else:
    ans = min(h,w)
    for i in range(1,h):
        sq = [i*w, (h-i)*(w//2), (h-i)*(w - w//2)]
        ans = min(ans,max(sq) - min(sq))
    h,w = w,h
    for i in range(1,h):
        sq = [i*w, (h-i)*(w//2), (h-i)*(w - w//2)]
        ans = min(ans,max(sq) - min(sq))
    print(ans)


Measured memory_bytes: 41692
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  scanf("%d",&n);
  set < int > se ;
for ( int i =0 ; i < n;  i++ ) {
    int x ; scanf("%d",&x);
    se.insert(x);
}
if ( (int)se.size() == n ) printf("YES\n");
else printf("NO\n");
return 0 ;
}


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

namespace Algorithm
{
    class Program
    {
        static int X;
        static int[] dp;
        static void Main(string[] args)
        {
            X = int.Parse(Console.ReadLine());
            dp = Enumerable.Repeat(-1, 100001).ToArray();

            var ans = Dfs(0);
            Console.WriteLine(ans);
        }

        static int Dfs(int n)
        {
            if (n >= X)
            {
                if (n == X) return 1;
                else return 0;
            }

            if (dp[n] >= 0) return dp[n];

            var ret = 0;
            for (var i = 100; i <= 105; i++)
            {
                ret = dp[n] = Dfs(n + i);
                if (ret == 1) break;
            }

            return ret;
        }
    }
}


Measured memory_bytes: 14140
/**
 *		author:  zvm
 *		created: 25.09.2020 14:53:51
**/

#include <bits/stdc++.h>

using namespace std ;

typedef long long int ll ;

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

	int n ;
	cin >> n ;

	vector<int> a(n), b(n), c(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] ;
	}

	sort(a.begin(),a.end());
	sort(c.begin(),c.end());

	ll ans = 0 ;
	for( int i = 0 ; i < n ; ++i ) {
		ll less = lower_bound(a.begin(),a.end(),b[i]) - a.begin() ;
		ll greater = c.end() - upper_bound(c.begin(),c.end(),b[i]) ;
		ans += less*greater ;
	}

	cout << ans << endl ;
}


Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
   int a,b,c,d,x,y; cin>>a>>b>>c>>d;
   x=c-a,y=d-b;
   cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string.h>
struct Node{
  int key;
  struct Node *right,*left,*parent;
};
  
struct Node *root,*NIL;
typedef struct Node * node;
struct Node * find(struct Node *u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u -> left;
    }
    else {
      u = u -> right;
    }
  }
  return u;
}
  
void insert(int k){
  struct Node *x=root;
  struct Node *y=NIL;
  struct Node *z;
  z=malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while( x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z; 
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
  
void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
  
void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(){
  int n,i,x;
  int a=0,b=0;
  char com[10];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");

    }
    if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");



    }
   

  }
   
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;}

typedef long long lint;

using namespace std;
int main(){
	string s,t,u;
	cin>>s>>t>>u;
	cout<<s.at(0)<<t.at(0)<<u.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

ll gcd(ll a, ll b) {
    if (b > a) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    int cnt = 1;
    for (ll i = 2; i * i <= min(a, b); i++) {
        if (a % i == 0 && b % i == 0) {
            a /= i;
            b /= i;
            cnt++;
        }
        while (a % i == 0) a /= i;
        while (b % i == 0) b /= i;
    }
    if (gcd(a, b) > 1) cnt++;
    cout << cnt;
}



Measured memory_bytes: 3632
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n;
	cin >> n;
	int p[200][3];

	for(int i=0;i<n;i++)
	{
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}

	int _p;
	for(int k=0;k<3;k++)
	{
		for(int i=0;i<n;i++)
		{
			_p = p[i][k];
			for(int j=i+1;j<n;j++)
			{
				if(_p == p[j][k])
				{
					p[i][k] = 0;
					p[j][k] = 0;
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		cout << p[i][0] + p[i][1] + p[i][2] << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll r;
	cin >> r;
	ll ans = 3*r*r;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,C,D[5010][2],i,j;
main(){
cin>>N;fill_n(*D+3,1e4,1e9);D[0][0]=1e9;
for(;cin>>C,i<N-1;i++)for(j=N/2;~j;)D[j+1][0]=min(D[j][0],D[j][1]+C),D[j--][1]=min(D[j][0]+C,D[j][1]);
cout<<min(D[N/2][0],D[N/2][1])<<endl;
}

Measured memory_bytes: 1204
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

int N;
string S;

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

    cin >> S;
    N = S.size();

    S = "@" + S;

    bool ok = true;

    if (S[1] == '0' || S[N] == '1') {
        ok = false;
    }

    for (int i = 1; i <= N; i++) {
        if (S[i] == '1' && S[N - i] == '0') {
            ok = false;
        }
    }

    if (!ok) {
        cout << -1 << "\n";
        return 0;
    }

    vector<int> pos;
    for (int i = 1; i <= N; i++) {
        if (S[i] == '1') {
            pos.push_back(i);
        }
    }

    vector<pair<int, int>> edges;

    for (int i = 1; i < pos.size(); i++) {
        edges.emplace_back(pos[i], pos[i-1]);
        for (int j = pos[i-1] + 1; j < pos[i]; j++) {
            edges.emplace_back(pos[i], j);
        }

        if (i == pos.size() - 1) {
            for (int j = pos[i] + 1; j <= N; j++) {
                edges.emplace_back(pos[i], j);
            }            
        }
    }

    for (auto e : edges) {
        cout << e.first << " " << e.second << "\n";
    }

    return 0;
}


Measured memory_bytes: 2788
#%%
n, u, v = map(int, input().split())
u, v = u-1, v-1
a, b = [0] * (n-1), [0] * (n-1)
reach = [[] for _ in range(n)]
for i in range(n-1):
    a[i], b[i] = map(lambda x: int(x)-1, input().split())
    reach[a[i]].append(b[i])
    reach[b[i]].append(a[i])

a_route = [[-1, -1] for _ in range(n)]
check = [0] * n
stack = [v]
check[v] = 1
a_route[v] = [-1, 0]

while len(stack) > 0:
    tmp = stack.pop(-1)
    tmp_list = reach[tmp]
    for i in tmp_list:
        if check[i] == 1:
            pass
        else:
            stack.append(i)
            check[i] = 1
            a_route[i] = [tmp, a_route[tmp][1]+1]

t_route = [[-1, -1] for _ in range(n)]
check = [0] * n
stack = [u]
check[u] = 1
t_route[u] = [-1, 0]

while len(stack) > 0:
    tmp = stack.pop(-1)
    tmp_list = reach[tmp]
    for i in tmp_list:
        if check[i] == 1:
            pass
        else:
            stack.append(i)
            check[i] = 1
            t_route[i] = [tmp, t_route[tmp][1]+1]
    
ans = 0
for i in range(len(a_route)):
    if t_route[i][1] < a_route[i][1]:
        ans = max(ans, a_route[i][1]-1)

print(ans)

Measured memory_bytes: 98208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    bool f=false;
    
    int xMax;
    for(int i=0;i<N;i++)cin >> x[i];
    xMax = *max_element(x.begin(),x.end());
    int Z = xMax+1;
    
    if(X >= Z || Z > Y)f=true;
    for(int i=0;i<M;i++){
        cin >> y[i];
        if(Z > y[i])f=true;   
    }
    
    if(f) cout << "War" << endl;
    else cout << "No War" << endl;
    
    return 0;
}

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

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    // A, B, C の合計の偶奇は操作してもかわらない
    // 足さなければいけないのは diff = 3*max - (A+B+C)
    // diff が奇のときは max 以外の整数の偶奇を揃える
    // つまり偶のときより 1 操作多い
    int max = a;
    if (max < b) {
        max = b;
    }
    if (max < c) {
        max = c;
    }
    int diff = 3 * max - (a + b + c);
    if (diff % 2 == 0) {
        cout << diff / 2 << endl;
    } else {
        cout << ((diff + 1) / 2) + 1 << endl;
    }
}

Measured memory_bytes: 256
use strict;
my ($w,$h,$n) = split(' ', <>);

#print "my ($w,$h,$n) = split(' ', <>);\n";

my $xmin = 0;
my $xmax = $w;
my $ymin = 0;
my $ymax = $h;
for (1..$n) {
    my ($x, $y, $a) = split(' ', <>);
    if ($a == 1) {
        ($xmin < $x) and $xmin = $x;
    } elsif ($a == 2) {
        ($xmax > $x) and $xmax = $x;
    } elsif ($a == 3) {
        ($ymin < $y) and $ymin = $y;
    } elsif ($a == 4) {
        ($ymax > $y) and $ymax = $y;
    } else {
        die;
    }
    #print "$xmin:$xmax, $ymin:$ymax\n";
}

if ($xmax < $xmin) {
    print "0\n";
} elsif ($ymax < $ymin) {
    print "0\n";
} else {
    printf("%d\n",  ($xmax-$xmin)*($ymax-$ymin));
}


Measured memory_bytes: 512
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n<a+b-1||(ll)a*b<n){
		cout<<-1<<endl;
		return 0;
	}
	vi out;
	rep(i,b)out.pb(b-i);
	int t=b;
	rep(i,a-1){
		int s=t+min(b,n-t-(a-i-2));
		rep(j,s-t)out.pb(s-j);
		t=s;
	}
	
	rep(i,n)cout<<out[i]<<" \n"[i==n-1];
}




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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    int n, m;
    cin >> n >> m;

    string ans = "No";
    if (n==m) ans = "Yes";

    AA(ans);
}

Measured memory_bytes: 3624
modarr11=[77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 76]
modarr21=[8, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7]
modarr22=[7, 8, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7]
modarr23=[8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7]
modarr31=[1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]
modarr32=[1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1]
modarr33=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]

s=input()
l=len(s)
if l%3!=0:
  s='0'*(3-l%3)+s
  l+=(3-l%3)
mod=10**9+7
cnt=0
dp=[[0]*13 for _ in range(l//3+1)]
for i in range(l-1,-1,-3):
  num=0
  qpos=0
  for j in range(3):
    if s[i-j]=='?':
      qpos+=1*(10**j)
    else:
      num+=int(s[i-j])*(10**j)
  if qpos==0:
    tmod=[0]*13
    tmod[num%13]=1
  elif qpos==1:
    tpos=num%13
    tmod=modarr33[-tpos:]+modarr33[:-tpos]
  elif qpos==10:
    tpos=num%13
    tmod=modarr32[-tpos:]+modarr32[:-tpos]
  elif qpos==100:
    tpos=num%13
    tmod=modarr31[-tpos:]+modarr31[:-tpos]
  elif qpos==11:
    tpos=num%13
    tmod=modarr23[-tpos:]+modarr23[:-tpos]
  elif qpos==101:
    tpos=num%13
    tmod=modarr22[-tpos:]+modarr22[:-tpos]
  elif qpos==110:
    tpos=num%13
    tmod=modarr21[-tpos:]+modarr21[:-tpos]
  elif qpos==111:
    tmod=modarr11
  if cnt==0:
    dp[1]=tmod
  elif cnt%2==0:
    for k in range(13):
      for l in range(13):
        dp[cnt+1][(k+l)%13]+=(tmod[k]*dp[cnt][l])%mod
  else:
    for k in range(13):
      for l in range(13):
        dp[cnt+1][(l-k)%13]+=(tmod[k]*dp[cnt][l])%mod
  cnt+=1
print(dp[cnt][5]%mod)

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

lb = sorted(v for v, _ in X)
ub = sorted(v for _, v in X)
mid = N // 2
if N % 2 == 1:
    print(ub[mid] - lb[mid] + 1)
else:
    ans = (ub[mid - 1] + ub[mid]) - (lb[mid - 1] + lb[mid]) + 1
    print(ans)


Measured memory_bytes: 124584
#include <iostream>

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

int main() {
    int n; cin >> n;
    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
        cout << "hon" << endl; return 0;
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        cout << "pon" << endl; return 0;
    }
    else cout << "bon" << endl;
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int64_t, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first >> A[i].second;
  }
  sort(A.begin(), A.end());

  int64_t answer = 0;
  for (int i = 0; i < N; i++) {
    int buy = min(M, A[i].second);
    answer += A[i].first * buy;
    M -= buy;
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		ArrayList<Integer> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}

}


Measured memory_bytes: 23252
from collections import defaultdict
import bisect

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

s = 0
S = [0]
for i, a in enumerate(A):
    s += a
    S.append(s % K)

cnt = 0
dic = {}

for i, s in enumerate(S):
    x = (s - i) % K

    if x in dic:
        cnt += dic[x]
        dic[x] += 1
    else:
        dic[x] = 1

    K_prev = i - K + 1

    if K_prev >= 0:
        y = (S[K_prev] - (K_prev)) % K
        dic[y] -= 1


print(cnt)

Measured memory_bytes: 46856