akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;
	static long pow = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		long n =sc.nextLong();
		long m =sc.nextLong();

		if(n >= m/2){
			System.out.println(m/2);
		}else{
			long ans = 0;
			ans += n;
			m -= n*2;
			ans += m/4;
			System.out.println(ans);
		}
		
		
	}
	
	
	
}

class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 23124
#include<stdio.h>

int Partition(int*,int,int);
int n;
int main(){

  int A[100001],i,m;

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

  m=Partition(A,0,n-1);

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

  printf("%d\n",A[i]);

  return 0;
}

int Partition(int* A,int p,int r){

  int x,i,j,tmp;

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

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

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int z;
		cin >> z;
		a.push_back(z-1);
	}
	int x = 0, c = 0;
	for (;;) {
		if (x == 1) {
			cout << c << endl;
			break;
		}
		if (c >= n) {
			cout << "-1" << endl;
			break;
		}
		c++;
		x = a[x];
	}
	return 0;
}

Measured memory_bytes: 892
#include<cstdio>

int div_ceil(int n, int m) {
	return (n + m - 1) / m;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) {
		int a;
		scanf("%d", &a);
	}
	printf("%d\n", div_ceil(n-1, k-1));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b;
    cin>>a>>b;
    for (long long int i=0;i<=1000000000;i++) {
        if (abs(a-i)==abs(b-i)) {
            cout<<i<<endl;
            break;
        } else if (i==1000000000) {
            cout<<"IMPOSSIBLE"<<endl;
        }
    }
}


Measured memory_bytes: 256
"""
import bisect
N = int(input())
ans = 0
hikidashi_list = [1, 6, 9]
tmp_6 = 6
tmp_9 = 9
while tmp_6 < N:
    tmp_6 *= 6
    hikidashi_list.append(tmp_6)

while tmp_9 < N:
    tmp_9 *= 9
    hikidashi_list.append(tmp_9)

hikidashi_list.sort()
while N > 0:
    now = bisect.bisect_left(hikidashi_list, N)
    if now == 0:
        N -= 1
    else:
        N -= hikidashi_list[now-1]
    ans += 1
print(ans)

# 貪欲に大きいお金から取るのでは無理
# N = 13 解3 (6, 6, 1)  本法5 (9, 1, 1, 1, 1)
"""

# DP
N = int(input())
dp = [100000000] * (N+1)
dp[0] = 0
dp[1] = 1
ans = 0
hikidashi_list = [1, 6, 9]
tmp_6 = 6
tmp_9 = 9
while tmp_6 < N:
    tmp_6 *= 6
    hikidashi_list.append(tmp_6)

while tmp_9 < N:
    tmp_9 *= 9
    hikidashi_list.append(tmp_9)
hikidashi_list.sort()
for i in range(N+1):
    for k in hikidashi_list:
        if i + k > N :
            break
        dp[i+k] = min(dp[i] + 1, dp[i+k])

print(dp[N])

