akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, cnt;
long long L;
struct Trie {
	int ch[2], dep;
}T[301000];
char p[101000];
void Put(int a, char *key) {
	if (!(*key))return;
	int c = *key - '0';
	if (!T[a].ch[c]) {
		T[a].ch[c] = ++cnt;
		T[cnt].dep = T[a].dep + 1;
	}
	Put(T[a].ch[c], key + 1);
}
long long Get(long long a) {
	if (!a)return 0;
	if (a & 1)return 1;
	return Get(a >> 1) << 1;
}
int main() {
	int i, root = 1;
	scanf("%d%lld", &n, &L);
	cnt = 1;
	for (i = 0; i < n; i++) {
		scanf("%s", p);
		Put(root, p);
	}
	long long res = 0;
	for (i = 1; i <= cnt; i++) {
		if ((!T[i].ch[0]) != (!T[i].ch[1])) {
			res ^= Get(L - T[i].dep);
		}
	}
	if (res)puts("Alice");
	else puts("Bob");
}

Measured memory_bytes: 1408
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x;
    cin >> x;
    ll y = x;
    ll cnt = 1;
    while(x != 0){
    	x = (x + y) % 360;
    	cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main()
{
    int a,b; cin >> a >> b;
    bool z = false;
    int ans;
    for(int i = 13; i <= 1000; i++) {
        int tmpa,tmpb;
        tmpa = 0.08 * i;
        tmpb = 0.1 * i;
        if(tmpa == a && tmpb == b) {
            z = true;
            ans = i;
            break;
        }
    }
    if(z) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

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

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    string S;
#define AA 19
    ll dp[AA][2][2][2][2][2];

    void input() {
        cin >> S;
        memset(dp, -1, sizeof(dp));

    }

    ll rec(int N = 0, bool tight = true, int state1 = 0, int state2 = 0, int state3 = 0, int state4 = 0) {
        if (dp[N][tight][state1][state2][state3][state4] != -1) return dp[N][tight][state1][state2][state3][state4];
        if (N == S.size()) {
            return state4;
        }

        int x = S[N] - '0';
        int lim = tight ? x : 9;
        ll ret = 0;
        for (int i = 0; i <= lim; ++i) {
//            rec(N+1,tight && i == lim, hoge, state1 + hoge, state2 + hoge, state3 + hoge);
            int next1 = i == 5;
            int next2 = (state1 == 1 && i == 1);
            int next3 = state2;
            int next4 = (state3 && i == 3) || state4;

            ret += rec(N + 1, tight && i == lim, next1, next2, next3, next4);
        }

        return dp[N][tight][state1][state2][state3][state4] = ret;
    }

    void solve() {
        input();
        ll val = rec();
        cout << val << endl;

    }
};


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

    Solve().solve();


    return 0;
}



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

int main() {
    int X, t;
    cin >> X >> t;
    cout << max(X-t, 0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if (0<=x-r && x+r<=w && 0<=y-r && y+r<=h)
    {
        printf("Yes\n");
    }else {
        printf("No\n");

    }
        return 0;
    
    
    
}


Measured memory_bytes: 2124
N=int(input())
c=list(input())
cnt=0
res=10**30
rcum=[0]*(N+1)
wcum=[0]*(N+1)
for i in range(N):
    rcum[i+1]=rcum[i]+(c[i]=='R')
    wcum[i+1]=wcum[i]+(c[i]=='W')
for i in range(N+1):
    a=wcum[i]+(rcum[N]-rcum[i])
    res=min(res,a)
for i in range(N+1):
    b=max(wcum[i],(rcum[N]-rcum[i]))
    res=min(res,b)
    

print(res)

Measured memory_bytes: 92292
s = input()


def main(s):
    a_index = 200000 
    z_index = -1
    i = 0

    for c in s:
        if c == 'A':
            a_index = min(a_index, i)
        elif c == 'Z':
            z_index = max(z_index, i)
        i += 1

    return (z_index - a_index) + 1


print(main(s))


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

int main() {
	int N, a[200];
	int alice=0, bob=0;
	cin >> N;
	for (int i = 0;i<N;++i) {
		cin >> a[i];
	}
	sort(a, a+N);
	
	if (N % 2 == 1) {
		for (int i = 0; i < N; ++i) {
			if (i % 2 == 0) alice += a[i];
			if (i % 2 == 1) bob += a[i];
		}
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (i % 2 == 1) alice += a[i];
			if (i % 2 == 0) bob += a[i];
		}
	}

	cout << alice - bob << endl;

	return 0;
}

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

