akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100000
#define INF (1<<29)
 
vector<int> G[MAX];
 
vector<int> bfs(int N)
{
    vector<int> d(N, INF);
    d[0] = 0;
     
    queue<int> Q;
    Q.push(0);
 
    while (!Q.empty()) {
        int v = Q.front(); Q.pop();
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i];
            if (d[v] + 1 < d[to]) {
                d[to] = d[v] + 1;
                Q.push(to);
            } 
        }
    }
    return d;
}

set<int> st, edges[MAX], edges2[MAX];

void erase(int v)
{
    for (auto &e: edges2[v]) {
        if (e != 0 && edges[e].count(v) > 0) {
            edges[e].erase(v);
            if (edges[e].size() == 0) {
                st.insert(e);
                erase(e);
            }
        }
    }
}

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
 
    auto d = bfs(N);
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (int)G[i].size(); j++) {
            int to = G[i][j];
            if (d[i] + 1 == d[to]) {
                edges[to].insert(i);
                edges2[i].insert(to);
            }
        }
    }
    
    int R;
    for (int i = 0; i < Q; i++) {
        cin >> R;
        R--;        
        int s = a[R], t = b[R];        
        if (d[s] == d[t] + 1 && s != 0 && edges[s].count(t) > 0) {
            edges[s].erase(t);
        }
        if (d[t] == d[s] + 1 && t != 0 && edges[t].count(s) > 0) {
            edges[t].erase(s);
        }

        if (st.count(s) == 0 && s != 0 && edges[s].size() == 0) {
            st.insert(s);
            erase(s);
        }

        if (st.count(t) == 0 && t != 0 && edges[t].size() == 0) {
            st.insert(t);
            erase(t);
        }            
        cout << st.size() << endl;;
    }    
    return 0;
}

Measured memory_bytes: 37348
#include <stdio.h>

int main(){
  int on, n, sn=0;
  scanf("%d",&n);
  on = n;
  for(; n; ){
    sn += + n%10;
    n/=10;
  }
  
  if ( on % sn == 0) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	if(n <= 1 || n % 2)
	{
		cout << 0;
		return 0;
	}
	int ans = 0;
	int den = 10;
	while(den <= n)
	{
		ans += n / den;
		den *= 5;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,sse,sse2")
#include<bits/stdc++.h>
using namespace std;
const int maxn = 303;
int q[maxn][maxn][maxn], f[maxn][maxn], g[maxn], nck[maxn][maxn], n, k, m;

#define mul(x, y) (((x)*1ll*(y))%m)

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k >> m;++n;
	
	for(int j = 0; j < maxn; j++)
		for(int i = 0; i < maxn; i++) {
			if(i < j) nck[i][j] = 0;
			else if(!j) nck[i][j] = 1;
			else nck[i][j] = (nck[i-1][j-1] + nck[i-1][j])%m;
		}
	for(int k = 1; k <= n; k++) {
		for(int c = 1; c <= n; c++) {
			int t = 1;
			for(int cnt = 1; k*cnt + c <= n; cnt++) {
				t = mul(t, nck[cnt*k - 1][k - 1]);
				q[k][c][cnt] = mul(t, nck[cnt*k + c - 1][c - 1]);
			}
		}
	}
	f[0][1] = g[1] = 1;
	for(int d = 1; d <= k; d++) {
		f[d][1] = 1;
		for(int k = 1; k <= n; k++) {
			for(int c = n; c; c--) {
				if(!f[d][c]) continue;
				int t = f[d][c];
				for(int cnt = 1; c + cnt*k <= n; cnt++) {
					t = mul(t, g[k]);
					f[d][c + cnt*k] = (f[d][c + cnt*k] + t*1ll*q[k][c][cnt])%m;
				}
			}
		}
		for(int c = 1; c <= n; c++) {
			g[c] += f[d][c];
			if(g[c] >= m) g[c] -= m;
		}
	}
	cout << f[k][n] << '\n';
}



Measured memory_bytes: 108416
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	pm := primeFactorize(n)
	ans := 0
	for _, v := range pm {
		for i := 1; i <= v; i++ {
			v -= i
			ans++
		}
	}

	fmt.Println(ans)
}

func primeFactorize(n int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			n /= i
			res[i]++
		}
	}
	if n != 1 {
		res[n]++
	}
	return res
}


Measured memory_bytes: 1832
import java.util.Scanner;
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int max = 0;
        for(int i = 0;i < s.length();i++){
            Set<Character> first = new HashSet<Character>(); 
            Set<Character> last = new HashSet<Character>(); 
            for(int j = 0;j <= i;j++){
                first.add(s.charAt(j));
            }
            for(int j = i+1;j < s.length();j++){
                last.add(s.charAt(j));
            }
            int cnt = 0;
            for(Character key : first){
                if(last.contains(key)){
                    cnt++;
                }
            }
            max = Math.max(max,cnt);
        }
        System.out.println(max);

    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf=1e18;