Measured memory_bytes: 3828
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    //縦＝X,横＝Yとして管理
    //初手はX=3通り、Y=6通り
    //二手目以降は、直左がXのX=2通り、直左がYのX=1通り、直左がXのY=2通り,直左がYのY=3通り
    ArrayList<String> mg = new ArrayList<String>();
    boolean iscontinue=false;
    for(int i=0;i<N-1;i++){
      if(S.substring(i,i+1).equals(S.substring(i+1,i+2))&&!iscontinue){
      mg.add("Y");
      iscontinue=true;
      }else if(iscontinue){
      iscontinue=!iscontinue;  
      continue;
      }else{
      mg.add("X");
      iscontinue=false;
      }
    }
    if(!iscontinue){
      mg.add("X");
    }
    long answer =1;
    long mod =1000000007;
    String tmp="";
    for(String s :mg){
      if(answer==1){
        if(s.equals("X")){
          answer=3;
          tmp="X";
        }else{
          answer=6;
          tmp="Y";
        }
      }else{
        if(s.equals("X")&&tmp.equals("X")){
          answer=(answer*2)%mod;
          tmp="X";
        }else if(s.equals("X")&&tmp.equals("Y")){
          answer=answer;
          tmp="X";
        }else if(s.equals("Y")&&tmp.equals("X")){
          answer=(answer*2)%mod;
          tmp="Y";
        }else{
          answer=(answer*3)%mod;
          tmp="Y";
        }
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 23252
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		for(int i = N - 1; i >= 0; --i) {
			System.out.print(A[i]);
			if(i != 0) System.out.print(" ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 26076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
ll pre[100002][2];
ll fact[1000002];
ll inv(ll a,ll b){
   ll res=1;
   while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b/=2;
   }
   return res;
}
ll ncr(ll n,ll r){
  if(r<0 or r>n) return 0;
  return (((fact[n]*inv(fact[r],mod-2))%mod)*inv(fact[n-r],mod-2))%mod;
}
ll dp[100002][13];
ll a[100002],b[100002];
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
      ll n,i;
      cin>>n;
      for(i=0;i<=n;i++) cin>>a[i];
        for(i=0;i<n;i++) cin>>b[i];
          ll ans=0,res=a[n];
          for(i=n-1;i>=0;i--){
            ll pp=min(b[i],res);
            ans+=pp;
            b[i]-=pp;
            ans+=min(b[i],a[i]);
            res=a[i]-min(b[i],a[i]);
          }
          cout<<ans;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int idx;
string s;
int rec(){
  idx++;
  bool isNumber = false;
  if(s[idx]!='[' && s[idx]!=']'){
    string t = "";
    while(s[idx]!='[' && s[idx]!=']'){
      t += s[idx++];
    }
    idx++;
    return stoi(t) / 2 + 1;
  }
  vector<int> v;
  while(s[idx]!=']'){
    v.push_back(rec());
  }
  sort(v.begin(), v.end());
  int ret = 0;
  FOR(i, 0, v.size() / 2 + 1){
    ret += v[i];
  }
  idx++;
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  FOR(i,0,n){
    cin >> s;
    idx = 0;
    cout << rec() << endl;
  }
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  int ans=min(a,c);
  c-=ans;
  ans+=min(b,c)*2;
  int t=min(b,c);
  b-=t;
  c-=t;
  ans+=b;
  if(c>0)ans++;
  cout<<ans<<endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::set<std::string> set;
	for (int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		set.insert(s);
	}
	printf("%d\n", (int) set.size());
	return 0;
}


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

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

  int n;
  int s, d;
  int ans;
  int temp;

  cin >> n;
  for(int i = 0;i < n;++i){
    cin >> s >> d;
    ans = 0;

    while(s != d){
      stack<int> sta;
      if(s != 0){
	for(int j = 1;j <= abs(s);j <<= 1){
	  if(abs(s) % j == 0){
	    sta.push(j);
	  }
	}
      }else{
	for(int j = 1;j <= 1000000000;j <<= 1){
	  sta.push(j);
	}
      }

      while(1){
	temp = sta.top(); sta.pop();
	if(s + temp <= d){
	  break;
	}
      }

      // cout << s << "(" << temp << ")" << " -> ";

      s += temp;
      ++ans;
    }
    // cout << d << endl;

    cout << ans << endl;

  }

  return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,k;
    cin>>n>>k;
    vl p(n),c(n);
    vll cc(n,vl(n,0));
    FOR(i,0,n){
        cin>>p[i];
        p[i]--;
    }
    FOR(i,0,n){
        cin>>c[i];
    }
    LL ans=-mod;
    FOR(i,0,n){
        ans=max(ans,c[i]);
        LL nw=i,t=0;
        FOR(j,0,min(n,k)){
            cc[i][j]+=c[p[nw]];
            if(j!=0)cc[i][j]+=cc[i][j-1];
            ans=max(cc[i][j],ans);
            nw=p[nw];
            if(nw==i){
                t=j+1;
                break;
            }
        }
        if(t!=0){
            LL rest=k%t,off=k/t*cc[i][t-1];
            ans=max(ans,off);
            FOR(j,0,rest){
                ans=max(ans,off+cc[i][j]);
            }
            if(k/t>1){
                LL rest2=k%t+t,off2=(k/t-1)*cc[i][t-1];
                ans=max(ans,off2);
                FOR(j,0,rest2){
                    ans=max(ans,off2+cc[i][j%t]);
                }
            }
        }
        
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 198876
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	//入力
	in(string, S, T);

	//S->T対応表
	char st[26] = {};

	//恒等写像で初期化
	for (int i = 0; i < 26; ++i)
		st[i] = 'a' + i;

	//スワップするやつ
	auto swap_c = [&](char c1, char c2) {
		std::swap(st[c1 - 'a'], st[c2 - 'a']);
	};
	//逆写像を得る
	auto get_rev = [&](char c) {
		for (int n = 0; n < 26; ++n)
			if (st[n] == c)
				return 'a' + n;
		return 0;	//警告抑止
	};

	//最初からなぞって、相違があったらスワップ
	loop(i, S.size())
		if (st[S[i] - 'a'] != T[i])
			swap_c(S[i], get_rev(T[i]));

	//テーブルをもとに置換を適用
	loop(i, S.size())
		S[i] = st[S[i] - 'a'];

	//結果の出力
	YesNo(S == T);
}


Measured memory_bytes: 916
#include <cstdio>
#include <cassert>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;

typedef long long LL;
#define X first
#define Y second
typedef pair<LL, LL> pii;
const int N = 1e6 + 100;

char s[2000000];
int main() {
	int ans = 0;
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	bool flag = false;
	s[0] = '0';
	for(int i = len; i >= 0; i --) {
		ans += min(s[i] - '0', 10 - s[i] + '0');
		
		if(s[i] > '5') s[i - 1] ++;
		else if(s[i] == '5') {
			if(s[i - 1] >= '5') s[i - 1] ++;			
		}
	}
	printf("%d\n", ans);

}


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

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a == b && b == c) cout << 1 << endl;
	else if (a == b || b == c || c == a) cout << 2 << endl;
	else cout << 3 << endl;
	return 0;
}

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

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  rep(i, n)
  {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a.begin(), a.end(),
      [](pair<int, int> x, pair<int, int> y){return x.first < y.first;});
  for(auto i : a)
    cout << i.second << " ";
  cout << endl;

  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int xmax = x;
    int ymin = y;
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        xmax = max(xmax, in);
    }
    for(int i = 1; i <= m; i++){
        int in;
        cin >> in;
        ymin = min(ymin, in);
    }
    if(xmax < ymin){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++)
        cin >> h[i];
    int sol=0, mx=0;
    for(int i=0; i<n-1; i++){
        if(h[i+1]<=h[i])
            sol++;
        else
            sol=0;
        if(sol>mx)
            mx=sol;
    }
    cout << mx;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int N, d, s[66] = { 0 };
	char C;
	cin >> N;
	while(N--){
		cin >> C >> d;
		if (C == 'S')s[d] = 1;
		if (C == 'H')s[d+13] = 1;
		if (C == 'C')s[d+26] = 1;
		if (C == 'D')s[d+39] = 1;
	}
	for (int i = 1; i <= 52; i++) {
		if (s[i]==0) {
			if (i < 14)cout << "S " << i << endl;
			else if (i < 27)cout << "H " << i-13 << endl;
			else if (i < 40)cout << "C " << i-26 << endl;
			else cout << "D " << i-39 << endl;
		}
	}	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define INF (1 << 29)

