akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int mem[3010][3010], n, m, a, b;
ll mod=998244353;
ll pwr(ll x, ll e){
	if(e==0){
		return 1;
	}
	ll tmp=pwr(x, e/2);
	tmp=tmp*tmp;
	tmp%=mod;
	if(e%2){
		tmp*=x;
		tmp%=mod;
	}
	return tmp;
}
ll dp(ll, ll);
int mem1[3010][3010], mem2[3010][3010];
ll dp1(ll x, ll y){
	if(mem1[x][y]!=-1){
		return mem1[x][y];
	}
	if(x==a){
		return 0;
	}
	ll res=(x-1)*dp(x-1, y-1)+y*dp1(x-1, y);
	res%=mod;
	mem1[x][y]=res;
	return res;
}
ll dp2(ll x, ll y){
	if(mem2[x][y]!=-1){
		return mem2[x][y];
	}
	if(y==b){
		return 0;
	}
	ll res=(y-1)*dp(x-1, y-1)+x*dp2(x, y-1);
	res%=mod;
	mem2[x][y]=res;
	return res;
}
ll dp(ll x, ll y){
	if(x==a && y==b){
		return 1;
	}
	if(mem[x][y]!=-1){
		return mem[x][y];
	}
	ll res=0;
	if(y==b){
		res=pwr(y, x-a);
		mem[x][y]=res;
		return res;
	}
	if(x==a){
		res=pwr(x, y-b);
		mem[x][y]=res;
		return res;
	}
	res=((y-1)*(x-1)+(y-1)+(x-1))*dp(x-1, y-1);
	res+=y*dp1(x-1, y);
	res+=x*dp2(x, y-1);
	ll tmp=y;
	// for(ll i=2; i<=x-a; ++i){
	// 	res+=(tmp*(x-i))%mod*dp(x-i, y-1);
	// 	res%=mod;
	// 	tmp*=y;
	// 	tmp%=mod;
	// }
	// tmp=x;
	// for(ll i=2; i<=y-b; ++i){
	// 	res+=(tmp*(y-i))%mod*dp(x-1, y-i);
	// 	res%=mod;
	// 	tmp*=x;
	// 	tmp%=mod;
	// }
	res%=mod;
	mem[x][y]=res;
	return res;
}
int main(){
    while(cin>>a>>b>>n>>m){
        ll ans=0;
        memset(mem, -1, sizeof mem);
        memset(mem1, -1, sizeof mem1);
        memset(mem2, -1, sizeof mem2);
        ans=dp(n, m);
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 110032
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
    ll s[1000000] = {}; //素数なら0
    s[0] = 1;
    s[1] = 1;
    for(ll i=2;i*i<1000000;i++)
    {
        if(s[i]==0){
            for(ll j=i*i ; j<1000000 ; j+=i ){   s[j]=1; }
        }
	}
	
	int n;
	while(cin >> n && n!=0)
	{
		ll ans =0;
		for(ll i=n+1;i<=2*n;i++)
		{
			if(s[i]==0){ans++;}
		}
		
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 8976
#!/usr/bin/env python3
import sys
import math

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, x = map(int, readline().split())
xda2 = x / (a * a)


def check1(rad):
    return a * math.tan(rad) <= (b - xda2) * 2


def check2(rad):
    return a * b * b >= x * math.tan(rad) * 2


def solve():
    check = check1 if 2 * x > a * a * b else check2
    ok, ng = 0.0, math.pi / 2.0
    eps = 1e-12
    while ng - ok > eps:
        m = (ng + ok) / 2.0
        if check(m):
            ok = m
        else:
            ng = m
    return ok


if __name__ == "__main__":
    print(solve() / math.pi * 180.0)


Measured memory_bytes: 3572
from math import sqrt
from fractions import gcd
A,B = list(map(int, input().split()))

N = gcd(A,B)
#print(N)
ans = set()
for i in range(2,int(1e6 + 100)):
  if N == 1:
    break
  while N % i == 0:
    ans.add(i)
    N /= i
if N > 1:
  ans.add(N)
  
print(len(ans) + 1)

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  ll m = abs(n - k);
  cout << min(m, n) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(N: int, K: int):
    d = int(N % K)
    if d == 0:
      print(d)
    else:
      print(1)
    return

def main():
    N, K = map(int, input().split())
    solve(N, K)

if __name__ == '__main__':
    main()

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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000007
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int x,q,t,b;
string s;
deque <char> d;
char c;

int main()
{
	cin >> s >> q;
	for(int i = 0;i < s.size();i++) d.pb(s[i]);
	while(q--){
		cin >> t;
		if(t == 1) b++;
		else {
			cin >> x >> c;
			if(x == 1){
				if(b % 2) d.pb(c);
				else d.push_front(c);
			}
			else {
				if(b % 2) d.push_front(c);
				else d.pb(c);
			}
		}
	}
	if(b % 2) for(auto i = d.rbegin();i != d.rend();i++) cout << *i;
	else for(auto i = d.begin();i != d.end();i++) cout << *i;
}

Measured memory_bytes: 1024
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = A[0]
if N == 1:
    print(ans)
    exit()
for i in range(1,N):
    A[i] = gcd(A[i-1], A[i])

print(A[N-1])

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ {
    class Program {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; i++)
                for (int j = 1; j <= 9; j++)
                    Console.WriteLine("{0}x{1}={2}", i, j, i * j);
        }
    }
}



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

signed main(){
  int N,ans=0;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  rep(i,N){
    if(i%2==1)continue;
    if(A[i]%2==0)continue;
    ans+=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
x1,y1,x2,y2 = list(map(int, input().split()))

vx = x2-x1
vy = y2-y1

x3 = x2 - vy
y3 = y2 + vx

x4 = x3 - vx
y4 = y3 - vy

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c ,x;
  cin >> a >> b >> c >> x;

  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++ ){
      for(int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) ans++;
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a,b,c;
    a = n/100;
    b = n/10%10;
    c = n%10;
    //cout << a << b << c << endl;
    if( a==7 || b==7 || c==7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    int n, h;
    cin >> h >> n;
    ll arr[n + 1], arr1[n + 1];
    for(int i = 1; i <= n; i++)  cin >> arr[i] >> arr1[i];
    ll dp[n + 1][h + 1];
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= h; j++)
            dp[i][j] = 1e12;
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= h; j++)
        {
            dp[i][j] = min(dp[i - 1][j], dp[i][max(0ll, j - arr[i])] + arr1[i]);
        }
    }
    cout << dp[n][h] << "\n";
}

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

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

