akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL H, W, N, sr, sc;
	std::string S, T;
	in >> H >> W >> N >> sr >> sc >> S >> T;

	std::map<LL, LL>cnt[2];
	rep(i, N)
	{
		++cnt[0][S[i]];
		++cnt[1][T[i]];
	}

	// 右へ
	LL px = sr, py = sc;
	rep(i, N)
	{
		if (S[i] == 'R') ++py;
		if (py > W)
		{
			out << "NO" << std::endl;
			return 0;
		}
		if (T[i] == 'L' && py > 1) --py;
	}

	// 左へ
	px = sr, py = sc;
	rep(i, N)
	{
		if (S[i] == 'L') --py;
		if (py <= 0)
		{
			out << "NO" << std::endl;
			return 0;
		}
		if (T[i] == 'R' && py < W) ++py;
	}

	// 上へ
	px = sr, py = sc;
	rep(i, N)
	{
		if (S[i] == 'U') --px;
		if (px <= 0)
		{
			out << "NO" << std::endl;
			return 0;
		}
		if (T[i] == 'D' && px < H) ++px;
	}

	// 下へ
	px = sr, py = sc;
	rep(i, N)
	{
		if (S[i] == 'D') ++px;
		if (px > H)
		{
			out << "NO" << std::endl;
			return 0;
		}
		if (T[i] == 'U' && px > 1) --px;
	}

	out << "YES" << std::endl;
}


Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	string s;
	while(true)
	{
		long long x=(n-1)%26;
		s+=('a'+x);
		n-=(x+1);
		n/=26;
		if(n<=0)
			break;
	}
	reverse(s.begin(),s.end());
	cout << s << endl;





}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll modinv(ll a){
  ll b = mod,u = 1,v = 0,t;
  while(b){
    t = a/b;
    a -= t*b;swap(a,b);
    u -= t*v;swap(u,v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}
int main(){
  ll N,K,i;scanf("%lld%lld",&N,&K);
  ll A[N],P[N];P[0] = P[1] = 1;
  for(i=0;i<N;i++) scanf("%lld",&A[i]);
  for(i=2;i<N;i++) P[i] = P[i-1]*i%mod;
  sort(A,A+N);ll ans = 0;
  for(i=0;i<=N-K;i++){
    ans = (ans-P[N-i-1]*modinv(P[K-1])%mod*modinv(P[N-i-K])%mod*A[i]%mod)%mod;
    ans = (ans+P[N-i-1]*modinv(P[K-1])%mod*modinv(P[N-i-K])%mod*A[N-i-1]%mod)%mod;
  }
  if(ans < 0) ans += mod;
  printf("%lld\n",ans);
}

Measured memory_bytes: 5188
#include<iostream>
#include<string>

using namespace std;


int culc(int ax, int ay, int bx, int by) {
	int dx, dy;
	dx = abs(ax - bx);
	dy = abs(ay - by);
	return dx + dy;
}

int main() {
	int N, M;
	int no;
	int dist;
	int min;
	int a[60], b[60];
	int c[60], d[60];
	cin >> N >> M;
	
	for (int i = 1; i <= N; i++)
	cin >> a[i] >> b[i];

	for (int i = 1; i <= M; i++)
		cin >> c[i] >> d[i];


	for (int i = 1; i <= N; i++) {
		min = 1000000011;
		for (int j = 1; j <= M; j++) {
			dist = culc(a[i], b[i], c[j], d[j]);
			if (dist < min) {
				min = dist;
				no = j;
			}
		}
		cout << no << endl;
	}

}

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

using namespace std;



int main()
{

	int n, a, b;
	cin >> n >> a >> b;
	if (a < b) swap(a, b);

	if (n == a == b)
	{
		cout << a << " " << b << endl;
	}
	else if (n >= a+ b)
	{
		cout << b <<" "<< "0";
	}
	else
	{
		cout << b <<" " << a + b - n;
	}

	
}

Measured memory_bytes: 256
while 1:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        print 'YES' if ((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)==((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)==((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0) else 'NO'
    except:
        break

Measured memory_bytes: 6356
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

class WarshallFloyd{
public:
    ll V;
    vector<vector<ll>> d;
    WarshallFloyd(ll V):V(V){
        d.assign(V, vector<ll>(V,LINF));
        for(int i = 0; i < V;i++){
            d[i][i] = 0;
        }
    }
    
    void add_edge(ll u,ll v,ll cost,bool undirected = false){
        d[u][v] = min(d[u][v],cost);
        if(undirected){
            d[v][u] = min(d[v][u],cost);
        }
    }
    
    void calc(){
        for (int i = 0; i < V; i++)      // ?????±????????????
            for (int j = 0; j < V; j++)    // ????§???????
                for (int k = 0; k < V; k++)  // ??????
                {
                    
                    if(d[j][i] == LINF || d[i][k] == LINF)continue;
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
                }
    }
    
    inline ll get_dist(ll s,ll t) {return d[s][t];} // // ????????? := d[i][i] < 0
};

int main(){
    ll V,E; cin >> V >> E;
    WarshallFloyd WF(V);
    for(int i = 0; i < E;i++){
        ll s,t,d; cin >> s >> t >> d;
        WF.add_edge(s, t, d);
    }
    WF.calc();
    
    for(int i = 0; i < V;i++){
        if(WF.get_dist(i, i) < 0){
            cout << "NEGATIVE CYCLE" << endl; return 0;
        }
    }
    
    vector<ll> ans(V);
    for(int i = 0; i < V;i++){
        for(int j = 0; j < V;j++){
            if(WF.get_dist(i, j) == LINF){
                cout << "INF";
            }else{
               cout << WF.get_dist(i, j);
            }
            if(j != V - 1)cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3220
#060 C Sentou
import sys
N, T = map(int, sys.stdin.readline().split())
L = list(map(int, sys.stdin.readline().split()))
E = [0 for _ in range(N)]
#print(L)
total=0
for i in range(N):
    E[i] = L[i]+T
    total +=E[i] - max(E[i-1], L[i])

if N==1:
    total=T
print(total)

Measured memory_bytes: 25232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];

	multiset<ll> s;
	rep(i,N){
		auto itr = s.lower_bound(A[i]);
		//自分以下の値がないとき
		if(itr == s.begin()){
			s.insert(A[i]);
		}
		//あるとき
		else{
			--itr;
			s.erase(itr);
			s.insert(A[i]);
		}
	}
	cout<<(int)s.size()<<endl;
}
/*
sの中からA[i]未満の最大値を探し、
それを除いて、A[i]を突っ込む
なかったら普通に突っ込む

2 1 4 5 3
[2]
[1,2]
[1,4]
[1,5]
[3,5]
*/

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll _power(ll a, int b)//计算a^b;
{
    ll ans=1, res=a;
    while(b){
        if(b&1) ans=ans*res%mod;
        res=res*res%mod;
        b>>=1;
    }
    return ans%mod;
}
ll n,a,b;
ll C(ll xx,ll yy){
    ll up=1,down=1;
    for(int i=n;i>=xx-yy+1;i--)up=up*i%mod;
    for(int i=1;i<=yy;i++)down=down*i%mod;
    return up*_power(down,mod-2)%mod;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    cout<<(_power(2,n)-1+mod-C(n,a)-C(n,b)+mod)%mod<<endl; //有多少个减号加多少个mod
    return 0;
}

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

int main()
{
    int n,a[2][105],b = 0;
    scanf("%d",&n);
    for(int i = 0; i< n; i++){
        scanf("%d",a[0]+i);
    }
    for(int i = 0; i< n; i++){
        scanf("%d",a[1]+i);
    }
    for(int i = 0; i < n;i++){
        int change = 0,sum = 0;
        for(int j = 0; j < n ; j++){
            sum += a[change][j];
            if(j == i&& change == 0){
                change = 1;
                j--;

            }
        }
        if(sum > b )
            b = sum;
    }
    printf("%d\n",b);
    return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
     
    ll A, B, K;
    cin >> A >> B >> K;

    ll cnt = 0;
    for(ll i=min(A, B); i>0; i--)
    {
        if(A%i==0 && B%i==0)
        {
            cnt++;

            if(cnt==K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

struct a {
  string s;
  int p;
  int c;
    bool operator<( const a& right ) const {
        return s == right.s ? p < right.p : s > right.s;
    }
};

int main() {
  int n;
  cin >> n;
  vector<a> S(n);
  for(int i = 0; i < n; i++) {
    cin >> S.at(i).s >> S.at(i).p;
    S.at(i).c = i+1;
  }
  sort(S.begin(),S.end());
  reverse(S.begin(), S.end());
  for(int i = 0; i < n; i++) {
    cout << S.at(i).c << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  bool frag=true;
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      frag=false;
    }
  }
  if(frag==true){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A&lang=jp>
 */

 func main(){
 	var a,b int
 	fmt.Scanf("%d %d",&a,&b)
 	fmt.Printf("%d %d %f\n",a/b,a%b,float64(a)/float64(b))
 }

Measured memory_bytes: 1192
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
print('Yes' if s[2]==s[3] and s[4]==s[5] else 'No')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 110000;

int N;
long long W, w[110], v[110];
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];

    // DPテーブル初期化
    REP(i, MAX_N) REP(j, MAX_V) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    REP(i, N) {
        REP(sum_v, MAX_V) {
            // i番目の品物を選ぶ場合
            if (sum_v - v[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            }
            // 選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    long long ans = 0;
    REP(sum_v, MAX_V) {
        if (dp[N][sum_v] <= W) ans = sum_v;
    }
    cout << ans << endl;
}


Measured memory_bytes: 94720
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d1 = abs(a - b);
    int d2 = abs(b - c);
    int d3 = abs(c - a);
    int sum = d1 + d2 + d3 - max(d1, max(d2, d3));
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 998244353
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

bool eq(pair<ll,ll> a)
{
    return a.ff == a.ss;
}

int main()
{
  FAST/**/
   
   ll n,x,m;
   cin>>n>>x>>m;
   
   map<ll,ll> enc;
   vector<ll> v;
   ll id = -1;
   v.pb(x);
   enc[x] = 0;
   while(v.size()<n)
   {
       ll curr = (v.back()*v.back())%m;
       auto it = enc.find(curr);
       if(it == enc.end())
       {
           enc[curr] = v.size();
           v.pb(curr);
       }
       
       else
       {
           id = it->ss;
           break;
       }
   }
   
   if(v.size() == n)
   {
       ll tot = 0;
       autoit(v,it)
            tot+=(*it);
       cout<<tot<<'\n';
       return 0;
   }
   
   ll las = (ll)v.size()-1;
   ll repe = las-id+1;
   ll sum1 = 0;
   for(ll i=id;i<(ll)v.size();i++)
        sum1+=v[i];
   ll prev = 0;
   for(ll i=0;i<id;i++)
       prev+=v[i];
   ll comp = (n-id)/repe;
   ll rem = n-(comp*repe)-id;
   prev+=(sum1*comp);
   for(ll j=0;j<rem;j++)
   {
       ll i1 = j+id;
       prev+=v[i1];
   }
   
   cout<<prev;
   
   
           
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 6744
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f // -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n, m, cnt;
int a[N], b[N];

int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) read(a[i]);
	if (m == 1) {
		printf("%d\n", a[1]);
		int cnt = (a[1] == 1) ? 1 : 2;
		printf("%d\n", cnt);
		if (cnt == 1) printf("%d\n", 1);
		else printf("%d %d\n", a[1] - 1, 1);
		return 0;
	}
	if (m == 2) {
		printf("%d %d\n", a[1], a[2]);
		int cnt = (a[1] == 1) ? 1 : 2;
		printf("%d\n", cnt);
		if (cnt == 1) printf("%d\n", n);
		else printf("%d %d\n", a[1] - 1, a[2] + 1);
		return 0;
	}
	for (int i = 1; i <= m; i++) if (a[i] & 1) cnt++;
	if (cnt > 2) {printf("Impossible\n"); return 0;}
	for (int i = 1; i <= m; i++) {
		if (a[i] & 1) {
			if (cnt == 2) swap(a[1], a[i]);
			else if (cnt == 1) swap(a[m], a[i]);
			cnt--;
		}
	}
	for (int i = 1; i <= m; i++) printf("%d ", a[i]); printf("\n");
	for (int i = 1; i <= m; i++) b[i] = a[i]; b[1]++, b[m]--;
	if (b[m] == 0) m--;
	printf("%d\n", m);
	for (int i = 1; i <= m; i++) printf("%d ", b[i]); printf("\n");
	return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Ord

main = do
  n <- readLn :: IO Int
  s <- getLine
  
  putStrLn $ minimumBy (comparing length) $ filter isParenCorrect [open ++ s ++ close | close <- (take (n+1) $ iterate (')':) []), open <- (take (n+1) $ iterate ('(':) [])]

  where
    isParenCorrect xs = last b == 0 && find (<0) b == Nothing
      where
        a = map f xs
        b = scanl (+) 0 a
        f '(' = 1
        f ')' = -1


Measured memory_bytes: 1404
#include<stdio.h>
#define N 100000

int S[N], n1;

int BinarySearch(int);

int main(){
  int T[N],  C[N], n2, i, j, count=0;

  scanf("%d", &n1);
  for(i =0; i < n1; i++)
    scanf("%d", &S[i]);

  scanf("%d", &n2);
  for(i = 0; i < n2; i++){
    scanf("%d", &T[i]);
    if(BinarySearch(T[i]) == 1)
      count++;
  }

  

  printf("%d\n", count);

  return 0;
}

int BinarySearch(int x){
  int l=0, r=n1, mid;

  while(l < r){
    mid = (l+r)/2;
    if(S[mid] == x)
      return 1;
    else if(x < S[mid])
      r = mid;
    else
      l = mid+1;
  }
  return 0;
}

Measured memory_bytes: 1176
using System;
using System.Collections.Generic;
using System.Linq;
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 Int() {
        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] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        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] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int K = cin.Int();
        Console.ReadLine();
        Console.WriteLine(Math.Ceiling((double)(N-1)/(K-1)));
        Console.ReadLine();
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <time.h>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 3030000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
//const int mod = 998244353;
int mod;

ll dp[6010][12010];

int main(){
	int n; cin >> n >> mod;
	int N = 3*n;
	dp[0][N] = 1;
	rep(i,N){
		rep(j,2*N+1){
			(dp[i+1][j+1] += dp[i][j]) %= mod;
			if(j > 0) (dp[i+2][j-1] += dp[i][j] * (i+1)) %= mod;
			(dp[i+3][j] += dp[i][j] * (i+1) * (i+2) % mod) %= mod;
		}
	}
	ll ans = 0;
	REP(j,N,2*N+1){
		(ans += dp[N][j]) %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 566676
#include <iostream>
#include <cmath>
#include <map>

using namespace std;

#define fi first
#define se second

typedef pair<double, double> P;
int N;
P h, d, cs[20];

#define SQ(x) ((x)*(x))

inline double getDist(P a, P b) {
  return sqrt(SQ(a.fi-b.fi) + SQ(a.se-b.se));
}

double dist[22][22];

map<int, double> mp;

bool dfs(int S, int now, double cost) {
  
  if(S == (1<<N)-1) {
    return true;
  }
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(dist[i][N+1] <= cost + dist[now][i]) return false;
  }
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(mp.count(S+(1<<i)) && mp[S+(1<<i)] <= cost+dist[now][i]) continue;
    mp[S+(1<<i)] = cost+dist[now][i];
    if(dfs(S+(1<<i), i, cost+dist[now][i])) return true;
  }
  
  return false;
}

bool solve() {
  
  mp.clear();
  
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      dist[i][j] = dist[j][i] = getDist(cs[i], cs[j]);
    }
    dist[i][N] = dist[N][i] = getDist(cs[i], h);
    dist[i][N+1] = dist[N+1][i] = getDist(cs[i], d);
  }
  
  for(int i=0; i<N; i++) {
    if(dist[i][N+1] <= dist[i][N]) continue;
    if(dfs(1<<i, i, dist[N][i])) return true;
  }
  return false;
}

int main() {
  
  while(cin >> N >> h.fi >> h.se >> d.fi >> d.se && (N)) {
    for(int i=0; i<N; i++) {
      cin >> cs[i].fi >> cs[i].se;
    }
    
    cout << (solve() ? "YES" : "NO") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 21460
#include <stdio.h>

int main(void) {
  int i, j, k, ansc = 0, ansh = 0, a, b, c;
  while( scanf("%d,%d,%d", &a, &b, &c) != EOF ) {
    if(a * a + b * b == c * c) ++ansc;
    if(a == b) ++ansh;
  }
  printf("%d\n%d\n", ansc, ansh);
  return 0;
}


Measured memory_bytes: 2572
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main(N, V, W, v, L):
    def precompute(N, V, W):
        U = 10**5 + 10
        dp = np.zeros((1024, U), np.int32)
        for v in range(1, min(1024, N + 1)):
            p = v // 2
            dp[v] = dp[p]
            dp[v, W[v]:] = np.maximum(dp[v, W[v]:], dp[p, :-W[v]] + V[v])
            for i in range(1, U):
                dp[v][i] = max(dp[v][i], dp[v][i - 1])
        return dp

    dp = precompute(N, V, W)
    values = np.empty(1024, np.int32)
    weights = np.empty(1024, np.int32)

    def solve(i, lim, values, weights, dp):
        if i < 1024:
            return dp[i][lim]
        values[0] = 0
        weights[0] = 0
        p = 0
        while i >= 1024:
            for j in range(1 << p):
                values[j + (1 << p)] = values[j] + V[i]
                weights[j + (1 << p)] = weights[j] + W[i]
            p += 1
            i >>= 1
        best = 0
        for n in range(1 << p):
            if weights[n] > lim:
                continue
            x = dp[i][lim - weights[n]] + values[n]
            best = max(best, x)
        return best

    Q = len(v)
    for i in range(Q):
        x = solve(v[i], L[i], values, weights, dp)
        print(x)

        
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i4,i4[::1],i4[::1],i4[::1],i4[::1])')(main)
    cc.compile()
    exit()

from my_module import main

N = int(readline())
stdin = np.array(read().split(), np.int32)
V = np.zeros(N + 1, np.int32)
W = np.zeros(N + 1, np.int32)
V[1:] = stdin[:N + N:2]
W[1:] = stdin[1:N + N:2]
query = stdin[N + N + 1:]
v, L = query[::2].copy(), query[1::2].copy()

main(N, V, W, v, L)


Measured memory_bytes: 434892
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')
    def is_ok(A, F, x, k):
        y = A - x // F
        tmp = y[y > 0].sum()
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 16
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 53524
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

ll b, k, n = 0, z = 0,s, x, y, a[200005] = {};
	vector<ll> v,vec;
int main() {
	cin >> n >> k >> s;
	
	rep(i, n) {
		if (i < k)cout << s << " ";
		else {
			if(s==1000000000)cout << 1 << " ";
			else cout << s+1 << " ";
		}
	}
	return 0;

}


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

int main(){
    int h, w, dot = 0, ans = 0;
    cin >> h >> w;
    char s[h][w];
    for(int i = 0; i < h; i++) cin >> s[i];

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.') dot++;
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.'){
                typedef pair<int, int> pair;
                int dt = dot - 1;
                int num = 0;
                vector<pair> xy;
                xy.push_back(make_pair(i, j));
                bool flag[h][w] = {};
                flag[i][j] = true;
                while(dt > 0){
                    num++;
                    stack<pair> xy2;
                    for(auto& it : xy){
                        int x = it.first;
                        int y = it.second - 1;
                        if(x >= 0 && y >= 0 && x < h && y < w){
                            if(s[x][y] == '.' && !flag[x][y]){
                                flag[x][y] = true;
                                xy2.push(make_pair(x, y));
                                dt--;
                            }
                        }
                        y = it.second + 1;
                        if(x >= 0 && y >= 0 && x < h && y < w){
                            if(s[x][y] == '.' && !flag[x][y]){
                                flag[x][y] = true;
                                xy2.push(make_pair(x, y));
                                dt--;
                            }
                        }
                        x = it.first - 1;
                        y = it.second;
                        if(x >= 0 && y >= 0 && x < h && y < w){
                            if(s[x][y] == '.' && !flag[x][y]){
                                flag[x][y] = true;
                                xy2.push(make_pair(x, y));
                                dt--;
                            }
                        }
                        x = it.first + 1;
                        if(x >= 0 && y >= 0 && x < h && y < w){
                            if(s[x][y] == '.' && !flag[x][y]){
                                flag[x][y] = true;
                                xy2.push(make_pair(x, y));
                                dt--;
                            }
                        }
                    }
                    xy.clear();
                    while(!xy2.empty()){
                        xy.push_back(make_pair(xy2.top().first, xy2.top().second));
                        xy2.pop();
                    }
                }
                if(ans < num) ans = num;
            }
        }
    }

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

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList()
    println(A.max()!! - A.min()!!)
}

Measured memory_bytes: 35832
N = input()
s = int(N) % 10
if s == 3:
    print('bon')
if s == 0:
    print('pon')
if s == 1:
    print('pon')
if s == 6:
    print('pon')
if s == 8:
    print('pon')

if s == 2:
    print('hon')
if s == 4:
    print('hon')
if s == 5:
    print('hon')
if s == 7:
    print('hon')
if s == 9:
    print('hon')

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, a[N], mark[N], seen[N], cnt, num[N];
long long ans;
vector<int> gr[N];
pair<int, int> mn = {1e9 + 1, 1e9 + 1};
void dfs(int v) {
	mark[v] = 1;
	mn = min(mn, make_pair(a[v], v));
	for (auto u : gr[v])
		if (!mark[u])
			dfs(u);
	return;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!mark[i]) {
			dfs(i);
			seen[mn.second] = 1;
			ans += mn.first;
			cnt++;
			mn = {1e9, 1e9};
		}
	}
	int nw = cnt * 2 - 2 - cnt;
	int plc = 0;
	iota(num, num + n, 0);
	sort(num, num + n, [] (int x, int y) { return a[x] < a[y]; });
	while (plc < n && nw > 0) {
		if (!seen[num[plc]]) {
			ans += a[num[plc]];
			nw--;
		}
		plc++;
	}
	if (nw > 0) {
		cout << "Impossible";
	}
	else {
		if (cnt == 1)
			cout << 0;
		else
			cout << ans;
	}
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    rep(i,M){
        int a;
        cin >> a;
        N-=a;
    }
    if(N<0) N = -1;
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 3580
fun main(args: Array<String>) {
    val (row, col) = readInputLine().split(" ").map { it.toLong() }
    
    if (row == 1L) {
        if (col == 1L) {
            println(1L)
            return
        }
        println(col - 2L)
        return
    }

    if (col == 1L) {
        println(row - 2L)
        return
    }

    println((row - 2L) * (col - 2L))
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37700
n = gets.to_i
a = gets.split.map &:to_i
cnt = 0
(0..n-1).each do |i|
  (n-1).downto(i+1) do |j|
    if a[j] < a[j-1]
      a[j], a[j-1] = a[j-1], a[j]
      cnt += 1
    end
  end
end
puts a * ' '
puts cnt


Measured memory_bytes: 6868
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,m,l,x,y,build[1001][2],assign[1001],assign2[1001],prev[1001][1001];
double route[2][1001][1001];

void backtrack(int from,int to){
	int z=prev[from][to];
	if(z==from){
		printf("%d ",assign[from]);
		return;
	}
	backtrack(from,z);
	backtrack(z,to);
}

int main(){
	while(scanf("%d",&n)*n){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&assign[i],&build[i][0],&build[i][1]);
			assign2[assign[i]]=i;
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				l=(build[i][0]-build[j][0])*(build[i][0]-build[j][0])+(build[i][1]-build[j][1])*(build[i][1]-build[j][1]);
				if(l<=2500){
					route[0][i][j]=sqrt((double)l);
					route[0][j][i]=sqrt((double)l);
					prev[i][j]=i;
					prev[j][i]=j;
				}
				else{
					route[0][i][j]=999999999;
					route[0][j][i]=999999999;
				}
			}
		}

		for(l=1;pow(2.0,l)<n-1;l++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					route[l%2][i][j]=route[(l+1)%2][i][j];
					for(k=0;k<n;k++){
						if(route[l%2][i][j]>route[(l+1)%2][i][k]+route[(l+1)%2][k][j]){
							route[l%2][i][j]=route[(l+1)%2][i][k]+route[(l+1)%2][k][j];
							prev[i][j]=k;
						}
					}
				}
			}
		}

		l--;

		for(scanf("%d",&m);m>0;m--){
			scanf("%d %d",&x,&y);
			x=assign2[x];
			y=assign2[y];
			if(x==y){
				printf("%d\n",assign[y]);
			}
			else if(route[l%2][x][y]<999999999){
				backtrack(x,y);
				printf("%d\n",assign[y]);
			}
			else printf("NA\n");
		}

	}
	return 0;
}

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

n=int(input())
T=[]
for i in range(n):
    S=sorted(list(input()))
    t=""
    for s in S:
        t+=s
    T.append(t)
T=sorted(T)
A=[]
cnt=0
c=T[0]
for t in T:
    if t==c:
        cnt+=1
    else:
        if cnt>1:
            A.append(cnt)
        c=t
        cnt=1
if cnt>1:
    A.append(cnt)
    
ans=0
for a in A:
    ans+=a*(a-1)//2
print(ans)

Measured memory_bytes: 11352
N = int(input())
S = list(input())
W = 0
E = S[1:N].count("E")
ans = E
for i in range(1,N):
  if S[i] == "E":
    E -= 1
  if S[i-1] == "W":
    W += 1
  ans = min(ans,E+W)
print(ans)

Measured memory_bytes: 8052
def main():
    N, M, K=map(int, input().split())
    friend_or_block = [0 for _ in range(N)]
    friends_chain = UnionFindTree(N)

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        friends_chain.unite(a, b)
        friend_or_block[a] += 1
        friend_or_block[b] += 1

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if friends_chain.same(c, d):
            friend_or_block[c] += 1
            friend_or_block[d] += 1

    print(' '.join(map(str, [friends_chain.count(i) - friend_or_block[i] - 1 for i in range(N)])))

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]

    def root(self, x):
        p, seq = self.parent[x], list()
        while p >= 0:
            seq.append(x)
            x, p = p, self.parent[p]
        for c in seq: self.parent[c] = x
        return x

    def same(self, x, y): return self.root(x) == self.root(y)

    def count(self, x): return -self.parent[self.root(x)]

    def unite(self, x, y):
        xr, yr = self.root(x), self.root(y)
        if xr == yr: return
        if self.parent[xr] > self.parent[yr]: xr, yr = yr, xr
        self.parent[xr] += self.parent[yr]
        self.parent[yr] = xr

if __name__ == '__main__':
    main()



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][100010];
ll n,k;
ll a[100];