struct edge { int to, cost; };
typedef pair<int, int> P;   // firstは最短距離、secondは頂点の番号

const int MAX_V = 1000, MAX_E = 1000;

int V, E;
vector<edge> G[MAX_V];
int d[MAX_V];
bool flag[MAX_V];
int cnt=0;

int dfs(int s, int depth) {
	//cout << s <<" "<< depth << endl;
	bool F=true;
	for (int i = 0; i < V; i++) {
		if (!flag[i]) { F = false; break; }
	}
	if(F) cnt++;

	for (int i = 0; i < G[s].size(); i++) {
		edge u = G[s][i];
		int v = u.to;
		if(flag[v]) continue;
		flag[v]=true;
		dfs(v,depth+1);
		flag[v]=false;
	}

	return cnt;
}


int main() {
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		G[s].push_back(edge{ t, 1 });
		G[t].push_back(edge{ s, 1 });
	}
	flag[0]=true;
	cout << dfs(0,0) << endl;
}

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

int main() {
  long long x;cin>>x;
  long long maisu_500 = x/500;
  long long maisu_5 = x%500 / 5;

  if (x < 5) {
    cout << 0 << endl;
  } else {
    cout << (maisu_500 * 1000 + maisu_5 * 5) << endl;
  }

}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node Node;
Node *NIL;