set<string> s;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    while(n--)
    {
        string str;
        cin >> str;
        s.insert(str);
    }

    cout << s.size() <<endl;

    return 0;
}


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

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

int h,w,n,sx,sy,gx,gy;
string s,field[1010];
const int INF = 1e+9;
int nxt[1000100][4],dir[1000100];
int dist[1010][1010];

void solve(){
	cin >> s;
	for(int i = 0;i < 4;i++) nxt[n + 1][i] = -1;
	for(int i = 0;i < n;i++) dir[i + 1] = (dir[i] + (s[i] == 'L' ? 3 : 1)) % 4;
	for(int i = n;i >= 0;i--){
		for(int j = 0;j < 4;j++){
			if(dir[i] == j) nxt[i][j] = i;
			else nxt[i][j] = nxt[i + 1][j];
		}
	}
	for(int i = 0;i < h;i++){
		cin >> field[i];
		for(int j = 0;j < w;j++){
			if(field[i][j] == 'S') sx = i,sy = j;
			else if(field[i][j] == 'G') gx = i,gy = j;
		}
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) dist[i][j] = INF;
	}
	using P = pair<int,pair<int,int>>;
	priority_queue<P,vector<P>,greater<P>> que;
	dist[sx][sy] = 0;
	que.emplace(0,make_pair(sx,sy));
	while(!que.empty()){
		P p = que.top();que.pop();
		int x = p.second.first,y = p.second.second;
		if(dist[x][y] < p.first) continue;
		for(int i = 0;i < 4;i++){
			int nx = x + dx[i],ny = y + dy[i];
			if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] != '#'
			&& nxt[dist[x][y]][i] != -1 && dist[nx][ny] > nxt[dist[x][y]][i]){
				dist[nx][ny] = nxt[dist[x][y]][i];
				que.emplace(dist[nx][ny],make_pair(nx,ny));
			}
		}
	}
	if(dist[gx][gy] != INF) cout << "Yes" << endl;
	else cout << "No" << endl; 
}

signed main(){
	while(cin >> h >> w >> n,n) solve();
}


Measured memory_bytes: 8140
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    string s,t;
    cin>>s>>t; 
    ll n=s.length()-t.length(),ans=t.length();
    for(ll i=0;i<=n;i++){
      ll j=0,curr=0;
      while(j<t.length()){
        if(t[j]!=s[i+j]){
          curr++;
        }
        j++;
      }
      ans=min(ans,curr);
    }
    cout<<ans; 
    return 0;
}   

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    if(sum%10!=0)cout<<sum<<endl;
    else {
        for(int i=0;i<n;i++){
            sum-=a[i];
            if(sum%10!=0){
                cout<<sum<<endl;
                return 0;
            }else {
                sum+=a[i];
            }
        }
        cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <cctype>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  int n, l=0, r=0;
  cin >> n;
  rep(i,n){
    string s,t;
    cin >> s >> t;
    if(s > t) l+=3;
    else if(s < t) r+=3;
    else{
      l+=1;
      r+=1;
    }
  }
  cout << l << " " << r << endl;
}



Measured memory_bytes: 3160
#

import sys
from bisect import bisect, bisect_left
input=sys.stdin.readline

def main():
    N=int(input())
    S=[input().strip("\n") for i in range(N)]
    S.sort()
    Ss=set(S)
    ooi=[]
    maxc=0
    for s in Ss:
        c=bisect(S,s)-bisect_left(S,s)
        if maxc<c:
            ooi=[s]
            maxc=c
        elif maxc==c:
            ooi.append(s)
    print("\n".join(sorted(ooi)))
        
        
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 109604
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    FAST_IO ;
    bigint N ; cin >> N ;
    bigint ans = 0 ;
    map<bigint , bigint > m ;
    int arr[N] ;
    for( int i = 0 ; i < N ; i++ ){
        cin >> arr[i] ;
        m[arr[i]]++ ;
    }
    for( auto x : m ){
        if( x.second < 2 )
            continue ;
        ans += ( x.second * ( x.second - 1 ) ) / 2 ;
    }
    for( int i = 0 ; i < N ; i++ ){
        bigint sum = ans ;
        if( m[arr[i]] < 2 )
            cout << sum << endl ;
        else{
            bigint x = m[arr[i]] ;
            sum -= (x * ( x - 1 )) / 2 ;
            x -- ;
            if( x < 2 )
                cout << sum << endl ;
            else
                cout << sum + ( x * ( x - 1 )) / 2 << endl ;
        }
    }
    return 0 ;
}


