akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int n;
  cin>>n;
  ll a,ans=1;
  vector<ll> arr(n);
  REP(i,0,n-1) {
  	cin>>arr[i];
  	if(!arr[i]) {
        cout<<0;
        return;
  	}
  }
  for(auto a:arr) {
    if(ans>((ll)1e18+a-1)/a) {
    	cout<<-1;
        return;
    }
    ans *= a;
  }
  if(ans>(ll)1e18) ans = -1;
  cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3972
N = int(input())
a_list = {}
for i in range(N):
    a = int(input())
    if a in a_list:
        a_list[a] += 1
    else:
        a_list[a] = 1

count = 0
for a, i in a_list.items():
    if i % 2 == 0:
        continue
    else:
        count += 1
print(count)


Measured memory_bytes: 15076
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,X;
  cin>>N>>X;
  int i,j;
  int m[N];
  int sum=0;
  int count=N;
  for(i=0;i<N;i++)
  {
    cin>>m[i];
  }
  sort(m,m+N);
  for(i=0;i<N;i++)
  {
    sum=sum+m[i];
  }
  int ans=(X-sum)/m[0];
  cout<<count+ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(void)
{
	int k, a, b;
	int nokori;
	long long bis = 1;

	cin >> k >> a >> b;
	nokori = k;

	if (a < b - 1)
	{
		while (nokori > 0) {
			if (bis >= a && nokori >= 2)
			{
				bis -= a;
				bis += b;
				nokori -= 2;
			}
			else if (nokori < 2)
			{
				bis += nokori;
				nokori = 0;

			}
			else
			{
				nokori--;
				bis++;
			}
		}
	}
	else
	{
		bis += k;
	}

	cout << bis << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
int N,A,B,C,l[8];

int main(){
  int N,x,a[100000];
  cin>>N>>x;
  for (int i(0);i<N;i++) cin>>a[i];
  ll cnt(0);
  if (a[0]>x){
    cnt+=a[0]-x;
    a[0]=x;
  }
  for (int i(0);i<N-1;i++){
    if (a[i]+a[i+1]>x){
      cnt+=a[i]+a[i+1]-x;
      a[i+1]-=a[i]+a[i+1]-x;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    if(N==1){
        p("Hello World");
    }else{
        int A, B;
        cin >> A >> B;
        p(A+B);
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007 
#define MOD2 998244353
#define INF 100000000
//#define MOD 922337203685419LL
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <chrono>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)
#define ALL(obj) (obj).begin(), (obj).end()

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}


//ll fact[]
//inline ll combi(int a, int b) {
//	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
//}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int 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 same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int m[81][81];
int main() {
	int h, w, a;
	cin >> h >> w;
	vector<vector<vector<bool>>> v(h, vector<vector<bool>>(w, vector<bool>(30000, false)));
	REP(i, h) {
		REP(j, w) {
			cin >> m[i][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cin >> a;
			m[i][j] = abs(m[i][j]-a);
		}
	}
	v[0][0][15000 + m[0][0]] = true;
	v[0][0][15000 - m[0][0]] = true;
	REP(i, h) {
		REP(j, w) {
			if (i > 0) {
				REP(k, 30000) {
					if (v[i - 1][j][k]) {
						v[i][j][k + m[i][j]] = true;
						v[i][j][k - m[i][j]] = true;
					}
				}
			}
			if (j > 0) {
				REP(k, 30000) {
					if (v[i][j - 1][k]) {
						v[i][j][k + m[i][j]] = true;
						v[i][j][k - m[i][j]] = true;
					}
				}
			}
		}
	}
	int res = 10000000;
	REP(i, 30000) if (v[h - 1][w - 1][i]) res = min(res, (int)abs(i - 15000));
	cout << res;
	return 0;
}


Measured memory_bytes: 25728
using System;
using System.Collections.Specialized;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        // 解
        int ans = 0;

        // 入力
        int[] inp = MyConsole.ReadInt(' ');

        // 処理
        ans = inp[0] - inp[1];
        if (ans < 0)
        {
            ans = 0;
        }
        
        // 出力
        MyConsole.WriteLine(ans);
    }
}

class MyConsole
{
    // 文字列または数値の入力
    public static string ReadStr() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Console.ReadLine()); }
    public static long ReadLong() { return long.Parse(Console.ReadLine()); }
    public static string[] ReadStr(char sep) { return Console.ReadLine().Split(sep); }
    public static int[] ReadInt(char sep) { return Console.ReadLine().Split(sep).Select(x => int.Parse(x)).ToArray(); }
    public static long[] ReadLong(char sep) { return Console.ReadLine().Split(sep).Select(x => long.Parse(x)).ToArray(); }

    public static void WriteLine(object param) { Console.WriteLine(param); }
}


