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

public class Main {

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int len = S.length();
		long K = sc.nextLong();
		char start = S.charAt(0);

		boolean all_same = true;
		for (int i = 0; i < len; i++) if (S.charAt(i) != start) all_same = false;

		//Sの全文字が同じ場合
		if (all_same) {
			sc.close();
			return len * K / 2;
		}

		//連続する文字数
		ArrayList<Integer> list = new ArrayList<Integer>();
		char prev = S.charAt(0);
		int cnt = 0;
		for (int i = 0; i < len; i++) {
			char c = S.charAt(i);
			if (c == prev) cnt++;
			else {
				list.add(cnt);
				cnt = 1;
			}
			prev = c;
		}
		if (cnt != 1) list.add(cnt);

		long ans = 0;
		//Sに対する答え
		for (int i : list) ans += i / 2;
		ans *= K;
		//Sの先頭と末尾が同じ場合
		if (S.charAt(0) == S.charAt(len - 1)) {
			int a = list.get(0);
			int b = list.get(list.size() - 1);
			ans -= (K - 1) * (a / 2 + b / 2 - (a + b) / 2);
		}

		sc.close();
		return ans;
	}
	public static void main(String[] args) {
		System.out.println(solve());
	}
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(){
	int idx=0;
	scanf("%d", &idx);
	char str[idx+1];
	scanf("%s", &str);
	if(idx%2==1){
		puts("No");
	}
	else{
		int tanda = 1;
		
		for(int i=0; i < idx/2; i++){
			if(str[i] != str[i + idx/2]){
				tanda = 0;
			}
		}
		if(tanda==1){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1580
import math
from sys import stdin
input = stdin.readline


def prime_fatorization(n):
  # O(sqrt(n))
  from collections import defaultdict
  # a = []
  a = defaultdict(int)
  while not(n % 2):
    # a.append(2)
    a[2] += 1
    n //= 2
  f = 3
  while f * f <= n:
    if not(n % f):
      # a.append(f)
      a[f] += 1
      n //= f
    else:
      f += 2
  if n != 1:
    # a.append(n)
    a[n] += 1
  return a


def main():
  N, M = list(map(int, input().split()))
  A = list(map(lambda x: int(x)//2, input().split()))

  # print(A)
  pre = A[0]
#   bool_ini = A[0] % 2
#   bool_end = -1

  for i in range(1, N):
    if pre % 2 != A[i] % 2:
      print(0)
      return
#  for i in range(1, N):
#    if A[i] % 2 == 0 and A[i] != pre:
#      print(0)
#      return
#    else:
#      bool_end = A[i] % 2
#
#    pre = A[i]
#
#  if bool_ini != bool_end:
#    print(0)
#    return

  if not A[0] % 2:
    fac2 = prime_fatorization(A[0])[2]
    for i in range(1, N):
      if not A[i]//(2**fac2) % 2:
        print(0)
        return

  lcm = A[0]
  for i in range(1, N):
    lcm = lcm * A[i] // math.gcd(lcm, A[i])
  print((M // lcm + 1) // 2)
  return


if(__name__ == '__main__'):
  main()


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

#define pb push_back

typedef long long ll;

using namespace std;

int n;
vector<int> c[4][401];

int fIdx[4][4] = {
	{1 + 4, 0, 3, 2 + 4},
	{1 + 4, 0 + 4, 1, 0},
	{1, 0 + 4, 3 + 4, 2},
	{3, 2, 3 + 4, 2 + 4}
};
map< vector<int> , int > cnt;


void addFace(vector<int> &v , int val) {
	for (int it = 0 ; it < 4 ; ++it) {
		rotate(v.begin(), v.begin() + 1, v.end());
		cnt[v] += val;
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0 ; j < 4 ; ++j)c[j][i].resize(4);
		for (int j = 0 ; j < 4 ; ++j) {
			scanf("%d", &c[0][i][j]);
		}
		for (int j = 1 ; j < 4; ++j) {
			c[j][i] = c[j - 1][i];
			rotate(c[j][i].begin(), c[j][i].begin() + 1, c[j][i].end());
		}
		for (int j = 0 ; j < 4 ; ++j)cnt[c[j][i]]++;
	}
	ll res = 0;
	vector<int> myFace;
	myFace.resize(4);
	for (int i = 0 ; i < n ; ++i) {
		for (int rt = 0 ; rt < 4 ; ++rt) {
			cnt[c[rt][i]]--;
		}
		for (int j = i + 1 ; j < n ; ++j) {
			for (int rt2 = 0 ; rt2 < 4 ; rt2++) {
				cnt[c[rt2][j]]--;
			}
			for (int rt2 = 0 ; rt2 < 4 ; rt2++) {
				ll ans =  1;
				vector< vector<int> > allFc;
				for (int faces = 0; faces < 4 ; ++faces) {
					for (int kk = 0 ; kk < 4 ; ++kk) {
						int idx = fIdx[faces][kk];
						myFace[kk]=(idx >= 4 ? c[rt2][j][idx - 4] : c[0][i][idx]);
					}
					ans *= cnt[myFace];
					if (ans == 0)break;
					allFc.push_back(myFace);
					addFace(myFace, -1);
				}
				for (int p = 0; p < allFc.size(); ++p) {
					addFace(allFc[p], +1);
				}
				res += ans;
			}
			for (int rt2 = 0 ; rt2 < 4 ; rt2++) {
				cnt[c[rt2][j]]++;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
 
using namespace std;
 
long long choose2(long long n) {
	return (n*(n-1)/2);
}
 
int main() {
	long long n;
	cin >> n;
	vector<int> s(n);
	map<int, int> cnt;
	long long total = 0;
 
	for (int i=0; i<n; i++) {
		cin >> s[i];
        s[i]--;
    }
 
	for (int i=0; i<n; i++)
		cnt[s[i]]++;
 
	for (int i=0; i<n; i++)
		total += choose2(cnt[i]);
 
	for (int i=0; i<n; i++) {
		long long ans = total;
		ans -= choose2(cnt[s[i]]);
		ans += choose2(cnt[s[i]]-1);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 13952
import java.util.*;
 
public class Main{
  public static int[] dp;
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    String s1 = S.substring(0,2);
    String s2 = S.substring(2,4);
    int n1 = Integer.parseInt(s1);
    int n2 = Integer.parseInt(s2);

    String ans = "";
    
    if(n1 <= 12 && n2 <= 12 && n1 > 0 && n2 > 0){
      ans = "AMBIGUOUS";
    }else if(n1 <= 12 && n1 > 0){
      ans = "MMYY";
    }else if(n2 <= 12 && n2 > 0){
      ans = "YYMM";
    }else{
      ans = "NA";
    }
   System.out.println(ans);
  }
}

Measured memory_bytes: 23764
def main():
    s = input()
    n = len(s)
    s = s[::-1]
    t = [0]*n
    a = [0]*2020
    x = 1
    ans = 0
    for i in range(n):
        if 0 < i:
            t[i] += t[i-1]
        v = int(s[i])
        v *= x
        t[i] += v
        t[i] %= 2019
        ans += a[t[i]]
        if t[i] == 0:
            ans += 1
        a[t[i]] += 1
        x *= 10
        x %= 2019
    print(ans)
#    print(t)

if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
const int inf=1e9+1;
int main(){

   ll n;
   cin >> n;
   vector <ll> a(n),b(n),c(n);
   for (ll i=0;i<n;i++)
    cin >> a[i] >> b[i]>> c[i];
   ll dp[3][n];
   dp[0][0]=a[0];
   dp[1][0]=b[0];
   dp[2][0]=c[0];
   for (ll i=1;i<n;i++)
   {
       dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
       dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
       dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
   }
   cout << max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
    return 0;
}




Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333



int main(void) {
  cin >> s;
  vector<pll> a;
  pll p;
  n = s.length();
  s = "1" + s;
  if (s[n] == '1' || s[1] == '0' || s[n - 1] == '0') ok = false;
  FOR(i, 2, n / 2 + 1) if (s[i] != s[n - i]) ok = false;

  p.first = 1; p.second = 2;
  a.pb(p);
  ll pre = 1, cur = 2, num = 3;
  FOR(i, 2, n / 2 + 1) {
	if (s[i] == '0') continue;
	rep(j, i - pre - 1) {
	  p.first = cur; p.second = num; a.pb(p);
	  num++;
	}
	p.first = cur; p.second = num; a.pb(p);
	cur = num; 
	num++;
	pre = i;
  }

  if (!ok) cout << "-1" << endl;
  else {
	while (num <= n) {
	  p.first = cur; p.second = num; a.pb(p);
	  num++;
	}
	rep(i, a.size()) cout << a[i].first << " " << a[i].second << endl;
  }


  return 0;
}

Measured memory_bytes: 3180
S = input()
N = len(S)

t1 = 0
t2 = 0
t3 = 0

for i in range(int(N/2)):
    if S[i] != S[-i-1]:
        break
else:
    t1 = 1
        
S2 = S[0:int((N-1)/2)]
N2 = len(S2)
for i in range(int(N2/2)):
    if S2[i] != S2[-i-1]:
        break
else:
    t2 = 1
    
S3 = S[int((N+3)/2)-1:N]
N3 = len(S3)
for i in range(int(N3/2)):
    if S[i] != S[-i-1]:
        break
else:
    t3 = 1
    
if t1 == t2 == t3 == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
import collections
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)
# print(max(c.values()))
# ans = [c[x] for x in c]
MAX = max(c.values())
ans = sorted([x for x in c if c[x] == MAX])
# ans = [x for x in c]
for i in ans:
    print(i)

Measured memory_bytes: 35572
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a)
	{
		cout<<a-k<<" "<<b;
	}
	else
		cout<<0<<" "<<max((ll)0,b-(k-a));
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

field = [(i, j) for i, j in zip(range(n), list(map(int, input().split())))]

#%%
town = 0 # 町は1始まりだが、indexの都合上-1する
order = 0 # 訪問順序
visited = {town: order} # 訪問済みの街を格納

while True:
    trans = field[town][1] - 1 # 現在のtownにあるテレポーターの移動先
    n_town = field[trans][0] # 遷移先の町. これはリストのindexになってるので-1しなくてよい
    if n_town not in visited.keys():
        order += 1
        visited[n_town] = order  # 訪問済みにする
    else: # 訪問済みを踏んだ時 TODO この実装だとループ内の数が数えられない
        st_circ = visited[n_town]
        break
    town = n_town

#%%
# ループ開始前まで
vk = list(visited.keys())
mae = len(vk[:st_circ])
circ = len(vk[st_circ:])

if k < mae:
    ans = vk[k]
else:
    idx = (k - mae) % circ
    ans = vk[idx + mae]

print(ans+1)

Measured memory_bytes: 59092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<ll,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m;
vector<pint> v[2][101010];
ll a[2][101010],dist[2][101010];

void bfs(int x,int flag){
    queue<pint> q;
    dist[flag][x]=0;
    q.push({0LL,x});
    while(q.size()){
        pint p=q.front();q.pop();
        ll d=p.first,now=p.second;
        for(auto to:v[flag][now]){
            if(dist[flag][to.second]>dist[flag][now]+to.first){
                dist[flag][to.second]=dist[flag][now]+to.first;
                q.push({dist[flag][to.second],to.second});
            }
        }
    }
}

int main(){
    cin>>n>>m;
    int s,t;
    cin>>s>>t;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        ll a,b;
        cin>>a>>b;
        x--;y--;
        v[0][x].push_back({a,y});
        v[1][x].push_back({b,y});
        v[0][y].push_back({a,x});
        v[1][y].push_back({b,x});
    }
    rep(i,n)rep(j,2)dist[j][i]=longinf;
    bfs(s-1,0);
    bfs(t-1,1);
    ll ans[n];
    rep(i,n)ans[i]=dist[0][i]+dist[1][i];
    rep(i,n-1)ans[n-i-2]=min(ans[n-i-1],ans[n-i-2]);
  rep(i,n)ans[i]=(ll)1e15-ans[i];
    rep(i,n)printf("%ld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 20288
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N, K;
int l[55];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> l[i];
  sort(l, l+N, greater<int>());
  int res = 0;
  for (int i = 0; i < K; ++i) res += l[i];
  cout << res << endl;
}


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

struct Problem {
public:

	LL F(LL X, LL Y) {
		LL ans = 10000000000;
		if (abs(X) % 2 == 0 && abs(Y) % 2 == 0)
			return abs(X) + abs(Y);
		else if (abs(X + Y) % 2 == 0)
			return abs(X) + abs(Y) - 1;
		else if (abs(X) + abs(Y) == 1) {
			return 1;
		}
		else {
			ans = min(ans, F(X + 1, Y));
			ans = min(ans, F(X - 1, Y));
			ans = min(ans, F(X, Y + 1));
			ans = min(ans, F(X, Y - 1));
			return ans + 2;
		}
	}

	void Solve() {
		while (true) {
			LL X, Y;
			cin >> X >> Y;
			if (cin.eof()) break;
			printf("%lld\n", F(X, Y));
		}
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int lim = 50;

bool edge[51][51];
bool visited[51];
int n, m;

void dfs(int u) {
  visited[u] = true;
  rep(i, n) {
    if (!edge[u][i] || visited[i]) continue;
    dfs(i);
  }
}

int main() {
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    edge[a[i]][b[i]] = edge[b[i]][a[i]] = true;
  }

  ll ans = 0;
  rep(i, m) {
    rep(j, n) visited[j] = false;
    edge[a[i]][b[i]] = edge[b[i]][a[i]] = false;
    dfs(0);
    bool ok = false;
    rep(j, n) if (!visited[j]) ok = true;
    if (ok) ans++;
    edge[a[i]][b[i]] = edge[b[i]][a[i]] = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9){
        cout << -1 << endl;
    }else {
        cout << a * b << endl;
    }
}


Measured memory_bytes: 256
while(True):
    a,b=map(int,input().split())
    if(a==0 and b==0):
        break
    else:
        for i in range(a):
            for j in range(b):
                if(i==0 or j==0 or i==a-1 or j==b-1):
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[220000];
ld b[220000];
main(){
  ll n,k,c;
  ld ans=0,tmp=0;
  cin>>n>>k;
  rep(i,0,n)cin>>a[i];
  rep(i,0,k)tmp+=(a[i]+1);
  b[0]=tmp;
  ans=b[0];
  rep(i,k,n){b[i-k+1]=b[i-k]-a[i-k]-1+a[i]+1;ans=max(ans,b[i-k+1]);}
  cout<<fixed<<setprecision(12)<<ans/2.0;
}


Measured memory_bytes: 5248
package main

import "fmt"

func main () {
	var five, seven int
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	
	if a == 5 {
		five++
	} else if a == 7 {
		seven++
	}

	if b == 5 {
		five++
	} else if b == 7 {
		seven++
	}

	if c == 5 {
		five++
	} else if c == 7 {
		seven++
	}

	if five == 2 && seven == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    bool flg=false;
    int n,a;cin >>n>>a;
    for (int i = 0; i <=a; ++i) {
        if((n-i)%500==0)flg=true;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a,b=set(map(int,input().split())),set(map(int,input().split()))
c=1;N=M=0
for k in range(m*n,0,-1):
 A=k in a;B=k in b
 if A and B:N+=1;M+=1
 elif A:c*=M;N+=1
 elif B:c*=N;M+=1
 else:c*=M*N-m*n+k
 c%=10**9+7
print(c)

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

int main()
{

    int n,count =0; 
    double d; 

    cin>>n>>d ; 


    for(;n--; )
    {
        long long x ,y; 

        cin>>x>>y; 

        if(sqrt(pow(x,2)  + pow(y,2)) <= d)
        {
            count++; 

        }
    }

    cout<<count;


}

Measured memory_bytes: 3692
n = int(input())
graph = [[] for i in range(n)]
irohash = {}
irojyun = []
for i in range(n-1):
    a,b = list(map(int,input().split()))
    a -= 1;b -= 1
    graph[a].append(b)
    graph[b].append(a)
    s = str(min(a,b)) + "," + str(max(a,b))
    irohash[s] = -1
    irojyun.append(s)

#最初の頂点を探す
ii = 0
for i in range(n):
    if len(graph[i]) == 1:
        ii = i
        break


iro = max([len(i) for i in graph])
stack = [[ii,graph[ii][0]]]
s = str(min(ii,graph[ii][0])) + "," + str(max(ii,graph[ii][0]))
irohash[s] = 1
while stack:
    oo = stack.pop()
    b,p = oo[0],oo[1]
    s = str(min(b,p)) + "," + str(max(b,p))
    piro = irohash[s]
    count = 1
    for v in graph[p]:
        s = str(min(p,v)) + "," + str(max(v,p))
        if irohash[s] != -1:continue
        if count == piro:count += 1
        irohash[s] = count
        stack.append([p,v])
        count += 1
print(iro)
for i in range(n-1):
    print(irohash[irojyun[i]])

Measured memory_bytes: 95264
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		String ans = "";
		while (N != 0) {
			if (N % 2 != 0) {
				N--;
				ans = "1" + ans;
			} else {
				ans = "0" + ans;
			}
			N /= -2;
		}
		if (ans == "") {
			ans = "0";
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21972
package main

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

const (
	A = iota
	C
	G
	T
)

const (
	M = 1046527
)

var (
	H  [M]string
	sc = bufio.NewScanner(os.Stdin)

)
func getChar(s string) int {
	switch s {
	case "A":
		return A + 1
	case "C":
		return C + 1
	case "G":
		return G + 1
	case "T":
		return T + 1
	default:
		return 0
	}
}

func getKey(s string) int {
	var sum int
	p := 1
	for i := 0; i < len(s); i++ {
		char := string(s[i])
		sum += p * getChar(char)
		p *= 5
	}
	return sum
}

func h1(key int) int { return key % M }
func h2(key int) int { return 1 + (key % (M - 1)) }

func find(s string) bool {
	key := getKey(s)
	var h int
	for i := 0; ; i++ {
		h = (h1(key) + i*h2(key)) % M
		if H[h] == s {
			return true
		} else if len(H[h]) == 0 {
			return false
		}
	}
	return false
}

func insert(s string) bool {
	key := getKey(s)
	var h int
	for i := 0; ; i++ {
		h = (h1(key) + i*h2(key)) % M
		if H[h] == s {
			return true
		} else if len(H[h]) == 0 {
			H[h] = s
			return true
		}
	}
	return false
}

func firstInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	a := sc.Text()
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	var str, command string
	n = firstInt()
	for i := 0; i < n; i++ {
		// fmt.Scan(&command, &str)
		command = nextLine()
		str = nextLine()
		if string(command[0]) == "i" {
			insert(str)
		} else {
			if find(str) {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		}
	}
}



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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a*b >= c*d) cout << a*b << endl;
  else cout << c*d << endl;
  
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m;
pair<int,int>p[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		p[i]=make_pair(b,a);
	}
	sort(p+1,p+m+1);
	int pos=1,ans=0;
	while(pos<=m){
		ans++;
		int ed=p[pos].first;
		while(pos<=m&&p[pos].second<ed)pos++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  int diff = abs(b - a);
  
  if(diff % 2 == 0){
    if (a > b)
      cout << abs(a - (diff / 2)) << endl;
    else
      cout << abs(b - (diff / 2)) << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> white(N, 0);
    vector<int> black(N, 0);
    for(int i = 0; i < N; ++i) {
        if(s[i] == '.')
            white[i] = 1;
        else
            black[i] = 1;
    }
    for(int i = 1; i < N; ++i) {
        white[i] += white[i-1];
        black[i] += black[i-1];
    }
    int ret = white[N-1];
    for(int i = 0; i < N; ++i) {
        int temp = black[i] + white[N-1] - white[i];
        ret = min(ret, temp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2180
import math

n, k = map(int, input().split())
A = list(map(int, input().split()))

l = 1
r = 10**9+1

while l < r:
    mid = (l+r)//2
    count = 0
    for i in range(n):
        if A[i] > mid:
            count += math.ceil(A[i]/mid-1)

    if count <= k:
        r = mid
    else:
        l = mid+1


print(l)


Measured memory_bytes: 31072
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
	cin >> n>>m;
    priority_queue<int> a;
    int x;
    fr(i,n){
      cin >>x;
      a.push(x);
    }
    fr(i,m){
      x= a.top()/2;
      
      a.pop();
      a.push(x);
    }
    ll ans=0;
    fr(i,n){
      ans+=a.top();
      a.pop();
    }
    cout << ans <<endl;
}


Measured memory_bytes: 892
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
ans1, ans2 = 0, 0
f = 0
f += a[0]
if f <= 0:
    f = 1
    ans1 += 1 - a[0]
for i in range(1, N):
    if f * (f + a[i]) < 0:
        f += a[i]
        continue
    ans1 += abs(f + a[i]) + 1
    if f > 0:
        f = -1
    else:
        f = 1
f = 0
f += a[0]
if f >= 0:
    f = -1
    ans2 += 1 + a[0]
for i in range(1, N):
    if f * (f + a[i]) < 0:
        f += a[i]
        continue
    ans2 += abs(f + a[i]) + 1
    if f > 0:
        f = -1
    else:
        f = 1
print(min(ans1, ans2))

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

int main(){
  int N,M;
  cin>>N>>M;
  std::vector<int> x(M),y(M);
  for(int i=0;i<M;i++){
    cin>>x[i]>>y[i];
    x[i]--;
    y[i]--;
  }
  std::vector<int> ball(N,1);
  std::vector<int> pred(N,0);
  pred[0]=1;
  for(int i=0;i<M;i++){
    ball[x[i]]--;
    ball[y[i]]++;
    if(pred[x[i]])pred[y[i]]++;
    if(ball[x[i]]==0)pred[x[i]]=0;
  }
  int ans=0;
  for(int i=0;i<N;i++)if(pred[i])ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
s = input()
ans_flag = False
if "keyence" in s:
  ans_flag = True
  
t = "keyence"
for i in range(1,7):
  first_half = t[:i]
  second_half = t[i:]
  if first_half == s[:len(first_half)]:
    if s[-len(second_half):] == second_half:
      ans_flag = True

print("YES" if ans_flag else "NO")

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int cnt[100][256];
char s[100];

int main() {
  int N;
  scanf("%d", &N);
  REP(i,N) {
    scanf("%s", s);
    REP(j, strlen(s)) {
      ++cnt[i][s[j]];
    }
  }

  string result = "";
  for (char c = 'a'; c <= 'z'; ++c) {
    int m = 999999;
    REP(i,N) m = min(m, cnt[i][c]);
    REP(i,m) result += c;
  }
  printf("%s\n", result.c_str());
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
// #define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 102
#define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const ll inf = (ll)1e18 + 10;



int a[25][25] = {{0}};
int dp[1 << 22];
signed main(){
  fast;
 
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++)
  	for(int j = 0 ; j < n;  j++)
  		cin >> a[i][j];


 dp[0] = 1;
 for(int i = 0 ; i < (1 << n) - 1 ; i++){
 	int x = bitcnt(i);
 	for(int j = 0 ; j < n ; j++){
 		int k = (1 << j);
 		   if( (i & k) == 0 && a[x][j]){
 		   	   dp[i | k] += dp[i];
 		   	   dp[i | k] %= mod; 
 		   }
 	}
 }

 cout << dp[(1 << n) - 1] << endl;


}	

Measured memory_bytes: 10496
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
yen = [0] * N
for i in range(N):
    yen[i] = s.count(s[i])-t.count(s[i])
if max(yen) >= 0:
    print(max(yen))
else:
    print(0)


Measured memory_bytes: 3060
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=[]
m=[]
z=0
a.sort(reverse=True)
for i in range(n):
    if a[i]>0:
        p.append(a[i])
    elif a[i]==0:
        z+=1
    else:
        m.append(a[i])
nump=len(p)
numm=len(m)
ans=1
if nump+numm<k:
    print(0)
elif numm<2 and nump>=k:
    for i in range(k):
        ans*=p[i]
        ans%=10**9+7
    print(ans)
elif 2*(numm//2)+nump<k: #2
    if z!=0:
        print(0)
    else:
        for i in range(n):
            a[i]=abs(a[i])
        a.sort()
        ans=-1
        for i in range(k):
            ans*=a[i]
            ans%=10**9+7
        print(ans)
elif  nump==0: #8?
    if z!=0 and k%2==1:
        print(0)
    elif z!=0 and numm<k:
        print(0)
    else:
        if k%2==0:
            m.sort()
            for i in range(k):
                ans*=m[i]
                ans%=10**9+7
        else:
            m.sort(reverse=True)
            for i in range(k):
                ans*=m[i]
                ans%=10**9+7
        print(ans)
else:
    if k%2==1:
        ans*=p[0]
        p=p[1:]
    m.sort()
    p.sort(reverse=True)
    nump=len(p)//2
    numm=numm//2
    nump1=0
    nump2=0
    numm1=0
    numm2=0
    for i in range(k//2):
        if nump2==nump:
            nump1=-1
        else:
            nump1=p[nump2*2]*p[nump2*2+1]
        if numm2==numm:
            numm1=-1
        else:
            numm1=m[numm2*2]*m[numm2*2+1]
        if numm1>=nump1:
            num=numm1
            numm2+=1
        else:
            num=nump1
            nump2+=1
        ans*=num
        ans%=10**9+7
    print(ans)


Measured memory_bytes: 31696
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	if (N == 3) {
		cout << 2 << endl;
		cout << "1 3" << endl;
		cout << "2 3" << endl;
		return 0;
	}

	if (N % 2 == 1) {
		vector<vector<int>> a(N / 2);
		for (int i = 1; i <= N / 2; i++) {
			a[i - 1].push_back(i);
			a[i - 1].push_back(N - i);
		}
		a.push_back(vector<int>());
		a.back().push_back(N);

		set<pair<int, int>> e;
		for (int i = 0; i < a[0].size(); i++)for (int j = 0; j < a.back().size(); j++) {
			e.insert({ min(a[0][i],a.back()[j]), max(a[0][i],a.back()[j])});
		}
		for (int i = 0; i < a.size() - 1; i++) {
			for (int j = 0; j < a[i].size(); j++)for (int k = 0; k < a[i + 1].size(); k++) {
				e.insert({ min(a[i][j],a[i + 1][k]), max(a[i][j],a[i + 1][k]) });
			}
		}

		cout << e.size() << endl;
		for (auto itr = e.begin(); itr != e.end(); itr++) {
			cout << (*itr).first << " " << (*itr).second << endl;
		}
	}
	else {
		vector<vector<int>> a(N / 2);
		for (int i = 1; i <= N / 2; i++) {
			a[i - 1].push_back(i);
			a[i - 1].push_back(N - i + 1);
		}

		set<pair<int, int>> e;
		for (int i = 0; i < a[0].size(); i++)for (int j = 0; j < a.back().size(); j++) {
			e.insert({ min(a[0][i],a.back()[j]), max(a[0][i],a.back()[j]) });
		}
		for (int i = 0; i < a.size() - 1; i++) {
			for (int j = 0; j < a[i].size(); j++)for (int k = 0; k < a[i + 1].size(); k++) {
				e.insert({ min(a[i][j],a[i + 1][k]), max(a[i][j],a[i + 1][k]) });
			}
		}

		cout << e.size() << endl;
		for (auto itr = e.begin(); itr != e.end(); itr++) {
			cout << (*itr).first << " " << (*itr).second << endl;
		}
	}
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long ans=0;
long long tens[6]={1,10,100,1000,10000,100000};
bool check(long long b,long long n){

    long long p=b;
    int size=0;
    while(p>0){
        p/=10;
        size++;
    }
    p=0;
    rep(i,size){
        p+=(b%10)*tens[size-1-i];
        b/10;
    }
    if(p<=n)return true;

    else{
        return false;
    }
    
}

int head(long long p){
    int now=0;
    while(p>0){
        now=p%10;
        p/=10;
    }
    return now;
}

int tail(long long p){
    return p%10;
}
int main(){
    long long n;
    cin>>n;
    long long ans=0;

    long long cnt[10][10]={};
    /*
        1<=x<=Nを満たす各xについて
        h=先頭の数字
        t=最後尾の数字として
        cnt[i][k]:=先頭がi桁で始まり、最後がkで終わる数字数として

        i=1~9,k=1~9の範囲で足し合わせる
        
        ans+=c[i][k]*c[k][i];
        
        */
    for(long long p=1;p<=n;p++){
        
        int h=head(p);
        int t=tail(p);
        cnt[h][t]++;
    }
    rep(i,10)rep(k,10)ans+=cnt[i][k]*cnt[k][i];

    cout<<ans<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int N, M, Q;
	int a[50], b[50], c[50], d[50];


	int p[10];
	cin >> N >> M >> Q;

	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	for (int i = 0; i < N; i++) {
		p[i] = 1;
	}


	int ans = 0;
	for (int i = 0; i < Q; i++) {
		if (p[b[i] - 1] - p[a[i] - 1] == c[i]) { ans += d[i]; }
	}

	while (true) {
		int last_index = -1;
		for (int i = N - 1; i >= 0; i--) {
			if (p[i] != M) {
				last_index = i;
				break;
			}
		}
		if (last_index == -1) { break; }

		int next = p[last_index] + 1;
		for (int i = last_index; i < N; i++) {
			p[i] = next;
		}
	
		int pt = 0;
		for (int i = 0; i < Q; i++) {
			if (p[b[i] - 1] - p[a[i] - 1] == c[i]) { pt += d[i]; }
		}
		
		if (pt > ans) { ans = pt; }
	}

	cout << ans;


}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

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

    int a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
}

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

int main()
{
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(k>=a-b&&k>=a-c&&k>=a-d&&k>=a-e&&k>=b-a&&k>=b-c&&k>=b-d&&k>=b-e&&k>=c-a&&k>=c-b&&k>=c-d&&k>=c-e&&k>=d-a&&k>=d-b&&k>=d-c&&k>=d-e&&k>=e-a&&k>=e-b&&k>=e-c&&k>=e-d){
        cout<< "Yay!" <<endl;
    } else {
        cout<< ":(" <<endl;
    }
}

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

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

    int max = 0;
    vector<int> v(n, 0);
    int x;

    for(int i = 0; i < n; i++) {
        cin >> x;
        if(x > max) max = x;
        v[i] = x;
    }

    long long int ans = 0;

    for(int i = 2; i <= (int)sqrt(max); i++) {
        long long int tmp = 0;
        for(int j = 0; j < n; j++) {
            if(v[j] > 1 && v[j] % i == 0) {
                tmp += v[j];
            }
        }
        if(tmp > ans) ans = tmp;
    }

    for(int i = 0; i < n; i++) {
        long long int tmp = 0;
        if(v[i] == 1) continue;
        for(int j = 0; j < n; j++) {
            if(v[j] > 1 && v[j] % v[i] == 0) {
                tmp += v[j];
            }
        }
        if(tmp > ans) ans = tmp;
    }

    cout << ans << endl;

    return 0;
}



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

int main(){

  int n;
  cin >> n;
  vector<string>blue(n);
  rep(i, n){
    cin >> blue.at(i);
  }
  int m;
  cin >> m;
  vector<string>red(m);
  rep(i, m){
    cin >> red.at(i);
  }
  int ans = -100;
  rep(i, n){
    int cnt = 0;
    rep(j, n){
      if(blue.at(i) == blue.at(j)){
        cnt++;
      }
    }
    rep(j, m){
      if(blue.at(i) == red.at(j)){
        cnt--;
      }
    }
    ans = max(ans, cnt);
  }
  if(ans<0) ans = 0;
  cout << ans << endl;
  return 0;




}



Measured memory_bytes: 3584
// yet

#include <iostream>
#include <complex>
#include <array>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int a,b;
    bool f=0;
    while(cin>>a>>b,a||b){
        if(f) cout<<endl;
        f=1;
        int n=0;
        int ans[3000];
        loop(y,a,b+1){
            if(y%400==0||(y%4==0&&y%100!=0)) ans[n++]=y;
        }
        if(n) rep(i,n) cout<<ans[i]<<endl;
        else cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1168
$n=<>;
print(&f(""));
sub f{
    my $i=@_[0];
    my $f=0;
    return 0 if (int($i) > $n);
    $f+=($i=~/3/)?1:0;
    $f+=($i=~/5/)?1:0;
    $f+=($i=~/7/)?1:0;
    local $r=($f==3)?1:0;
    $r+=&f($i.$_) for ("7","5","3");
    return $r
}


Measured memory_bytes: 384
import math
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, K = list(map(int, sys.stdin.readline().split()))
A = [sys.stdin.readline().rstrip() for _ in range(H)]

sh = sw = -1
for h, r in enumerate(A):
    if 'S' in r:
        sh = h
        sw = r.index('S')


def step(h, w):
    return math.ceil(min(h, w, H - h - 1, W - w - 1) / K)


def ok(h, w):
    return 0 <= h < H and 0 <= w < W


dh = [0, 1, 0, -1]
dw = [1, 0, -1, 0]

# 最初の魔法でどこまで端にいけるか
que = deque([(sh, sw, K)])
seen = [[0] * W for _ in range(H)]
seen[sh][sw] = True
min_step = step(sh, sw)
while que:
    sh, sw, k = que.popleft()
    for hh, ww in zip(dh, dw):
        h = sh + hh
        w = sw + ww
        if not ok(h, w) or A[h][w] == '#' or seen[h][w]:
            continue
        if k > 0:
            min_step = min(min_step, step(h, w))
            seen[h][w] = True
            que.append((h, w, k - 1))
print(min_step + 1)


Measured memory_bytes: 86364
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<pair<int, int>> num(n);
  REP(i, n) num[i] = {a[i], i};
  sort(ALL(num), greater<pair<int, int>>());
  vector dp(n + 1, -LINF);
  dp[0] = 0;
  REP(i, n) {
    auto [val, idx] = num[i];
    vector nx(n + 1, -LINF);
    REP(j, i + 1) {
      int r = i - j;
      chmax(nx[j + 1], dp[j] + 1LL * val * abs(j - idx));
      chmax(nx[j], dp[j] + 1LL * val * abs(n - 1 - r - idx));
    }
    dp.swap(nx);
  }
  cout << *max_element(ALL(dp)) << '\n';
  return 0;
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21460
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt(),w = sc.nextInt();
    int bom[][] = new int[h+2][w+2];
    for(int i = 1;i<=h;i++){
      String s = sc.next();
      for(int j = 1;j<=w;j++){
        if(s.substring(j-1,j).equals("#")){
          bom[i][j] = 1;
        }
      }
    }
    for(int i = 1;i<=h;i++){
      for(int j = 1;j<=w;j++){
        if(bom[i][j] == 1){
          System.out.print("#");
          continue;
        }
        int count = 0;
        if(bom[i-1][j-1] == 1){
          count++;
        }
        if(bom[i-1][j]  == 1){
          count++;
        }
        if(bom[i-1][j+1] == 1){
          count++;
        }
        if(bom[i][j-1] == 1){
          count++;
        }
        if(bom[i][j+1] == 1){
          count++;
        }
        if(bom[i+1][j-1] == 1){
          count++;
        }
        if(bom[i+1][j]  == 1){
          count++;
        }
        if(bom[i+1][j+1] == 1){
          count++;
        }
        System.out.print(count);
      }
      System.out.println("");
    }
  }
}


Measured memory_bytes: 22356
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int h, w, k;
int f[105][105];

int main() {
    cin >> h >> w >> k;
    if (w == 1) {
        puts("1");
        return 0;
    }
    f[0][0] = 1;
    for (int i = 1; i <= h; i++) {
        for (int s = 0; s < (1 << (w - 1)); s++) {
            bool valid = true;
            for (int j = 0; j < w - 2; j++) if ((s & (1 << j)) && (s & (1 << (j + 1)))) valid = false;
            if (!valid) continue;
            for (int j = 0; j < w; j++) {
                if (j != 0 && (s & (1 << (j - 1)))) (f[i][j] += f[i - 1][j - 1]) %= MOD;
                else if (j != w - 1 && (s & (1 << j))) (f[i][j] += f[i - 1][j + 1]) %= MOD;
                else (f[i][j] += f[i - 1][j]) %= MOD;
            }
        }
    }
    printf("%d\n", f[h][k - 1] % MOD);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int i,a[100],j,n,minj,sw,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&a[i]);

  }


  for(i=0;i<n;i++){

    minj = i;

    for(j=i;j<n;j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }

      sw = a[i];
      a[i]= a[minj];
      a[minj] = sw;
      if(i != minj) count++;
    }

  for(i=0;i<n-1;i++){

    printf("%d ",a[i]);

  }
  printf("%d",a[n-1]);
  printf("\n");
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
	string s;
	cin>>s;
	if(s[0]=='a')cout<<"square1001"<<endl;
	else cout<<"e869120"<<endl;
}


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

vector< int > preorder;
vector< int > inorder;

void printPost(int n,
	       int inBegin,
	       int inEnd) {
  if (inBegin == inEnd)
    return;
  if (inBegin == (inEnd-1)) {
    cout << inorder[inBegin];
    if (inorder[inBegin] == preorder[0])
      cout << endl;
    else
      cout << ' ';
    return;
  }
  for (int j = 0; j < n; j++) {
    for (int i = inBegin; i < inEnd; i++)
      if (inorder[i] == preorder[j]) {
	printPost(n, inBegin, i);
	printPost(n, i+1, inEnd);
	cout << inorder[i];
	if (inorder[i] == preorder[0])
	  cout << endl;
	else
	  cout << ' ';
	return;
      }
  }
}
  

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  preorder = vector< int > (n, 0);
  for (int i = 0; i < n; i++)
    cin >> preorder[i];
  inorder = vector< int > (n, 0);
  for (int i = 0; i < n; i++)
    cin >> inorder[i];
  printPost(n, 0, n);
  return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include<string>
using namespace std;
char s[19][19];
int main() {
	int h, w;
	int cnt = 0;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for (int j =0 ; j < w; j++) {
			cin >> s[i][j];
			if (s[i][j] == '#') { cnt++; }
	}
	}
	if (cnt == h + w - 1) { cout << "Possible" << endl; }
	else { cout << "Impossible" << endl; }
}


Measured memory_bytes: 256
class Stack():
    def __init__(self):
        self.stack = []
        self.top = 0

    def is_empty(self):
        return self.top == 0

    def push(self, x):
        self.stack.append(x)
        self.top += 1

    def pop(self):
        if not self.is_empty():
            self.top -= 1
            return self.stack.pop()
        else:
            print("empty")

stack = Stack()
for x in input().split(" "):
    if x in ("+", "-", "*"):
        l1 = stack.pop()
        l2 = stack.pop()
        if x == "+":
            stack.push(l1 + l2)
        elif x == "-":
            stack.push(l2- l1)
        else:
            stack.push(l1 * l2)
    else:
        stack.push(int(x))
print(stack.pop())



Measured memory_bytes: 5596