akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    set<string> S;
    for(int i = 0;i < N;i++) {
        string t;
        cin >> t;
        S.insert(t);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19120
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    k = I()
    x = I()
    y = I()
    if n <= k:
        print(n*x)
    else:
        print(k*x + (n-k)*y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//using ll=long long;

int main(){
    string S;
    int N;
    cin >> N >> S;
    int count = 0;
    for(int i = 1; i < N; i++){
        string X = S.substr(0, i);
        string Y = S.substr(i);
        vector<char> lx;
        vector<char> ly;
        for(int j = 0; j < X.length(); ++j){
            auto itr = find(lx.begin(), lx.end(), X[j]);
            if(itr == lx.end()) lx.push_back(X[j]);
        }
        for(int k = 0; k < Y.length(); ++k){
            auto itr = find(ly.begin(), ly.end(), Y[k]);
            if(itr == ly.end()) ly.push_back(Y[k]);
        }
        sort(lx.begin(), lx.end());
        sort(ly.begin(), ly.end());
        vector<char> intersection;
        set_intersection(lx.begin(), lx.end(), ly.begin(), ly.end(), inserter(intersection, intersection.end()));
        if(intersection.size() > count) count = intersection.size();
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){


	long long  a;
	long long  b;
	long long  s;

	cin>>a>>b;

	s=a+b;
	if( s < 3 ){
		cout<<"Impossible"<<endl;
	}else if( (s % 3 == 0 )||(a % 3 == 0)||(b % 3 == 0)){
		cout<<"Possible"<<endl;
	}else
		cout<<"Impossible"<<endl;


	}




Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min(a,b)+Math.min(c,d));
    }
}


Measured memory_bytes: 22996
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{

	public static void main(String[] args) { //x=0; y=1
		Scanner input = new Scanner(System.in);
		long x = input.nextLong();
		long y = input.nextLong();
		long ans = 0;
		if (Same(x,y)) {
			if (x>y) {
				ans = Math.abs(x-y)+2;
				if (y==0||x==0) ans--;
			} 
			else ans = Math.abs(x-y);
		}else {
			ans = Math.abs(Math.abs(x)-Math.abs(y))+1;
		}
		System.out.println(ans);
	}
	public static boolean Same(long a, long b) {
		if (a<=0&&b<=0) return true;
		if (a>=0&&b>=0) return true;
		return false;
	}
	/*Cases:
	 * 1. abs(y-x)
	 * 2. 
	 * 
	 * */
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  vector<int>dp(N,INT_MAX);
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i+j<N)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[N-1]<<endl;

  return 0;
}


