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

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        HashMap<String, Integer> sn = new HashMap<String, Integer>();
        sn.put("S", 0);
        sn.put("H", 1);
        sn.put("C", 2);
        sn.put("D", 3);
        char[] ns = new char[]{'S', 'H', 'C', 'D'};

        int n = s.nextInt();
        boolean[][] c = new boolean[4][13];
        for(int i = 0; i < c.length; ++i) {
            for(int j = 0; j < c[0].length; ++j) {
                c[i][j] = false;
            }
        }
        for(int i = 0; i < n; ++i) {
            c[sn.get(s.next())][s.nextInt() - 1] = true;
        }

        for(int i = 0; i < c.length; ++i) {
            for(int j = 0; j < c[0].length; ++j) {
                if(c[i][j] == false) System.out.println(ns[i] + " " + (j + 1));
            }
        }
    }
}

Measured memory_bytes: 18028
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())
    a_l = list(map(int, input().split()))

    if any(i == 0 for i in a_l):
        print(0)
        return

    ans_max = 10 ** 18
    ans = 1
    for i in a_l:
        ans *= i
        if ans > ans_max:
            ans = -1
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21784
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 5005;
const int mod = 1e9 + 7;

string s;
lint solve(int l, int r){
	lint ret = 0;
	for(int i=l; i<r; i++){
		ret = ret * 10 + s[i] - '0';
	}
	return ret;
}

int main(){
	cin >> s;
	int n = s.size();
	lint ans = 0;
	for(int i=0; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			lint ret = solve(i, j);
			int empt = 0;
			if(j < n) empt += n - 1 - j;
			if(i > 0) empt += i - 1;
			ans += ret << empt;
		}
	}
	cout << ans << endl;
}


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