Measured memory_bytes: 13396
n = input()

nc = n.replace("x","")

ncr = nc[::-1]

ans = -1

if ncr == nc:
    ans = 0
    nl = list(n)
    lenn = len(n)
    i = 0
    j = 1
    ri = 0
    le = 0
    while(1):
        if i >= lenn-(j):break
        if n[i] == n[lenn-(j)]:
            i += 1
            j += 1
        else:
            if n[i] == "x":
                i +=1
            else:
                j +=1
            ans += 1

print(ans)

Measured memory_bytes: 3956
import java.util.*;
 
public class Main {
    static final long MOD=1000000007;
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long[] nums=new long[n];
        nums[0]=sc.nextInt();
        for(int i=1;i<n;i++){
            nums[i]=nums[i-1]+sc.nextInt();
        }
        long output=Long.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            output=Math.min(output, Math.abs(nums[n-1]-nums[i]*2));
        }
        System.out.println(output);
    }
}


Measured memory_bytes: 65044
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>

using namespace std;


int main(){


	int N;
	cin >> N;

	vector<int>b(N+2,0);
	b.push_back(0);

	for(int i = 1;i <= N;i++){
		cin >> b[i];
	}

	b.push_back(0);

	int S = 0;

	for(int i = 0;i <= N;i++){
		S += abs(b[i] - b[i+1]);
	}



	for(int i = 1;i <= N;i++){
		int ans = 0;
	    ans = S + abs(b[i-1] - b[i+1]) - (abs(b[i-1]-b[i]) + abs(b[i] - b[i+1]));
	    cout << ans <<endl;
	}

	return 0;

}


Measured memory_bytes: 1656
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = get!(usize, i32);
    let mut aa = vec![0; n+1];
    for s in get!(String).split_whitespace() {
        let a = s.parse::<usize>().unwrap();
        aa[a] += 1;
    }
    aa.sort();
    let mut m = 0;
    for &a in aa.iter() {
        if a != 0 {
            m += 1;
        }
    }
    m -= k;
    let mut r = 0;
    for a in aa.into_iter() {
        if m <= 0 {
            println!("{}", r);
            return;
        }
        if a == 0 { continue; }
        m -= 1;
        r += a;
    }
}

Measured memory_bytes: 4524
using System;

public class Program
{
    public static void Main()
    {
        bool[] arr = {true, false, false};
        while (true)
        {
            string line = Console.ReadLine();
            if (string.IsNullOrEmpty(line)) break;
            bool temp = arr[line[0]-'A'];
            arr[line[0]-'A'] = arr[line[2]-'A'];
            arr[line[2]-'A'] = temp;
        }
        for (int i = 0; i < 3; i++)
        {
            if (arr[i]) Console.WriteLine((char)(i+'A'));
        }
    }
}

Measured memory_bytes: 8776
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, Ma, Mb;
int a[50], b[50], c[50];
int dp[50][410][410];
// dp[N][a][b]:= N番目までで、Aをa(g),Bをb(g)買うための最小費用。