Measured memory_bytes: 12320
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    N = int(input())
    if N<=999:
        print('ABC')
    else:
        print('ABD')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

ll a[100002];

int main(){
  int n;
  cin>>n;
  ll cnt=0;
  REP(i,n){
    int A;
    cin>>A;
    if(A>100000){cnt++;}
    else{a[A]++;}
  }
  REP(i,100001){
    if(a[i]<i){
      cnt+=a[i];
    }else if(a[i]>i){
      cnt=cnt+a[i]-i;
    }
  }
  print(cnt);
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}
int main(){
  ll N; cin>>N;
  string S; cin>>S;
  if(N==1) cout<<1<<endl;
  else{
    ll count=0;
    rep(i,N-1){
      if(S[i]==S[i+1]) continue;
      else count++;
    }
    count++;
    cout<<count<<endl;
  }
}

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

"""
def dfs(x, y):
    if x==0 and y==0:
        return False
        
    res = False
    
    if x>0:
        res |= not dfs(x-1, y)
    
    if y>0:
        res |= not dfs(x, y-1)
    
    if min(x, y)>0:
        res |= not dfs(x-1, y-1)
    
    return res
    
t = [[False]*5 for _ in range(5)]

for i in range(5):
    for j in range(5):
        t[i][j] = dfs(i, j)

for ti in t:
    print(*ti)
"""

N = int(input())
a = [int(input()) for _ in range(N)]

for ai in a:
    if ai%2==1:
        print('first')
        exit()

print('second')

Measured memory_bytes: 43868
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int c,d,n,m;
    while(~scanf("%d %d",&n,&m))
    {
        if(n==2||m==2)
        {
            printf("No\n");
        }
        else if(n==1&&m==3)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==5)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==1&&m==8)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==1&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==3&&m==5)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==8)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==10)
        {
            printf("Yes\n");
        }
        else  if(n==3&&m==12)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==7)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==8)
        {
            printf("Yes\n");
        }
        else  if(n==5&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==5&&m==12)
        {
            printf("Yes\n");
        }
        else  if(n==7&&m==8)
        {
            printf("Yes\n");
        }
        else if(n==7&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==7&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==8&&m==10)
        {
            printf("Yes\n");
        }
        else if(n==8&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==10&&m==12)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==6)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==9)
        {
            printf("Yes\n");
        }
        else if(n==4&&m==11)
        {
            printf("Yes\n");
        }
        else if(n==6&&m==9)
        {
            printf("Yes\n");
        }
        else if(n==6&&m==11)
        {
            printf("Yes\n");
        }
        else if(n==9&&m==11)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

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

	for (int i = 0; i < str.length(); i++)
		cout << "x";

	return 0;
}

Measured memory_bytes: 256
using System;
					
public class Program
{	
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		for(int i = 0; i < n ; i++) {
			string X = Console.ReadLine();
			string Y = Console.ReadLine();
			
			int xLen = X.Length + 1;
			int yLen = Y.Length + 1;
			int[,] DP = new int[xLen, yLen];
			
			for(int j = 1; j < xLen; j++) {
				for(int k = 1; k < yLen; k++) {
					DP[j,k] = LCS(DP, j, k, X, Y);
				}
			}
			
			Console.WriteLine(DP[X.Length, Y.Length]);
		}
	}
	
	public static int LCS(int[,] DP, int i, int j, string X, string Y)
	{
		if(X[i-1] == Y[j-1]) return DP[i-1, j-1] + 1;
		else return Math.Max(DP[i-1,j], DP[i,j-1]);
	}
}

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

using namespace std;

typedef pair<int, int> P;

int main(){
    long sum = 0;
    long N, K;
    cin >> N >> K;
    P p[100000];
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        sum += p[i].second;
        if(sum >= K){
            cout << p[i].first << endl;
            break;
        }
    }
}

Measured memory_bytes: 1152
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=[];b=[]
for i in range(len(v)):
  if i%2==0:a.append(v[i])
  else:b.append(v[i])