Measured memory_bytes: 1024
def main():
    import sys
    buf = sys.stdin.buffer

    class UnionFind:
        def __init__(self, size):
            self.parent = [-1] * size
            self.rank = [1] * size

        def get_root(self, node):
            parent = self.parent[node]
            if parent == -1:
                root = node
            else:
                root = self.get_root(parent)
                self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
            return root

        def in_same_group(self, node1, node2):
            root1 = self.get_root(node1)
            root2 = self.get_root(node2)
            return root1 == root2

        def unite(self, node1, node2):
            if self.in_same_group(node1, node2):
                return
            main_root = self.get_root(node1)
            sub_root = self.get_root(node2)
            if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
                main_root, sub_root = sub_root, main_root

            self.parent[sub_root] = main_root
            self.rank[main_root] += self.rank[sub_root]

    n, m, k = map(int, buf.readline().split())
    uf = UnionFind(n)
    minus_count = [1] * n

    query = list(map(int, buf.read().split()))
    follows = query[:2*m]
    blocks = query[2*m:]

    for a, b in zip(follows[0::2], follows[1::2]):
        uf.unite(a-1, b-1)
        minus_count[a-1] += 1
        minus_count[b-1] += 1

    for a, b in zip(blocks[0::2], blocks[1::2]):
        if uf.in_same_group(a-1, b-1):
            minus_count[a-1] += 1
            minus_count[b-1] += 1

    result = [uf.rank[uf.get_root(i)] - minus_count[i] for i in range(n)]
    print(*result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 40168
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double R;
    cin >> R;
    cout << R * 2 * 3.141 << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
const int INF = 2e9;
const ll INFLL = 4e18;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n;
	sd(n);
	if(n>=30) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

bool match(char x, char y){
    return (x == y || x == '?' || y == '?' || x == 'X' || y == 'X');
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string a, b, c;
    cin >> a >> b >> c;
    ll A = len(a), B = len(b), C = len(c);

    bool ab[20000], ac[20000], bc[20000];
    char AB[20000], AC[20000], BC[20000];

    rep(i, 20000){
        AB[i] = AC[i] = BC[i] = 'X';
        ab[i] = ac[i] = bc[i] = true;
    }

    rep(i, A) AB[5000 + i] = AC[5000 + i] = a[i];
    rep(i, B) BC[5000 + i] = b[i];

    for (ll i = 1000; i <= 9000; ++i){
        rep(j, B) ab[i] = ab[i] and match(AB[i + j], b[j]);
        rep(j, C) ac[i] = ac[i] and match(AC[i + j], c[j]);
        rep(j, C) bc[i] = bc[i] and match(BC[i + j], c[j]);
    }

    ll ans = 1e18;

    for (ll i = 1000; i <= 9000; ++i)
    {
        for (ll j = 1000; j <= 9000; ++j){
            if(abs(i-j) > 4000) continue;
            if(ab[i] and ac[j] and bc[5000+j-i]){
                ll L = min({5000LL,i,j});
                ll R = max({5000LL + A, B + i, C + j});
                ans = min(ans, R - L);
            }
        }
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 384
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    now = 0
    for i in range(N):
        if A[i]==now+1:
            now +=1
        else:
            pass
    if now == 0:
        print(-1)
    else:
        print(N-now)
if __name__ == "__main__":
    main()    

Measured memory_bytes: 77644
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        int ans=0;
        while((1<<ans)<=n)
            ans++;
        ans--;
        printf("%d\n",1<<ans);
    }
    return 0;
}


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

int main () { 
 int num;
 cin >> num;

 int max = -1000001, min = 1000001, data;
 long long sum = 0;
 for (int i = 0; i < num; i++) {
  cin >> data;
  if (min > data) {
   min = data;
  }
  if (max < data) {
   max = data;
  }
  sum += data;
 }

 cout << min << " " << max << " " << sum << endl;
//printf("%d %d %ld\n", min, max, sum);

 return 0;
}

Measured memory_bytes: 1164
unittest
{
	assert( [ "4 4 6" ].parse.expand.solve == 5 );
	assert( [ "5 4 3" ].parse.expand.solve == 0 );
	assert( [ "1 7 10" ].parse.expand.solve == 0 );
	assert( [ "1 3 3" ].parse.expand.solve == 1 );
}

import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nab = input.front.split.to!( long[] );
	return tuple( nab[ 0 ], nab[ 1 ], nab[ 2 ] );
}