struct edge{
	int to,cst;
};

vector<vector<edge>> g;
vector<int> d;

void add_edge(int a,int b,int c){
	g[a].push_back(edge({b,c}));
	g[b].push_back(edge({a,c}));
};



void calc_d(int cur,int pre){
	for(auto&& w:g[cur]){
		if(w.to!=pre){
			d[w.to]=d[cur]+w.cst;
				calc_d(w.to,cur);
		}
    }
};

signed main(){
	int n;cin>>n;
	g.resize(n);
	for(int i=0;i<n-1;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		add_edge(a,b,c);
	}
	for(int i=0;i<n;i++){
	cerr<<i+1<<" ";
	for(auto&& w:g[i])cerr<<w.to+1<<" ";
    cerr<<endl;
	}
	cerr<<endl;

	int q,k;cin>>q>>k;k--;
	d.resize(n,-1);
	d[k]=0;
	calc_d(k,-1);
	for(auto&& w:d)cerr<<w<<" "<<endl;
	cerr<<endl;
	for(int i=0;i<q;i++){
		int x,y;cin>>x>>y;x--;y--;
		cout<<d[x]+d[y]<<endl;
	}	
}

Measured memory_bytes: 14336
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

   //int t; cin>>t; while(t--) 
	int k, a,b; cin>>k>>a>>b;
	if(a%k==0 || b/k>a/k) cout<<"OK";
	else cout<<"NG";
	
	
    return 0 ;  
}

Measured memory_bytes: 3576
/*
制約
2 ≤ 式に含まれるオペランドの数 ≤ 100
1 ≤ 式に含まれる演算子の数 ≤ 99
演算子は +、-、* のみを含み、１つのオペランドは10^6 以下の正の整数
-1 × 10^9 ≤ 計算途中の値 ≤ 10^9
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char line[1024] = {0};
    int stack[101] = {0};
    char operand[8] = {0};
    int j = 0;
    int k = 0;
    
    fgets( line, sizeof(line), stdin);
    
    for ( int i = 0; i < strlen(line); i++ ) {
        //printf("line[%d]=%c\n", i, line[i]);
        // オペランド
        if ( ('0' <= line[i]) && (line[i] <= '9') ) {
            operand[j] = line[i];
            j++;
        } else {
            // オペランドの確定
            if ( operand[0] != 0 ) {
                stack[k] = atoi(operand);
                k++;
                memset( operand, 0, sizeof(operand) );
                j = 0;
            }
            // 演算子のとき
            if ( line[i] != ' ' ) {
                //printf("%d %c %d = ", stack[k - 2], line[i], stack[k - 1]);
                switch ( line[i] ) {
                    case '+':
                        stack[k - 2] += stack[k - 1];
                        break;
                    case '-':
                        stack[k - 2] -= stack[k - 1];
                        break;
                    case '*':
                        stack[k - 2] *= stack[k - 1];
                        break;
                    case '/':
                        stack[k - 2] /= stack[k - 1];
                        break;
                }
                //printf("%d\n", stack[k - 2]);
                stack[k] = 0;
                k--;
            }
        }
        /*printf("stack:");
        if ( stack[0] != 0 ) {
            for ( int l = 0; l < k; l++ ) {
                printf("%d", stack[l]);
                if ( l == k - 1 ) {
                    printf("\n");
                } else {
                    printf(" ");
                }
            }
        } else {
            printf("null\n");
        }
        */
    }
    
    printf("%d\n", stack[0]);
    
    return 0;
}


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

int main()
{
  int n,m,i;
  cin>>n>>m;
  int arr[m];
  for(i=0; i<m; i++)
  {
    cin>>arr[i];
    n=n-arr[i];
  }
  if(n>=0)
    cout<<n;
  else
    cout<<"-1";
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    ll A,B;
    cin >> A >> B;

    ll ans = A - 2 * B;
    if(ans <= 0)
        cout << 0 << endl;
    else
    {
        cout << ans << endl;
        
    }
    
    return 0;
}

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

int N, K;
vector<int> A[2000];
pair<int, int> E[2000 - 1];

int see(int v, int par, int d) {
  int res = 1;
  if(d == 0) return res;
  for(int w : A[v]) {
    if(w == par) continue;
    res += see(w, v, d - 1);
  }
  return res;
}