signed main() {
  cin >> N >> Ma >> Mb;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= 400; j++) {
      for (int k = 0; k <= 400; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 400; j++) {
      for (int k = 0; k <= 400; k++) {
        if (dp[i][j][k] == INF) {
          continue;
        }

        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        dp[i + 1][j + a[i]][k + b[i]] =
            min(dp[i][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
      }
    }
  }

  int ans = INF;
  for (int i = 1; i <= 400; i++) {
    for (int j = 1; j <= 400; j++) {
      if (i * Mb == j * Ma) {
        chmin(ans, dp[N][i][j]);
      }
    }
  }

  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 55552
using System;
using System.Collections;

namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] t;
            string s = Console.ReadLine();
            t = s.Split(' ');
            string u = t[1] + t[0];
            Console.WriteLine(u);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main(){
	int N, K, R, S, P, ans, ren_r, ren_s, ren_p, n;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;
	ans = 0;
	for(int i = 0; i <= K-1; i++){
		ren_r = 0;
		ren_s = 0;
		ren_p = 0;
		for(int j = 0; j <= (N-1)/K; j++){
			n = i + K*j;
			if(n >= N){
				break;
			}else{
				if(T.substr(n, 1) == "r"){
					ren_r++;
					if(ren_s != 0){
						ans += ((ren_s+1)/2)*R;
						ren_s = 0;
					}else if(ren_p){
						ans += ((ren_p+1)/2)*S;
						ren_p = 0;
					}
				}else if(T.substr(n, 1) == "s"){
					ren_s++;
					if(ren_p != 0){
						ans += ((ren_p+1)/2)*S;
						ren_p = 0;
					}else if(ren_r){
						ans += ((ren_r+1)/2)*P;
						ren_r = 0;
					}
				}else if(T.substr(n, 1) == "p"){
					ren_p++;
					if(ren_r != 0){
						ans += ((ren_r+1)/2)*P;
						ren_r = 0;
					}else if(ren_s){
						ans += ((ren_s+1)/2)*R;
						ren_s = 0;
					}
				}
			}
		}
		if(ren_r > 0){
			ans += ((ren_r+1)/2)*P;
		}else if(ren_s > 0){
			ans += ((ren_s+1)/2)*R;
		}else if(ren_p > 0){
			ans += ((ren_p+1)/2)*S;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
import numpy as np

n = int(input())
a_str = input().split()
a_num = [int(a) for a in a_str]
a_array = np.array(a_num)

rate_list = [1,400,800,1200,1600,2000,2400,2800,3200]

count = 0

for i in range(8):
    if len(a_array[np.where((a_array>=rate_list[i])&(a_array<rate_list[i+1]))]):
        count += 1

if count == 0:
    min_count = 1
else:
    min_count = count

count += len(a_array[a_array>=rate_list[8]])
max_count = count

print(str(min_count)+" "+str(max_count))

Measured memory_bytes: 21280
#include <cstdio>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n, m; n = in(), m = in(), n || m;) {
		array<int, 11> s = {};
		while (n--) {
			int d = in();
			s[in()] += d;
		}
		int c = 0;
		for (int i = 10; i >= 0; i--) {
			int d = min(s[i], m);
			m -= d;
			c += (s[i] - d) * i;
		}
		outl(c);
	}
}


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

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

    int sc=0,r=0;

    for(auto c: str){ 
        if(c=='p'){ 
            if(r>0) --r;
            else    ++r,--sc;
        }else{ 
            if(r>0) --r,++sc;
            else    ++r;
        }
    }

    cout << sc << endl;
    
    return 0;
}


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

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

bool isMatch(string str, int s, int g, char c) {
    FOR(i, s, g) {
        if (str[i] == c) {
            return true;
        }
    }
    
    return false;
}

int main(void){
    int n, cnt, ans = 0;
    string s;
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    REP(i, n) {
        cnt = 0;
        for (char c = 'a'; c <= 'z'; ++c) {
            if (isMatch(s, 0, i, c) && isMatch(s, i, n, c)) {
                cnt++;
            }
        }
        
        ans = max(ans, cnt);
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 40;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
    long long N, K; cin >> N >> K;
    vector<vector<long long> > s(N); // s[i] := 種類 i の美味しさの集合
    for (int i = 0; i < N; ++i) {
        long long t, d; cin >> t >> d; --t;
        s[t].push_back(d);
    }

    // 各種類について、美味しい順に並べる
    for (auto &v : s) {
        sort(v.begin(), v.end(), greater<long long>());
        if (v.empty()) v.push_back(-INF); // 番兵
    }

    // 「美味しさの最大値」の大きいネタ順
    sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
            return a[0] > b[0];});
 
    // まず K 種類選ぶ場合
    long long cur = 0;
    priority_queue<long long> que;
    for (int i = 0; i < K; ++i) {
        cur += s[i][0];
        for (int j = 1; j < s[i].size(); ++j) que.push(s[i][j]);
    }
    for (int i = K; i < N; ++i) for (int j = 0; j < s[i].size(); ++j) que.push(s[i][j]);

    // 走査
    long long res = cur + K*K;
    for (long long x = K-1; x >= 1; --x) {
        long long v = s[x][0];
        long long w = que.top();
        if (v < w) {
            que.pop(); cur += w;
            que.push(v); cur -= v;
        }
        res = max(res, cur + x*x);
    }
    cout << res << endl;
    
}

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