A=Counter(a);B=Counter(b)
c=A.most_common()[0][0];d=B.most_common()[0][0]
if len(set(a))!=1 and len(set(b))!=1:
  if c==d:
    e=A.most_common()[1][1];f=B.most_common()[1][1]
    if e<=f:
      d=B.most_common()[1][0]
    else:
      c=A.most_common()[1][0]
  x=len(a)-a.count(c)
  y=len(b)-b.count(d)
  print(x+y)
elif len(set(a))==1 and len(set(b))==1:
  if a[0]!=b[0]:print(0)
  else:print(len(a))
elif len(set(a))==1:
  if c==d:
    d=B.most_common()[1][0]
  x=len(a)-a.count(c)
  y=len(b)-b.count(d)
  print(x+y)
else:
  if c==d:
    c=A.most_common()[1][0]
  x=len(a)-a.count(c)
  y=len(b)-b.count(d)
  print(x+y)

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

int main()
{long long N ;
cin >> N;
if(N%2==0 || N%5 == 0)
cout << -1;
else
{
  long long a = 7;
  long long i = 1;

  while(a%N != 0 && i != INT_MAX)
  {
      a = a*10 %N +7%N;
      i++;
  }

 cout << (i == INT_MAX ? -1 : i);

}
}

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

int main()
{
int x, a, b;
  cin >> x >> a >> b;
  
  int A = x-a; if (A<0) A = -A;
  int  B = x-b; if (B<0) B = -B;
  
  if (A<B) cout << "A" << endl;
  else cout << "B" << endl;
}

Measured memory_bytes: 256
from math import atan, degrees

a,b,x = map(int,input().split())
if a * a * b == x * 2:
    print(45)
elif a * a * b > x * 2:
    t = 2 * x / (a * b * b)
    print(90 - degrees(atan(t)))
else:
    h = (2 / a) * (a * b - x / a)
    print(degrees(atan(h / a)))


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

template <typename ArrayT>
void DumpArray(const ArrayT &arr)
{
	for (auto it = arr.begin(); it != arr.end(); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
};
template <typename T>
bool ChMin(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
bool ChMax(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

// 繰り下がり有無
static const int DESC = 1;
static const int NONE = 0;

const int ILEN = 10000005;
const int KLEN = 2;

int DP[ILEN][KLEN];

class Solver
{
	void InitDP()
	{
		REP (i, ILEN)
			REP (k, KLEN) {
				DP[i][k] = INT_MAX;
			}
	}

  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		string S;
		cin >> S;

		// 桁DP
		// dp[桁（下位から）]
		//   [前の桁からの繰り下がりなし/あり]
		//   = 使用した紙幣枚数

		SolveDP(S);

		// 結果を計算
		// ※ 配るDPの場合、結果は S.Length(＝最後のi + 1) に格納されている
		// ※ 整数問題の場合、all 0
		// の分を1個マイナスするのを忘れずに！先行0にも要注意！ ※
		// MOD系は、最後のMODを忘れないことと、MODの前処理で負数にしないこと
		int ans = min(DP[S.length()][DESC]+1, DP[S.length()][NONE]);

		DumpDP(S.length());

		cout << ans << endl;
	}

	void SolveDP(string s)
	{
		InitDP();
		DP[0][NONE] = 0;

		// ※loopはいつも昇順にしたほうが良さそう
		// ※逆順にすると、遷移も逆方向にしないといけないので
		// ※桁数を逆にする方が簡単
		REP (i, s.size()) {
			auto ni = i + 1;
			auto x = s[i] - '0';

			// ■繰り下がりなし
			if (INT_MAX != DP[i][NONE]) {
				// x を出す
				ChMin(DP[ni][NONE], DP[i][NONE] + x);
				// 繰り下がって0を出す
				ChMin(DP[ni][DESC], DP[i][NONE] + (10 - x));
			}

			// ■繰り下がりあり
			if (INT_MAX != DP[i][DESC]) {
				if (x == 9) {
					// 0を出して、更に繰り下がりするしかない
					ChMin(DP[ni][DESC], DP[i][DESC]);
				} else {
					// x + 1 を出す
					ChMin(DP[ni][NONE], DP[i][DESC] + x + 1);
					// 0 を出して、更に繰り下がらせる
					ChMin(DP[ni][DESC], DP[i][DESC] + (9 - x));
				}
			}
		}
	}

	void DumpDP(int len)
	{
		#if defined(HOME)
		REP (i, len + 1) {
			cerr << DP[i][0] << "-" << DP[i][1] << " ";
		}
		cerr << endl;
		#endif
	}
};

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 80540
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string S[n];
    rep(i,n)cin >> S[i];
    string t;
    cin >> t;

    int l = 1;
    int r = 1;

    rep(i,n){
        string s = S[i];
        rep(j,s.size())if(S[i][j] == '?')s[j] = 'a';
        if(t < s){
            continue;
        }
        r++;

        rep(j,s.size())if(S[i][j] == '?')s[j] = 'z';
        if(s < t){
            l++;
        }
    }

    srep(i,l,r+1){
        cout << i;
        if(i == r) cout << endl;
        else cout << ' ';
    }
    return 0;
}




Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll n;
    cin >> n;
    ll ans = 0;
    repeq(i,n-1){
        ans += i;
    }
    cout << ans << endl;
}

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