int main() {
  cin >> N >> K;
  for(int i = 0; i < N - 1; ++i) {
    int a, b; cin >> a >> b; --a; --b;
    A[a].push_back(b); A[b].push_back(a); E[i] = {a, b};
  }
  int res = N;
  if(K % 2 == 0) {
    for(int v = 0; v < N; ++v) {
      res = min(res, N - see(v, -1, K / 2));
    }
  } else {
    for(int i = 0; i < N - 1; ++i) {
      int a = E[i].first, b = E[i].second;
      res = min(res, N - see(a, b, (K - 1) / 2) - see(b, a, (K - 1) / 2));
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int main () {
  string N;
  cin >> N;
  vector<int> A(4);
  rep(i,4)  A[i] = N[i] - '0';

  rep(s,(1<<3)) {
    int x = A[0];
    rep(i,3) {
      if((s>>i) & 1) {
        x += A[i+1];
      } else {
        x -= A[i+1];
      }
    }
    if(x == 7) {
      cout << A[0];
      rep(i,3) {
        if((s>>i) & 1) {
          cout << '+';
        } else {
          cout << '-';
        }
        cout << A[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
dp = [10 ** 4 for i in range(N+1)]
dp[0] = 0
for i in range(1,N+1):
    dp[i] = min(dp[i],dp[i-1]+1)

    a = 1
    while(i - 6 ** a >= 0):
        #process
        dp[i] = min(dp[i],dp[i-6**a]+1)
        a += 1
    
    b = 1
    while(i - 9 ** b >= 0):
        #process
        dp[i] = min(dp[i],dp[i-9**b]+1)
        b += 1
    
print(dp[N])

Measured memory_bytes: 3864
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function dpspu(g::Dict{Int,Array{Array{Int,1},1}},k)
	n = length(g)
	d = Array{Int}(n)
	d[k] = 0
	vst = zeros(Int, n)
	stack = Int[]
	push!(stack, k)
	while length(stack) > 0
		now = pop!(stack)
		for i in 1:length(g[now][1])
			if vst[g[now][1][i]] == 0
				vst[g[now][1][i]] = 1
				d[g[now][1][i]] = d[now]+g[now][2][i]
				push!(stack,g[now][1][i])
			end
		end
	end
	d
end

function main()
	n = parseInt(readline())
	g = Dict{Int,Array{Array{Int,1},1}}()
	for i in 1:n
		g[i] = [Int[],Int[]]
	end
	for i in 1:n-1
		a,b,c = readline() |> split |> parseMap
		push!(g[a][1],b)
		push!(g[a][2],c)
		push!(g[b][1],a)
		push!(g[b][2],c)
	end
	q,k = readline() |> split |> parseMap
	sp = dpspu(g,k)
	for i in 1:q
	x,y = parseMap(split(readline()))
		println(sp[x]+sp[y])
	end
end

main()

Measured memory_bytes: 188552
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int a[maxn];
int vis[maxn];
bool check(int n)
{
  while(n)
  {
     if(vis[n%10])
        return 0;
     n/=10;
  }
  return 1;
}
int main()
{
  int n,k;
  int x;
  while(~scanf("%d%d",&n,&k))
  {
  for(int i=0;i<k;i++)
  {
        scanf("%d",&x);
        vis[x]=1;
  }
  for(int i=n;;i++)
  {
        if(check(i))
        {
          printf("%d\n",i);
          return 0;
        }
  }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    
    int ans = 0;
    for ( int i = (int)s.length() - 1; i >= 0; i-- ) {
        if ( i % 2 != 0 ) continue;
        string t = s.substr(0, i);
        int j, k, flag = 1;
        for ( j = 0, k = (int)t.length() / 2 ; k < t.length(); j++, k++ ) {
            // cout << i << s[j] << " " << s[k] << endl;
            if ( s[j] != s[k] ) {
                flag = 0;
                break;
            }
        }
        if ( flag == 1 ) {
            ans = (int)t.length();
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int N;
long int A[101];

int main(){

  std::cin >> N;

  for(int i = 0; i < N; i++) std::cin >> A[i];

  int min = A[0], max = A[0];

  for(int i = 1; i < N; i++){
    if(A[i] > max) max = A[i];
    if(A[i] < min) min = A[i];
  }
  

  std::cout << max - min << '\n';

}


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

using namespace std;

int main()
{
  int N, M;
  vector< pair<int, int> > cards;
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    cards.push_back(make_pair(a, 1));
  }
  
  for (int i = 0; i < M; i++) {
    int b, c;
    scanf("%d %d", &b, &c);
    cards.push_back(make_pair(c, b));
  }
  
  sort(cards.rbegin(), cards.rend());
  
  long long ans = 0;
  int card_num = 0;
  
  for (int i = 0; i < cards.size(); i++) {
    cards[i].second = min(cards[i].second, N - card_num);
    ans += (long long)cards[i].first * cards[i].second;
    card_num += cards[i].second;
    if (card_num == N) break;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 2420
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)
move = 0
max = 0
(1..H.count-1).each do |i|
  if H[i] <= H[i-1]
    move += 1
    max = move if move > max
  else
    move = 0
  end
end
puts max


Measured memory_bytes: 9980
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    double ans = 0;
    for(int i=1;i<=n;i++){
        double a = (double)1/n;
        if(i<k){
            int b = i;
            double cnt=1;
            while(b<k){
                b*=2;
                cnt*=2;
            }
            a*=1/cnt;
        }
        ans+=a;
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n =int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sum = 0
for i in range(n):
  if A[i] < B[i]:
    if B[i] >= A[i]+A[i+1]:
      sum += A[i]+A[i+1]
      A[i+1] = 0
    else:
      sum += B[i]
      A[i+1] -= B[i]-A[i]
  else:
    sum += B[i]
print(sum)
                    
                   
   

Measured memory_bytes: 19156
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n, d = map(int, input().split())
    answer = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if pow(x, 2) + pow(y, 2) <= pow(d, 2):
            answer += 1

    #output
    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n,r;
  cin>>n;
  vector<bool> exist(8,false);
  int var=0;
  REP(i,n){
    cin>>r;
    REP(j,8){
      if(r<400*(j+1)){
        exist[j]=true;
        break;
      }
    }
    if(r>=3200){
      var++;
    }
  }
  int m=0;
  REP(i,exist.size()){
    if(exist[i]){
      m++;
    }
  }
  if(m==0){
    cout<<1<<" ";
  }else{
    cout<<m<<" ";
  }
  cout<<m+var;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

a,b,n = LI()

m = min(b-1, n)
print(int(a*m/b)-a*int(m/b))

Measured memory_bytes: 9184
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	std::string S;
	in >> N >> S;
	if (N % 2 == 1)
	{
		out << "No" << std::endl;
		return 0;
	}
	out << (S.substr(0, N / 2) == S.substr(N / 2, N / 2) ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;

vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

int main(){
    int q;
    cin >> q;
    vector<bool> prime = prime_table(100010);
    int like[100010] = {0};
    for(int i = 1; i < 100010; i++){
        if(prime[i] && prime[(i+1)/2]) like[i+1] = like[i] + 1;
        else like[i+1] = like[i];
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << like[r+1] - like[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0,n;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[1]=='B')
        s[1]='R';
        else{
            s[1]='B';
        }
        cout<<s<<endl;

    ALL_UP_WITH;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    string s;cin>>s;
    ll cl=0,cr=0,ans=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]){if(s[i+1]=='L')cl++;else cr++;}
        else ans++;
    }
    if(s[n-1]=='L')cl--;else cr--;
    if(s[0]==s[n-1]){
        if(s[0]=='L'){
            puta(ans+min(k,cr)*2);
        }else{
            puta(ans+min(k,cl)*2);
        }
    }else{
        if(cl>=k){
            puta(ans+k*2);
        }else{
            puta(n-1);
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll inf = 100000000000010;
struct edge {
	int to, cost;
};
int n;//頂点数
vector<edge>g[100010];//隣接リスト
ll D[100010];//距離

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(D, D + n, inf);
	D[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (D[v] < p.first) {
			continue;
		}
		for (int i = 0; i < g[v].size(); i++) {
			edge e = g[v][i];
			if (D[e.to] > D[v] + e.cost) {
				D[e.to] = D[v] + e.cost;
				que.push(P(D[e.to], e.to));
			}
		}
	}
}

int main() {
	cin >> n;
	int a, b, c;
	edge ed;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b >> c;
		ed.to = b - 1;
		ed.cost = c;
		g[a - 1].push_back(ed);
		ed.to = a - 1;
		g[b - 1].push_back(ed);
	}
	int q, k; cin >> q >> k;
	int x, y;
	vector<ll>ans;
	dijkstra(k - 1);
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		ans.push_back(D[x - 1] + D[y - 1]);
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 10212
#include<cstdio>
#include<string>
#include<vector>
#include<iostream>
#include<sstream>

using namespace std;

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

int main(){
	while(1){
		int n;
		string s;
		
		cin>>n;
		if(n==0)break;
		cin>>s;
		
		char bef;
		int cont=0;
		
		rep(p,n){
		
			stringstream ss;
			bef=s[0];
			cont=1;
			reps(i,s.size()-1){
				
				if(s[i]!=bef){
					ss<<cont<<bef;
					bef=s[i];
					cont=1;
				}else{
					cont++;
				}
			}
			ss<<cont<<bef;
			s=ss.str();
		}
		cout<<s<<endl;
	}
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout << d << endl;
#define coutd(d) cout << std::setprecision(10) << d << endl;
#define cinline(n) getline(cin, n);
#define replace_all(s, b, a) replace(s.begin(), s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

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

inline bool inside(int y, int x, int H, int W)
{
  return (y >= 0 && x >= 0 && y < H && x < W);
}

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

struct BIT
{
  long long n;
  vector<long long> dat;

  void initialize(long long n_input) {
    n = n_input + 1;
    dat.resize(n + 1);
    for (int i = 0; i <= n; i++) dat[i] = 0;
  }

  long long sum(long long i) {
    long long s = 0;
    while (i >= 0) {
      s += dat[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }

  long long sum_between(long long i, long long j) {
    return i <= j ? sum(j) - sum(i - 1) : 0;
  }

  void add(long long i, long long x) {
    while (i <= n) {
      dat[i] += x;
      i |= i + 1;
    }
  }
};

signed main()
{
  ll n;
  cin >> n;
  vi a(n), as(n);
  rep(i, n) {
    cin >> a[i];
    as[i] = a[i];
  }
  vsort(as);

  int ub = n; // ng ... 「基準値以上の値が半数以上あるか」という判定で中央値を求めるため下限がok
  int lb = 0; // ok
  BIT bit;

  ll border = ((n * (n + 1) / 2) + 1) / 2;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int midn = as[mid];        // asc sort された a の要素値で、期待値になりうるかを判定する
    bit.initialize(2 * n + 1); // 2n とするのは index となる累積和の値が負数になりうるため(オフセット)
    int sum = 0;               // 累積和
    bit.add(sum+n, 1);
    ll result = 0;             // midn が中央値となりうる区間の総数
    rep(i, n) {
      sum += a[i] >= midn ? 1 : -1;
      result += bit.sum(sum + n);
      bit.add(sum + n, 1);
    }
    if (result >= border)
      lb = mid;
    else
      ub = mid;
  }
  cout << as[lb] << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

// vector<vector<int> > vvi;
// vector<vector<vector<int> > > vvvi;
//
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++){
        cin >> a[i];
    }

    queue<pair<int, int> > black_idx;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (a[i][k] == '#'){
                black_idx.push(make_pair(i, k));
            }
        }
    }

    ll calc[1010][1010];
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (a[i][k] == '#'){
                calc[i][k] = 0;
            }else{
                calc[i][k] = INF;
            }
        }
    }

    while(not black_idx.empty()){
        pair<int, int> idx = black_idx.front();
        black_idx.pop();
        int fi = idx.first;
        int se = idx.second;
        for (int i = 0; i < 4; i++){
            if (0 <= fi + dy[i] && fi + dy[i] < h && 0 <= se + dx[i] && se + dx[i] < w && calc[fi + dy[i]][se + dx[i]] == INF){
                black_idx.push(make_pair(fi + dy[i], se + dx[i]));
                chmin(calc[fi+dy[i]][se+dx[i]], calc[fi][se] + 1);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            chmax(ans, calc[i][k]);
        }
    }
    cout << ans << endl;

    return 0;
}



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

#define INF 999999

int m;
int num[7];
int maisu[7];
int g;
int dp[8][1001];
int n;

signed main()
{
	while (true)
	{
		cin >> m;
		if (m == 0) break;

		rep(i,8) rep(j,1001) dp[i][j] = 0;

		rep(i,m)
		{
			cin >> num[i] >> maisu[i];
		}

		dp[0][0] = 1;
		/*
		for (int i = num[0]; i <= num[0] * maisu[0]; i += num[0])
		{
			dp[0][i] = 1;
		}
		*/

		rep(i, m)
		{
			rep(j,1001)
			{
				rep(k,maisu[i] + 1)
				{
					if (j + num[i] * k <= 1000)
					{
						dp[i + 1][j + num[i] * k] += dp[i][j];
					}
				}
			}
		}

		cin >> g;

		rep(i,g)
		{
			cin >> n;
			printf("%d\n", dp[m][n]);
		}
	}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
  ll h,w;
  cin>>h>>w;
  vector< vector<char> > arr(h,vector<char>(w,'.'));
  vector< vector<ll> > dp(h,vector<ll>(w,0));
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      cin>>arr[i][j];
    }
  }
  for(ll j=w-2;j>=0;j--){
    if(arr[h-1][j]=='.'){
      dp[h-1][j] = 1;
    }
    else{
      for(;j>=0;j--){
        dp[h-1][j] = 0;
      }
    }
  }

  for(ll i=h-2;i>=0;i--){
    if(arr[i][w-1]=='.'){
      dp[i][w-1] = 1;
    }
    else{
      for(;i>=0;i--){
        dp[i][w-1] = 0;
      }
    }
  }

  for(ll i=h-2;i>=0;i--){
    for(ll j=w-2;j>=0;j--){
      if(arr[i][j]=='.'){
        dp[i][j] = (dp[i][j+1]%mod + dp[i+1][j]%mod)%mod;
      }
    }
  }

  cout<<dp[0][0]<<"\n";


}

Measured memory_bytes: 9088
#include <cstdio>
#include <algorithm>
#include <functional>
#include <bitset>

using namespace std;

const int N_MAX = 50;

int N, A, B;
long v[N_MAX + 1];
long t[N_MAX + 1][N_MAX + 1];

long comb(int n, int r) {
  t[0][0] = 1;
  t[1][0] = 1;
  t[1][1] = 1;
  for (int i = 2; i < n + 1; i++) {
    for (int j = 0; j < i + 1; j++) {
      t[i][j] = t[i - 1][j - 1] + t[i - 1][j];
    }
  }
  return t[n][r];
}

int main() {
  scanf("%d %d %d", &N, &A, &B);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &v[i]);
  }

  sort(v, v + N_MAX + 1, greater<long>());
  long sum = 0;
  for (int i = 0; i < A; i++) {
    sum += v[i];
  }
  double ave = sum / (double)A;

  int cnt = 0;
  int pos = 0;
  long last = v[A - 1];
  for (int i = 0; i < N; i++) {
    if (v[i] == last) {
      cnt++;
      if (i < A) {
        pos++;
      }
    }
  }

  long ans = 0;
  if (pos == A) {
    for (int i = A; i <= B; i++) {
      ans += comb(cnt, i);
    }
  } else {
    ans = comb(cnt, pos);
  }

  printf("%lf\n", ave);
  printf("%ld\n", ans);
}


Measured memory_bytes: 128
n = gets.chomp.to_i

# 先頭がi, 末尾がjの自然数の個数
arr = 10.times.map{Array.new(10, 0)}

(1..n).each do |num|
  num_s = num.to_s
  arr[num_s[0].to_i][num_s[-1].to_i] += 1
end

count = 0
10.times do |i|
  10.times do |j|
    # A: arr[i][j], B: arr[j][i]とみなせば組み合わせは掛け算で表される
    count += arr[i][j] * arr[j][i]
  end
end

puts count

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

int main() {
    int n, t, a;
    std::cin >> n >> t >> a;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    int diff = 1000000000;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp = t*1000 - 6 * h[i];
        if (abs(tmp - a*1000) < diff) {
            diff = abs(tmp - a*1000);
            ans = i+1;
        }
    }
    std::cout << ans << std::endl;
}




Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>

int main(void)
{
	int n=1,i,j;
	double m,hyojunhensa=0,a=0,s[1001],sum=0;

	while(n!=0)
	{
		sum=0;
		a=0;
		scanf("%d",&n);
		if(n!=0)
		{
			for(i=0;i<n;i++)
			{
				scanf("%lf",&s[i]);
				sum+=s[i];
			}
			m=sum/n;
			for(j=0;j<n;j++)
			{
				a+=pow(s[j]-m,2.0);
			}
			hyojunhensa=sqrt(a/n*1.0);
			printf("%f\n",hyojunhensa);
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 404, MAX_M = 100005;

int X[MAX_M], Y[MAX_M], in[MAX_N], ok[MAX_N], N, M;
vector<int> vec[MAX_N];

void work(int x) {
  memset(in, 0, sizeof in);
  in[x] = 1, vec[x].push_back(x);
  for (int i = M; i; --i) {
    if (in[X[i]] && in[Y[i]]) {
      ok[x] = 1;
      return;
    } else if (in[X[i]]) {
      vec[x].push_back(Y[i]);
      in[Y[i]] = 1;
    } else if (in[Y[i]]) {
      vec[x].push_back(X[i]);
      in[X[i]] = 1;
    }
  }
}

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; ++i)
    scanf("%d%d", &X[i], &Y[i]);
  
  for (int i = 1; i <= N; ++i)
    work(i);

  int res = 0;
  for (int i = 1; i <= N; ++i)
    if (!ok[i])
      for (int j = i + 1; j <= N; ++j)
	if (!ok[j]) {
	  memset(in, 0, sizeof in);
	  int flag = 1;
	  for (int x : vec[i]) in[x] = 1;
	  for (int y : vec[j]) if (in[y]) flag = 0;
	  res += flag;
	}
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 1152
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<(a-b*2<0 ? 0 : a-b*2)<<'\n';
  
  return(0);
}


Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2020/04/12
 *      Author: SkAaO
 */

#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;

	int num = 0;
	int b_num = 0; //海外の学生の中での順位
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'a'){
			if(num < A + B){
				num++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else if(S.at(i) == 'b'){
			b_num++;
			if((num < A + B) && (b_num <= B)){
				num++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else if(S.at(i) == 'c'){
			cout << "No" << endl;
		}
	}

	return 0;
}




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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,i,t,a;
	cin>>n>>t>>a;
	double h[n];
	for(i=0;i<n;i++)cin>>h[i];
	for(i=0;i<n;i++)h[i]=t-h[i]*0.006;
	
	double diff=1000000000;
	int ans;
	for(i=0;i<n;i++){
		if(abs(a-h[i])<diff){
			diff=abs(a-h[i]);
			ans=i;
		}
	}
	cout<<ans+1<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;

int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];


int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
using namespace std;
int main(){
   

    string s;
    cin >> s;
    int size = s.size();
    if(s[size-1] == 's'){
        cout << s << "es" <<endl;
    }else{
        cout << s << "s" <<endl;
    }

}





Measured memory_bytes: 6204
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
cands = [0] * N
for i in range(K):
    _ = readline()
    a = list(map(int, readline().split()))
    for x in a:
        cands[x - 1] += 1


def solve():
    # print(cands)
    return sum(1 for c in cands if c == 0)


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 9252
#include<stdio.h>

int main(){
	int n,a[11],i,j,x;
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		for(i=0;i<10;i++)a[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&x);
			a[x]++;
		}
		for(i=0;i<10;i++){
			if(a[i]==0)printf("-");
			else for(j=0;j<a[i];j++)printf("*");
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
x1, y1, x2, y2 = map(int, input().split())

# deltax2_1 = x1 - x2
# deltay2_1 = y1 - y2
deltax1_2 = x2 - x1
deltay1_2 = y2 - y1
#
# x3 = x2 + deltay2_1
# y3 = y2 - deltax2_1
# x4 = x1 - deltay1_2
# y4 = y1 + deltax1_2

x3 = x2 - deltay1_2
y3 = y2 + deltax1_2
x4 = x1 - deltay1_2
y4 = y1 + deltax1_2


print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }


 
int main(int argc, char const *argv[]) {
  int a,b;
  cin >> a >> b;
  if(a==1){
    if(b==2)cout << "3" << endl;
    if(b==3) cout << "2" << endl;
  }
  if(a==2){
    if(b==1)cout << "3" << endl;
    if(b==3) cout << "1" << endl;
  }
  if(a==3){
    if(b==2)cout << "1" << endl;
    if(b==1) cout << "2" << endl;
  }
  return 0;
}


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

#define ll long long

using namespace std;

int main(){
    ll A,B,K;
    ll ans1 = 0;
    ll ans2 = 0;
    cin >> A >> B >> K;
    if(A >= K){
        ans1 = A - K;
        ans2 = B;
    }
    else{
        ans2 = B - (K - A);
        if(ans2 < 0) ans2 = 0;
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    vector <int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++)
    {
        sum+=v[i];
    }
    //cout<<sum<<endl;
    //cout<<v[n-1]<<endl;
    if(v[n-1]<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    /*double a=(v[0]*v[1])/2;
    cout<<(int)a<<endl;
    double a,b;
    cin>>a>>b;
    if(b%a==0)
    {
        cout<<a+b<<endl;
        return 0;
    }
    else
    int y,m,d;
    char c;
    cin>>y>>c>>m>>c>>d;
    if(m>=5) cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;*/
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#define P pair<int, int>
using namespace std;

const int MAX_H = 50, MAX_W = 50;

int H, W;
char s[MAX_H][MAX_W + 1];

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

int bfs() {
	queue<pair<int, int>> que;
	que.push(make_pair(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == H - 1 && p.second == W - 1) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] != '#' && d[nx][ny] == -1) {
				que.push(make_pair(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[H - 1][W - 1];
}

void solve() {
	memset(d, -1, sizeof(d));
	int ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.') {
				ans++;
			}
		}
	}

	int res = bfs();
	if (res == -1) puts("-1");
	else printf("%d\n", ans - res - 1);
}

int main() {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", s[i]);
	}

	solve();
}

Measured memory_bytes: 256
namespace DotNetLab.Fs.Console

open System
open System.Collections.Generic

[<AutoOpen>]
module Misc =
  type Long = int64
  let inline long x = int64 x

  let readLine f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let [|n; a|] = readLine int
    let xs = readLine int

    let maxX = Seq.concat [[|a|]; xs] |> Seq.max
    let maxSum = n * maxX + 1

    // dp.[j].[k].[s] = c:
    //   xs.[0..(j - 1)] から k 個を選び、その総和が s に等しいような選び方の総数が c
    let dp =
      Array.init (n + 1) (fun _ ->
        Array.init (n + 1) (fun _ ->
          Array.zeroCreate (maxSum + 1)
          ))
    dp.[0].[0].[0] <- 1L
    for j in 1..n do
      for k in 0..n do
        for s in 0..maxSum do
          dp.[j].[k].[s] <-
            if s < xs.[j - 1] then
              dp.[j - 1].[k].[s]
            elif k >= 1 && s >= xs.[j - 1] then
              dp.[j - 1].[k].[s] + dp.[j - 1].[k - 1].[s - xs.[j - 1]]
            else 0L

    let count =
      (seq { 0..n } |> Seq.sumBy (fun k -> dp.[n].[k].[k * a])) - 1L

    printfn "%d" count

    // exit code
    0


Measured memory_bytes: 56260
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0;j<k;j++){
        llong s = 0; 
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if ( i == n ) return n;    
        } 
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000*10000;
    llong mid;
    while(right-left>1){
        mid = (left + right) / 2;
        int v = check(mid);
        if(v>=n)right=mid;
        else left = mid;
    } 
    return right;
}

int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using vector = std::vector<int>;
using lint = long long int;
using string = std::string;

int main() {
  string s; input >> s;
  if (s.back() == 's') {
	s += "es";
  } else {
	s += "s";
  }
  std::cout << s << std::endl;
}



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

using namespace std;

int main()
{
    string s;
    cin >> s;

    int ans = 0;
    int length = s.size() - 1;
    while (length > 0) {
        string sub = s.substr(0, length);
        if (length % 2 == 0) {
            int mid = length / 2;
            if (sub.substr(0, mid) == sub.substr(mid, mid)) {
                ans = length;
                break;
            }
        }
        length--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
import itertools

n,m,q=map(int,input().split())

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    A,B,C,D=map(int,input().split())
    a.append(A)
    b.append(B)
    c.append(C)
    d.append(D)

p=list(range(1,m+1))
ans=0
cnt=0

for i in itertools.combinations_with_replacement(p, n):
    ans=max(ans,cnt)
    cnt=0
    for j in range(q):
        if i[b[j]-1] - i[a[j]-1]==c[j]:
            cnt+=d[j]

print(max(cnt,ans))

Measured memory_bytes: 67980
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    vector<int> as(n);
    vector<vector<P>> xy(n);
    rep(i, n) {
        cin>>as[i];
        rep(j, as[i]) {
            int x, y;
            cin>>x>>y; x--;
            xy[i].emplace_back(x, y);
        }
    }
    int cnt = 0;
    rep(i, 1<<n) {
        vector<int> group;
        rep(j, n) if ((i>>j)&1) group.push_back(j);

        vector<bool> honest(n, false);
        for (auto g : group) honest[g] = true;
        bool find = true;
        for (auto g : group) {
            rep(j, as[g]) {
                P p = xy[g][j];
                if (p.second && !honest[p.first]) {
                    find = false;
                    break;
                }
                if (!p.second && honest[p.first]) {
                    find = false;
                    break;
                }
            }
        }
        if (find) {
            int s = group.size();
            cnt = max(cnt, s);
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<array>
#include<utility>

template<typename T, size_t N>
void sort_array(std::array<T, N>& array);

int main()
{
	std::array<int, 10> input;
	for (unsigned long i = 0; i < input.size(); ++i)
	{
		std::cin >> input[i];
	}

	sort_array<int,input.size()>(input);
    
    std::cout << input[0] << std::endl
              << input[1] << std::endl
              << input[2] << std::endl;
	return 0;
}

template<typename T, size_t N>
void sort_array(std::array<T, N>& array)
{
	int temp = 0;
	for (unsigned long i = 0; i < array.size(); ++i)
	{
		temp = array[i];
		for (unsigned long j = i; j < array.size(); ++j)
		{
			if (temp < array[j])
			{
				std::swap(array[j], temp);
			}
		}
		array[i] = temp;
	}
}

Measured memory_bytes: 1160
N = input()
a = [0] * 2050
n = 0
p = 1
for i in range(len(N)):
    n += int(N[len(N)-1-i]) * p
    p *= 10
    p %= 2019
    a[int(n) % 2019] += 1
ans = 0
for i in range(2019):
    if i == 0:
        ans += a[i] * (a[i]+1) // 2
    else:
        ans += (a[i]-1) * a[i] // 2
print(ans)


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

int main() {
	int count=0;
	int a[6];
	int b[4];
	for (int aa = 0;aa < 4;aa++) {
		b[aa] = 0;
	}
	for (int i = 0;i < 6;i++) {
		cin >> a[i];
		if (a[i] == 1)
			b[0]++;
		else if (a[i] == 2)
			b[1]++;
		else if (a[i] == 3)
			b[2]++;
		else if(a[i]==4)
			b[3]++;
	}
	if (a[0] == a[2] and a[1] == a[3])
		count++;
	else if (a[0] == a[4] and a[1] == a[5])
		count++;
	else if (a[2] == a[4] and a[3] == a[5])
		count++;
	else if (a[0] == a[1] or a[2] == a[3] or a[4] == a[5])
		count++;
	sort(b, b + 4);
	if (b[0] == 1 and b[1] == 1 and b[2] == 2 and b[3] == 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 888