akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int n,l;
      cin >> n >> l;
      vector<string> s(n);
      rep(i,n)cin >> s[i];
      sort(ALL(s));
      rep(i,n){
            cout << s[i];
      }
      return 0;
}

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

 
int main() {
  // 科目の数Nを受け取る
  int N;
  cin >> N;
  
  vector<int> A(210);
  
  int sousa = 0;
  
  for (int i = 0; i < N ; i++){
  
    cin >> A.at(i);

  }
  
  while (true){
  bool oddExist = false;
    for (int j = 0 ; j < N ; j++){
      if (A.at(j)%2 != 0) {
          oddExist = true;
      }
  }
  
    if(oddExist == true){
      break;
  }
    // 半分にする処理
    for (int k = 0; k < N ; k++) {
        A.at(k) = A.at(k)/2;
    }
    ++sousa;
    // cout << sousa << endl;

  }
  
  cout << sousa << endl;

}

Measured memory_bytes: 3628
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    a = -1
  else:
    a = int(S[i])
  for j in range(10):
    if a!=-1 and a!=j:
      continue
    for k in range(13):
      dp[i+1][(k*10+j)%13] += dp[i][k]
  for k in range(13):
    dp[i+1][k] %=(10**9+7)
print(dp[len(S)][5])


Measured memory_bytes: 70280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
int main(void) {
	int n, r;
	scanf("%d%d", &n, &r);
	if (n >= 10) {
		printf("%d", r);
	}
	else {
		printf("%d", r + (100 * (10 - n)));
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

error = 0
warikireru_3 = 0
warikireru_5 = 0

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            warikireru_3 = 1
        if A[i] % 5 == 0:
            warikireru_5 = 1
        if not(warikireru_3 == 1 or warikireru_5 == 1):
            error += 1
    warikireru_3 = 0
    warikireru_5 = 0

if error == 0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3064
'use strict'


function Main(input) {
  const s = input.trim().split('')
  const N = s.length - 1
  
  var answer = 0
  for (let bit = 0; bit < (1 << N); bit++) {
    let tmpStrs = [s[0]]
    for (let i = 0; i < N; i++) {
        const num = s[i + 1]
        if (bit & (1 << i)) {
            tmpStrs.push(num)
        } else {
            tmpStrs[tmpStrs.length - 1] += num
        }
    }
    answer += tmpStrs.reduce((p, c) => p + parseInt(c), 0) // 文字列を数に変換するので、初期値の0を渡す
  }

  console.log(answer)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var N = GetLong();
		var M = GetLong();
		var X = GetLong();
		var C = new long[N];
		var A = new long[N, M];
		for(long i = 0; i < N; i++)
		{
			C[i] = GetLong();
			for(long j = 0; j < M; j++)
				A[i, j] = GetLong();
		}

		long min = long.MaxValue;
		for(long s = 0; s < leftShift(1, N); s++)
		{
			long sum = 0;
			var cnt = new long[M];
			for(long i = 0; i < N; i++)
			{
				if(!contains(s, i))
					continue;

				sum += C[i];
				for(long j = 0; j < M; j++)
					cnt[j] += A[i, j];
			}
			if(cnt.All(x => (x >= X)))
				chmin(ref min, sum);
		}
		WriteLine(min < long.MaxValue ? min : -1);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 28228
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>
#include<queue>

using namespace std;

#define ll long long
typedef pair<ll, ll> P;

int main(){
    string a , b , c ;
    cin >> a >> b >> c ;
    int dif = 'A' - 'a';
    // cout << dif;
    char e = a[0] + dif;
    char f = b[0] + dif;
    char g = c[0] + dif;
    cout << e << f << g << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

#define MAXN 100000
#define MOD 1000000007

using namespace std;

class TreeNode
{
public:
    vector<int> ch; // children
    unsigned long long wd, bd; // number of ways when the node painted into white and black

    TreeNode(): wd(1), bd(1) {}
};

TreeNode tree[MAXN+1];
vector<int> g[MAXN+1];

void build(int rt)
{
    int temp;
    queue<int> q;
    set<int> vis;

    q.push(rt);

    while(!q.empty())
    {
        temp = q.front(); q.pop();
        if(vis.count(temp)) continue;
        else vis.insert(temp);

        vector<int>& node = g[temp];
        for(int i=0, sz=node.size() ; i<sz ; i++)
        {
            if(vis.count(node[i])) continue;

            tree[temp].ch.push_back(node[i]);
            q.push(node[i]);
        }
    }
}

void dfs(TreeNode& node)
{
    if(node.ch.size() == 0) return;

    int sz = node.ch.size();
    for(int i=0 ; i<sz ; i++) dfs(tree[node.ch[i]]);

    // painted into black
    for(int i=0 ; i<sz ; i++)
    {
        node.bd *= tree[node.ch[i]].wd;
        node.bd %= MOD;
    }

    // painted into white
    for(int i=0 ; i<sz ; i++)
        node.wd = node.wd * ((tree[node.ch[i]].wd + tree[node.ch[i]].bd) % MOD) % MOD;
}

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

    int n, x, y;
    cin >> n;

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

    build(1);

    dfs(tree[1]);
    cout << (tree[1].wd + tree[1].bd) % MOD;

    return 0;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define print_vec(vec) for(int i=0;i<sz(vec);i++) cout << vec[i] << " ";
#define FORin(vec) for(int& x : vec) cin>>x;

void go(){
	string s,t;cin>>s>>t;
	bool ans=false;
	for(int i=0;i<sz(s);i++) {
		string tmp=s.back() + s.substr(0,sz(s)-1);
		if(tmp==t) {
			ans=true;
			break;
		}
		s=tmp;
	}
	if(ans) cout << "Yes";
	else cout << "No";
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3668
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 13;
const int MAXM = 2010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int odd = n / 2 + n % 2;
    cout << fixed << setprecision(9) << 1.0 * odd / n;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0 ;
		int arr[] = new int[n];
		for(int i = 0; i< n ; i++) {
			arr[i] = scan.nextInt();
		}
		int arr2[] = arr.clone();
		Arrays.sort(arr);
		
		for(int i = 0 ; i < n ; i++) {
			if(arr[i] != arr2[i]) {
				count++;
			}
		}
		//System.out.println(count);
		
		if(count == 0 || count ==2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
	}
}


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

int maxar(vector<int> arra){
  int maxi=0;
  for(int i=0;i<arra.size();i++){
    if (maxi<arra[i]){maxi=arra[i];}
  }
  return maxi;
}

int iwhere(vector<int> arra,int val){
  for(int i=arra.size();i>=0;i--){
    if (arra[i]==val){return i;}
  }
  return -1;
}

//idx目を削除してつめる関数
void delindx(vector<int> &arra,int idx){
  for(int i=idx;i<=arra.size();i++){
    if ((i+1)<arra.size()){
      arra[i]=arra[i+1];
    }else{
      arra[i]=0;
    }
  }
  return;
}


int main(){
  int N,maxi=0;
  cin>>N;
  vector<int> ar(N);
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    cin>>ar[i];
  }
  
  maxi=maxar(ar);
  int nowmax=maxi;
  //int wi=N-1;
  int creakflg=0;
  
  for(int wi=N-1;wi>=0;wi--){
    creakflg=0;
    for(int i=wi+1;i>=1;i--){
      if (ar[i-1]==i){
        delindx(ar,i-1);
        ans[wi]=i;
        creakflg=1;
        //wi--;
        break;
      }
    }
    
    
    if (creakflg==0){
      //kainasi
      cout<<(-1)<<endl;
      return 0;
    }
  }

  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int n;
int a[200001];

bool validate(int mid)
{
	map<int, int> m;
	for(int i = 1; i < n; i++){
		if(a[i - 1] < a[i]){
			continue;
		}
		if(mid == 1) return false;
		auto itr = m.find(a[i]);
		if(itr == m.end()){
			m[a[i]] = 2;
			itr = m.find(a[i]);
			m.erase(++itr, m.end());
		} else {
			// a[i]以下で、かつm[v]がundefindedまたはm[v] < midとなるようなvを探す
			for(int j = a[i]; j >= 1; j--){
				itr = m.find(j);
				if(itr == m.end()){
					// m[j]がundefinedなのでこれをインクリメント
					m[j] = 2;
					itr = m.find(j);
					m.erase(++itr, m.end());
					break;
				} else if(m[j] < mid){
					// m[j] < midなるjなのでこれをインクリメント
					(*itr).second++;
					m.erase(++itr, m.end());
					break;
				} else if(j == 1){
					return false;
				}
			}
		}
	}
	return true;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int l = 0, r = n;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(validate(mid)) r = mid;
		else l = mid;
	}
	cout << r << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int n[]={a,b,c};
	int i,j,tmp;
	
	for(i=0; i<3; i++){
		for(j=i+1; j<3; j++){
			if(n[i]>n[j]){
				tmp=n[i];
				n[i]=n[j];
				n[j]=tmp;
			}
		}
	}
	int x=n[2];
	for(i=1; i<=k; i++){
		x=x*2;
	}
	printf("%d\n",n[0]+n[1]+x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt[214514];
int main(){
	ll n,q;
	string s;
	cin>>n>>q>>s;
	s="B"+s;
	for(int i=1;i<=n;i++){
		cnt[i]+=cnt[i-1];
		if(s.substr(i-1,2)=="AC")cnt[i]++;
	}
	while(q--){
		ll l,r;
		cin>>l>>r;
		if(s[l]=='C'&&s[l-1]=='A')cout<<cnt[r]-cnt[l-1]-1<<endl;
		else cout<<cnt[r]-cnt[l-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4608
#include<stdio.h>
main(){
  int n,i,sum;
  while(scanf("%d",&n)!=EOF){
    int l=2,a[1000001]={0};
    sum=0;
    while(n>=l*l){
      if(a[l]==0){
	for(i=l+l;i<=n;i+=l){
	  a[i]=1;
	}
      }
      l++;
    }
    for(i=2;i<=n;i++){
      if(a[i]==0){
	sum++;
      }
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
ll h,w;
ll g(ll a, ll b){
    ll ap = a/2;
    ll bp = b/2;
    if(abs(ap*b-(a-ap)*b) < abs(bp*a-(b-bp)*a))
        return ap*b;
    return bp*a;
}
ll f(ll a, ll b){
    ll c = h*w-a-b;
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);
    if(a > c) swap(a,c);
    return c-a;
}
int main(){
    cin >> h >> w;
    ll ans = min(h,w);
    for(int i = 0; i <= h; ++i)
        ans = min(ans,f(w*i,g(h-i,w)));
    swap(h,w);
    for(int i = 0; i <= h; ++i)
        ans = min(ans,f(w*i,g(h-i,w)));
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
    int parent;
    int left;
    int right;
}Node;

Node T[MAX];
int n;

void preOrder(int);
void inOrder(int);
void postOrder(int);

int main(){
    int i,id,left,right,root;

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

    for(i=0;i<n;i++){
        scanf("%d%d%d",&id,&left,&right);
        
        T[id].left=left;
        T[id].right=right;
        
        if(left!=NIL) T[left].parent=id;
        if(right!=NIL) T[right].parent=id;
    }

    for(i=0;i<n;i++){
        if(T[i].parent==NIL) root=i;
    }

    printf("Preorder\n");
    preOrder(root);
    printf("\n");

    printf("Inorder\n");
    inOrder(root);
    printf("\n");

    printf("Postorder\n");
    postOrder(root);
    printf("\n");

    return 0;
}

void preOrder(int u){
    if(u==NIL) return;

    printf(" %d",u);
    preOrder(T[u].left);
    preOrder(T[u].right);
}

void inOrder(int u){
    if(u==NIL) return;

    inOrder(T[u].left);
    printf(" %d",u);
    inOrder(T[u].right);
}

void postOrder(int u){
    if(u==NIL) return;

    postOrder(T[u].left);
    postOrder(T[u].right);
    printf(" %d",u);
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  set<ll> st;st.insert(a);st.insert(b);st.insert(c);
  YesNo(st.size()==2);
  return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll K, A, B; cin >> K >> A >> B;
   if(A >= B - 1 || K < A){
      cout << (1 + K) << endl;
      return 0;
   }
   cout << A + (B - A) * ((K - A + 1) / 2) + (K - A + 1 ) % 2<< endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{int s[10],sum,i;


  sum=0;
  for(i=0; i<10; i++)
    scanf("%d",&s[i]);

   for(i=0; i<10; i++)
     {  sum=sum+s[i];}

  printf("%d\n",sum);

  return(0);

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; else return gcd(b, a % b); }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
template <class T> bool amax(T &x, T y) { if (x < y) { x = y; return 1; } else return 0; }
template <class T> bool amin(T &x, T y) { if (x > y) { x = y; return 1; } else return 0; }
template <class T> i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template <class T> i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }

int main() {
  ioinit();
  int a, b, q;
  cin >> a >> b >> q;
  vi64 s(a + 2), t(b + 2);
  s[0] = t[0] = -1e18, s[a + 1] = t[b + 1] = 1e18;
  reps(i, a) cin >> s[i];
  reps(i, b) cin >> t[i];
  rep(i, q) {
    i64 x;
    cin >> x;
    int sr = ubi(s, x), sl = sr - 1;
    int tr = ubi(t, x), tl = tr - 1;
    i64 ans = 1e18;
    amin(ans, abs(x - s[sl]) + abs(s[sl] - t[tl]));
    amin(ans, abs(x - t[tl]) + abs(t[tl] - s[sl]));
    amin(ans, abs(x - s[sr]) + abs(s[sr] - t[tr]));
    amin(ans, abs(x - t[tr]) + abs(t[tr] - s[sr]));
    amin(ans, abs(x - s[sl]) + abs(x - t[tr]) * 2);
    amin(ans, abs(x - s[sr]) + abs(x - t[tl]) * 2);
    amin(ans, abs(x - t[tl]) + abs(x - s[sr]) * 2);
    amin(ans, abs(x - t[tr]) + abs(x - s[sl]) * 2);
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 2944
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


A, B = LI()
# 上から4つまででいい
# 0,3,7,11の順に0になるから。
# じゃあ最大の0は今どこなのか？
if B % 4 == 0:
    # 0になるのが1つ前
    pass
elif B % 4 == 1:
    # 0 になるのが2つ前
    B = B^(B-1)
elif B % 4 == 2:
    # 0になるのが３つ前
    B = B^(B-1)^(B-2)
elif B%4 == 3:
    #  B = B^(B-1)^(B-3)^(B-4)
    B = 0
    
A = A - 1
if A % 4 == 0:
    pass
elif A % 4 == 1:
    A = A ^ (A-1)
elif A % 4 == 2:
    A = A ^ (A - 1) ^ (A - 2)
else:
    #  A = A ^ (A - 1) ^ (A - 2) ^ (A - 3)
    A = 0

#  print(A,B)
print(A^B)
#  print(functools.reduce(lambda i, j: int(i) ^ int(j), AB))


Measured memory_bytes: 65516
/**
*    created: 23.05.2020 00:33:32
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a - c) * (b - d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool a[200001];
bool d[200001];
int main(){
  cin>>n>>m;
  set<int> s;
  set<int> t;
  for(int i=0;i<m;i++){
    int b,c;cin>>b>>c;
    b--;c--;
    if(b==0){
      s.insert(c);
    }
    if(c==n-1){
      t.insert(b);
    }
    a[b]=1;
    d[c]=1;
  }
  for(int i=0;i<n;i++){
    if(a[i]==1 && d[i]==1){
      if(s.find(i)!=s.end() && t.find(i)!=t.end()){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 9984
#include <iostream>

#include <vector>
#include <algorithm>

int main()
{
    auto n = std::size_t(0);
    auto m = std::size_t(0);

    std::cin >> n >> m;

    // graph : vector bool to express vertecies
    auto graph = std::vector<std::vector<bool>>(n, std::vector<bool>(n, false));
    for (std::size_t i = 0; i < m; ++i)
    {
        auto a = std::size_t(0);
        auto b = std::size_t(0);
        std::cin >> a >> b;
        graph[a - 1][b - 1] = true;
        graph[b - 1][a - 1] = true;
    }

    auto v = std::vector<std::size_t>(n);
    for (auto i = std::size_t(0); i < n; ++i) v[i] = i;

    auto count = std::size_t(0);
    do
    {
        auto check = bool(true);
        for (auto it = v.begin(); it != v.end() - 1; ++it)
        {
            check &= graph[*it][*(it + 1)];
            if (!check) break;
        }
        if (check) ++count;

    } while (std::next_permutation(v.begin() + 1, v.end()));

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
n=6
a=[int(input()) for i in range(n)]
dero=np.zeros((25,2))
for i in range(5):
  for j in range (5):
    dero[i*5+j][0]=a[j]-a[i]
    dero[i*5+j][1]=a[5]
frag=0
for i in range(25):
  if dero[i][0]>dero[i][1]:
    frag=1
if frag==0:
  print("Yay!")
else:
    print(":(")

Measured memory_bytes: 12444
program sumofthreeintegers
  implicit none
  integer :: k, s
  integer :: i, j, c

  read(*,*) k, s

  do i = 0, k
     do j = 0, k
        if ( s-i-j>=0 .and. s-i-j<=k ) then
           c = c + 1
        end if
     end do
  end do

  write(*,'(i0)') c
  stop
end program sumofthreeintegers


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

using namespace std;

bool check(string &s) {
  if (s.find("AGC") != string::npos) {
    return false;
  }

  for (int i = 1; i < s.size(); ++i) {
    swap(s[i], s[i - 1]);
    if (s.find("AGC") != string::npos) {
      return false;
    }
    swap(s[i], s[i - 1]);
  }

  return true;
}

const int md = 1e9 + 7;

int solve(string s, int n, map<pair<string, int>, int> &memo) {
  auto memo_key = make_pair(s, n);
  if (memo.count(memo_key) > 0) {
    return memo[memo_key];
  }

  if (!check(s)) {
    return 0;
  }

  if (n == 0) {
    return 1;
  }

  vector<char> next_chs{'A', 'C', 'G', 'T'};
  int ans = 0;
  for (auto next_ch : next_chs) {
    string s2;
    if (s.size() > 3) {
      copy(s.begin() + s.size() - 3, s.end(), back_inserter(s2));
    } else {
      copy(s.begin(), s.end(), back_inserter(s2));
    }

    s2 += next_ch;
    ans = (ans + solve(s2, n - 1, memo)) % md;
  }

  return memo[memo_key] = ans % md;
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  map<pair<string, int>, int> memo;
  int ans = solve("", n, memo);
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 2688
use proconio::{fastout, input};
use std::cmp::min;
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize
    }
    let mut div = Vec::new();
    for i in 1..=min(a, b) {
        if a % i == 0 && b % i == 0 {
            div.push(i);
        }
    }
    div.reverse();
    println!("{}", div[k - 1]);
}


Measured memory_bytes: 2176
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] t = new int[n+1], x = new int[n+1], y = new int[n+1];
			for (int i = 1; i < n+1; i++) {
				t[i] = in.nextInt();
				x[i] = in.nextInt();
				y[i] = in.nextInt();
			}

			for (int i = 1; i < n+1; i++) {
				int dt = t[i] - t[i-1];
				int dx = x[i] - x[i-1];
				int dy = y[i] - y[i-1];
				if (dx + dy > dt) {
					out.println("No");
					return;
				}
				if ((dt - abs(dx + dy)) % 2 == 0) {
					continue;
				} else {
					out.println("No");
					return;
				}
			}
			out.println("Yes");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

typedef long long ll;

int main() {
  int N, D, X[10][10];
  std::cin >> N >> D;
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < D; j++) {
      std::cin >> X[i][j];
    }
  }

  int ans = 0;
  for (size_t i = 0; i < N; i++) {
    for (size_t j = i + 1; j < N; j++) {
      int d2 = 0;
      for (size_t k = 0; k < D; k++) {
        int sub = X[i][k] - X[j][k];
        d2 += sub * sub;
      }
      for (size_t n = 1; n <= d2; n++) {
        if(n * n == d2) {
          ++ans;
          break;
        }
      }
    }
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    a = int(input())

    print(n**2-a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62404
n=int(input())
l=[]
for i in range(n):
    s,p=map(str,input().split())
    l.append([s,int(p),i+1])
l=sorted(l,reverse=True,key=lambda x:x[1])
l = sorted(l, key=lambda x:x[0])
 
for i in range(n):
    print(l[i][-1])

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int b[100000];
signed main(){
  int a,b=0,c;
  cin>>a;
  c=a;
  for(int i=0;i<3;i++){
    b=b*10+c%10;
    c=c/10;
  }
  if(b==a){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
    
  return(0);
}


Measured memory_bytes: 256
def read_input():
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    return op, a, b

def submit():
    op, a, b = read_input()

    if op == '+':
        print(a + b)
    else:
        print(a - b)


if __name__ == '__main__':
    submit()


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


using namespace std;


const int N = 1e5 + 10;
struct node{
    int t, x, y;
}A[N];

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

    A[0].t = A[0].x =  A[0].y = 0;

    for(int i = 1; i <= n; i ++)
        cin >> A[i].t >> A[i].x >> A[i].y;
    bool is = true;
    for(int i = 1; i <= n; i++){
        int sum = abs(A[i].x - A[i-1].x) + abs(A[i].y - A[i-1].y);
        if(sum + A[i-1].t > A[i].t) is = false;

        if(((A[i].x + A[i].y)%2) != (A[i].t % 2)) is = false;
    }

    cout << (is ? "Yes":"No") << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
typedef long long ll;
int main() {
    string b;
    cin >> b ;
    if (b=="A"){
        printf("T");
    }
    else if(b=="T"){
        printf("A");

    }
    else if(b=="C"){
        printf("G");

    }
    else{
        printf("C");
    }
    // cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 3e3+10;
const int M = 1e6+10;
/*=================================================================================*/

ll dp[N][N], n, ans;
char chr[N];

int main() {
   cin>>n;
   scanf("%s", chr+1);
   dp[1][1] = 1;
   for(int i = 2; i <= n; ++i) {
      if(chr[i-1] == '<') {
         dp[i][1] = 0;
         for(int j = 2; j <= i; ++j) {
            dp[i][j] = (dp[i][j-1] + dp[i-1][j-1]) % mod;
         }
      } else {
         dp[i][i] = 0;
         for(int j = i-1; j; --j) {
               dp[i][j] = (dp[i][j+1] + dp[i-1][j]) % mod;
         }
      }
   }
   for1(i, n) {
      ans = (ans + dp[n][i]) % mod;
   }
   cout<<ans<<endl;
}

/*
 4 5 6 7 3 2 1
*/

Measured memory_bytes: 49928
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;

int main(){
  string S;
  cin >> S;
  if(S[2]==S[3] && S[4]==S[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
signed main(){
    int n;
    cin>>n;
    double sum=0;
    for(int i=0;i<n;i++){
        double a;
        string s;
        cin>>a>>s;
        if(s=="JPY"){
            sum+=a;
        }
        else{
            sum+=380000*a;
        }
    }
    double c=sum;
    printf("%.12Lf\n",c);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,A,B;cin >> N >> A >> B;
    cout << min(A*N,B) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * This line was copied from template
 * This is bsol.cpp
 * 
 * @author: Nikolay Kalinin
 * @date: Sat, 16 Mar 2019 15:02:50 +0300
 */
#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 200005;
const int MOD = 1000000007;

int a[maxn], last[maxn], nxt[maxn];
int n;
int dp[maxn];

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

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < maxn; i++) last[i] = n;
    for (int i = n - 1; i >= 0; i--)
    {
        nxt[i] = last[a[i]];
        last[a[i]] = i;
    }
    dp[0] = 1;
    for (int i = 0; i < n - 1; i++)
    {
        add(dp[i + 1], dp[i]);
        if (nxt[i] != i + 1) add(dp[nxt[i]], dp[i]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1LL<<50;

int N, M;
int a[2010], b[2010];
ll c[2010];
ll d[1010];
bool negative[1010];
int main() {
    cin>>N>>M;
    REP(i,0,M){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        c[i] = -c[i];
    }
    REP(i,0,N){
        d[i] = inf;
    }
    d[0] = 0;
    REP(j,0,N-1){
        REP(i,0,M){
            if(d[a[i]]==inf) continue;
            d[b[i]] = min(d[b[i]], d[a[i]] + c[i]);
        }
    }
    REP(j,0,N-1){
        REP(i,0,M){
            if(d[a[i]]==inf) continue;
            if(d[b[i]] > d[a[i]] + c[i]){
                d[b[i]] = d[a[i]] + c[i];
                negative[b[i]]=true;
            }
            if(negative[a[i]]) negative[b[i]]=true;
        }
    }
    if(negative[N-1]) p("inf");
    else p(-d[N - 1]);
    return 0;
}

Measured memory_bytes: 256
A, B, C = [int(x) for x in input().split()]

d = sorted([A, B, C], reverse=True)
parity = (A + B + C) % 2

if (parity == 0 and d[0] % 2 == 1) or (parity == 1 and d[0] % 2 == 0):
    goal = d[0] + 1
else:
    goal = d[0]

print((goal * 3 - (A + B + C)) // 2)

Measured memory_bytes: 3060
use strict;
use warnings;

my $buf = <>;
chomp $buf;

$buf =~ s/eraser//g;
$buf =~ s/erase//g;
$buf =~ s/dreamer//g;
$buf =~ s/dream//g;
if($buf eq ""){
	print "YES\n";
}else{
	print "NO\n";
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int N, A, B, C;
vector<int>l;
int rec(int i, int a, int b, int c) {
	if (i == N) {
		if (!a || !b || !c)return INF;//A,B,Cいずれも竹は1本は必ず使ってないとダメ
		return abs(a - A) + abs(b - B) + abs(c - C);
	}
	//今ある竹を採用しない場合
	int res = rec(i + 1, a, b, c);
	//A,B,Cを使う場合
	//(a?10:0)とかは最初の１本目は合体コストなし2本目からはコスト10
	chmin(res, rec(i + 1, a + l[i], b, c) + (a ? 10 : 0));
	chmin(res, rec(i + 1, a, b + l[i], c) + (b ? 10 : 0));
	chmin(res, rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0));

	return res;
}
int main() {
	cin >> N >> A >> B >> C;
	l.resize(N);
	REP(i, N)cin >> l[i];
	cout << rec(0, 0, 0, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    long long temp=0;
    if(a>b)
    {
        while(a--)
        {
            temp=temp*10+b;
        }
    }
    else
    {
        while(b--)
        {
            temp=temp*10+a;
        }
    }
    cout<<temp;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
        	String S = in.next();
        	
        	int ans1 = 0;
        	for (int i = 0; i < S.length(); ++i) {
        		if ((i % 2 == 1 && S.charAt(i) == '0') || (i % 2 == 0 && S.charAt(i) == '1')) {
        			++ans1;
        		}
        	}
        	
        	int ans2 = 0;
        	for (int i = 0; i < S.length(); ++i) {
        		if ((i % 2 == 0 && S.charAt(i) == '0') || (i % 2 == 1 && S.charAt(i) == '1')) {
        			++ans2;
        		}
        	}
        	
        	out.print(Math.min(ans1, ans2));
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; ++i) arr[i] = this.nextInt();
            return arr;
        }
    }
}


Measured memory_bytes: 24532
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e6 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
inline void print(ll n){
	if(!n) return ;
	ll p = n%26;
	
	if(p) print(n/26);
	else print((n-26)/26),p += 26;
	
	printf("%c",(p-1)+'a');
	return ;
}

int main()
{	
	ll n;
	scanf("%lld",&n);
	print(n);
	return 0;
}

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

int main(){
	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int> count(N);
	
	for (int i = 0; i < Q; i++)
	{
		int a;
		cin >> a;
		count[--a]++;
	}

	for (int i = 0; i < N; i++)
	{
		if (K - Q + count[i] > 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[allow(unused_macros)]
macro_rules! echo {
    ($ x : expr ) => {
        println!("{}", $x);
    };
}

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        X: i128,
        K: i128,
        D: i128,
    }
    if X.abs() >= K * D {
        echo!((X.abs() - K * D).abs());
    } else {
        let toutatu_count = X.abs() / D;
        let remain_K = K - toutatu_count;
        let anss = vec![(X.abs() - D * toutatu_count).abs(), (X.abs() - D * (toutatu_count + 1)).abs()];
        echo!(anss[(remain_K % 2) as usize]);
    }
}


Measured memory_bytes: 2196
from itertools import combinations
import math
n = int(input())
li_point = list()
li_kyori = list()
for i in range(n):
    li_point.append(list(map(int, input().split())))


for x, y in combinations(range(n), 2):
    li_kyori.append(
        math.sqrt(
            abs(li_point[x][0] - li_point[y][0]) ** 2 +
            abs(li_point[x][1] - li_point[y][1]) ** 2
        )
    )

ave = sum(li_kyori) / len(li_kyori)
print(ave * (n - 1))


Measured memory_bytes: 3064
import itertools

N = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))

seq = [i for i in range(1,N+1)]
perm = [int(''.join(map(str,p))) for p in itertools.permutations(seq)]
perm.sort()

a = perm.index(P) + 1
b = perm.index(Q) + 1
print(abs(a-b))


Measured memory_bytes: 4728
#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--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
const int N=1e5+5;
int x,y,a,b,c,p[N],q[N],r[N];
priority_queue<int>qw;
int main()
{
    sc2(x,y);sc2(a,b);sc(c);
    rep(i,1,a)sc(p[i]);
    rep(i,1,b)sc(q[i]);
    rep(i,1,c)sc(r[i]);
    sort(p+1,p+a+1);
    sort(q+1,q+b+1);
    sort(r+1,r+c+1);
    rep(i,1,c)qw.push(r[i]);
    long long sum=0;
    rep(i,a-x+1,a){
        //cout<<p[i]<<" "<<qw.top()<<endl;
        if(qw.top()>p[i]){
            sum+=qw.top();
            qw.pop();
            qw.push(p[i]);
        }else{
            rep(j,i,a)sum+=p[j];
            break;
        }
    }
    rep(i,b-y+1,b){
        //cout<<q[i]<<" "<<qw.top()<<endl;
        if(qw.top()>q[i]){
            sum+=qw.top();
            qw.pop();
            qw.push(q[i]);
        }else{
            rep(j,i,b)sum+=q[j];
            break;
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 2044
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 1e5 + 5;

ll dp[500][500];
ll a[500], p[500];

ll sum(ll l, ll r) {
	return p[r] - (l ? p[l - 1] : 0);
}


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	for (ll i = 0; i < n; i++) cin >> a[i];
	p[0] = a[0];
	for (ll i = 1; i < n; i++) {
		p[i] = p[i - 1] + a[i];
	}

	for (ll i = 0; i < 500; i++) {
		for (ll j = 0; j < 500; j++) dp[i][j] = LLONG_MAX;
	}
	for (ll i = 0; i < n; i++) {
		dp[i][i] = a[i];
	}

	for (ll len = 2; len <= n; len++) {
		for (ll i = 0; i + len - 1 < n; i++) {
			ll j = i + len - 1;
			for (ll k = i; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum(i, j));
			}
		}
	}

	cout << dp[0][n - 1] - sum(0, n - 1) << endl;


	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	for (int x = 0;x < n;x++) {
		string a, b;
		cin >> a >> b;
		int za = a.size();
		int zb = b.size();
		vector<int>v;

		for (int i = 0;i < max(za, zb);i++) {
			if (i < min(za, zb)) {
				int c = za - i - 1;
				int d = zb - i - 1;
				v.push_back((a[za - i - 1] - '0') + (b[zb - i - 1] - '0'));
			}
			else {
				if (za < zb)v.push_back(b[zb - i - 1] - '0');
				else v.push_back((a[za - i - 1]) - '0');
			}
		}
		int z = v.size();
		for (int i = 0;i < v.size();i++) {
			if (i != z- 1 && v[i] >= 10) {
				v[i] -= 10;
				v[i + 1]++;
			}
		}
		if (v.size() > 80)cout << "overflow";
		else if (v.size() == 80 && v[79] >= 10)cout << "overflow";
		else 	for (int i =z - 1;i > -1;i--)cout << v[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    cout << min(b / a, c) << endl;
}


Measured memory_bytes: 256
n=int(input())
p=input()
P=p.split()
count=0
for i in range(len(P)):
    P[i]=int(P[i])
for j in range(len(P)):
    if P[j]!=j+1:
        count+=1
if count<=2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060