typedef struct{
    char name[256];
    int cost;
} ITEM;

int main(void)
{
    int i, j, k;
    int n, m, kk;
    ITEM list[100];
    char key[256], temp[256];
    int look, sum;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%s%d", list[i].name, &list[i].cost);
        }
        
        scanf("%d", &m);
        for (i = 0; i < m; i++){
            scanf("%s", key);
            for (j = 0; j < n; j++){
                if (strcmp(key, list[j].name) == 0){
                    look = j;
                }
            }
            
            sum = 0;
            scanf("%d", &kk);
            for (j = 0; j < kk; j++){
                scanf("%s", temp);
                for (k = 0; k < n; k++){
                    if (strcmp(temp, list[k].name) == 0){
                        sum += list[k].cost;
                    }
                }
            }
            list[look].cost = list[look].cost > sum ? sum : list[look].cost;
        }
        scanf("%s", key);
        for (j = 0; j < n; j++){
            if (strcmp(key, list[j].name) == 0){
                printf("%d\n", list[j].cost);
                break;
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   int n;
   long long int a[100005],b[100005],c[100005];
   long long int sum[100005];
   
   while(cin>>n)
   {
     for(int i=0;i<n;i++) cin>>a[i];       
     for(int i=0;i<n;i++) cin>>b[i]; 
     for(int i=0;i<n;i++) cin>>c[i];
     sort(a,a+n);
     sort(b,b+n);
     sort(c,c+n);
     int j=0;
     int k=0;
     //bool flag=false;
     long long int ans=0;
     memset(sum,0,sizeof(sum));
     for(int i=0;i<n;i++)
     {
       while((c[j]<=b[i])&&(j!=n)) j++;
       sum[i]=(n-j);        
     }
     for(int kk=(n-2);kk>=0;kk--) sum[kk]=sum[kk]+sum[kk+1];
     
     j=0;
     
     for(int i=0;i<n;i++)
     {
       while((b[j]<=a[i])&&(j!=n)) j++;
       ans=ans+sum[j];
     }
     cout<<ans<<endl;                 
   }
   return 0;
 }
 

        


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int i, n, x, sum;
  vector<int> a;
  vector<int>::iterator it;
  while(cin >> n) {
    sum = 0;
    for(i=n; i>0; i--) {
      cin >> x;
      a.push_back(x);
    }
    sort(a.begin(), a.end(), greater<int>());
    i=1;
    for(it = a.begin(); it != a.end(); it++) {
      sum += *it*i;
      i++;
    }
    cout << sum << endl;
    a.clear();
  }
  return 0;
}


Measured memory_bytes: 1220
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
from math import ceil
 
D, G = [int(t) for t in input().split()]
p = []
c = []
for i in range(D):
    p_, c_ = [int(t) for t in input().split()]
    p.append(p_)
    c.append(c_)
 
def minsolve(G, p, c, i):
    """100i点以下の問題だけでGを達成する最小問題数"""
    if i <= 0:
        return float('inf')
    n = min(ceil(G / (100 * i)), p[i-1])
    s = 100 * i * n
    if n == p[i-1]:
        s += c[i-1]
    if s >= G:
        return min(n, minsolve(G, p, c, i-1))
    else:
        return min(n + minsolve(G - s, p, c, i-1), minsolve(G, p, c, i-1))
 