int main() {
  int A;
  int64_t B, N;
  cin >> A >> B >> N;
  if (B > N){
    cout << A * N / B << endl;
  }
  else {
    cout << A * (B - 1) / B << endl;
  }
}


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

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define REP(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;

ll n,a,b;
ll ans;
int main(){
    cin>>n>>a>>b;
    ans+=(n/(a+b))*a;
    ll m = n%(a+b);
    ans+=(m>a?a:m);
    puts(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( array[ 0 ] ))

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	int up = N / 100, low = N % 100;
	int flag = 0;
	if (up < 13 && up > 0){
		flag += 2;
	}
	if (low < 13 && low > 0){
		flag++;
	}
	switch (flag){
	case 3:
		cout << "AMBIGUOUS";
		break;
	case 2:
		cout << "MMYY";
		break;
	case 1:
		cout << "YYMM";
		break;
	case 0:
		cout << "NA";
		break;
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


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

int main(void){
	const ll MOD = 1e9+7;
	ll n,m;
	cin>>n>>m;
	ll dp[n+5],a[m];
	bool flag[n+5];
	memset(flag,false,sizeof(flag));
	memset(dp,0,sizeof(dp));
	for(ll i=0;i<m;i++){
		cin>>a[i];
		flag[a[i]]=true;
	}
	if(!flag[1])dp[1]=1;
	if(!flag[2])dp[2]=1+dp[1];
	for(ll i=3;i<=n;i++){
		if(!flag[i]){
			dp[i]=(dp[i]+dp[i-1])%MOD;
			dp[i]=(dp[i]+dp[i-2])%MOD;
		}
		//cout<<"i:"<<i<<" dp:"<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
}


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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 5e5+5;
const int mod = 1e9+7;

int f[N];

void precompute(){
    f[0] = 1;
    for(int i = 1; i < N; i++)
        f[i] = f[i-1] * 1ll * i % mod;
}

int power(int a, int b){
    a %= mod;
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = res * 1ll * a % mod;
            b--;
        }
        a = a * 1ll * a % mod;
        b >>= 1;
    }
    return res;
}

int ncr(int n, int r){
    if(n < r) return 0;
    return f[n] * 1ll * power(f[r], mod - 2) % mod * power(f[n-r], mod - 2) % mod;
}

void add(int& a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

void sub(int& a, int b){
     a -= b;
     if(a < 0)
        a += mod;
}

void solve(){
    
    int n, m; cin >> n >> m;
    int ans = ncr(m, n) * 1ll * f[n] % mod;
    int sum = 0;
    for(int i = 0; i <= n; i++){
        int val = ncr(n, i) * 1ll * ncr(m - i, n - i) % mod * f[n - i] % mod;
        if(i & 1)
            sub(sum, val);
        else
            add(sum, val);
    }
    cout << ans * 1ll * sum % mod;
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	precompute();
	for(int i = 1; i <= t; i++){
	   // cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5548
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x[5];

    for(int i=0;i<5;i++){
        cin>>x[i];
    }    
    for(int i=0;i<5;i++){
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int k;
ll ans;
int gcd(int x,int y)
{
	int r=x%y;
	while(r)
	{
		x=y;
		y=r;
		r=x%y;
	}
	return y;
}
int main()
{
	cin>>k;
	for(int a=1;a<=k;a++)
	for(int b=1;b<=k;b++)
	for(int c=1;c<=k;c++)
	{
		ans+=gcd(gcd(a,b),c);
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

struct edge { int to, cost; };

int b_s(vector<vector<int>>& a, int key,int z) {
	int left = -1;
	int right = a[z].size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[z][mid] > key)right = mid;
		else left = mid;
	}
	return left;
}


int main() {
	int n;
	long double d;
	cin >> n >> d;
	hei(long double) x(n), y(n);
	rep(i, 0, n)cin >> x[i] >> y[i];
	int ans = 0;
	rep(i, 0, n) {
		if (d*d >= x[i] * x[i] + y[i] * y[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>t(n);
  vector<int>a(n);
  long takahashi = 0;
  long aoki = 0;
  int i;
  for(i=0;i<n;i++){
    cin >>t[i] >> a[i];
  }
  takahashi = t[0];
  aoki = a[0];
  for(i=1;i<n;i++){
    if(takahashi<=t[i]&&aoki<=a[i]){
      takahashi = t[i];
      aoki = a[i];
    }else{
      if(takahashi%t[i]!=0)takahashi += t[i]-takahashi%t[i];
      if(aoki%a[i]!=0)aoki += a[i]-aoki%a[i];
      if(aoki/a[i]>=takahashi/t[i]){
        takahashi += t[i] * (aoki/a[i] - takahashi/t[i]);
      }else{
        aoki += a[i] * (takahashi/t[i] - aoki/a[i]);
      }
    }
  }
  cout << takahashi+aoki << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int board[30][30];
signed main() {
    int H, W; cin >> H >> W;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> board[i][j];
        }
    }

    int ans = INF;
    for(int x=0; x<H; x++) {
        for(int y=0; y<W; y++) {
            int sum = 0;
            for(int i=0; i<H; i++) {
                for(int j=0; j<W; j++) {
                    int dist = min(abs(i - x), abs(j - y));
                    sum += dist * board[i][j];
                }
            }
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) o++;
	}
      }
    }

    cout << o << endl;

    cin >> n >> x;
  }


  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int i;
  long long int a,b;
  cin>>a>>b;
  int c=1;
  for(i=1;i<=min(a,b);++i){
    if(a%i==0&&b%i==0){
      c*=i;
      a/=i;
      b/=i;
      i=1;
    }
  }
  cout<<c*a*b;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  if(n==m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n,m; cin >> n >> m;
  vi s(m),c(m);
  rep(i,m) cin >> s[i] >> c[i];
  bool ok = true;
  vi ans(n,-1);
  rep(i,m) {
    s[i]--;
    if(n != 1 && s[i] == 0 && c[i] == 0) ok = false;
    if(ans[s[i]] != -1 && ans[s[i]] != c[i]) ok = false;
    ans[s[i]] = c[i];
  }

  if(ok == false){
    cout << -1 << endl;
    return 0;
  }
  rep(i,n) {
    if(ans[i] == -1){
      if(n != 1 && i == 0) cout << 1;
      else cout << 0;
    }
    else{
      cout << ans[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#global count
#count = 0

def marge(A,left,mid,right):
    #    global count
    n1 = mid -left
    n2 = right -mid
    L = []
    R = []
    for i in range(left,n1+left):
        L.append(A[i])
    for i in range(mid,n2+mid):
        R.append(A[i])

    L.append(float("inf"))
    R.append(float("inf"))
    cnt = 0
    r_id,l_id = 0,0
    for k in range(left,right):
        if(L[l_id] <= R[r_id]):
            A[k] = L[l_id]
            l_id += 1
        else:
            A[k] = R[r_id]
            r_id += 1
            cnt += len(L)-1 - l_id

    return cnt

def margeSort(A,left,right):
    if left+1 < right:
        mid = int((left+right)/2)
        c1 = margeSort(A,left,mid)
        c2 = margeSort(A,mid,right)
        c3 = marge(A,left,mid,right)
        return c1+c2+c3
    else:
        return 0

n = int(input())
st = input()
A = list(map(int,st.split()))
ans = margeSort(A,0,n)

print(ans)

Measured memory_bytes: 32184
n = int(input())
A = list(map(int,input().split()))
B = []
for i in range(n):
    B.append(A[i]-(i+1))
B.sort()

if len(B)%2:
    ans = 0
    for i in range(n):
        ans += abs(B[i]-B[len(B)//2])
else:
    ans = float("inf")
    tmp = 0
    for i in range(n):
        tmp += abs(B[i]-B[len(B)//2-1])
    ans = min(ans, tmp)
    tmp = 0
    for i in range(n):
        tmp += abs(B[i]-B[len(B)//2])
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 100476
#include <stdio.h>

int main(void){
	int n;
	while(scanf("%d", &n),n){
		int card[256],temp[256]={0};
		int m,i,k;
		n*=2;
		
		for(i=0;i<n;i++){
			card[i]=i+1;
		}
		scanf("%d",&k);
		for(int j=0;j<k;j++){
			scanf("%d",&m);
			if(m==0){
				int count=0;
				for(i=0;i<n;i++){
					temp[i]=card[i];
				}
				for(i=0;i<n/2;i++){
					card[count]=temp[i];
					count++;
					card[count]=temp[i+n/2];
					count++;
				}
			}
			else {
				for(i=0;i<m;i++){
					temp[i]=card[i];
				}
				for(i=m;i<n;i++){
					card[i-m]=card[i];
				}
				for(i=0;i<m;i++){
					card[n-m+i]=temp[i];
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%d\n",card[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int n,ans,ans2,a,b,c;
int main(){
  while(cin>>n&&n){
    cin>>a>>b>>c;
    ans=a,ans2=b+c;
    for(int i=0;i<n-1;i++){
      cin>>a>>b>>c;
      if(ans2<b+c)ans=a,ans2=b+c;
    }
    cout<<ans<<' '<<ans2<<endl;
  }
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
    long long n,h; cin>>n>>h;
    long long dp[n][2]={};
    long long a=0,b=0,j;
    for(int i=0;i<n;i++)
    {
        cin>>dp[i][0]>>dp[i][1];
        if(dp[i][0]>a)
        {
            j = i; b = dp[i][1]; a = dp[i][0];
        }

        if(dp[i][0]==a and dp[i][1]<b)
        {
            j = i; b= dp[i][1];
        }

    }

    //cout<<j<<" "<<a<<" "<<b<<endl;

    vector<long long> v;
    bool c = false; long long sum =0,ans=0;

    for(int i =0;i<n;i++)
    {
        if(i==j) continue;
        else if(dp[i][1]>=a) v.push_back(dp[i][1]);
    }

    sort(v.begin(),v.end());
    
    for(int i=v.size()-1;i>=0;i--)
    {
        sum+=v[i];
        ans++;
        if(sum>=h)
        {
            c = true; break;
        }
    }

    if(c) {cout<<ans; return 0;}

    while(sum<h)
    {
        if(sum+b>=h)
        {
            ans++ ; sum+=b;
        }
        else 
        {
            ans++; sum+=a;
        }
    }

    cout<<ans;
}

Measured memory_bytes: 5824
# coding: utf-8


def main():
    K, A, B = map(int, input().split())

    if B - A <= 2:  # 差が2までなら叩きつづける
        return 1 + K

    K += -(A-1)

    if K % 2 == 0:
        return (K // 2 - 1) * (B - A) + B

    return (K // 2 - 1) * (B - A) + B + 1


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

ull f_u(ull n) { 
    ull count = 0,i; 
    for (i=5;n/i>0;i*=5) count+=n/i;
        
    return count; 
} 

int main(){
    ull n;cin>>n;
    ull ans=0;
    if(n%2==1) ans=0;
    else ans=f_u(n/2);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz              size()
#define pb              push_back
#define Fr              first
#define Sc              second
#define Log2(x)         (31^__builtin_clz(x))
#define endl            "\n"
#define int             ll
using namespace std;
typedef long long ll;
int a, b, c;
vector<double> v;
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int d=1000;
  int e=0;
  int f=0;
  rep(i,a){
 if(i==0){
 if(b[i]<=b[i+1]){
   e+=d/b[i];
   d%=b[i];
 }
 }
    else if(i==a-1){
    f=e*b[i]+d;
    }
    else{
      if(e==0){
    if(b[i-1]>=b[i]&&b[i]<=b[i+1]){
      e+=d/b[i];
    d%=b[i];
    }
        if(b[i-1]<=b[i]&&b[i]>=b[i+1]){
       d+=e*b[i];
      e=0;
    }
      }
      else{
         if(b[i-1]<=b[i]&&b[i]>=b[i+1]){
           d+=e*b[i];
      e=0;
    }
    if(b[i-1]>=b[i]&&b[i]<=b[i+1]){
      e+=d/b[i];
    d%=b[i];
    }   
      }
    }
 }
  out(f);
  
}

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

vector<vector<ll>> tree(200010, vector<ll>());
vector<ll> cnts(200010, 0);

void dfs(int n, ll x, int parent)
{
  cnts[n] += x;
  for (auto v:tree[n]) {
    if (v == parent) continue;
    dfs(v, cnts[n], n);
  }
}

int main()
{
  ll N;
  scanf("%lld",&N);
  ll Q;
  scanf("%lld",&Q);
  for(int i=0; i<N-1; i++){
    ll a,b;
    scanf("%lld",&a);
    scanf("%lld",&b);
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  for (int i=0; i<Q; i++){
    ll p,x;
    scanf("%lld",&p);
    scanf("%lld",&x);
    p--;
    cnts[p] += x;
  }
  dfs(0, 0, -1);
  for (int i=0; i<N; i++) {
    if (i==0) cout << cnts[i];
    else cout << " " << cnts[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    PY = []
    for i in range(m):
        p, y = map(int, input().split())
        PY.append([i, p, y])
    PY = sorted(PY, key=lambda x: x[2])
    PY = sorted(PY, key=lambda x: x[1])

    res = [] * m
    prev = PY[0][1]
    last = 0
    for i in range(m):
        idx, p, y = PY[i]
        if prev != p:
            last = 1
            prev = p
        else:
            last += 1

        id = str(p).zfill(6) + str(last).zfill(6)
        res.append([idx, id])

    res = sorted(res, key=lambda x: x[0])
    for i in res:
        print(i[1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 43444
use std::cmp::min;

fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let nums = get_line().split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect::<Vec<u64>>();
    let (a, b, k) = (nums[0], nums[1], nums[2]);
    let mut result: Vec<u64> = Vec::new();

    for i in 1..min(a, b) + 1 {
        if a % i == 0 && b % i == 0 { result.push(i); }
    }
    result.sort_by(|a, b| b.cmp(a));
    println!("{}", result[(k - 1) as usize]);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const double PI = 3.14159265358979323846;
const int MAX = 1e10;
const int MOD = 1e9+7;

const int MAX_N = 100005;



int main(int argc, char *args[]) {
	ll h; cin >> h;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		h -= a;
	}
	if (h <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0 ; i < m ; i++) {
            int k = sc.nextInt();
            List<Integer> l = new ArrayList<>();
            for (int j = 0 ; j < k ; j++) {
                l.add(sc.nextInt());
            }

            list.add(l);
        }

        int[] p = new int[m];

        for (int i = 0 ; i < m ; i++) {
            p[i] = sc.nextInt();
        }

        int count = 0;
        for (int i = 0 ; i < Math.pow(2, n) ; i++) {
            boolean flg = true;
            int[] b = new int[10];
            int temp = i;
            int index = 0;
            while (temp > 0) {
                b[index] = temp % 2;
                temp /= 2;
                index++;
            }
            for (int j = 0 ; j < m ; j++) {
                int d = 0;
                for (int k = 0 ; k < list.get(j).size() ; k++) {
                    if (b[list.get(j).get(k) - 1] == 1) d++;
                }
                if (d % 2 != p[j]) {
                    flg = false;
                }
            }
            if (flg) count++;
        }

        System.out.println(count);

    }

}

Measured memory_bytes: 22864
N, K = map(int, input().split())
S = input()
S = list(S)

if S[K-1]=="A":
    S[K-1] = "a"
if S[K-1]=="B":
    S[K-1] = "b"
if S[K-1]=="C":
    S[K-1] = "c"
S_ = ""
for x in S:
    S_+=x
print(S_)

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

#define ll long long int

int memo[(int)1e5 + 1];
vector<int> adj[(int)1e5 + 1];

bool vis[(int)1e5 + 1];

int dfs(int x) {
	
	if(vis[x])return memo[x];

	vis[x] = true;
	
	int temp = 1;

	for(int i = 0; i < adj[x].size(); i++) {
		memo[x] = max(memo[x], temp + dfs(adj[x][i]));
	}

	return memo[x];
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m; cin >> n >> m;
	int s,t;
	
	while(m--) {
		cin >> s >> t;
		adj[s].push_back(t);
	}

	for(int i = 1; i <= n; i++) {
		dfs(i);
	}

	int ans = 0;
	
	for(int i = 1; i <= n; i++) {
		ans = max(ans,memo[i]);
	}

	cout << ans << '\n';

	return 0;
}

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

int main() {
  int N;
  string A;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string x;
    cin >> x;
    
    if (x == "Y") {
     A = "OK";
      break;
    }

  }
  
  if (A == "OK")
    cout << "Four" << endl;
  
  else 
    cout << "Three" << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    ll ans = 0;
    map<ll,int> mp1;
    ll temp = N;
    vector<ll> sosu;
    while(temp>1){
        bool watta = false;
        for(ll i=2;i<=sqrt(temp);++i){
            if(temp%i==0){
                temp /= i;
                ++mp1[i];
                if(mp1[i]==1){
                    sosu.push_back(i);
                }
                watta = true;
                break;
            }
        }
        if(!watta){
            sosu.push_back(temp);
            break;
        }
    }
    vector<ll> z;
    for(ll s:sosu){
        ll semp = s;
        while(semp<=N){
            z.push_back(semp);
            semp *= s;
        }
    }
    sort(ALL(z));
    
    map<ll,int> mp2;
    for(ll x:z){
        mp2[x]++;
        if(N%x==0 && mp2[x]==1){
  
            N /= x;
            ++ans;
            if(N==1){break;}
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


int main()
{
	int N, K;
	double p[200005], t;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> t;
		p[i] = (1 + t) / 2;
	}
	double s[200005], m;
	m = 0;
	for (int i = 0; i < N; i++)
	{
		if (i == 0) s[i] = p[i];
		else s[i] = s[i - 1] + p[i];
		if (i >= K) s[i] -= p[i - K];
		m = max(m, s[i]);
	}
	printf("%f", m);
}

Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


class Main {

	public static void main(String... args) {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			
			Paper paper = new Paper();
			while (scanner.hasNext()) {
				String line = scanner.nextLine();
				String[] lines = line.split(",");
				paper.drop(Integer.parseInt(lines[0]),
						Integer.parseInt(lines[1]), Integer.parseInt(lines[2]));
			}
			paper.printOutput();
			
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
	
	static class Paper {
		private List<List<Integer>> X_LIST = new ArrayList<List<Integer>>();
		Paper() {
			for (int i = 0; i < 10; i++) {
				List<Integer> yList = new ArrayList<Integer>();
				for (int j  = 0; j < 10; j++) {
					yList.add(0);
				}
				X_LIST.add(yList);
			}
		}
		
		void drop(int x, int y, int size) {
			dropCell(x, y);
			
			switch (size) {
			case 3:
				dropCell(x + 2, y);
				dropCell(x - 2, y);
				dropCell(x, y + 2);
				dropCell(x, y - 2);
			case 2:
				dropCell(x + 1, y + 1);
				dropCell(x + 1, y - 1);
				dropCell(x - 1, y + 1);
				dropCell(x - 1, y - 1);
			case 1:
				dropCell(x + 1, y);
				dropCell(x - 1, y);
				dropCell(x, y + 1);
				dropCell(x, y - 1);
			default:
				break;
			}
		}
		
		void dropCell(int x, int y) {
			if (x < 0 || y < 0 || 9 < x || 9 < y) {
				return;
			}
			List<Integer> yList = X_LIST.get(x);
			yList.set(y, yList.get(y) + 1);
		}
		
		void printOutput() {
			int whiteNum = 0;
			int maxDensity = 0;
			for (List<Integer> yList : X_LIST) {
				for (Integer i : yList) {
					whiteNum = (0 < i) ? whiteNum : whiteNum + 1;
					maxDensity = (maxDensity < i) ? i : maxDensity;
				}
			}
			System.out.println(whiteNum);
			System.out.println(maxDensity);
		}
	}
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

vector<pair<ll,ll>> G;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin >>n  >> m;
  REP(i,m){
      ll a,b;cin>>a>>b;a--;b--;
      G.push_back(mp(a,b));
  }
  reverse(all(G));
  UnionFind UF(n);
  stack<ll> ans;
  ll tmp = n * (n-1) /2;
  REP(i,m){
      ans.push(tmp);
      ll f = G[i].first;   
      ll s = G[i].second;
      ll a = UF.size(f);
      ll  b= UF.size(s);
      if(!UF.findSet(f,s)){
          tmp += a*(a-1)/2;
          tmp += b*(b-1)/2;
          tmp -= (a+b)*(a+b-1)/2;
      }
      UF.unionSet(f, s);
  }
  REP(i,m){
      ll tmp = ans.top();ans.pop();
      cout<< tmp << endl;
  }


}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
vector<int> ar[100001];
int a[100001];

int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
}
int x,y;
while(m--)
{
	cin>>x>>y;
	ar[x].pb(y);
	ar[y].pb(x);
}
int ans=0;
for(int i=1;i<=n;i++)
{
	if(ar[i].size()==0)
	{
		ans++;
	}
	else
	{
		int flag=1;
		for(int res:ar[i])
		{
			if(a[i]<=a[res])
			{
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
	
			ans++;
		}
	}
}
cout<<ans<<endl;
}



Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int a, b, c, k; cin >> a >> b >> c >> k;
    int sum = a + b + c;
    int ma = max(a, max(b, c));
    int maxn = ma;
    while(k--) maxn *= 2;
    cout << sum - ma + maxn << endl;
}

Measured memory_bytes: 256
N = gets.to_i
H = Hash.new{100}
N.times{
    h = Hash.new{0}
    s = gets.chomp
    ("a" .. "z").each{|c|
        h[c] = s.count(c)
    }
    #warn h.inspect
    h.each{|k, v|
        if H[k] > v
            H[k] = v
        end
    }
}
puts H.map{|k, v| k * v}.join


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
using namespace std;
const ll MOD=1000000007ll;
const int MAX=510000;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
int main()
{
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int n = h + w;
    fact[0]=1;
        // 階乗の計算
	REP(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[n]=power(fact[n], MOD-2);
        // 逆元の計算
	FORR(i, 0, n) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
    long long ans=0;
    for (int i = 0;i <= h-a-1;i++)
    {
        ans += (comb(i+b-1,i)*comb(w-b-1+h-i-1,w-b-1)) % MOD;
        // cout << comb(i+b-1,i) << comb(w-b-1+h-i-1,w-b-1) << endl;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 5888