bool rec(ll man, ll index){
  if(index<0)
    return true;

  if(dp[man][index]!=-1)
    return dp[man][index];


  bool rst=false;
  REP(i, n){
    rst = rst||!rec((man+1)%2, index-a[i]);
  }

  return dp[man][index]=rst;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n>>k;
  REP(i,n)cin>>a[i];
  REP(i,2)REP(j,100010)dp[i][j]=-1;

  bool ans = rec(0, k);
  if(ans)
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;

}


Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	rep(i, h){
		rep(j, w){
			if(i<b){
				if(j<a) cout << 0;
				else cout << 1;
			} else{
				if(j<a) cout << 1;
				else cout << 0;
			}
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

ll n, a, b;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0)
    cout << (b - a) / 2 << "\n";
  else
    cout << min((a + b - 1) / 2, (2 * n - a - b + 1) / 2) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int s[n+1];
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++) {
		if(s[i]%2==0) {
			if(s[i]%3!=0 && s[i]%5!=0) {
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100005
int a[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(n&1){
		printf("0");
		return 0;
	}
	printf("%d",a[n/2+1]-a[n/2]);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 0; j < s.length(); j++)
        {
            if (i == j)
            {
                continue;
            }
            if (s[i] == s[j])
            {
                cout << "no\n";
                return 0;
            }
        }
    }
    cout << "yes\n";
    return 0;
}


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

int main() {
	int a[5] = {};
	int aa[5] = {};
	string s[5] = { "A","B","C","D","E" };
	int b, c;
	while (cin >> b >> c, b, c) {
		int d, e;
		a[0] = b + c;
		aa[0] = a[0];
		for (int i = 0; i < 4; i++) {
			cin >> d >> e;
			a[i + 1] = d + e;
			aa[i + 1] = a[i + 1];
		}
		sort(aa, aa + 5);

		for (int i = 0; i < 5; i++) {
			if (a[i] == aa[4]) {
				cout << s[i] << ' '<<a[i]<<endl;
				break;
			}
		}

	}
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int gcd(int a,int b);

int n,t,ans;

main() {
    cin >> n >> ans,n--;
    rep(i,n) {
        cin >> t;
        ans = ans/gcd(ans,t)*t;
    }
    cout << ans << endl;
}

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



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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int> &vec) {
    for (auto &e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

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

    for (int i = 0; i < s.length(); i++) {
        cout << 'x';
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

ls = makePrimeChecker(10**6)

ls_ans = []
while True:
    try:
        n = int(input())
        ls_ans.append(sum(ls[:n+1]))
    except:
        break

for i in range(len(ls_ans)):
    print(ls_ans[i])


Measured memory_bytes: 21968
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    n = in_n()
    a = sorted(in_nl())

    a_max = a[-1]
    diff = 10**9 + 7
    for i in range(n - 1):
        t = abs(a_max / 2 - a[i])
        if t < diff:
            a_mid = a[i]
            diff = t

    print(a_max, a_mid)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19204
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

const int N = 110;
int n, dp[2][N];

int main() {

	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d", dp[0] + i);
	for(int i = 0; i < n; ++i)
		scanf("%d", dp[1] + i);
	for(int i = n - 1; i >= 0; --i)
		dp[1][i] += dp[1][i + 1];
	for(int i = 1; i < n; ++i)
		dp[0][i] += dp[0][i - 1];
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		ans = max(ans, dp[0][i] + dp[1][i]);
	}
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 256
import java.io.*;
 
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
int n=Integer.parseInt(line);
System.out.println(1+n*(n+1)/2);
}
}
}

Measured memory_bytes: 16864
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

typedef pair<int, int> t;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cntg = 0;
    int cntp = 0;
    
    int win = 0;
    int los = 0;
    REP(i,s.size()) {
        if (s[i] == 'g') {
            if (cntp + 1 <= cntg) {
                cntp++;
                win++;
            }else {
                cntg++;
            }
        }else {
            if (cntp + 1 <= cntg) {
                cntp++;
            }else {
                cntg++;
                los++;
            }
        }
    }
    print(win - los);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string s; cin >> s;
    string t = "";
    int n = s.size();
    rep(i, 0, n){
        if(i%2 == 0){
            t += s[i];
            // cerr << s[i] << endl;
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 592
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
c = collections.Counter(s)
for i in c.values():
  if i & 1:
    print('No')
    exit()
print('Yes')







Measured memory_bytes: 27180