akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> p(n + 1);
    vector<ll> same(n + 1, 0);
    ll cnt = 0;
    for (ll i = 1; i < n + 1; i++) {
        cin >> p[i];
        if (i == p[i]){
            same[i] = 1;
        }
    }
    for (ll i = 1; i < n;i++){
        if (same[i]){
            swap(p[i], p[i + 1]);
            cnt++;
            same[i] = 0;
            if(same[i + 1]) same[i + 1] = 0;
        }
    }
    if (same[n]){
        swap(p[n - 1], p[n]);
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4848
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

void f(int a){
    while(a){
        cout<<a%2;
        a=a>>1;
    }
}


signed main(void) {
    int i,j;
    int n, k;
    cin >> n >> k;
    vi a(n+1,0);
    rep(i,n)cin >> a[i+1];
    rep(i,n)a[i+1] += a[i];
    vi v;
    rep(i,n+1)rep(j,i)v.push_back(a[i]-a[j]);
    int ans = 0;
    for(int i = 40; i >= 0; i--){
        vi t;
        rep(j,v.size())if(v[j]&(1LL<<i))t.push_back(v[j]);
        if(t.size()>=k)v = t, ans |= (1LL<<i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  char s[1201];
  int count[27] = {0};
  while(scanf("%[^\n]\n",s)!=EOF){
    for(int i=0; s[i]!='\0';i++) {
      if(isalpha(s[i])) {
        count[tolower(s[i])-'a']++;
      }
    }
  }
  for(char c = 'a';c<='z';c++) {
    printf("%c : %d\n",c,count[c-'a']);
  }
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    bool skip = false;
    rep(i,50){
        rep(j,N){
            if (A[j] % 2 != 0){
                skip = true;
                break;
            }
            A[j] /= 2;
        }
        if(skip){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define piii pair<int,pair<int,int>>
#define endl "\n"
 
using namespace std;

const int mlt=(1<<18)+69;
const ll inf=1e18;
//TTBDC

int main()
{
  fatafat
  int h,w,m,x,y;
  cin>>h>>w>>m;
  map<int,int> mc,mr;
  map<pair<int,int>,int> mp;
  set<int> rs,cs;
  int mxr = 0,mxc = 0;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    mc[y]++;
    mr[x]++;
    mp[{x,y}]++;
    if(mc[y]>mxc){
      mxc = mc[y];
      cs.clear();
      cs.insert(y);
    }
    else if(mc[y]==mxc)cs.insert(y);
    if(mr[x]>mxr){
      mxr = mr[x];
      rs.clear();
      rs.insert(x);
    }
    else if(mr[x]==mxr)rs.insert(x);
  }
  for(int i1:cs){
    for(int i2:rs){
      if(mp[{i2,i1}]==0){
        cout<<mc[i1]+mr[i2];
        return 0;
      }
    }
  }
  cout<<mxr+mxc-1;
  return 0;
}

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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


static const long long MOD = 1e9+7;;
using mint = Fp<MOD>;

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    mint ans=modpow(mint(2),n)-1;
    mint A=1,B=1;
    for(long long i=0;i<a;++i){
        A*=n-i;
        A/=i+1;
    }
    for(long long i=0;i<b;++i){
        B*=n-i;
        B/=i+1;
    }
    ans-=A+B;

    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順
//priority_queue<int> que; // 降順

using namespace std;

const int mod=1e9+7;

signed main()
{
    SPEED;
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
Ts = gets.split.map(&:to_i)
M = gets.to_i
Ps = Array.new(M)
Xs = Array.new(M)
M.times do |i|
  Ps[i], Xs[i] = gets.split.map(&:to_i)
end

total = Ts.reduce(&:+)

M.times do |i|
  puts total - Ts[Ps[i] - 1] + Xs[i]
end


Measured memory_bytes: 1788
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z =   998244353 ;
ll inf = 100000000000000000 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;

void solve()
{
	ll n , m ;
	cin >> n >> m ;
	string str[n] ;
	fo(i , n)
	{
		cin >> str[i] ;
	}
	ll ans[n][m] ;
	fo(i , n)
	{
		fo(j , m)
		{
			ans[i][j] = 0 ;
		}
	}
	if(str[0][0] == '#')
		ans[0][0] = 1 ;
	
	for(ll j = 1 ; j < m ; j++)
	{
		if((str[0][j-1] == '.') && (str[0][j] == '#'))
		{
			ans[0][j] = (ans[0][j-1] + 1) ;
		}
		else
			ans[0][j] = ans[0][j-1] ;
	}
	
	for(ll i = 1 ; i < n ; i++)
	{
		if((str[i-1][0] == '.') && (str[i][0] == '#'))
		{
			ans[i][0] = (ans[i-1][0] + 1) ;
		}
		else
		{
			ans[i][0] = ans[i-1][0] ;
		}
	}
	
	for(ll i = 1 ; i < n ; i++)
	{
		for(ll j = 1 ; j < m ; j++)
		{
			ll ans_1 = ans[i][j-1] , ans_2 = ans[i-1][j] ;
			
			if((str[i][j-1] == '.') && (str[i][j] == '#'))
			{
				ans_1++ ;
			}
			
			if((str[i-1][j] == '.') && (str[i][j] == '#'))
			{
				ans_2++ ;
			}
			ans[i][j] = min(ans_1 , ans_2) ;
		}
	}
	
	cout << ans[n-1][m-1] << endl ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll t ;
	//cin >> t ;
	t = 1 ;
	while(t--)
	{
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 384
N,M,X,Y = (int(x) for x in input().split())
x_arr = sorted([int(x) for x in input().split()]+[X])
y_arr = sorted([int(x) for x in input().split()]+[Y])

if(x_arr[-1] < y_arr[0]):
    print("No War")
else:
    print("War")



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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset((a), 0, sizeof(a))
#define str(a) strlen(a)
#define pii pair<int, int>
#define y second
#define x first
typedef long long LL;

const int maxn = 110;
const int INF = 0x3f3f3f3f;

int n, m, a[maxn][maxn], f[maxn][maxn];
char s[maxn];
queue<pii> Q;

int main()
{
	scanf("%d%d", &n, &m);
	REP(i, 1, n)
	{
		scanf("%s", s + 1);
		REP(j, 1, m) if ( s[j] == '.' ) a[i][j] = 1; else a[i][j] = 2;
	}
	REP(i, 1, n) REP(j, 1, m) f[i][j] = INF;
	Q.push(pii(1, 1)); f[1][1] = a[1][1] - 1;
	while ( !Q.empty() )
	{
		pii u = Q.front(); Q.pop();
		pii v = pii(u.first + 1, u.second);
		if ( a[u.first][u.second] == 1 && a[v.first][v.second] == 2 )
		{
			if ( f[v.x][v.y] > f[u.x][u.y] + 1 )
			{
				f[v.x][v.y] = f[u.x][u.y] + 1;
				Q.push(v);
			}
		}
		else if ( f[v.x][v.y] > f[u.x][u.y] ) { f[v.x][v.y] = f[u.x][u.y]; Q.push(v); }

		v = pii(u.first, u.second + 1);
		if ( a[u.first][u.second] == 1 && a[v.first][v.second] == 2 )
		{
			if ( f[v.x][v.y] > f[u.x][u.y] + 1 )
			{
				f[v.x][v.y] = f[u.x][u.y] + 1;
				Q.push(v);
			}
		}
		else if ( f[v.x][v.y] > f[u.x][u.y] ) { f[v.x][v.y] = f[u.x][u.y]; Q.push(v); }
	}
	printf("%d\n", f[n][m]);
	return 0;
}


Measured memory_bytes: 384
use std::cmp::{max, min};
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        $iter.take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let s = s.split_whitespace().next().unwrap();
    let n = s.len();
    let t = s
        .chars()
        .enumerate()
        .fold((n, '0'), |(res, prev), (i, cur)| {
            if prev != cur {
                (min(res, max(i, n - i)), cur)
            } else {
                (res, cur)
            }
        });
    println!("{}", t.0);
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        double a = (num);
        double b = a/2;
        double x = Math.ceil(b);
        double y = Math.floor(b);
        double z = x * y;
        int c = (int)z;
        System.out.println(c);
        scan.close();
    }
}

Measured memory_bytes: 21588
n, m = gets.split().map(&:to_i)
h = gets.split().map(&:to_i)
ab = []
graph = Array.new(n).map{Array.new()}

m.times do 
  ab << gets.split().map(&:to_i)
end

ab.each do |a, b|
  graph[a-1] << b
  graph[b-1] << a
end

sum = 0

graph.each_with_index do |tenbou, index|
  myH = h[index]
  flag = true
  tenbou.each do |i|
    next if myH > h[i-1]
    flag = false
  end
  sum += 1 if flag
end

puts sum

Measured memory_bytes: 30720
////**********CODED BY :- DURGESH KUMAR***************////
    #include<bits/stdc++.h>
    #define ff double
    #define endl "\n"
    #define ll long long
    #define pb push_back
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define test ll t;cin>>t;while(t--)
    #define REP(i,n) for(int i=0;i<(n);i++)
    #define FOR(i,a,b) for(int i=(a);i<=(b);i++)
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
    #define M 1000000007
    using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=1;i<=n-1;i++)
    cin>>arr[i];
    arr[0]=INT_MAX;
    arr[n]=INT_MAX;
    ll brr[n];
    for(int i=1;i<=n;i++)
    {
    brr[i]=min(arr[i-1],arr[i]);
    }
    ll sum=0;
    for(int i=1;i<=n;i++)
    sum=sum+brr[i];

    cout<<sum<<endl;


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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;

  int a,b,c,d;
  a = s[0]-'0';
  b = s[1]-'0';
  c = s[2]-'0';
  d = s[3]-'0';

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        int ans = a;
        if(i==0) ans+=b;
        else if(i==1) ans-=b;
        if(j==0) ans+=c;
        else if(j==1) ans-=c;
        if(k==0) ans+=d;
        else if(k==1) ans-=d;

        if(ans == 7){
          cout << s[0];
          if(i==0) cout << '+';
          else cout << '-';
          cout << s[1];
          if(j==0) cout << '+';
          else cout << '-';
          cout << s[2];
          if(k==0) cout << '+';
          else cout << '-';
          cout << s[3];
          cout << '=' << 7 << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,m,a=1,b=1,ans;
    lli i;
    vector<lli> v;
    map<lli,lli> map;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<"0"<<endl;
        exit(0);
    }
    else{
        rep(i,1,n+1){
            a*=i;
            a%=N;
        }
        rep(i,1,m+1){
            b*=i;
            b%=N;
        }
        ans=(a*b)%N;
        if(n==m){
            ans=(ans*2)%N;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  // 2 <= N <= 100
  // -100 <= L <= 100
  // 入力はすべて整数
  int N, L;
  cin >> N >> L;
  // 5 2の場合、2 3 4 5 6 (総和は20)
  // (2 + 6) * 5 / 2
  // (L + L + N - 1) * N / 2
  // (2 * L + N - 1) * N / 2
  // 全部プラス⇒絶対値が最小を取り除くが正解
  // 欲しいのは総和⇒3 4 5 6の和18
  int total_sum = (2 * L + N - 1) * N / 2;
  int abs_min = 100;
  if (L >= 0) {
    cout << total_sum - L << endl;
    return 0;
  }
  if (N + L - 1 < 0) {
    cout << total_sum - (N + L - 1) << endl;
    return 0;
  }
  cout << total_sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int n, t, l, b;
    while(1){
        cin >> n >> t >> l >> b;
        if(n + t + l + b == 0) break;
        int a;
        vector<int> f(n + 1, 0);
        rep(i, 0, l){
            cin >> a;
            f[a] = 1;
        }  
        rep(i, 0, b){
            cin >> a;
            f[a] = -1;
        }
        double dp[110][110];
        rep(i, 0, 110) rep(j, 0, 110) dp[i][j] = 0.0;
        dp[0][0] = 1.0;
        rep(i, 0, t){
            rep(j, 0, n){
                double now = dp[i][j];
                if(f[j] == 1) now = ((i - 1) >= 0 ? dp[i - 1][j] : 0); 
                if(now < 1e-8) continue;
                rep(k, 1, 7){
                    int next = j + k;
                    if(next > n) next = n - (next - n);
                    if(f[next] == -1) next = 0;
                    dp[i + 1][next] += now / 6.0;
                }
            }
        }
        // rep(j, 0, t + 1){
        //         cout << j << "  :";            
        //     rep(i, 0, n + 1){
        //         cout << dp[j][i] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
        double ans = 0.0;
        rep(i, 0, t + 1) ans += dp[i][n];
        // rep(i, 0, t) ans /= 6.0;
        printf("%.12lf\n", ans);
    }
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

ll GCD(ll a, ll b) {
    return (b > 0) ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b) {
    return a / GCD(a, b) * b;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = GCD(a, b);
    set<ll> d;
    for(int i = 1; i <= sqrt(g); i++){
        if(g % i == 0){
            d.insert(i);
            d.insert(g / i);
        }
    }
    vector<ll> div;
    for(ll x : d)div.push_back(x);
    int ans = 0;
    rep(i, div.size()){
        bool prime = true;
        rep(j, i){
            if(div[j] == 1)continue;
            if(div[i] % div[j] == 0)prime = false;
        }
        if(prime)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

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

int main() {
    long long N, i;
    cin >> N;
    vector<int> A(N);
    unordered_map<int, long long> umc;
    unordered_map<int, long long> ums;
    for(i = 0; i < N; i++) {
        cin >> A[i];
        umc[A[i]]++;
    }
    long long s = 0;
    for(i = 0; i < N; i++) {
        ums[A[i]] = (umc[A[i]] ? (umc[A[i]] * (umc[A[i]] - 1)) / 2 : 0); 
    }
    for(auto &a : ums) s += a.second;
    for(i = 0; i < N; i++) {
        long long ss = s - ums[A[i]];
        long long a = umc[A[i]];
        a--;
        if(a) ss += (a * (a - 1)) / 2;
        cout << ss << endl;
    }
	return 0;
}

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

int main() {
    int x,y;
    cin>>x>>y;
    if((x==1||x==3||x==5||x==7||x==8||x==10)&&(y==3||y==5||y==7||y==8||y==10||y==12)) cout<<"Yes"<<endl;
    else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
# A = [['.']+list(input())+['.'] for i in range(H)]
A = [list(input()) for i in range(H)]
flag = True
endi = 0
for i in range(H):
    if A[i].index('#') == endi:
        for j in range(W):
            if A[i][j] == '#':
                endi = j
        continue
    flag = False
    break


if flag:
    print('Possible')
else:
    print('Impossible')



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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

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

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x; 
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, k;
    cin >> n >> k;
    vll a(n);
    cin >> a;

    const ll mod = 1000000007;

    map<ll, ll> mp; 
    vll b(n, 0);
    REP(i, n) {
        for (auto& p : mp) {
            if (p.first > a[i]) b[i] += p.second;
        }
        mp[a[i]]++;
    }

    map<ll, ll> mpsum;
    for (auto& p: mp) {
        ll sum = 0;
        for (auto& p2: mp) if (p.first < p2.first) sum += p2.second;
        mpsum[p.first] = sum % mod;
    }

    ll ans = 0;
    ll kk = k * (k - 1LL) / 2LL % mod;
    REP(i, n) {
        // cout << a[i] << " " << (mpsum[a[i]] * kk + b[i]) %
        ans = (ans + mpsum[a[i]] * kk + k * b[i]) % mod;
    }

    // REP(i, n) cout << b[i] << " "; cout << endl;
    // for (auto& p : mp) cout << p.first << " " << p.second << " " << endl;
    // cout << " --" << endl;
    // for (auto& p : mpsum) cout << p.first << " " << p.second << " " << endl;

    cout << ans << endl;

    return 0;
}
// 10 100
// 10 9 8 7 5 6 3 4 2 1


Measured memory_bytes: 512
#include<stdio.h>
using namespace std;
int a = 0,b = 0;
int d = 0,r = 0;
double f = 0.0f;
int main(){
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%d %d %f\n",d,r,f);

}


Measured memory_bytes: 2724
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    double A = sc.nextInt();
    double B = sc.nextInt();

    double Hour = sc.nextInt();
    double Minute = sc.nextInt();

    double x1 = A * Math.cos(2 * Math.PI * (Hour + Minute / 60) / 12);
    double y1 = A * Math.sin(2 * Math.PI * (Hour + Minute / 60) / 12);
    double x2 = B * Math.cos(2 * Math.PI * Minute / 60);
    double y2 = B * Math.sin(2 * Math.PI * Minute / 60);
    
    System.out.println(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

  }
}

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

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

    rep(i, S.size()) {
        cout << 'x';
    }
    cout << endl;

    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    long long big{0};
    long long height{0};
    for(int i=0;i<n;i++){
        if(i==0){
            big=v[i];
        }
        if(big<v[i]){
            big=v[i];
        }
        height+=big-v[i];
    }
    cout<<height<<"\n";
    return 0;
}


Measured memory_bytes: 3976
def count_neighbor_bomb(H,W,ci,cj, grid):
    count = 0
    for i in range(-1,2):
        if (ci + i)< 0 or (ci + i) > H-1:
            continue
        for j in range(-1,2):
            if (cj + j)< 0 or (cj + j) > W-1:
                continue
            if grid[ci + i][cj + j] == "#":
                count += 1
    return count

H,W = map(int, input().split())
grid = [list(input()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            print("#", end="")
            continue
        bomb_num = count_neighbor_bomb(H,W,i,j,grid)
        print(grid[i][j].replace(".", str(bomb_num)), end="")
    print("")


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  int b[n];
  rep(i, n - 1) cin >> b[i];
  int ans = b[0] + b[n - 2];
  rep(i, n - 1) {
    if(i != 0 && i != b[n - 2]) {
      ans += min(b[i], b[i - 1]);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	long long X, K;
	cin >> X >> K;
	for(int i = K - X + 1; i <= X + K - 1; i++){
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		int x=b+c;
		if(a<x)
			System.out.println(x-a);
		else
			System.out.println("0");

	}

}


Measured memory_bytes: 22740
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ?決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ?最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ?
 */

/*
 DP
 ?DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w,n;
	cin>>h>>w>>n;
	vector<vector<char>> m(h,vector<char>(w));
	REP(i,h) REP(j,w) cin>>m[i][j];
	ll ret=0;
	REP(i,n) {
		vector<vector<ll>> dir(h,vector<ll>(w,INF));
		queue<P> q;
		REP(j,h) REP(k,w) {
			if(i==0) {
				if(m[j][k]=='S') {
					dir[j][k]=0;
					q.push(P(j,k));
				}
			} else {
				if(m[j][k]=='0'+i) {
					dir[j][k]=0;
					q.push(P(j,k));
				}
			}
		}
		while(!q.empty()) {
			P p=q.front();
			q.pop();
			ll dx[]={1,0,-1,0};
			ll dy[]={0,1,0,-1};
			REP(j,4) {
				ll nx=p.first+dx[j];
				ll ny=p.second+dy[j];
				if(nx>=0&&nx<h&&ny>=0&&ny<w&&m[nx][ny]!='X'&&dir[nx][ny]==INF) {
					q.push(P(nx,ny));
					dir[nx][ny]=dir[p.first][p.second]+1;
				}
			}
		}
		REP(j,h) REP(k,w) {
			if(m[j][k]=='1'+i) ret+=dir[j][k];
		}
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 11772
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w = readline() |> split |> parseMap
	d = zeros(Int,26)
	for i in 1:h
		a = readline() |> chomp
		for j in 1:w
			d[Int(a[j])-96] += 1
		end
	end
	x = (h>>1)*(w>>1)
	y = h%2*(w>>1)+w%2*(h>>1)
	z = h*w%2
	ct = 0
	for i in 1:26
		if d[i]%2==1
			ct += 1
		end
	end
	if ct!=z
		println("No")
	else
		ct = 0
		for i in 1:26
			if d[i]%4==2
				ct += 1
			end
		end
		if ct>y
			println("No")
		else
			println("Yes")
		end
	end

end

main()

Measured memory_bytes: 166172
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct TreeNode {
	int val;
	TreeNode *left, *right;
	TreeNode(int x) :val(x), left(NULL), right(NULL) {}
};

int main()
{
	//freopen("data_in.txt", "rb", stdin);
	int n = 0;
	cin >> n;
	vector<int> A(n), B(n);
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < n; ++i) cin >> B[i];
	int res = 0;
	long long sum = 0;
	vector<int> rt;
	for (int i = 0; i < n; ++i) {
		if (A[i] < B[i]) {
			res++;
			sum += B[i] - A[i];
		}
		else rt.push_back(A[i] - B[i]);
	}
	sort(rt.begin(), rt.end());
	int m = rt.size();
	for (int i = m - 1; i >= 0; --i) {
		if (sum <= 0) break;
		sum -= rt[i];
		res++;
	}
	if (sum > 0) cout << -1;
	else cout << res;
	return 0;
}



Measured memory_bytes: 1660
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    class Pair {
        public int no { get; set; }
        public int cnt { get; set; }
    }

    public void Solve() {
        var N = sc.nextInt();
        var A = new Pair[N];
        for (int i = 0; i < N; i++) {
            var pair = new Pair();
            pair.no = i + 1;
            pair.cnt = sc.nextInt();
            A[i] = pair;
        }
        var ans = A.OrderBy(a => a.cnt).Select(a => a.no.ToString()).ToArray();
        WriteLine(String.Join(" ", ans));
    }
    
}

class Scanner {
    string[] s;
    int i;

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

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

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 35928
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
int a[N], b[N];
int n, k, sum = 0;


int ok(int x) {
    
    
    
    for(int i=0;i<n;i++) {
        b[i] = a[i] % x;
    }
    sort(b, b + n);
    
    int l = 0, r = n - 1;
	int rem = 0;
	int reqd = 0;
	
	while(l <= r)
	{
		if(rem <= 0)
		{
			rem += b[l];
			reqd += b[l];
			l++;
		}
		else
		{
			rem -= (x - b[r]);
			reqd += (x - b[r]);
			r--;
		}
	}
	if(reqd > 2 * k)
		return 0;
	if(rem != 0) {
	    printf("\n");
	    return 0;
	}
		
	return 1;
}


int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    
    int flag = 0;
    // cout<<right<<endl;
    for(int i=sum;i>=2;i--) {
        // cout<<i<<endl;
        if(sum % i)continue;
        if(ok(i)) {
            cout<<i<<endl;
            flag = 1;
            break;
        }
    }
    
    
    if(flag == 0)cout<<1<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> num(N);
    rep(i, N)cin >> num[i];
    ll maxest = 0;
    bool ans = true;
    rep(i, N) {
        if (num[i] <= maxest - 2)ans = false;
        else if (num[i] > maxest)maxest = num[i];
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 1024
/* ファイル名：ITP1_3_C.c	*/
/* 内容：２つの整数 x, y を読み込み、それらを値が小さい順に出力する。	*/
/* 		x, y は複数回入力され、x と y がともに"0"のときに処理を終了する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:２つの整数 x, y を読み込み、それらを値が小さい順に出力する。	*/
int main( void )
{
	/* 内部変数定義	*/
	int x;	/* 入力される変数x	*/
	int y;	/* 入力される変数y	*/
	int s;	/* 入れ替え用変数	*/
	
	while(1){
		scanf("%d %d",&x,&y);	/* xとyを取得	*/
		
		if((x == 0) 
		&& (y == 0)){
			break;	/* x と y がともに"0"のときに処理を終了	*/
		}
		else{
			/* 処理なし	*/
		}
		
		if(x > y){
			s = x;/* x が y より大きかった場合、2つの数を入れ替える*/
			x = y;
			y = s;
		}
		else{
			/* 処理なし	*/
		}
		
		printf("%d %d\n",x,y);	/* x と y を出力	*/
	}
	return 0;
}



Measured memory_bytes: 2036
def factorization(n):
   y=n
   list=[]
   print(n, end=":")
   for i in range(2,int(n**(1/2)//1)+1):
      if y%i==0:
         c=0
         while y%i==0:
            c += 1
            y=y//i
         list.append([i, c])
         for j in range(c):
            print("", i, end="")
   if y!=1:
      print("", y, end="")
   print()
n=int(input())
factorization(n)


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

int main() {
  ll N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  ll sl = 1;
  ll i = 2;
  ll n=N, m=M;
  while (true) {
    if (n==1 && m==1) break;
    while (n%i==0 || m%i==0) {
      sl *= i;
      if (n%i==0) n /= i;
      if (m%i==0) m /= i;
    }
    i++;
  }
  bool is_cat = true;
  for (ll i=0; i<sl; i+=(sl/N*sl/M)) {
    if (S.at(i*N/sl) != T.at(i*M/sl)){ is_cat=false; break; }
  }
  if (is_cat) cout << sl << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = ''
for x in range(N, 1000):
    temp = str(x)
    if len(set(temp)) == 1:
        answer = x
        break

print(answer)


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===


int dp[5010][5010];


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

	memset(dp, 0, sizeof(dp));
	for (int i = N - 1; i >= 0; --i) {
		for (int j = N - 1; j >= 0; --j) {
			if (S[i] == S[j]) {
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			ans = max(ans, min(dp[i][j], abs(i - j)));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 98432
N,M = map(int,input().split())
s = [0]*M
c = [0]*M
for i in range(M):
    s[i],c[i] = map(int,input().split())

left = 10**(N-1)
right = 10**N
if N == 1:
    left = 0

for i in range(left,right):
    check = str(i)
    for j in range(M):
        if check[s[j]-1] != str(c[j]):
            break
    else:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
def main():
    N, W = map(int, input().split())
    MV = 10**5
    dp = [float('INF')] * (MV + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(MV, -1, -1):
            if v > i:
                tmp = w
            else:
                tmp = dp[i - v] + w
            dp[i] = min(dp[i], tmp)
    ans = 0
    for v, w in enumerate(dp):
        if W >= w:
            ans = max(ans, v)
        else:
            break
    print(ans)


main()


Measured memory_bytes: 89292
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> w(N), s(N), v(N);
    rep(i, N) cin >> w[i] >> s[i] >> v[i];

    vector<int> sorted(N);
    iota(all(sorted), 0);
    sort(all(sorted), [&](int l, int r) { return w[l] + s[l] < w[r] + s[r]; });

    vv<ll> dp = vvec(N + 1, 2e4 + 1, 0LL);
    rep(i, N) rep(j, 2e4 + 1) {
        if (s[sorted[i]] >= j) dp[i + 1][j + w[sorted[i]]] = dp[i][j] + v[sorted[i]];
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }

    ll ans = 0;
    rep(j, 2e4 + 1) ans = max(ans, dp[N][j]);
    write(ans);
}

Measured memory_bytes: 160640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;

int N, M;
unordered_map<string, int> s_map, t_map;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    s_map[tmp]++;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    string tmp;
    cin >> tmp;
    t_map[tmp]++;
  }

  int ans = 0;
  for (auto &p : s_map) {
    ans = max(ans, p.second - t_map[p.first]);
  }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long m = Long.parseLong(sc.next());
		long o = 2 * n + 2 * (m - 2);
		System.out.println(Math.abs(n * m - o));
	}
}

Measured memory_bytes: 21588
#include<stdio.h>
int min(int x,int y){
  if(x<y){
    return x;
  }else{
    return y;
  }
}
int max(int x,int y){
  if(x<y){
    return y;
  }else{
    return x;
  }
}

int main(){
  int a = 0;
  int b = 0;
  int c = 0;
  int x = 0;
  int y = 0;
  long sum = 0;
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
  //printf("%d %d %d %d %d ",a,b,c,x,y);
  if(a+b<2*c){
    sum = a*x+b*y;
  }else{
    if(a > 2*c && b > 2*c){
      sum = 2*c*max(x,y);
    }else if(a > 2*c){
      if(x<y){
        sum = (2*c)*x+b*(y-x);
      }else{
        sum = 2*c*x;
      }
    }else if(b>2*c){
      if(x>y){
        sum = (2*c)*y + a*(x-y);
      }else{
        sum = 2*c*y;
      }
    }else{
      if(x>y){
        sum = (2*c)*y + a*(x-y);
      }else{
        sum = (2*c)*x + b*(y-x);
      }
    }
  }
  printf("%ld",sum);
  return 0;
}
    

Measured memory_bytes: 128
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

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

vector<string> room;
vector<vector<int> > dir;

bool dfs(int y0, int x0, int y1, int x1){
	if(y0 == y1 && x0 == x1)
		return true;

	for(int i=0; i<4; ++i){
		dir[y0][x0] = i;
		int y = y0 + dy[i];
		int x = x0 + dx[i];
		if(room[y][x] == '#' || (dir[y][x] != -1 && dir[y][x] == (i+2)%4))
			continue;
		if(dfs(y, x, y1, x1))
			return true;
	}

	dir[y0][x0] = -1;
	return false;
}

int main()
{
	int h, w, m;
	cin >> h >> w >> m;

	room.assign(h+2, string(w+2, '#'));
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			cin >> room[i][j];
		}
	}

	vector<vector<int> > per(h+2, vector<int>(w+2));
	vector<vector<int> > on = per, off = per;
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			cin >> per[i][j];
		}
	}
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			cin >> on[i][j];
		}
	}
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			cin >> off[i][j];
		}
	}
	vector<int> taskY(m), taskX(m);
	for(int i=0; i<m; ++i){
		cin >> taskY[i] >> taskX[i];
		++ taskY[i];
		++ taskX[i];
	}

	int t = 0;
	dir.assign(h+2, vector<int>(w+2, -1));
	vector<vector<int> > prev(h+2, vector<int>(w+2, -1));
	int y = taskY[0];
	int x = taskX[0];
	prev[y][x] = 0;
	int ret = on[y][x];

	for(int i=1; i<m; ++i){
		dfs(y, x, taskY[i], taskX[i]);
		while(y != taskY[i] || x != taskX[i]){
			int d = dir[y][x];
			dir[y][x] = -1;
			y += dy[d];
			x += dx[d];
			++ t;

			if(prev[y][x] == -1){
				ret += on[y][x];
			}else{
				ret += min(off[y][x] + on[y][x], per[y][x] * (t - prev[y][x]));
			}
			prev[y][x] = t;
		}
	}

	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			if(prev[i][j] != -1){
				ret += off[i][j];
			}
		}
	}

	cout << ret << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

ll dp[100005];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		int w;
		ll v;
		cin >> w >> v;
		for (int j = W; j >= w; j--) {
			dp[j] = max(dp[j], dp[j - w] + v);
		}
	}
	cout << dp[W] << endl;
	return 0;
}

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

map<int, int> cnt;
map<int, int> mod;
map<int, int> same;
int main() {
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		++cnt[x];
		++mod[x % m];
	}
	for(auto e : cnt) {
		same[e.first % m] += e.second - e.second % 2;
	}
	int ans = 0;
	for(auto &e : mod) {
		if(e.first == 0 or e.first == m - e.first) {
			ans += e.second / 2;
			e.second -= e.second / 2 * 2;
			continue;
		}
		int mini = min(e.second, mod[m - e.first]);
		ans += mini;
		e.second -= mini;
		mod[m - e.first] -= mini;
	}
	for(auto e : same) {
		int mini = min(e.second, mod[e.first]);
		ans += mini / 2;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 14336
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
struct node{
	int u, v, w;
	node(int _u, int _v, int _w):u(_u), v(_v), w(_w){}
};
vector<node>ans;
inline int lowbit(int x) {
	return x & -x;
}
int main() {
	int L;
	scanf("%d", &L);
	for(int i=19;i>1;i--) {
		ans.push_back(node(i, i+1, 0));
		ans.push_back(node(i, i+1, (1<<(20-i-1))));
	}
	while( L ) {
		int p = int(log2(lowbit(L)));
		if( p == 19 ) {
			ans.push_back(node(1, 2, 0));
			ans.push_back(node(1, 2, 1<<18));
		}
		else ans.push_back(node(1, 20-p, L^lowbit(L)));
		L ^= lowbit(L);
	}
	printf("%d %d\n", 20, ans.size());
	for(int i=0;i<ans.size();i++)
		printf("%d %d %d\n", ans[i].u, ans[i].v, ans[i].w);
} 

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

struct UF {
  vector<int> d;
  UF(int n) : d(n, -1){};
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y); 
  }
  int size(int x) {
    return -d[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(size(x) > size(y)) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
};

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  UF uf(h * w);
  rep(y, h) {
    rep(x, w) {
      if(s[y][x] == '.') continue;
      rep(i, 4) {
	int nx = x + dx[i], ny = y + dy[i];
	if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
	if(s[ny][nx] == '.') continue;
	uf.unite(y*w+x, ny*w+nx);
      }
    }
  }
  if(uf.size(0) == h + w -1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define input(arr,n) for(int i = 0; i<n; i++) cin>>arr[i]
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	map<string,int> m;
	for(int i = 0; i<n;i++)
	{
		string g;
		cin>>g;
		m[g]++;
	}
	cout<<"AC x "<<m["AC"];
	cout<<"\nWA x "<<m["WA"];
	cout<<"\nTLE x "<<m["TLE"];
	cout<<"\nRE x "<<m["RE"]; 
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
A, B = map(int, input().split())
p = list(map(int, input().split()))

a = 0
b = 0
c = 0

for x in p:
    if x <= A:
        a += 1
    elif x <= B:
        b += 1
    else:
        c += 1

print(min(a, b, c))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  int keep = 0;
  bool ans = false;
  for (int i = 0; i < n; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) keep++;
    else keep = 0;
    if (keep >= 3) ans = true;
  }
  
  if (ans) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#define INT long long
#define MOD 1000000007
#define oo (1e18)+1
using namespace std;

INT n, a[100010], cnt[100010], ans = 0;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i], cnt[a[i]]++;
    for(int i = 1 ; i < 100000 ; i++ )
        ans = max( ans, cnt[i-1]+cnt[i]+cnt[i+1]);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792