int main() {

    string S;
    cin >> S;

    for (int i = 0; i < 3; i++) {
        if (S[i] == S[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = []
out = {}

input = input().split(" ")
for i in input:
	arr.append(int(i))
	
	if out.get(arr[-1], False):
		out[arr[-1]] += 1
	else:
		out[arr[-1]] = 1

count = 0
for key in out:
	if key > out[key]:
		count += out[key]
	else:
		count += out[key] - key

print(count)

Measured memory_bytes: 23284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=145000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3696
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

#define MAX_COUNT 1000001

string ss;

int main()
{
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    vector<pii> d(n);
    d[0] = make_pair(0,0);
    ll mi = a[0];
    ll mic = 1;
    for(int i = 1;i< n;i++)
    {
        if(a[i] == mi)
        {
            mic++;
        }
        else if(a[i] < mi)
        {
            mi = a[i];
            mic = 1;
        }
        d[i] = make_pair(a[i] - mi, mic);
    }
    sort(d.begin(), d.end());
    ll dm = d.back().first;
    ll c = 0;
    for(auto i = d.rbegin();i != d.rend();i++)
    {
        if(i->first == dm)
        {
            c++;
        }
        else
        {
            break;
        }
//        cout << i->first << "," << i->second << endl;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class20
    {
        static void Main()
        {
            int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            Dictionary<string, string> Ptable= new Dictionary<string, string>();
            Dictionary<string, int> table = new Dictionary<string, int>();
            int AC = 0;
            for(int i = 0; i < N[1]; i++)
            {
                string[] str = Console.ReadLine().Split();
                if (table.ContainsKey(str[0])) //存在する
                {
                    if (Ptable[str[0]] != "AC")
                    {
                        if (str[1] == "WA")
                            table[str[0]] += 1;
                        else
                        {
                            Ptable[str[0]] = "AC";
                            AC += 1;
                        }

                    }
                }
                else　　　　　　　　　　　　　//存在しない
                {
                    Ptable.Add(str[0], str[1]);
                    if (str[1] == "WA")
                        table.Add(str[0], 1);
                    else
                    {
                        table.Add(str[0], 0);
                        AC += 1;
                    }
                        
                }

            }
            Dictionary<string, int> ACtable = new Dictionary<string, int>();
            foreach (string st in Ptable.Keys)
            {
                if (Ptable[st] == "WA")
                    table.Remove(st);
            }

                
            int WA = table.Values.Sum();
            Console.WriteLine("{0} {1}", AC, WA);
        }
    }
}


Measured memory_bytes: 36052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char N[4];
  cin >> N;
  if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3596
i = gets.chomp.to_s
len = i.length

until i == "0"
	arr = i.split("")
	sum = 0
	for k in 0..len - 1
		sum += arr[k].to_i
	end
	
	puts sum
	
	i = gets.chomp.to_s
	len = i.length
end

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define scint(x) scanf("%d", &x)
#define sclng(x) scanf("%ld", &x)
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int n = S.size();
    int ans = 753;
    // rep(i, n - 2){
    //     string sub = S.substr(i, 2);
    //     int k = stoi(sub);
    //     // printf("%d\n", k);
    //     ans = min(abs(753 - k), ans);
    // }
    rep(i, n - 2){
        string sub = S.substr(i, 3);
        int k = stoi(sub);
        // cout << k << endl;
        ans = min(abs(753 - k), ans);
    }
    // rep(i, n - 4){
    //     string sub = S.substr(i, 4);
    //     int k = stoi(sub);
    //     // printf("%d\n", k);
    //     ans = min(abs(753 - k), ans);
    // }

    cout << ans << endl;
    
    return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size())
    {
        REP(j, 1, s.size() - i + 1)
        {
            string temp = s.substr(i, j);
            //cout << temp << endl;
            bool flag = false;
            rep(i, temp.size())
            {
                if (temp[i] == 'A' || temp[i] == 'C' || temp[i] == 'G' || temp[i] == 'T')
                {
                    continue;
                }
                else
                {
                    flag = true;
                }
            }
            if (flag == false)
                ans = max(ans, (int)temp.size());
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char mk[4]={'S','H','C','D'};
  int n,c[4][14],i,j,s;
  char g;

  for(i=0;i<4;i++)
    for(j=0;j<14;j++)c[i][j]=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    int m;
    scanf(" %c %d",&g,&s);
      if(g=='S')m=0;
      if(g=='H')m=1;
      if(g=='C')m=2;
      if(g=='D')m=3;
      c[m][s]=1;
  }
  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      if(c[i][j]==0)printf("%c %d\n",mk[i],j);
    }
  }

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define per(i,a,b) for (int i = (a); i >= (b); i--)
using namespace std;
typedef long long ll;

ll x, y, ans;

int main() {
	cin >> x >> y;
	if (x % y == 0)
		return puts("-1"), 0;
	ans = 1000000000000000000ll / x * x;
	if (ans % y == 0)
		ans -= x;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    long long a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long long dp[n];
    for (int i = 0; i < n; i++)
    {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
    {
        for (int j = 1; j <= k; ++j)
        {
            if (i - j >= 0)
            {
                long long val1 = abs(a[i] - a[i - j]) + dp[i - j];
                dp[i] = min(dp[i], val1);
            }
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    bool f = false, ff = false;
    rep(i,3) if(s[i]=='A') f = true;
    rep(i,3) if(s[i]=='B') ff = true;
    if(f&&ff) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if (
      (x - r >= 0 )
      && (y - r >=0)
      && (x + r <= W)
      && (y + r <= H)
      )
    {
      printf("Yes\n");
    }else
    {
    printf("No\n");
    }

  return 0;
}

Measured memory_bytes: 584
N = int(input())
p = [int(_) for _ in input().split()]
cnt = 0
for i in range(1, N - 1):
    L = p[i - 1]
    C = p[i]
    R = p[i + 1]

    if L < C < R or R < C < L:
        cnt += 1

print(cnt)


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

int main(){
  int s,w;
  cin>>s>>w;
  if(s>w){cout<<"safe";return 0;}
  cout<<"unsafe";
  return 0;
}

Measured memory_bytes: 3632
#line 1 "main.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

#line 2 "/home/imperi/Documents/cp-library/lib/UnionFind/UnionFind.cpp"

#include <cstddef>
#line 6 "/home/imperi/Documents/cp-library/lib/UnionFind/UnionFind.cpp"

class UnionFind{
  public:
  using size_t=std::size_t;
  private:
  std::vector<size_t> par,sz;
  size_t group;

  public:

  UnionFind(size_t n=0):par(n,0),sz(n,1),group(n){
    std::iota(par.begin(),par.end(),0);
  }

  size_t root(size_t n){
    if(par[n]==n)return n;
    return par[n]=root(par[n]);
  }

  bool unite(size_t a,size_t b){
    a=root(a);b=root(b);
    if(a==b)return false;
    group--;
    if(sz[a]<sz[b])std::swap(a,b);
    sz[a]+=sz[b];
    par[b]=a;
    return true;
  }

  size_t size(){return par.size();}
  size_t groups(){return group;}
  size_t group_size(size_t n){return sz[root(n)];}

  bool same(size_t a,size_t b){return root(a)==root(b);}
};
#line 85 "main.cpp"

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

  ll n,q;
  std::cin>>n>>q;

  UnionFind uni(n);

  while(q--){
    ll mode,x,y;
    std::cin>>mode>>x>>y;
    if(mode==0){
      uni.unite(x,y);
    }else{
      std::cout<<uni.same(x,y)<<"\n";
    }
  }

  return 0;
}



Measured memory_bytes: 3308
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int w = in.nextInt();

        int[] wa = new int[n];
        long[] va = new long[n];
        for (int i = 0; i < n; i++) {
            wa[i] = in.nextInt();
            va[i] = in.nextInt();
        }
        long[][] dp = new long[n][w];
        for (int i = 0; i < w; i++) {
            if (i >= wa[0] - 1)
                dp[0][i] = va[0];
        }

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < w; j++) {
                long val = j - wa[i] >= 0 ? dp[i - 1][j - wa[i]] + va[i] : 0;
                dp[i][j] = Math.max(dp[i - 1][j], val);
            }
        }

        long ans = 0;
        for (int k = 0; k < w; k++) {
            ans = Math.max(ans, dp[n - 1][k]);
        }
        out.println(ans);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}


Measured memory_bytes: 128468
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, q = LI()
    s = 'X' + SI()
    Q = [LI() for _ in range(q)]

    ac = [0]
    for i in range(1, n + 1):
        if (s[i], s[i - 1]) == ('C', 'A'):
            ac.append(ac[-1] + 1)
        else:
            ac.append(ac[-1])

    for l, r in Q:
        print(ac[r] - ac[l])
    # return res


main()


Measured memory_bytes: 24476
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]){
	long double x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	long double distance = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
	cout << fixed << std::setprecision(8) << distance << endl;
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

    map<int, int> coo;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        coo[a] = 1;
    }
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        coo[b] = -1;
    }

    ll ans = 1;
    ll cnt = 0;
    for (auto p : coo) {
        ll k = p.second;
        if (cnt * k < 0) {
            ans *= abs(cnt);
            ans %= MOD;
        }
        cnt += k;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1):
        z = n - i - j
        if (i * 10000 + j * 5000 + z * 1000) == y and z >= 0:
            print("{} {} {}".format(i, j, z))
            break
    else:
        continue
    break