Node *root;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z=(Node *)malloc(sizeof(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(Node *u){
  if (u==NIL)return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



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

void solve_odd(int H, int W, int d){
    for (int h = 0; h < H; ++h){
        for (int w = 0; w < W; ++w){
            if ((h + w) & 1){
                cout << 'R';
            }else{
                cout << 'Y';
            }
        }
        cout << endl;
    }
}

void f(int offset, int c, int H, int W, int d, int dd, vector<vector<int>> & A){
    int x = 0;
    int y = 0;
    if (c == 1){
        x = dd;
        y = -dd;
    }else if (c == 2){
        x = d;
        y = 0;
    }else if (c == 3){
        x = dd;
        y = dd;
    }
    x += offset;
    for (int i = 0; i < dd; ++i){
        for (int j = 0; j < dd; ++j){
            int h = i + j + x;
            int w = dd - 1 - i + j + y;
            for (int k = 0; k * d + h < H + 4 * d; ++k){
                for (int m = 0; m * d + w < W + 4 * d; ++m){
                    if ((k + m) & 1) continue;
                    if (h + k * d >= 0 and w + m * d > 0) A[h + k * d][w + m * d] = c;
                }
            }
        }
    }
}

void solve_even(int H, int W, int d){
    int dd = d / 2;
    vector<vector<int>> A(H + 4 * d, vector<int>(W + 4 * d, 0));
    for (int offset = 0; offset <= 1; ++offset){
        for (int c = 0; c < 4; ++c){
            f(offset, c, H, W, d, dd, A);
        }
    }
    string s = "RYGB";
    for (int h = d; h < H + d; ++h){
        for (int w = d; w < W + d; ++w){
            cout << s[A[h][w]];
        }
        cout << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, d;
    cin >> H >> W >> d;
    if ((d % 2) == 1){
        solve_odd(H, W, d);
    }else{
        solve_even(H, W, d);
    }
    return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  string s; cin >> s;
  ll k; cin >> k;
  int i = 0;
  while(s[i] == '1' and k > 0) {
    i++;
    k--;
  }
  if(k == 0) {
    print(1);
    return 0;
  }
  cout << s[i] << '\n';
}

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

int main() {
  int N, count = 0, button_now = 1;
  cin >> N;
  vector<int> a(N + 1);
  for(int i = 1; i < N + 1; i++){
    cin >> a.at(i);
  }
  while(button_now != 2){
    button_now = a.at(button_now);
    count++;
    if(button_now == 2){
      cout << count << endl;
      break;
    }
    if(count == N){
      cout << -1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a, b, c, k;
    cin >> a>> b >> c >> k;
    int ans = 0;
    ans += min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    ans -= k;
    cout << ans << '\n';
    return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 100000;
int n,m;
int p[MAX_N];

namespace union_find {
  int parent[MAX_N];
  int rank[MAX_N];
  void init()
  {
    for (int i = 0; i < n; i++) {
      parent[i] = i;
      rank[i] = 0;
    }
  }

  int find(int a)
  {
    if (parent[a] == a) return a;
    return parent[a] = find(parent[a]);
  }

  void merge(int a, int b)
  {
    a = find(a);
    b = find(b);

    if (a == b) return;
    if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      parent[b] = a;
      if (rank[a] == rank[b])
        rank[a]++;
    }
  }
}


int main()
{
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }

  union_find::init();
  int x,y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    union_find::merge(x-1,y-1);
  }

  int c = 0;
  for (int i = 0; i < n; i++) {
    c += union_find::find(i) == union_find::find(p[i]) ? 1 : 0;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


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


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


int main() {
    ll N;
    cin >> N;

    vector<ll> A(N);
    map<ll, ll> L, R;
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        L[(i+1) + A[i]]++;
        R[(i+1) - A[i]]++;
    }

    ll ret = 0;
    for(auto itr=L.begin(); itr != L.end(); itr++) {
        ret += (itr->second) * (R[itr->first]);
    }

    cout << ret << endl;

    return 0;    
}



Measured memory_bytes: 39004
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/9
Solved on 2019/3/9
@author: shinjisu
"""


# ABC 121
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_D_v1():
    A, B = getIntList()
    dmp((A, B))
    res = A
    for i in range(A+1, B+1):
        res = res ^ i
    dmp(res)
    return res


def prob_D_v2():
    A, B = getIntList()
    dmp((A, B))
    if (B-A) % 2 == 0:
        res = (A^B) ^ (A+B)//2
        count = (B-A)//2 
    else:
        res = (A^B)
        count = (B-A)//2
    dmp((res,count))
    if count % 2 == 0:
        res = res ^ res
    dmp(res)
    return res


def prob_D_v3():
    A, B = getIntList()
    dmp((A, B))
    pairCount = (B-A+1)//2
    dmp(pairCount, 'pairCount')
    xorAB = A ^ B
    dmp(xorAB, 'xorAB')
    res = xorAB
    if pairCount % 2 == 0:
        res = res ^ xorAB  # 0
    dmp(res)
    if (B-A+1) % 2 == 1:
        res = res ^ (A+B)//2
    dmp(res)
    return res


def answer(a, b):
    ans = 0
    if debug:
        for i in range(a, b+1):
            ans = ans ^ i
        dmp(ans, 'ans')
    return ans


def prob_D():
    A, B = getIntList()
    dmp((A, B))
    count = B-A+1
    mod4 = count % 4
    dmp((count, mod4), 'count, mod4')
    if mod4 == 0:
        if A % 2 == 0:
            res = 0
        else:
            res = A ^ 1 ^ B
    elif mod4 == 1:
        if A % 2 == 0:
            res = B
        else:
            res = A
    elif mod4 == 2:
        if A % 2 == 0:
            res = 1
        else:
            res = A ^ B
    else:  # == 3
        if A % 2 == 0:
            res = 1 ^ B
        else:
            res = A ^ 1
    dmp(res)
    #answer(A, B)
    return res


debug = False  # True False
ans = prob_D()
print(ans)
#for row in ans:
#    print(row)




Measured memory_bytes: 3192
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A')
		{
			s[i]='T';
		}
		else if(s[i]=='T') s[i]='A';
		else if(s[i]=='G') s[i]='C';
		else if(s[i]=='C') s[i]='G';
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    n--;
    int q1 = 1, q2 = 1;
    while (n/q1 >= 26){
        q1 *= 26, q2++;
        n -= q1;
    }
    string s;
    for (int q = 0; q < q2; q++){
        for (int q3 = 'b'; q3 <= 'z'; q3++){
            if (n >= q1){
                n -= q1;
            }else{
                s += q3-1;
                break;
            }
        }
        if (s.size() <= q){
            s += 'z';
        }
        q1 /= 26;
    }
    cout << s << endl;
    return 0;
}


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

num = [0 for _ in range(N)]
for a in A:
    num[a-1] += 1
num.sort()
cum = [0 for _ in range(N)]
cum[0] = num[0]
for i in range(1, N):
    cum[i] = cum[i-1] + num[i]

index = N - 1
ans = N
for k in range(1, N+1):
    while ans > 0:
        tmp_index = index
        while tmp_index >= 0 and num[tmp_index] > ans:
            tmp_index -= 1
        decided = N - tmp_index - 1
        rest_total = 0 if tmp_index < 0 else cum[tmp_index]
        if rest_total >= ans * (k - decided):
            index = tmp_index
            break
        ans -= 1
    print(ans)

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> c(H);
    vector<int> gyou(H), retu(W);
    int cnt = 0;
    for(int i = 0; i < H; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < (1 << 12); i++) {
        if(i == (1 << H + W)) break;
        cnt = 0;
        bitset<12> bit(i);
        set<int> s;
        for(int u = 0; u < H + W; u++) {
            if(bit.test(u)) {
                s.insert(u);
            }
        }
        for(int u = 0; u < H; u++) {
            if(s.count(u)) continue;
            for(int v = 0; v < W; v++) {
                if(s.count(v + H)) continue;
                if(c[u][v] == '#') cnt++;
            }
        }
        if(cnt == K) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
res = [0] * (n+1)
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        if i*j > n: break
        res[i*j] += 1
    ans += i*res[i]
print(ans)

Measured memory_bytes: 156676
#include <bits/stdc++.h>
using namespace std;
int minnn(int a, int b){
    if (a<b) return a;
    return b;
}
int main()
{
    int n,a[100],x,s=0,minn,dd=23456789;
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        scanf("%d",&x);
        s+=x;
        if (x%10!=0&&x<dd) dd=x;
    }
    if (dd==23456789) dd=s;
    //printf("%d",dd); printf("%d",s);
    if (s%10!=0) printf("%d",s); else printf("%d",s-dd);
    return 0;
}


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

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

	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}



Measured memory_bytes: 3648
n, m = [int(item) for item in input().split()]
edge = []
inf =  2000 * 10**10
for i in range(m):
    a, b, c = [int(item) for item in input().split()]
    edge.append([a-1, b-1, -c])

def BellmanFord(start):
    dist = [inf for i in range(n)]
    dist[0] = 0
    for i in range(n):
        for u, v, c in edge:
            if dist[u] != inf and (dist[u] + c) < dist[v]:
                dist[v] = dist[u] + c
                if i == n-1 and v == n-1:
                    return "inf"
    return -dist[-1]

ret = BellmanFord(0)
print(ret)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=1; i<=m; i++){
		for(int j=0; j<n-1; j++){
			if(a[j]%i > a[j+1]%i) swap(a[j], a[j+1]);
		}
	}
	for(int i=0; i<n; i++){
		cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int N,Y;
  std::cin >> N >> Y;
  int z = Y/1000;

  for(int i=0; i <= Y/10000; i++){
    for(int j=0; j <= Y/5000; j++){
      int p = z - 5*j - 10*i;
      if(p >= 0 && i + j + p == N){
        std::cout << i << ' ' << j << ' ' << p << '\n';
        return 0;
      }
    }
  }

  std::cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    while(1){
        int a = -1, b = -1;
        cin >> a >> b;
        if(a == -1) break;
        string s = to_string(a + b);
        cout << s.length() << endl;
    }
}


Measured memory_bytes: 3228
n = int(input())
if n <= 3:
    print("No")
elif n == 5:
    print("No")
elif n == 6:
    print("No")
elif n == 9:
    print("No")
elif n == 10:
    print("No")
elif n == 13:
    print("No")
elif n == 17:
    print("No")    
else:
    print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int dp[50][500][500];

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	rep(i, 50)rep(j, 500)rep(k, 500) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		rep(j, 500)rep(k, 500) {
			if (dp[i][j][k] == inf) continue;
			chmin(dp[i + 1][j][k], dp[i][j][k]);
			chmin(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
		}
	}
	int ans = inf;
	rrep(i, 500)rrep(j, 500) {
		if (i * mb == j * ma) chmin(ans, dp[n][i][j]);
	}
	cout << (ans == inf ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 49152
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef deque<ll> dqll;

const ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;

  string str;
  cin >> str;
  ll cur = 0;
  ll ans = 1;
  ll state = 0;
  while (cur < N) {
    if (cur == 0) {
      if (cur == N - 1 || str[cur] != str[cur + 1]) {
        ans *= 3;
        ans %= mod;
        cur++;
        state = 0;
      } else {
        ans *= 6;
        ans %= mod;
        cur += 2;
        state = 1;
      }
    } else {
      if (cur == N - 1 || str[cur] != str[cur + 1]) {
        if (state == 0) {
          ans *= 2;
        } else {
          // do nothing
        }
        ans %= mod;
        cur++;
        state = 0;
      } else {
        if (state == 0) {
          ans *= 2;
        } else {
          ans *= 3;
        }
        ans %= mod;
        cur += 2;
        state = 1;
      }
    }
  }  // while

  cout << ans << endl;

  return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (int)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }




int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
		//  ======= FAST I/O =========
	fastio;
	//  ==========================
	int n, m;
	cin >> n >> m;
	if (m == 0) {
		if (n == 1)
			cout << "0";
		else if (n == 2)
			cout << "10";
		else
			cout << "100";
		return 0;
	}
	vector<int> a(n + 1, 0);
	bool ok = true;
	set<pair<int, int>> s;
	while (m > 0) {
		int ss, cc;
		cin >> ss >> cc;
		if (ss == 1 && cc == 0 && n > 1)
			ok = false;
		s.insert({ ss, cc });
		--m;
	}
	if (!ok) {
		cout << "-1";
		return 0;
	}
	if (s.size() <= n) {
		for (auto p : s) {
			for (auto pp : s) {
				if (p != pp && p.first == pp.first && p.second != pp.second)
					ok = false;
			}
		}
		if (!ok)
			cout << "-1";
		else {
			a[1] = 1;
			for (auto p : s)
				a[p.first] = p.second;
			for (int i = 1; i <= n; ++i)
				cout << a[i];
		}
	}
	else
		cout << "-1";
	return 0;
}


Measured memory_bytes: 256
from itertools import product
H,W,K=map(int,input().split())

A = [input() for j in range(H)]
    
ans=0

for i in product([0,1],repeat=H):
    for j in product([0,1],repeat=W):
        cnt=0
        for row in range(H):
            for col in range(W):
                if (A[row][col]=="#" and i[row]==0 and j[col]==0):
                    cnt+=1
        if cnt==K:
            ans+=1
        
print(ans)

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

int main()
{
    long long n;

    scanf("%lld", &n);
    long long m = sqrt(n) + 0.5;
    for (long long i = m; i >= 0; i--) {
        if (n % i == 0) {
            int s = 0;
            m = n / i;
            while (m) {
                s++;
                m /= 10;
            }
            m = s;
            break;
        }
    }
    printf("%lld\n", m);
}


Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
long = read :: String -> Integer
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map long . words
printer = unlines . (:[]) . show 

solver [l,r] = minimum [ (i*j)`mod`2019 |i<-[l..(l+2019)], i<=r, j<-[(i+1)..(i+2019)], j<=r]



Measured memory_bytes: 1020
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	
	int c1x,c1y,c1r,c2x,c2y,c2r;
	double xsa,ysa;
	cin>>c1x>>c1y>>c1r;
	cin>>c2x>>c2y>>c2r;
	xsa = c1x-c2x;
	ysa = c1y-c2y;
	if((sqrt(xsa*xsa+ysa*ysa) + c1r == c2r) || (sqrt(xsa*xsa+ysa*ysa) + c2r == c1r)) cout<<"1\n";
	else if(sqrt(xsa*xsa+ysa*ysa) + c1r < c2r || sqrt(xsa*xsa+ysa*ysa) + c2r < c1r) cout<<"0\n";
	else if(xsa*xsa+ysa*ysa > (c1r+c2r)*(c1r+c2r)) cout<<"4\n";
	else if(xsa*xsa+ysa*ysa == (c1r+c2r)*(c1r+c2r)) cout<<"3\n";
	else if(xsa*xsa+ysa*ysa < (c1r+c2r)*(c1r+c2r)) cout<<"2\n";
	return 0;
	}

Measured memory_bytes: 3132
#!/usr/bin/env python3
N, A, B = [int(str) for str in input().strip().split()]

if (B - A) % 2:
    left = A + (B - A) // 2
    right = N - (B - A) // 2 - A
    print(min(left, right))
else:
    print((B - A) // 2)

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

int main() {
  int n, m;
  cin >> n >> m;
  if(n==m) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <set>
using namespace std;

string str;


bool isSymmetry(string &s) {
  string s2 = "";
  for(int i = s.length()-1; i >= 0; --i) {
    s2 += s[i];
  }
  return s2 == s;
}

void solve() {
  set<string> vis;

  for(int j = str.length(); j > 2; --j) {
    for(int i = 0; i+j <= str.length(); ++i) {
      string s = str.substr(i, j);
      if(isSymmetry(s) && vis.find(s) == vis.end()) {
	if(vis.size() != 0) cout << " ";
	vis.insert(s);
	cout << s;
	while(1) {
	  s = s.substr(1, s.length()-2);
	  vis.insert(s);
	  if(s.length() < 3) break;
	}
      }
    }
  }
  cout << endl;
}

main() {
  char c;
  str = "";
  while(scanf("%c", &c) != EOF) {
    if(c == '\n') {
      solve();
      str = "";
    } else if(!isalpha(c)) {
      continue;
    } else {
      str += toupper(c);
    }
  }
}

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

struct data{
	int p, y, cnt;
	data(int _p, int _y, int _cnt) : p(_p), y(_y), cnt(_cnt){}
};

bool operator<(const data& l, const data&r){
	if(l.y == r.y) return l.p < r.p;
	return l.y < r.y;
}

int main(){
	int N, M; cin >> N >> M;

	vector<data> yp;
	vector<int> num(N+1);
	for(int i=0; i<M; ++i){
		int y, p; cin >> p >> y;
		yp.emplace_back(p, y, i);
	}

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

	vector<string> ans(M);
	for(int i=0; i<M; ++i){
		++num[yp[i].p];
		string ken = to_string(yp[i].p), x = to_string(num[yp[i].p]);
		while(ken.size() < 6) ken = "0"s + ken;
		while(x.size() < 6) x = "0"s + x;

		ans[yp[i].cnt] = ken + x;
	}

	for(string& answer : ans) cout << answer << endl;
}


Measured memory_bytes: 8692
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    // unsigned long long int a, b; cin >> a >> b;
    string res = "EQUAL";
    // if(a > b) res = "GREATER";
    // else if(a < b) res = "LESS";
    // else "EQUAL";
    // cout << res << endl;
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) res = "GREATER";
    else if(a.size() < b.size()) res = "LESS";
    else{
        rep(i, a.size()){
            if(a[i] == b[i]) continue;
            if(a[i] > b[i]) res = "GREATER";
            else res = "LESS";
            break;
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;
int main(){
	string a, b;
	string S;
	int A, B;
	bool Forward = false;
	bool Back = false;

	cin >> S;
	
	a = S.substr(0, 2);
	b = S.substr(2, 2);
	
	A = stoi(a);
	B = stoi(b);

	if (A >= 1 && A <= 12) {
		Forward = true;
	}
	if (B >= 1 && B <= 12) {
		Back = true;
	}

	if (Forward&&Back) {
		cout << "AMBIGUOUS" << endl;
	}else if (Forward) {
		cout << "MMYY" << endl;
	}else if (Back) {
		cout << "YYMM" << endl;
	}else {
		cout << "NA" << endl;
	}
}


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

ll solve() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = min(C, A+B+1) + B;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#define MAX 100005
typedef struct pp{
  char name[100];
  int t;
}P;
void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P x);
P dequeue(void);
P Q[MAX+1],Q2[MAX+1];
int head, tail, n;

int main(){
  int c,time=0;
  char elaps[100];
  int i, q;
  P u;
  initialize();
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }

  while(isEmpty()!=1){
    u=dequeue();
    c=u.t-q;
    if(c>0){
      u.t=c;
      enqueue(u);
      time+=q;
    }
    else{
      time+=u.t;
      printf("%s %d\n",u.name,time);
    }
  }
  
 return 0;
}


void initialize(void){
  head=0;
  tail=0;
}

int isEmpty(void){
  
  if(head==tail)  return 1;
  else return 0;
}

int isFull(void){
  if(head==(tail+1)%MAX) return 1;
  else return 0 ;
  
}

void enqueue(P x){
  if(isFull()==1){
    fprintf(stderr,"??¨?????????????????????????????????\n");
    exit(1);
  }
  Q2[tail]=x;
  if(tail+1==MAX) tail=0;
  else tail++;
}
P dequeue(void){
  P x;
  if(isEmpty()==1){
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
  }
  x=Q2[head];
  if(head+1==MAX) head=0;
  else head++;
  return x;
}

Measured memory_bytes: 18864
from sys import exit
s=input()
l=len(s)
for i in range(l-2):
    if s[i]==s[i+2]:
        print(str(i+1)+" "+str(i+3))
        exit()
    if s[i]==s[i+1]:
        print(str(i+1)+" "+str(i+2))
        exit()
if s[l-2]==s[l-1]:
    print(str(l-1)+" "+str(l))
else:
    print("-1 -1")


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;
	string ex = "CODEFESTIVAL2016";
	int count = 16;
	for (int i = 0; i < 16; i++) {
		if (S[i] == ex[i]) {
			count--;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,pp,e,o,ans,p[60][60],x;
int main() {
	scanf("%d %d", &n, &pp);
	for (int i = 0; i <= 50; i++) {
		p[i][0] = 1; p[i][1] = i;
		for (int j = 2; j <= i; j++) {
			p[i][j] = p[i - 1][j - 1] + p[i - 1][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x);
		if (x % 2 == 0) e++; else o++;
	}
	if (pp == 0) {
		for (int i = 0; i <= e; i++) {
			for (int j = 0; j <= o; j+=2) {
				ans = ans + p[e][i] * p[o][j];
			}
		}
	} else {
		for (int i = 0; i <= e; i++) {
			for (int j = 1; j <= o; j+= 2) {
				ans =ans + p[e][i] * p[o][j];
			}
		}
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
# coding: utf-8
num_box, num_ans_candy = map(int, input().split())
l_box = list(map(int, input().split()))

eat_counter = 0
for index in range(num_box - 1):
    double_candy = l_box[index] + l_box[index + 1]
    if double_candy > num_ans_candy:
        num_eat_candy = double_candy - num_ans_candy
        if l_box[index + 1] < num_eat_candy:
            num_eat_candy -= l_box[index + 1]
            eat_counter += l_box[index + 1]
            l_box[index + 1] = 0
            l_box[index] -= num_eat_candy
        else:
            l_box[index + 1] -= num_eat_candy
        eat_counter += num_eat_candy

print(eat_counter)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k,w[110],v[110];
ll f[100010];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i],&v[i]);
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=k;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
		}
	}
	cout<<f[k]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a == b) {
        cout << a + b << endl;
    }else if(a > b + 1) {
        cout << 2 * a - 1 << endl;
    }else if(a + 1 < b) {
        cout << 2 * b - 1 << endl;
    }else if(a - b == 1) {
        cout << a + b << endl;
    }else if(b - a == 1) {
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256