typedef struct{
  double x,y;
}Point;

void koch(int n, Point a,Point b){
  Point s,t,u;
  double th = M_PI*60.0/180.0;
  if(n == 0)return;
  s.x = (2.0*a.x + 1.0*b.x)/3.0;
  s.y = (2.0*a.y + 1.0*b.y)/3.0;
  t.x = (1.0*a.x + 2.0*b.x)/3.0;
  t.y = (1.0*a.y + 2.0*b.y)/3.0;
  u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
  u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;
  koch(n - 1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n - 1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n - 1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n - 1,t,b);
}

int main(){
  Point a,b;
  int n;
  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2112
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = LI()
    b = list(set([i for i in s]))
    b.sort()
    f = {i:bisect.bisect_left(b,i) for i in s}
    s = [f[i] for i in s]
    m = max(s)
    d = [0]*(m+1)
    for i in s:
        d[i] += 1
    if d[m] > 1:
        print("No")
        return
    ans = defaultdict(lambda : 0)
    ans[m] = 1
    k = 2
    for i in range(n):
        na = defaultdict(lambda : 0)
        su = 0
        for j in range(k):
            l = m-j
            if l < 0:
                break
            na[l] = ans[l]
            p = d[l]-ans[l]
            if p > 0:
                if su < p:
                    na[l] += su
                    su = 0
                else:
                    na[l] = d[l]
                    su -= p
            su += ans[l]
            ans[l] = na[l]
        k <<= 1
    for i in s:
        if d[i] != ans[i]:
            print("No")
            return
    print("Yes")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 135576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

map<int, int> mp;
vector<int> v;

int cnt = 0;

llong solve(int sum, int idx){
  if(sum == 75){
    return 1;
  }
  if(sum > 75 || idx == cnt){
    return 0;
  }
  
  llong res = 0;
  int mx = mp[v[idx]];
  for(int i = 1; i <= mx+1; ++i){
    res += solve(sum*i, idx+1);
  }
  return res;
}
int main(){

  llong n;
  cin >> n;

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

  for(int i = 2; i <= n; ++i){
    int num = i;
    for(int j = 2; j <= i; ++j){
      if(num % j == 0){
        while(num % j == 0){
          mp[j]++;
          num /= j;
        }
      } 
    }
  }
  REPI(itr, mp){
    v.push_back(itr->first);
    cnt++;
  }

  cout << solve(1,0) << endl;

  /*
  REPI(itr,mp){
    cout << itr->first << " " << itr->second << endl;
  }
  */


  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };


int main(void)
{
	while(cin >> n >> m && n)
	{
		int nin = 2 * n;
		Array order(m);
		readAll(order, m);
		Array ans(nin);
		for (int i = 1; i < nin + 1; i++)
		{
			int pos = i;
			for (int j = 0; j < m; j++)
			{
				if(order[j] == 0)
				{
					pos = pos <= n
						? pos * 2 - 1
						: (pos - n) * 2;
					continue;
				}

				pos = pos <= order[j]
					? nin - order[j] + pos
					: pos - order[j];
			}
			ans[pos - 1] = i;
		}
		for (int i = 0; i < nin; i++)
		{
			cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n) cin >> a[i] >> b[i];
  sort(ALL(a));
  sort(ALL(b));
  ll res;
  if(n%2==0){
    ll mida = a[n/2-1]+a[n/2];
    ll midb = b[n/2-1]+b[n/2];
    res = midb-mida+1;
  }else{
    ll mida=a[(n+1)/2-1];
    ll midb=b[(n+1)/2-1];
    res = midb-mida+1;
  }
  cout << res << endl;


  return 0;
}


Measured memory_bytes: 6368
#include<iostream>
#include <string>
using namespace std;
int main()
{
    int s[200];
    int swap,min,sum,N;
    min = 0;
    sum = 0;
    cin >> N;
    for (int i=0;i<N;i++)
      cin >> s[i];
    for (int i=0;i<N;i++){
      for (int j=i+1;j<N;j++)
        if (s[i] > s[j]){
            swap = s[i];
            s[i] = s[j];
            s[j] = swap;
        };
        if ((min==0)&&(s[i] % 10 != 0))
          min = s[i];
      sum += s[i];
    }
    if (sum % 10 != 0){
      cout << sum << endl;
    }
    else if (min > 0){
      cout << sum-min << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> a(n);
    int64_t sum = 0;
    for (auto&& aa : a) {
        cin >> aa;
        sum += aa;
    }

    if (sum % (n * (n + 1) / 2) > 0) {
        cout << "NO" << endl;
        return 0;
    }

    auto k = sum / (n * (n + 1) / 2);
    auto l = 0L;
    for (auto i : irange(0L, n)) {
        auto d = a[(i + 1) % n] - a[i];

        if ((k - d) % n > 0) {
            cout << "NO" << endl;
            return 0;
        }

        auto t = (k - d) / n;
        if (t < 0) {
            cout << "NO" << endl;
            return 0;
        }

        l += t;
    }

    if (l != k) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int kosu[101];
void addkosu(int k){
	int a = k;
	FOR(i,2,k+1){
		while(a%i==0){
			a/=i;
			kosu[i]++;
		}
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	FOR(i,2,n+1)addkosu(i);
	int ans = 0;
	FOR(i,2,101){
		FOR(j,2,101){
			FOR(k,j+1,101){
				if(i==k||j==k||i==j)continue;
				if(kosu[i]>=2&&kosu[j]>=4&&kosu[k]>=4)ans++;
			}
		}
	}
	FOR(i,2,101){
		if(kosu[i]>=74)ans++;
		FOR(j,2,101){
			if(i==j)continue;
			if(kosu[i]>=14&&kosu[j]>=4)ans++;
			if(kosu[i]>=2&&kosu[j]>=24)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

def prime_factors(n):
    ret = []
    apnd = ret.append
    while n >= 4:
        if n % 2:
            break
        else:
            n //= 2
            apnd(2)
    i = 3
    while n >= i * i:
        if n % i:
            i += 2
        else:
            n //= i
            apnd(i)
    apnd(n)
    return ret

def main():
    input = lambda: stdin.readline()[:-1]
    A, B = map(int, input().split())

    num = [1] + prime_factors(A) + prime_factors(B)
    num = set(num)
    ans = 0
    for i in num:
        if not A % i and not B % i:
            ans += 1
    print(ans)

main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n];
  for(int i=0;i<n;i++) cin >>a[i];
  sort(a,a+n);
  long long int ans=1000000009,k,cnt=0;
  for(int i=a[0];i<=a[n-1];i++){
    for(int j=0;j<n;j++){
          k=a[j]-i;
          cnt+=(k*k);
    }
    ans=min(ans,cnt);
    cnt=0;
  }
  cout << ans<<endl;
}


Measured memory_bytes: 256
t = input()
p = input()

for i in range(len(t)):
    for j in range(len(p) + 1):
        if j == len(p):
            print(i)
        else:
            if i + j >= len(t):
                break
            elif t[i + j] == p[j]:
                continue
            else:
                break


Measured memory_bytes: 5572
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    ll n,a,b;
    while(cin>>n>>a>>b)
    {
        if(a>b)swap(a,b);
        ll ans=((b-a)%2==0?0:min(a,n-b+1))+(b-a)/2;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int maxn=100005;
int n,t;
int a[maxn];
int ans,ansi;
int main()
{
  scanf("%d%d",&n,&t);
  int now;
  scanf("%d",&now);
  for(int i=2,p;i<=n;i++){
    scanf("%d",&p);
	if(p<now)now=p;
	else if(p-now>ansi)ans=1,ansi=p-now;
	else if(p-now==ansi)ans++;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct P { int x, y; };
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<P> R(N), B(N);
  for(auto& r: R) std::cin >> r.x >> r.y;
  for(auto& r: B) std::cin >> r.x >> r.y;
  std::vector<std::vector<int>> G(N+N);
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(R[i].x < B[j].x && R[i].y < B[j].y) {
        G[i].push_back(j+N);
        G[j+N].push_back(i);
      }
    }
  }
  std::vector<bool> used(N+N, false);
  std::vector<int> match(N+N, -1);
  auto dfs = [&](auto&& f, int v)->bool {
    used[v] = true;
    for(int u: G[v]) {
      int w = match[u];
      if(w < 0 || !used[w] && f(f, w)) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  };
  int ans = 0;
  for(int v = 0; v < N+N; ++v) if(match[v] < 0) {
    std::fill(used.begin(), used.end(), false);
    if(dfs(dfs, v)) ++ans;
  }
  fin(ans);
  return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int n, a[N], b[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)scanf("%d", &b[n - i + 1]);
    int st = 0, ed = -1, l = 1, r = n;
    for (int i = 1; i <= n; i++) {
        if (a[i] == b[i]) {
            if (st == 0)st = i;
            ed = i;
        }
    }

    for (int i = st; i <= ed; i++) {
        if (a[l] != b[i] && b[l] != b[i])swap(b[l], b[i]), l++;
        else if (a[r] != b[i] && b[r] != b[i])swap(b[r], b[i]), r--;
        else {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    for (int i = 1; i <= n; i++)printf("%d%c", b[i], " \n"[i == n]);
    return 0;
}

Measured memory_bytes: 5356
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>

using namespace std;

typedef long long ll;

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

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

const int mod = 1000000007;
const int INF = 1001001001;

char maze[55][55];
bool isReached[55][55];
int dist[55][55];
queue<pair<int, int>> q;

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

int main() {
    int r, c;
    cin >> r >> c;
    int sx = 0;
    int sy = 0;
    int gy = r-1;
    int gx = c-1;
    rep(i, r) cin >> maze[i];
    rep(i, 55) rep(j, 55) dist[i][j] = INF;
    dist[sy][sx] = 0;
    q.emplace(sy, sx);
    while(!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || ny >= r || nx < 0 || nx >= c) continue;
            if(maze[ny][nx] == '#') continue;
            if(dist[ny][nx] != INF) continue;
            dist[ny][nx] = min(dist[ny][nx], dist[y][x]+1);
            q.emplace(ny, nx);
        }
    }
    if (dist[gy][gx] != INF) {
        int step = dist[gy][gx];
        int blackCount = 0;
        rep(i, r) rep(j, c) if (maze[i][j] == '#') blackCount += 1;
        int ans = r * c - step - blackCount - 1;
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	long long int  n, m, r, R[10], a, b, c, dis[210][210], inf = 1e9;
	for (int i = 0; i < 210; i++) {//距離の初期化
		for (int j = 0; j < 210; j++) {
			dis[i][j] = inf;
		}
		dis[i][i] = 0;
	}
	cin >> n >> m >> r;
	for (int i = 0; i < r; i++)cin >> R[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		dis[a][b] = min(dis[a][b], c);
		dis[b][a] = dis[a][b];
		for (int j = 1; j <= n; j++) {//ワーシャルフロイド
			for (int k = 1; k <= n; k++) {
				dis[j][k] = min(dis[j][k], min(dis[j][a] + dis[b][k], dis[j][b] + dis[a][k]) + dis[a][b]);
			}
		}
	}
	sort(R, R + r);
	ll yan, ans = 1e9;
	do {//ねくすとっ☆ぱーみゅてーしょん！！
		yan = 0;
		for (int i = 0; i < r - 1; i++)yan += dis[R[i]][R[i + 1]];
		ans = min(yan, ans);
	} while (next_permutation(R, R + r));
	cout << ans << endl;
	return 0;
}


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

int N;
int main() {
  cin >> N;
  int count=0;
  for (int c=1;c<N;c++) {
    double Nc = sqrt(N-c);
    for(int a = 1;a < Nc;a++) {
      if ((N-c)%a==0) {
        count+=2;
      }
    }
    int a = round(Nc);
    if ( abs(Nc - a) < 0.0000001) {
      count+=1;
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 3176
from operator import itemgetter

N = int(input())
H=[]
s=0
ans = 0

for i in range(N):
        H.append(list(map(int,input().split())))


H.sort(key=itemgetter(1))

for i in range(N):
    s += H[i][0]
    if H[i][1] < s:
        ans += 1
        break

if ans == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53720
import math
a,b,x = map(int,input().split())
if 2*x>=a*a*b:
    l = 2*(b-x/a**2)
    print(math.degrees(math.atan(l/a)))
else:
    l = 2*x/a**2
    print(math.degrees(math.atan(a*b**2/2/x)))

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

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

  if(n==3){cout<<"2 5 63"<<endl; return 0;}
  if(n==4){cout<<"2 5 20 63"<<endl; return 0;}
  if(n==5){cout<<"2 5 20 63 12600"<<endl; return 0;}

  set<int>ans;
  int cnt=0,now=0;
  for(int i=1; i<=30000; ++i){
    now=i;
    if(i%6==2)ans.insert(i),cnt+=i;
    if(ans.size()==n)break;
    if(i%6==3)ans.insert(i),cnt+=i;
    if(ans.size()==n)break;
    if(i%6==4)ans.insert(i),cnt+=i;
    if(ans.size()==n)break;
    if(i%6==0)ans.insert(i),cnt+=i;
    if(ans.size()==n)break;
  }
  now++;
  if(cnt%6==2){
    ans.erase(8);
    while(1){
      if(now%6==0){
        ans.insert(now);
        break;
      }
      now++;
    }
  }
  else if(cnt%6==3){
    ans.erase(9);
    while(1){
      if(now%6==0){
        ans.insert(now);
        break;
      }
      now++;
    }
  }
  else if(cnt%6==5){
    ans.erase(9);
    while(1){
      if(now%6==4){
        ans.insert(now);
        break;
      }
      now++;
    }
  }
  for(auto&p:ans)cout<<p<<" ";
}

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

int main() {
  string input;
  cin >> input;
  int N;
  N = input.length();

  if(input[0]==input[1] || input[1]==input[2] || input[2]==input[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	if n == 1 {
		fmt.Println(0)
		return
	}

	leftBlacks := make([]int, n+1)
	rightWhites := make([]int, n+1)
	for i := 0; i < n; i++ {
		if s[i] == '.' {
			rightWhites[0]++
		}
	}

	for i := 0; i < n; i++ {
		if s[i] == '.' {
			rightWhites[i+1] = rightWhites[i] - 1
			leftBlacks[i+1] = leftBlacks[i]
		} else {
			rightWhites[i+1] = rightWhites[i]
			leftBlacks[i+1] = leftBlacks[i] + 1
		}
	}

	min := rightWhites[0] + leftBlacks[0]
	for i := 1; i < n+1; i++ {
		if rightWhites[i]+leftBlacks[i] < min {
			min = rightWhites[i] + leftBlacks[i]
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 5248
h, w = map(int, input().split())
a = [ list(input()) for _ in range(h) ]

rows = [ False for _ in range(h) ]
cols = [ False for _ in range(w) ]

# 必要な行idを列挙
for y in range(h):
    is_ok = False
    for x in range(w):
        if a[y][x] != ".":
            is_ok = True
    if is_ok:
        rows[y] = True

# 必要な列idを列挙
for x in range(w):
    is_ok = False
    for y in range(h):
        if a[y][x] != ".":
            is_ok = True
    if is_ok:
        cols[x] = True

for y in range(h):
    if not rows[y]:
        continue
    for x in range(w):
        if rows[y] and cols[x]:
            print(a[y][x], end = "")
    print()


Measured memory_bytes: 4596
let () =
  Scanf.scanf "%d %d %d" @@ fun h w n ->
  let a =
    Array.init n (fun i ->
      Scanf.scanf " %d" (fun x -> Array.make x (i+1)))
    |> Array.to_list |> Array.concat
  in
  for i = 0 to h*w-1 do
    a.(i/w*w + if i/w mod 2 = 0 then i mod w else w-1 - i mod w)
    |> Printf.printf "%d ";
    if i mod w = w-1 then print_newline ();
  done;

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll bisa,n,i,a[202020],has;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	bisa=1;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	if(a[1]!=0)
		bisa=0;
	for(i=2;i<=n;i++)
		if(a[i]-a[i-1]>1)
			bisa=0;
	has=-1;
	if(bisa)
	{
		has=0;
		for(i=2;i<=n;i++)
		{
			if(a[i]==a[i-1]+1)
				has++;
			else
				has+=a[i];
		}
	}
	cout<<has<<"\n";
		
}

Measured memory_bytes: 1792