auto solve( long n, long a, long b )
{
	if( b < a ) return 0L;
	if( n == 1 && b != a ) return 0L;
	return 1 + ( b * ( n - 2 ) ) - ( a * ( n - 2 ) );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,K;
int main(){
    cin >> N >> K;
    int x,res = 0;
    rep(i,N){
        cin >> x;
        if(x >= K-x) res += 2*(K-x);
        else res += 2*x;
    }
    pr(res);
}

Measured memory_bytes: 256
class Position
  def initialize(x = 0, y = 0, count = 0)
    @x = x
    @y = y
    @count = count
  end
  attr_reader :x, :y, :count
end

h, w = gets.split.map(&:to_i)
maze = h.times.map {gets.chomp}
field = nil

Position.send(:define_method, :succ) do
  x = @x + 1
  y = @y
  if x >= w
    x = 0
    y += 1
    return false if y >= h
  end
  Position.new(x, y)
end

Position.send(:define_method, :move) do |dir|
  x, y = @x, @y
  dx, dy = [[1, 0], [0, -1], [-1, 0], [0, 1]][dir]
  x += dx
  y += dy
  return false if x >= w || x < 0 || y >= h || y < 0
  return false if field[y][x] != "."
  Position.new(x, y, @count + 1).mark
end

Position.send(:define_method, :mark) do
  field[@y][@x] = "*"
  self
end

solve_maze = ->(start) {
  return 0 if maze[start.y][start.x] == "#"
  field = maze.map(&:dup)
  max = 0
  q = [start.mark]
  while (po = q.shift)
    max = po.count if po.count > max
    4.times do |dir|
      nxt = po.move(dir)
      q << nxt if nxt
    end
  end
  max
}


start = Position.new
max = 0
loop do
  hosuu = solve_maze.(start)
  max = hosuu if hosuu > max
  break unless (start = start.succ)
end

puts max

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = (a + b) / 2;
        if((a + b) % 2 == 0) System.out.println(ans);
        else System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 35492
def solve(x):
    if len(x) == n:
        ans.append(x)
        return 0
    syurui = len(set(x))
    for i in range(syurui + 1):
        solve(x + chr(97 + i))


n = int(input())

a = "a"

ans = []

solve(a)

ans = sorted(ans)

print(*ans)

Measured memory_bytes: 14476
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> d(n);
    int a, b;
    for (int i=0; i<m; i++) {
        cin >> a >> b;
        d[a-1].push_back(b-1);
        d[b-1].push_back(a-1);
    }

    int navi[n] = {};
    int cnt = 1;
    
    queue<int> que;
    que.push(0);

    while (que.size()) {
        if (cnt > n) break;

        for (int i : d[que.front()]) {
            if (navi[i] == 0) {
                navi[i] = que.front()+1;
                cnt++;

                que.push(i);
            }
        }
        que.pop();
    }


    if (cnt < n) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for (int i=1; i<n; i++) cout << navi[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 10040
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

  string S;
  cin >> S;
  int length = S.size();

  if(length == 1){
    cout << "0\n";
    return 0;
  }

  int diff1 = 0;
  char check = '1';
  for(int i=0; i<length; ++i){
    if(S[i] != check)
      ++diff1;
    check = check == '0' ? '1' : '0';
  }

  int diff2 = 0;
  check = '0';
  for(int i=0; i<length; ++i){
    if(S[i] != check)
      ++diff2;
    check = check == '0' ? '1' : '0';
  }

  cout << min(diff1, diff2) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 52;
ll n, x;
ll p[N], layer[N];
ll cnt;
ll get(ll curr, ll remain){
  if(remain <= curr) return 0;
  if(remain >= layer[curr] - curr) return p[curr];
  if(remain == layer[curr-1] + 2){
    return p[curr-1] + 1;
  } else if(remain > layer[curr-1] + 2){
    ll ans = 0;
    ans += p[curr-1] + 1;
    ans += get(curr - 1, remain - layer[curr-1] - 2);
    return ans;
  } else {
    return p[curr] - get(curr, layer[curr] - remain);
  }
}
int main(){
  cin >> n >> x;
  p[0] = 1;
  layer[0] = 1;
  for(int i = 1; i <= n; i ++){
    p[i] = 2*p[i-1]+1;
    layer[i] = 2*layer[i-1] + 3;
  }
  //cout << layer[n] << " " << p[n] << endl;
  cout << get(n, x) << endl;
  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include<iostream>
#include <sstream>  // for string streams
#include <string>  // for string
#include <stack> 
#include <cmath>
  #pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  void printprecise(double l,int precision) 
  {
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l;
}

  vector<int> primes;
  
int32_t main()
{
       

 
  


   int n;
   cin >> n;
   int ans = n/2;
   if(n%2!=0)
   {
    ans++;
   }

   
   printprecise((db)((db)(ans)/(db)(n)),10);

    return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    cin>>n;
    ll ans=0;
    rep(i,1,n){
        if(i%3 and i%5) ans+=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int x, y;
    string s;
    cin >> x >> y >> s;
    REP(i, x){
        if(i == y-1){
            s[i] = tolower(s[i]);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,d;
  cin >> n >> d;
  
  int ans=0;
  int i;  
  long long x;
  long long y;

  for(i=0;i<n;i++){
      cin >> x >> y;
      if(x*x + y*y <= d*d){
          ans++;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll a,b,c;
	cin >> a >> b >> c;
	
	cout << max(c - (a-b),(ll)0) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    # 入力
    n = int(input())

    boolls = [[]]
    for i in range(n):
        tmpls = []
        for x in boolls:
            y = x.copy()
            x.append(True)
            y.append(False)
            tmpls.append(x)
            tmpls.append(y)
        boolls = tmpls

    boolls.sort(key=lambda _: _.count(True), reverse=True)

    xyls = []
    for i in range(n):
        ai = int(input())
        tuples = []
        for j in range(ai):
            x, y = map(int, input().split())
            tuples.append((x, y == 1))
        xyls.append(tuples)

    tmpTrueCnt = n
    max_cnt = 0
    for boolx in boolls:
        truecnt = boolx.count(True)
        if truecnt == 0:
            break
        if max_cnt > truecnt:
            break

        if tmpTrueCnt > truecnt:
            tmpTrueCnt = truecnt

        ok = True
        for i in range(len(boolx)):
            tf = boolx[i]
            if tf:
                for message in xyls[i]:
                    if boolx[message[0] - 1] != message[1]:
                        ok = False
                        break
            if not ok:
                break
        if ok:
            max_cnt = tmpTrueCnt
            break

    print(max_cnt)


main()


Measured memory_bytes: 11760
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner teclado = new Scanner (System.in);
		int A;
		int B;
		A=teclado.nextInt();
		B=teclado.nextInt();
		
		
		if(((A*2)-1) > A+B &&  (((A*2)-1)) > ((B*2)-1) ){
			System.out.println((A*2)-1);
		}else if(((B*2)-1) > A+B && ((B*2)-1) >((A*2)-1) ) {
			System.out.println((B*2)-1);			
		}else {
			System.out.println(A+B);
		}
	}
	
}

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

int main()
{

  int a,n;
  cin >> n;
  a = 0;
  rep(i, n + 1){
    a += i;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3580
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        ans[a-1] = 0
    if h[b-1] <= h[a-1]:
        ans[b-1] = 0
print(sum(ans))

Measured memory_bytes: 20056
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// range query using segment tree
#define ISMAXRANGE	1		// 1 = max range, 0 = min range
#define VERYBIG		(1LL << 60)	


class segment_tree {
	vector<long long> t;
	long size;
public:
	segment_tree(long n) {
		if (ISMAXRANGE) t.assign(4 * n + 1, 0);
		else t.assign(4 * n + 1, VERYBIG);
		size = n;
	}

	void initialize_array(vector<long long>& v) {
		initialize_with_array(1, 0, size - 1, v);
	}

	void initialize_with_array(long startpos, long l, long r, vector<long long>& v) {
		if (l == r) {
			t[startpos] = v[l];
		}
		else {
			long m = (l + r) / 2;
			initialize_with_array(2 * startpos, l, m, v);
			initialize_with_array(2 * startpos + 1, m + 1, r, v);

			if (ISMAXRANGE == 1) t[startpos] = max(t[startpos * 2], t[startpos * 2 + 1]);
			else  t[startpos] = min(t[startpos * 2], t[startpos * 2 + 1]);
		}
	}

	void update(long index, long long val) { // insert val into location index
		update_full(1, 0, size - 1, index, val);
	}

	void update_full(long startpos, long l, long r, long index, long long val) {
		if (l == r) {
			t[startpos] = val;
		}
		else {
			long m = (l + r) / 2;
			if (index <= m) update_full(2 * startpos, l, m, index, val);
			else update_full(2 * startpos + 1, m + 1, r, index, val);

			if (ISMAXRANGE) t[startpos] = max(t[startpos * 2], t[startpos * 2 + 1]);
			else t[startpos] = min(t[startpos * 2], t[startpos * 2 + 1]);
		}
	}

	long long query(long l, long r) {  // get range min/max between l and r
		if (l > r) {
			if (ISMAXRANGE) return 0;
			else return VERYBIG;
		}
		return query_full(1, 0, size - 1, l, r);
	}

	long long query_full(long startpos, long left, long right, long l, long r) {	 // left/right = current range, l/r = intended query range
		if ((left >= l) && (right <= r)) return t[startpos];
		long m = (left + right) / 2;
		long long ans;
		if (ISMAXRANGE) ans = -(1LL << 60);
		else ans = VERYBIG;
		if (m >= l) {
			if (ISMAXRANGE) ans = max(ans, query_full(startpos * 2, left, m, l, r));
			else ans = min(ans, query_full(startpos * 2, left, m, l, r));
		}
		if (m + 1 <= r) {
			if (ISMAXRANGE) ans = max(ans, query_full(startpos * 2 + 1, m + 1, right, l, r));
			else ans = min(ans, query_full(startpos * 2 + 1, m + 1, right, l, r));
		}
		return ans;
	}
};



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

	long long n, i, j, k, ans, x;
	cin >> n;
	vector<long long> h(n), a(n);
	for (i = 0; i < n; i++) cin >> h[i];
	for (i = 0; i < n; i++) cin >> a[i];

	segment_tree st(n + 10);
	vector<long long> dp(n, 0);

	for (i = 0; i < n; i++) {
		x = st.query(0, h[i]);
		dp[i] = x + a[i];
		st.update(h[i], dp[i]);
	}

	ans = *max_element(dp.begin(), dp.end());

	cout << ans << "\n";


	return 0;
}





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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;
  if(s[0]==s[2]) prt("Yes");
  else prt("No");
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++) {
		x = r * x - d;
		cout << x << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct RollingHash {
    typedef long long int_type;
    typedef pair<int_type,int_type> hash_type;

    int_type base1;
    int_type base2;
    int_type mod1;
    int_type mod2;
    vector<int_type> hash1;
    vector<int_type> hash2;
    vector<int_type> pow1;
    vector<int_type> pow2;

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    hash_type get(int l,int r) {
        int_type t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        int_type t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

};
int n,m;
string s;
set<RollingHash::hash_type > S;

int main() {
    int r=1,l=0;
    cin>>n>>m;
    cin>>s;

    RollingHash rh;
    rh.init(s);

    rep(i,m) {
        string q;
        cin>>q;
        if(q=="R++") r++;
        if(q=="R--") r--;
        if(q=="L++") l++;
        if(q=="L--") l--;

        S.insert(rh.get(l,r));
    }
    cout<<S.size()<<endl;

    return 0;
}

Measured memory_bytes: 29524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  int Alice, Bob;
  vector <int> data(100);
  
  cin >> num;
  Alice = 0;
  Bob = 0;
  for (int i = 0; i < num; i++) {
    cin >> data.at(i);
  }
  
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  
  for(int i = 0; i < data.size(); i++) {
    if (i % 2 == 0) {
      Alice = Alice + data.at(i);
    } else {
      Bob = Bob + data.at(i);
    }
  }
  cout << Alice - Bob << endl;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int K = cin.nextInt();
            int[,] gcdArray = new int[K, K];
            for (int i = 0; i < K; i++)
            {
                for (int j = 0; j < K; j++)
                {
                    gcdArray[i, j] = GCD(i + 1, j + 1);
                }
            }

            long ans = 0;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        ans += gcdArray[gcdArray[i - 1, j - 1] - 1, k - 1];
                    }
                }
            }
            Console.WriteLine(ans);
        }

        int GCD(int a, int b)
        {
            int min = Math.Min(a, b);

            for (int i = min; i >= 1; i--)
            {
                if (a % i == 0 && b % i == 0)
                {
                    return i;
                }
            }
            return 0;
        }

    }
}


Measured memory_bytes: 27880
#include<bits/stdc++.h>
using namespace std;
inline void io()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}
int main()
{
    io();
    string a, b = "";
    cin >> a;
    for (int i = 0; i < a.length(); ++i)
    {
        if (a[i] == 'B') {
            if (b.empty())
                continue;
            else
                b.erase(b.begin() + b.length() - 1);
        }
        else
            b += a[i];
    }
    cout << b << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
/*
横一列を黒にしたい
9割埋まってるけど一発で黒く出来ないところは？
2発なら確実にいける
一発で黒く出来るところを埋めるパターン、2発で埋めるパターン両方試す
*/
//main
signed main(){
  int N;cin>>N;
  std::vector<string> s(N);
  for(int i=0;i<N;i++)cin>>s[i];
  int black=0;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)black+=s[i][j]=='#';
  if(black==N*N)fin(0);
  if(black==0)fin(-1);
  std::vector<int> can(N,0);
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)can[j]+=s[i][j]=='#';
  int res=LINF,tmp=0;
  for(int i=0;i<N;i++,tmp=0){
    if(!can[i])continue;
    for(int j=0;j<N;j++)tmp+=s[i][j]=='.';
    res=min(res,tmp);
  }
  for(int i=0;i<N;i++,tmp=0){
    for(int j=0;j<N;j++)tmp+=s[i][j]=='.';
    res=min(res,tmp+1);
  }
  int mn=0;
  for(int j=0;j<N;j++,tmp=0){
    for(int i=0;i<N;i++)tmp+=s[i][j]=='#';
    if(tmp==N)mn++;
  }
  fin(res+N-mn);
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(void)
{
	char c[100];
	int n;
	int i,t,count=0;
	while(scanf("%s",c)!=EOF){
		n=strlen(c);
		t=0;
		for(i=0;i<n/2;i++){
			if(c[i]==c[n-i-1]){
				t=t+1;
			}
		}
		if(t==n/2){
			count=count+1;
		}
	}
	printf("%d\n",count);
	return 0;
}
	

Measured memory_bytes: 540
/* Coached by Dukkha */
#include <stdio.h>

#define N 100000

int aa[N];

long long solve(int n, int p) {
	int i, sum;
	long long cnt;

	cnt = sum = 0;
	for (i = 0; i < n; i++) {
		sum += aa[i];
		if (i % 2 == p) {
			if (sum >= 0) {
				cnt += sum + 1;
				sum = -1;
			}
		} else {
			if (sum <= 0) {
				cnt += 1 - sum;
				sum = 1;
			}
		}
	}
	return cnt;
}

int main() {
	int n, i;
	long long ans0, ans1;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	ans0 = solve(n, 0);
	ans1 = solve(n, 1);
	printf("%lld\n", ans0 < ans1 ? ans0 : ans1);
	return 0;
}


Measured memory_bytes: 512
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf.chars().nth(0).unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let b = buf.chars().nth(1).unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let c = buf.chars().nth(2).unwrap();

    println!("{}{}{}", a, b, c);
}


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

typedef long long ll;

ll mini(ll a, ll b){
  if (a<b) return a;
  else return b;
}

int main(){
  ll N, K;
  cin >> N >> K;
  
  while(true){
    if (N>K){
      ll rem=N/K;
      N-=rem*K;
    }
    else{
      ll ans=mini(N, K-N);
      cout << ans << endl;
      return 0;
    }
  }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll ans;
vector<vector<ll> > vv(60000);

bool check(ll n){
	ll nn=n;
	ll c3=0;
	ll c5=0;
	ll c7=0;
	while(1){
		if(nn%10==3) c3=1;
		if(nn%10==5) c5=1;
		if(nn%10==7) c7=1;
	   nn/=10;	
		if(nn==0) break;
	}
	if(c3&&c5&&c7) return true;
	else return false;
}

int main(){

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

cin>>N;

vv[0].pb(3);
vv[0].pb(5);
vv[0].pb(7);

for(ll i=1; i<=10; i++){
	for(ll j=0; j<vv[i-1].size(); j++){
		ll add1=3*pow(10,i)+vv[i-1][j];
		ll add2=5*pow(10,i)+vv[i-1][j];
		ll add3=7*pow(10,i)+vv[i-1][j];
		vv[i].pb(add1);
		vv[i].pb(add2);
		vv[i].pb(add3);
	}
}

for(ll i=2; i<=10; i++){
	for(ll j=0; j<vv[i].size(); j++){
		if(vv[i][j]<=N){
			if(check(vv[i][j])) ans++;
		}
	}
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 4596
if __name__ == '__main__':
    n, s = map(int, input().split())
    s = s/1000
    exist = False
    for x in range(n+1):
        if (s-n-9*x)>=0 and (s-n-9*x)%4==0:
            y = (s-n-9*x)/4
            z = n-(x+y)
            if 0<=z and y<=n:
                print(str(x)+' '+str(int(y))+' '+str(int(z)))
                exist = True
                break
    if not(exist):  #!じゃなくてnot()
        print("-1 -1 -1")


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

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define PQ priority_queue
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 2000100
#define INF 9223372036854775807
int fac[MAXN],p25[MAXN],p26[MAXN];
int power(int x, int y, int m=MOD) { 
    if (y == 0) 
        return 1; 
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
}  
int nCr(int n,int r,int M=MOD){
    int num=fac[n],den=(fac[r]*fac[n-r])%MOD;
    den = power(den,M-2,M);
    int ans = (num*den)%M;
    return ans;
}
void solve(){
	int k;   cin>>k;
	string s;   cin>>s;
	int n=s.size();
	int sum=0;
	f(pos,n,n+k+1){
		sum=(sum+((nCr(pos-1,n-1)*p25[pos-n])%MOD)*p26[n+k-pos])%MOD;
	}
	cout<<sum;
}
signed main(){
    fastio
    fac[0]=p25[0]=p26[0]=1;
    f(i,1,MAXN)	fac[i]=(fac[i-1]*i)%MOD,p25[i]=(25*p25[i-1])%MOD,p26[i]=(26*p26[i-1])%MOD;
    int t=1;
    for(;t--;solve());
}

Measured memory_bytes: 51128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string a, b;
  while (cin >> a >> b, a != "0") {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      hit += a[i] == b[i];
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        blow += a[i] == b[j];
      }
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }

  return 0;
}


Measured memory_bytes: 3156
from collections import Counter


def main():
    n, m = map(int, input().split())
    cs = Counter()
    for _ in range(n):
        aa = list(map(int, input().split()))[1:]
        for a in aa:
            cs[a] += 1
    print(len([v for k, v in cs.items() if v == n]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import math
import fractions
import collections
import itertools
import pprint
N=int(input())
a=list(map(int,input().split()))
ex=a[0]
for i in range(1,N):
    ex=ex^a[i]
l=[]
for i in range(N):
    l.append(ex^a[i])
print(*l)

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

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

    vector<int> v;
    while (n--)
        v.push_back(0);
    while (m--)
        v.push_back(1);

    int ans = 0;
    for (int i = 0; i < v.size(); i++)
        for (int j = i + 1; j < v.size(); j++)
            ans += ((v[i] + v[j]) % 2 == 0);
    cout << ans << '\n';

    return 0;
}

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

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


Measured memory_bytes: 256
S = input()
n,w,s,e = 0,0,0,0
for i in S:
    if i == "N":
        n = 1
    if i == "W":
        w = 1
    if i == "S":
        s = 1
    if i == "E":
        e = 1
#print(n,s,w,e)
if n == s and w == e:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n, p := scanInt(sc), scanInt(sc)
	as := nextIntSlice(sc, n)
	nums := make([]int, 2)
	for _, v := range as {
		nums[v%2]++
	}
	patternNum := 0
	for i := 0; i <= nums[1]; i++ {
		if i%2 != p {
			continue
		}
		v := 1
		for j := 1; j <= i; j++ {
			v *= nums[1] - j + 1
			v /= j
		}
		patternNum += v
	}
	return exp(2, nums[0]) * patternNum
}

func exp(b, e int) int {
	r := 1
	p := b
	c := e
	for c > 0 {
		if c&1 == 1 {
			r *= p
		}
		p = p * p
		c >>= 1
	}
	return r
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;


public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());

        Pattern space = Pattern.compile(" ");
        Map<Integer, List<Integer>> nexts = new HashMap<>();
        int[] a = new int[n - 1];
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            int[] line = space.splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();
            a[i] = line[0] - 1;
            b[i] = line[1] - 1;
            nexts.computeIfAbsent(a[i], unused -> new ArrayList<>()).add(b[i]);
            nexts.computeIfAbsent(b[i], unused -> new ArrayList<>()).add(a[i]);
        }
        Deque<Integer> c = space.splitAsStream(stdin.readLine())
                                .map(Integer::new)
                                .sorted(Comparator.reverseOrder())
                                .collect(Collectors.toCollection(ArrayDeque::new));

        int[] score = new int[n];
        Deque<Integer> queue = new ArrayDeque<>();
        queue.add(0);
        while (!queue.isEmpty()) {
            Integer current = queue.pollFirst();
            score[current] = c.pollFirst();
            for (Integer next : nexts.get(current)) {
                if (score[next] == 0) {
                    queue.addLast(next);
                }
            }
        }

        int sum = IntStream.range(0, n - 1).map(i -> Math.min(score[a[i]], score[b[i]])).sum();
        String line = Arrays.stream(score).mapToObj(Integer::toString).collect(Collectors.joining(" "));
        stdout.println(sum);
        stdout.println(line);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}

Measured memory_bytes: 38716
#include <bits/stdc++.h>
using namespace std;
int main(){
    for(;;){
		int x,y;
		cin>>x>>y;
		if(x==0&&y==0){
			break;
		}
        if(x<=y){
			cout<<x<<" "<<y<<endl;
		}
		else {
			cout<<y<<" "<<x<<endl;
		}
	}
}



Measured memory_bytes: 3068