else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] whn = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] maxH = new int[whn[0]];
        int[] maxW = new int[whn[1]];
        for (int i = 0; i < whn[2]; i++)
        {
            int[] xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            maxH[xy[0]] = Max(maxH[xy[0]], xy[1]);
            maxW[xy[1]] = Max(maxW[xy[1]], xy[0]);
        }
        int[] ruisekiMH = new int[whn[0] + 1];
        for (int i = whn[0] - 1; i >= 0; i--)
        {
            ruisekiMH[i] = Max(ruisekiMH[i + 1], maxH[i]);
        }
        int[] ruisekiWH = new int[whn[1] + 1];
        for (int i = whn[1] - 1; i >= 0; i--)
        {
            ruisekiWH[i] = Max(ruisekiWH[i + 1], maxW[i]);
        }
        int res = int.MaxValue;
        for (int i = 0; i < whn[0]; i++)
        {
            res = Min(res, i + ruisekiMH[i + 1]);
        }
        for (int i = 0; i < whn[1]; i++)
        {
            res = Min(res, i + ruisekiWH[i + 1]);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13392
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int frd = 0 ;
    int game = 0 ;
    int target[101] = {0} ;
    int ans[101][101] = {0} ;
    int score[101] = {0} ;

    cin >> frd >> game ;
    for ( int i = 0 ; i < game ; i++ )
    {
        cin >> target[i] ;
    }
    for ( int i = 0 ; i < game ; i++ )
    {
        for ( int j = 0 ; j < frd ; j++ )
        {
            cin >> ans[i][j] ;
        }
    }

    for ( int i = 0 ; i < game ; i++ )
    {
        for ( int j = 0 ; j < frd ; j++ )
        {
            if ( target[i] == ans[i][j] )
            {
                score[j]++ ;
            }
            else
            {
                score[target[i]-1]++ ;
            }
        }
    }

    for ( int i = 0 ; i < frd ; i++ )
    {
        cout << score[i] << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 3148
def resolve():
    N = int(input())
    factors = prime_factors(N)
    minf = float("inf")
    
    for bits in range(1<<len(factors)):
        fac_a = 1
        for odr in range(len(factors)):
            if bits & (1<<odr):
                fac_a *= factors[odr]

        fac_b = N // fac_a
        l = max(len(str(fac_a)), len(str(fac_b)))
        minf = min(minf, l)
    print(minf)

def prime_factors(n):
    i = 2
    factors = []
    while i**2 <= n:
        if n % i != 0:
            i += 1
        else:
            factors.append(i)
            n = n // i
    if n > 1:
        factors.append(n)
    return factors
    



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z') {
        cout << 'a' << endl;
    } else
        cout << 'A' << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3648
H, W = [int(i) for i in input().split()]
s = []
for i in range(H):
    s.append(input())
#print(s)
s_num = []
for i in range(H):
    tmp = []
    for j in range(W):
        if(s[i][j] == "."):
            tmp.append(0)
        else:
            tmp.append(1)
    s_num.append(tmp)

#print(s_num)
ans = True
for i in range(H):
    for j in range(W):
        if(s_num[i][j] == 1):
#            print("{},{}".format(i, j))
            sum_num = 1
            if(i > 0):
                sum_num += s_num[i-1][j]
            if(i < H-1):
                sum_num += s_num[i+1][j]
            
            if(j > 0):
                sum_num += s_num[i][j-1]
            if(j < W-1):
                sum_num += s_num[i][j+1]
            if(sum_num < 2):
                ans = False
                break

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
import math

A,B,H,M=(int(x) for x in input().rstrip('\n').split())

x=6*M
y=H*30+M*0.5
si=math.pi*(x-y)/180
print(math.sqrt(A**2+B**2-2*A*B*math.cos(si)))

Measured memory_bytes: 9500
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e8)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
ll dp[2][100];
ll lf[100];
int main()
{
  dp[1][0] = 1000;
  dp[0][0] = 0;
  int n;
  cin>>n;
  vector<ll>a(n+1);	
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
      if(dp[0][i-1] == (dp[1][i-1]/a[i])){
		  dp[0][i] = dp[0][i-1];
		  lf[i] = max(lf[i-1],dp[1][i-1]%a[i]);
	  }
	  else if(dp[0][i-1] > (dp[1][i-1]/a[i])){
		  dp[0][i] = dp[0][i-1];
		  lf[i] = lf[i-1];
	  }
	  else{
		  dp[0][i] = dp[1][i-1]/a[i];
		  lf[i] = dp[1][i-1]%a[i];
	  }
      
      dp[1][i] = max(dp[1][i-1],dp[0][i-1]*a[i]+lf[i]);
     // cout<<dp[0][i]<<" "<<lf[i]<<" "<<dp[1][i]<<'\n';
  }
  cout<<dp[1][n];

}


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