m = min(minsolve(G, p, c, i) for i in range(1, D+1))
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

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

typedef long long ll;

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

	int sum = 0;

	int n; cin >> n;
	vi a(n+1);
	vi b(n+1);
	vi c(n);
	for (int i=1;i<=n;i++)
		cin >> a[i];

	for (int i=1;i<=n;i++)
		cin >> b[i];

	for (int i=1;i<=n-1;i++)
		cin >> c[i];


	int prev = -1;
	for (int i = 1; i <= n; i++)
	{
		sum += b[a[i]];
		if (a[i] == (prev+1))
			sum += c[prev];

		prev = a[i];
	}

	cout << sum << "\n";
	return 0;
}


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

#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t;while(t--)
#define sfi(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define f(i,a,n) for(int i=a ; i<n; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int main()
{
    string s;
    int k;
    cin>>k>>s;
    int l=s.length();
    if(l<=k)
        cout<<s;
    else
        cout<<s.substr(0,k)<<"...";
}



Measured memory_bytes: 3620
//問題やり直し
#include <iostream>
#include <string>
using namespace std;

typedef struct{           /* _person がタグ名 */
    int x,y,t;               /* 整数型メンバ age */
} acord_t;

int main(void)
{
  int N;
  cin >> N;
  acord_t point[N];
  for(int i=0; i<N; i++){
    cin >> point[i].t;
    cin >> point[i].x;
    cin >> point[i].y;
  }

  for(int j=0; j<N; j++){
    // cout << "fucnk";
    int x_dis,y_dis,t_dis;
    if(j==0){
      x_dis = point[j].x;
      y_dis = point[j].y;
      t_dis = point[j].t;
    }else{
      x_dis = point[j].x - point[j-1].x;
      y_dis = point[j].y - point[j-1].y;
      t_dis = point[j].t - point[j-1].t;
    }

    int x_front,x_back,y_front,y_back;
    //x_back+y_back=1/2{t_dis-x_dis-y_dis}
    if((t_dis-x_dis-y_dis) %2 != 0){
      cout << "No\n";
      return 0;
    }
    // int x_back_min, y_back_min;
    // if(x_dis>0) x_back_min = 0;
    // else x_back_min = -x_dis;
    // if(y_dis>0) y_back_min = 0;
    // else y_back_min = -y_dis;
    // if(x_back_min+y_back_min > (t_dis-x_dis-y_dis)/2){
    //   cout << "NO\n";
    //   return 0;
    // }
    if(abs(x_dis)+abs(y_dis) > t_dis){
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 1408
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    A = [0] * M
    C = [0] * M
    for i in range(M):
        A[i], b = map(int, readline().split())
        C[i] = ~sum(1 << (int(s) - 1) for s in readline().split())

    dp = [INF] * (1 << N)
    dp[0] = 0
    for bit in range(1 << N):
        for a, c in zip(A, C):
            if dp[bit & c] < INF:
                dp[bit] = min(dp[bit], dp[bit & c] + a)

    ans = dp[(1 << N) - 1]
    if ans < INF:
        print(ans)
    else:
        print(-1)
    return


if __name__ == '__main__':
    main()


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

int main(){
  char res[1001] = "0";

  while(1){
    int sum = 0;

    scanf("%s", res);
    if(res[0] == '0'){
      break;
    }

    int i=0;
    while(res[i]){
      sum += res[i] - '0';
      i++;
    }

    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;
	cin >> n >>m;
	//確率pの試行を成功するまでトライしたとき、トライすることになる期待値は1/p
	//期待値漸化式　E=(E+1)(1-p) + pをEについて解くと求まる。
	//今回の確率は1/(2^m)だから期待値は2^m
	ll ans = ll(pow(2,m)) * (1900 * m + 100 * (n - m));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def dfs(i, total):
    global ans
    if i == len(s)-1:
        ans += eval(total)
        return ans
    dfs(i + 1, total + "+" + s[i+1])
    dfs(i + 1, total + s[i+1])
    
ans = 0
s = input()
dfs(0, s[0])
print(ans)

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 ll a,b,k; cin>>a>>b>>k;

 FOR(i,a,min(a+k,b+1))cout<<i<<endl;
 FOR(i,b-k+1,b+1){
     if(i>=a+k)cout<<i<<endl;
 }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

ll S(ll n) {
    ll result = 0;
    while (n > 0) {
        result += n % 10;
        n /= 10;
    }
    return result;
}

double f(ll n) {
    return (double)n / S(n);
}

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

    vector<ll> candidates;

    for (ll i = 0; i < 15; i++) {
        //下からi桁目まで9が続く
        for (ll j = 0; j < pow(10, 4); j++) {
            candidates.push_back(j * pow(10, i) + pow(10, i) - 1);
        }
    }

    sort(candidates.begin(), candidates.end(), [](ll &lhs, ll &rhs) {
        return f(lhs) < f(rhs);
    });

    ll u = 0, cnt = 0;
    for (auto e : candidates) {
        if (e > u) {
            cout << e << endl;
            u = e;
            if (++cnt == K) {
                break;
            }
        }
    }
}

Measured memory_bytes: 2420
console.log((args=>{
  const [[N],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  A.sort((a,b)=>b-a);
  let c = A[0];
  for ( let i = 1; i*2 < N-1; i++ ) {
    c += 2 * A[i];
  }
  if ( N&1 ) c += A[(N-1)/2];
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define pii pair <int , int>
#define F first
#define S second
const int N = 1e6 + 5;
int a[N], dp[N], pd[N], ps[N];

int check(int n, int x) {
    while (n % x == 0) n/=x;
    return (n % x == 1);
}
int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k, c; cin >> n >> c >> k;
    string s; cin >> s;
    for (int i = 1; i <= n; i++) if (s[i - 1] == 'o') a[i] = 1;
    if (k == 0) {
        int cnt = 0;
        for (int i = 1; i <= n; i++) cnt += a[i];
        if (cnt > c) return 0;
        for (int i = 1; i <= n; i++) if (a[i]) cout << i << "\n";
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1];
        if (a[i] == 1) dp[i] = max(dp[i], 1 + (i - k > 0 ? dp[i - k - 1] : 0));
    }
    for (int i = n; i >= 1; i--) {
        pd[i] = pd[i + 1];
        if (a[i] == 1) pd[i] = max(pd[i], 1 + (i + k + 1 < N ? pd[i + k + 1] : 0));
    }
    for (int i = -k; i <= n; i++) {
        if ((i > 0 ? dp[i - 1] : 0ll) + pd[i + k] >= c) ps[max(i, 0ll)]++, ps[i + k]--;
    }
    for (int i = 1; i <= n; i++) {
        ps[i] += ps[i - 1];
        if (a[i] && ps[i] == 0) cout << i << "\n";
    }
}


Measured memory_bytes: 14484
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
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();
		for(int i = 0; i < b; i++) {
			if((a*(i+1))%b==c) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 35784
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 c;
        if (b < 10) {
            c = 10 * a + b;
        } else if (b < 100) {
            c = 100 * a + b;
        } else {
            c = 1000 * a + b;
        }
        boolean flag = false;
        int target = 1;
        for (int i = 1; target <= c; i++) {
            target = (int) Math.pow(i, 2);
            if (target == c) {
                flag = true;
            }
        }
        System.out.println(flag ? "Yes" : "No");

    }
}

Measured memory_bytes: 23636
#include <stdio.h>

int main(void){
    
    static int n,x,min=100000 ;
    scanf ("%d%d",&n,&x) ;
    
    for (int i=0; i<n; i++ ){
        
        int m[i] ;
        scanf ("%d",&m[i]) ;
        
        x -= m[i] ;
        
        if ( min>m[i] ){
            min = m[i] ;
        }
    }
    
    printf ("%d\n",n+x/min) ;

    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;

    for(int i = 1; i <= 3; i++)
    {
        if(i != A && i != B)
        {
            cout << i << endl;
        }
    }
    return 0;
}

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

typedef long long ll;

int main()    
{
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        m[x] = i;
    }

    for(auto it = m.begin(); it != m.end(); ++it){
        cout<<it->second<<" ";
    }
}

Measured memory_bytes: 8208
n = int(input())

answer = int('9' * 5)
for i in range(1, n):
    str_w = str(n - i)
    str_i = str(i)

    answer = min(
        answer,
        sum([int(w) for w in str_w]) + sum([int(wi) for wi in str_i])
    )
print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN = 200005, mod = 998244353;
int n;
string a;
vector<LL> v;
LL ans = 0, cnt[MAXN];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a;
    for(int i = 1; i <= n; ++i)
    	if(n % i == 0 && (n / i) % 2 == 1)
    		v.pb(i);
    for(int i = 0; i < v.size(); ++i) {
    	int x = v[i];
    	//cout << x << endl;
    	string s, t, s0;
    	LL val = 0;
    	for(int j = 0; j < x; ++j) {
    		val *= 2;
    		val += a[j] - '0';
    		val %= mod;
    		s += a[j];
    		s0 += '0' + '1' - a[j];
    	}
    	t = s;
    	while(t.size() < a.size())
    		t += s0 + s;
    	//cout << t << " " << s << endl;
    	cnt[i] = val;
    	if(t <= a)
    		++cnt[i];
    	cnt[i] %= mod;
    }
    for(int i = 0; i < v.size(); ++i)
    	for(int j = i + 1; j < v.size(); ++j)
    		if(v[j] % v[i] == 0) {
    			cnt[j] -= cnt[i];
    			if(cnt[j] < 0)
    				cnt[j] += mod;
    		}
    for(int i = 0; i < v.size(); ++i) {
    	//cout << v[i] << " " << cnt[i] << endl;
    	ans += cnt[i] * v[i] * 2;
    	ans %= mod;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1252
import sys
input = sys.stdin.readline

S = input().rstrip('\r\n')
ans = 0
count = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)
print(ans)

Measured memory_bytes: 3060
while True :
    n, m = map(int, input().split())
    
    if n == 0 :
        break
    
    else :
        T = []
        H = []
        
        for i in range(n) :
            T.append(int(input()))
            
        for i in range(m) :
            H.append(int(input()))
        
        Ts = sorted(T)
        Hs = sorted(H)
        
        sumT = sum(Ts)
        sumH = sum(Hs)
        
        d = (sumT - sumH) / 2
        D = abs(d)
        
        f = 0
        # flag
        
        if d < 0 :
            for i in range(len(Ts)) :
                if (Ts[i] + D) in Hs :
                    print(Ts[i], int(Ts[i] + D))
                    f = 1
                    break
        else :
            for i in range(len(Ts)) :
                if (Ts[i] - D) in Hs :
                    print(Ts[i], int(Ts[i] - D))
                    f = 1
                    break
        
        if f != 1 :
            print(-1)
    
    


Measured memory_bytes: 5616
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
A = sorted(iil(),reverse=True)

if A[m-1]*4*m >= sum(A):
    print('Yes')
else:
    print('No')

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

signed main(void){
    int a,b,x; cin >> a >> b >> x;
    double p = a;
    double q = 2*double(pow(a,2)*b - x)/(pow(a,2));
    if(x < pow(a,2)*double(b/2)){
        p = 2*x/double(a*b);
        q = b;
    }
    // cout << p << ' ' << q << endl;
    printf("%.10f\n",360 * atan(q/p)/(2*M_PI));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=3e3+9;
const ll maxx=1e12+9;

int n,m,t,ar[maxn][maxn];
ll dp[maxn][maxn][4];

int main()
{
    scanf("%d%d%d",&n,&m,&t);
    for(int i=0;i<t;i++)
    {
        int rr,cc,vv;
        scanf("%d%d%d",&rr,&cc,&vv);
        ar[rr][cc]=vv;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            for(int k=1;k<=3;k++) dp[i][j][k]=max(dp[i][j-1][k],max(dp[i][j-1][k-1],dp[i-1][j][3])+ar[i][j]);
        }
    }
    ll ans=0;
    for(int k=0;k<=3;k++) ans=max(ans,dp[n][m][k]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 320440
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;

  map<string, int> mm;

  for(int i=1;i>=-1;i-=2){
    cin >> n;

    for(int j=0;j<n;j++){
      string s;
      cin >> s;
      mm[s] += i;
    }
  }


  int ans = 0;

  for(auto p : mm) {
    ans = max(ans, p.second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,j,k,l;
	
	while(scanf("%d %d", &i, &j) != EOF){
		
		l = 0;
		for(k = i + j; k != 0; k /= 10){
			l++;
		}
		
		printf("%d\n", l);
	}
	
	return 0;
}

Measured memory_bytes: 0
a = int(input())
ar = list(map(int,input().split(" ")))
if a < 3:
    print(0)
    exit()
count = 0
for i in range(a-2):
    for j in range(i+1,a-1):
        for k in range(j+1,a):
            if ar[i] != ar[j] and ar[j] != ar[k] and ar[i] != ar[k]:
                br = [ar[i],ar[j],ar[k]]
                br.sort()
                if br[0] + br[1] > br[2]:
                    count += 1
print(count)

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

char s[100010];
int main() {
  scanf("%s", s);
  int N = strlen(s), l = 1, r = N + 1;
  while (r - l > 1) {
    int K = l + r >> 1;
    bool ok = 1;
    for (int i = N - K; i < K - 1 and ok; ++i) {
      if (s[i] != s[i + 1]) ok = 0;
    }
    (ok ? l : r) = K;
  }
  printf("%d\n", l);
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    string s; cin >> s;
    if(s=="Sunny") {
        print("Cloudy");
    } else if(s=="Cloudy") {
        print("Rainy");
    } else {
        print("Sunny");
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

pii mp[90001];
int cost[90001];

main(){
  int h,w,d; cin >> h >> w >> d;
  int a;
  rep(i,h) rep(j,w){
    cin >> a;
    mp[a] = pii(i,j);
  }
  FOR(i,1,d+1) cost[i] = 0;
  FOR(i,d+1,h*w+1) cost[i] = cost[i-d] + abs(mp[i].fst-mp[i-d].fst) + abs(mp[i].snd-mp[i-d].snd);
  int q; cin >> q;
  int l,r;
  rep(i,q){
    cin >> l >> r;
    printf("%d\n",cost[r]-cost[l]);
  }
}


Measured memory_bytes: 2176
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        for(int i = 0; i < str.length(); i++){
            char c = str.charAt(i);
            if(Character.isUpperCase(c)){
                c = Character.toLowerCase(c);
            }
            else{
                c = Character.toUpperCase(c);
            }
            System.out.print(c);
        }
        System.out.println("");
    }
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
double toDegree(double rad){
    return (180.0*rad)/PI;
}

double toRadian(double degree){
    return PI*(degree/180.0);
}

int main(){
    double a,b,x;
    cin>>a>>b>>x;

    double degree=0;
    if(x*2>=a*a*b){
        double h=2*(a*b-(x/a))/a;
        double rad=atan2(h,a);
        degree=toDegree(rad);
    }
    else{
        double h=(2*x/a)/b;
        double rad=atan2(b,h);
        degree=toDegree(rad);
    }
    cout<<fixed<<setprecision(20)<<degree<<endl;
}

Measured memory_bytes: 512
/**
 *    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=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    cin>>n;
    ll a[N];
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll prod=1,sprod=1;
    rep(i,1,n){
        sprod*=sqrtl(a[i]);
        if(sprod>1e9) return cout<<-1,0;
        prod=prod*a[i];
    }
    cout<<(prod>1000000000000000000?-1:prod);
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

vector<char> ss{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    map<char, int> sm, tm;

    int tmp = 1;
    rep(i, n){
        if(sm[s[i]] == 0){
            sm[s[i]] = tmp;
            tmp++;
        }
    }

    tmp = 1;
    rep(i, n){
        if(tm[t[i]] == 0){
            tm[t[i]] = tmp;
            tmp++;
        }
    }

    rep(i, n){
        s[i] = ss[sm[s[i]]];
        t[i] = ss[tm[t[i]]];
    }

    if(s == t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 776