int main(){
    int n,k;cin>>n>>k;
    int a[200005];
    for(int i=0;i<n;i++)cin>>a[i];
    bool dp[200005]; //repersenting looser/winner of first on that
    //memset(dp,0,sizeof(dp));

    dp[0]=false;

    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0){
                if(dp[i-a[j]]==false){dp[i]=true;break;}
            }
        }
    }
    if(dp[k]==true){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int N = S.size();
	vector<Pi> data;
	vint ans(N, 0);

	int i = 0;
	while (i < N) {
		int cnt1 = 0, cnt2 = 0;
		int pos;
		while (i < N && S[i] == 'R') cnt1++, i++;
		pos = i;
		while (i < N && S[i] == 'L') cnt2++, i++;
		ans[pos] = cnt1/2 + (cnt2+1)/2;
		ans[pos-1] = (cnt1+1)/2 + cnt2/2;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 3840
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 1000
char s[MAXN+5];int f[5];
int main()
{
	scanf("%s",s+1);
	int lens=strlen(s+1);
	for(int i=1;i<=lens;i++)
	{
		if(s[i]=='S') f[1]=1;
		if(s[i]=='N') f[2]=-1;
		if(s[i]=='E') f[3]=1;
		if(s[i]=='W') f[4]=-1;
	}
	if((f[1]+f[2]==0)&&((f[3]+f[4]==0))) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//小数点以下　cout << fixed << setprecision(10) << num << endl;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    char ss[30];
    ss[1]='A';
    ss[2]='B';
    ss[3]='C';
    ss[4]='D';
    ss[5]='E';
    ss[6]='F';
    ss[7]='G';
    ss[8]='H';
    ss[9]='I';
    ss[10]='J';
    ss[11]='K';
    ss[12]='L';
    ss[13]='M';
    ss[14]='N';
    ss[15]='O';
    ss[16]='P';
    ss[17]='Q';
    ss[18]='R';
    ss[19]='S';
    ss[20]='T';
    ss[21]='U';
    ss[22]='V';
    ss[23]='W';
    ss[24]='X';
    ss[25]='Y';
    ss[0]='Z';
    rep(i,s.size()){
        for(int j=0;j<=25;j++){
            if(s[i]==ss[j]) cout << ss[(j+n)%26];
        }
    }
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int h,n;
    cin>>h>>n;
    int a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    vi dp(h+1,INF);
    dp[0]=0;
    rep(i,h+1)rep(j,n){
        dp[i]=min(dp[i],dp[i-1]+b[j]);
        dp[i]=min(dp[i],dp[max(i-a[j],0)]+b[j]);
    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
a = []
ref = []
for i in range(N):
    a.append(i+1)

ref = list(itertools.permutations(a))

print(abs(ref.index(p)-ref.index(q)))


Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll sqrt(ll x){
    ll res = 0LL;
    while((res+1) * (res+1) <= x){
        res++;
    }
    return res;
}

int main(){
    ll n, s;    cin >> n >> s;
    ll n_sqrt = sqrt(n);

    for(ll b = 2; b <= n_sqrt; b++){
        ll n_tmp = n;
        ll s_can = 0;
        while(b <= n_tmp){
            s_can += n_tmp % b;
            n_tmp /= b;
        }
        s_can += n_tmp;
        if(s_can == s){
            cout << b << endl;
            return 0;
        }
    }

    for(ll a = min(n_sqrt, s); a >= 1; a--){
        if(n-s+a < 0)   continue;
        if((n-s+a) % a == 0) {
            ll b = (n-s+a)/a;
            if(b >= 2 && a < b && (s-a) < b){
                cout << b << endl;
                return 0;
            }
        }
    }

    if(n == s){
        cout << n+1 << endl;
        return 0;
    }

    cout << -1 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int n,a[109],num[109],ma=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		num[a[i]]++;
		if(ma < a[i])ma=a[i];
	}
	if(num[ma] < 1){
		cout<<"Impossible"<<endl;
		return 0;
	}
	if(ma % 2 ==0){
		for(int i=ma;i>ma/2;i--){
			if(num[i]<1){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		if(num[ma/2]!=1){
			cout<<"Impossible"<<endl;
			return 0;
		}
		for(int i=ma/2-1;i>=1;i--){
			if(num[i]!=0){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		cout<<"Possible"<<endl;
		return 0;
	}
	if(ma % 2 ==1){
		for(int i=ma;i>(ma+1)/2;i--){
			if(num[i]<1){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		if(num[(ma+1)/2]!=2){
			cout<<"Impossible"<<endl;
			return 0;
		}
		for(int i=ma/2;i>=1;i--){
			if(num[i]!=0){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		cout<<"Possible"<<endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int ans = 0;
  if (s == "SUN") ans = 7;
  else if (s == "MON") ans = 6;
  else if (s == "TUE") ans = 5;
  else if (s == "WED") ans = 4;
  else if (s == "THU") ans = 3;
  else if (s == "FRI") ans = 2;
  else if (s == "SAT") ans = 1;

  cout << ans << endl;

  return 0;
}


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

int main() {

	string s; cin >> s;
	int oneCnt = 0;
	int zeroCnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') zeroCnt++;
		else oneCnt++;
	}
	
	cout << 2 * min(zeroCnt, oneCnt) << endl;
	return 0;
}

Measured memory_bytes: 512
l_bingo = [[0 for i in range(3)] for j in range(3)]
l_map = []
l_map.append(list(map(int, input().split())))
l_map.append(list(map(int, input().split())))
l_map.append(list(map(int, input().split())))

N = int(input())
for i in range(N):
  num = int(input())
  for j in range(3):
    for k in range(3):
      if l_map[j][k] == num:
        l_bingo[j][k] = 1

ans = "No"
for i in range(3):
  if l_bingo[i][0] == l_bingo[i][1] == l_bingo[i][2] == 1:
    ans = "Yes"
    break
  elif l_bingo[0][i] == l_bingo[1][i] == l_bingo[2][i] == 1:
    ans = "Yes"
    break

if l_bingo[0][0] == l_bingo[1][1] == l_bingo[2][2] == 1:
  ans = "Yes"
elif l_bingo[0][2] == l_bingo[1][1] == l_bingo[2][0] == 1:
  ans = "Yes"

print(ans)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N;int A,B;cin>>N>>A>>B;
    long V[N];
	rep(i,0,N) cin>>V[i];
	sort(V,V+N);
    long dp[N+1][N+1]={};
    rep(i,0,N+1) dp[i][0]=1;
	rep(i,1,N+1)rep(j,1,i+1){
		dp[i][j]=dp[i-1][j-1];
        if(i==j) continue;
		if(V[i-j-1]==V[i-1]) dp[i][j]+=dp[i-1][j];
	}//pprint(dp,N+1,N+1);
    reverse(V,V+N);
    long sum=0;
    rep(i,1,A) sum+=V[i-1];
    map<pair<long,double>,long> cal;
    long a,b;
    rep(i,A,B+1){
      sum+=V[i-1];
      a=sum/i,b=sum-a*i;
      cal[{a,1.*b/i}]+=dp[N][i];
    }auto it=cal.end();it--;
    long c=it->first.first;
    double d=it->first.second;
    d+=c%10;c/=10;
    cout<<c<<setprecision(16)<<d<<endl;
    cout<<it->second<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str,str2[200000],strmemo="";
	long long int n, m;
	cin >> n>>m>>str;
	str[m - 1] = str[m - 1] + 32;
	cout <<str ;
	
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdlib.h>
using namespace std;

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *pointer;

node s;
pointer nil=&s;
pointer R=nil;


void insert(pointer z){
  pointer y=nil;
  pointer x=R;
  while(x!=nil){
    y=x;
    if(z->key < x->key)x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==nil) R = z;
  else if(z->key < y->key) y->l= z;
  else y->r=z;
}


void print(pointer t,int pp){
  if(t==nil) return;
  if(pp)cout<<" "<<t->key;
  print(t->l,pp);
  if(!pp)cout<<" "<<t->key;
  print(t->r,pp);
}

pointer find(pointer x,int k){
  while(x!=nil && k!=x->key){
    if(k < x->key ) x=x->l;
    else x=x->r;
  }
    return x;
  }

pointer min(pointer x){
  while(x->l!=nil)x=x->l;
return x;
}

pointer successor(pointer x){
  if(x->r!=nil)return min(x->r);
pointer  y=x->p;
  while(y!=nil && x==y->r)x=y,y=y->p;
  return y;
}



void del(pointer x,pointer z){
  pointer y;
  if(z->l ==nil || z->r==nil)y=z;
  else y=successor(z);
  if (y->l!=nil)x=y->l;
  else x=y->r;
  if(x!=nil) x->p=y->p;
  if(y->p==nil) R=x;
  else if(y==y->p->l) y->p->l=x;
  else y->p->r=x;
  if(y!=z) z->key= y->key;
}



int main(){
  int n,a;
 cin>>n;
  string str;
  for(int i=0;i<n;i++){
    cin>>str;
    if(str=="insert"){
      pointer   T=(pointer)malloc(sizeof(node));
      cin>>T->key;
      T->l=nil;
      T->r=nil;
      insert(T);
    }else if(str=="print"){
      print(R,0);
      cout<<endl;
      print(R,1);
      cout<<endl;
    }else if(str=="find"){
        cin>>a;
	pointer point=find(R,a);
	if(point->key==a) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
    }else if(str=="delete"){
      cin>>a;
	pointer point=find(R,a);
	del(R,point);
    }
  }
  return 0;
}

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		char[] s = new char[3];
		s[0] = S.charAt(0);
		s[1] = S.charAt(1);
		s[2] = S.charAt(2);
		int num = 0;
		for (int i = 0; i < 3; i++) {
			if (s[i] == 'o') {
				num++;
			}
		}
		System.out.println(700 + 100 * num);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cstdlib>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair

void solve() {
  string s;
  map<int,int> rc;
  set<int> b, a;
  
  while (1) {
    getline(cin, s);
    int l = s.find(',');
    if (l == -1) break;
    int lhs = atoi(s.substr(0,l).c_str());//, rhs = s.substr(l+1);
    if (rc.count(lhs)) {
      rc[lhs]++;
    } else {
      rc.insert(mp(lhs, 1));
    }
    b.insert(lhs);
  }
  
  while (getline(cin, s)) {
    int lhs = atoi(s.substr(0, s.find(',')).c_str());
    if (rc.count(lhs)) {
      rc[lhs]++;
    }
    a.insert(lhs);
  }
  
  map<int,int>::iterator it = rc.begin();
  while (it != rc.end()) {
    if (b.count(it->first) && a.count(it->first))
      cout<<it->first<<" "<<it->second<<endl;
    it++;
  }
}

int main (int argc, char const* argv[]) {
  solve();
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;

    if (a < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    
    return 0;
     

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans;
    if(k <= a) ans = k;
    else if (k <= a+b) ans = a;
    else ans = a-(k-(a+b));
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int x_1, y_1, x_2, y_2;
	cin >> x_1 >> y_1 >> x_2 >> y_2;

	cout << x_2-y_2+y_1 <<" "<< y_2+x_2-x_1 <<" "<< x_1-y_2+y_1 <<" "<< y_1+x_2-x_1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  long long X,Y;
  cin>>X>>Y;
  long long ans=0LL;
  while(X<=Y){
    X*=2;
    ans++;
  }
  cout<< ans <<endl;
}



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

int dp[100001];

int main()
{
    memset(dp, -1, sizeof(dp));
    int n, k;
    cin>>n>>k;
    int a[n];
    dp[0]=0;
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=1;i<=k;i++)
   {
       for(int j=0;j<n;j++)
       {
           if((i-a[j])<0)
           {
               if(dp[i]==-1)
               {dp[i]=0;}
               else
               {
                dp[i]=(dp[i]||0);
               }
           }
           else
           {
               if(dp[i]==-1)
               {
                   dp[i]=!dp[i-a[j]];
               }
               else
               {
                   dp[i]=(dp[i]||(!dp[i-a[j]]));
               }
           }
       }
   }
 /*for(int i=0;i<=k;i++)
   {
       cout<<dp[i]<<" ";
   }
   cout<<endl*/
   if(dp[k])cout<<"First\n";
   else cout<<"Second\n";
   return 0;
}



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

int main() {
  while(true) {
    int ng;
    cin >> ng;
    if(ng == 0) break;
    vector<int> resultCandidits;
    for(int c = (ng / 500); c >= 0; --c) {
      int leftc = ng - c * 500;
      for(int b = leftc / 300; b >= 0; --b) {
        int leftb = leftc - b * 300;
        if(leftb % 200 == 0 && leftb / 200 >= 0) {
          int a = leftb / 200;
          // cout << (c / 3 * 2244 + c % 3 * 850) + (b / 4 * 1870 + b % 4 * 550) + (a / 5 * 1520 + a % 5 * 380) << endl;
          resultCandidits.push_back((c / 3 * 2244 + c % 3 * 850) + (b / 4 * 1870 + b % 4 * 550) + (a / 5 * 1520 + a % 5 * 380));
          // cout << "c:" << c << ", b:" << b << ", a:" << a << endl;
        }
      }
    }
    cout << *(min_element(resultCandidits.begin(), resultCandidits.end())) << endl;
  }

  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b; cin >> a >> b;
  if (a > 0) cout << "Positive" << endl;
  else if (a <= 0 && b >= 0) cout << "Zero" << endl;
  else {
    ll n = b-a+1;
    if (n%2 == 1) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
  return 0;
}


Measured memory_bytes: 256