akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main() {
  std::vector<std::vector<int>> a(3, std::vector<int>(3));
  for (auto &aa : a) {
    std::cin >> aa.at(0) >> aa.at(1) >> aa.at(2);
  }

  int n;
  std::cin >> n;

  std::vector<std::vector<bool>> c(3, std::vector<bool>(3));
  for (int i = 0; i < n; ++i) {
    int b;
    std::cin >> b;

    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (a.at(j).at(k) == b) {
          c.at(j).at(k) = true;
        }
      }
    }
  }

  for (const auto &v : c) {
    if (v.at(0) && v.at(1) && v.at(2)) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  for (int j = 0; j < 3; ++j) {
    if (c.at(0).at(j) && c.at(1).at(j) && c.at(2).at(j)) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  if (c.at(0).at(0) && c.at(1).at(1) && c.at(2).at(2)) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  if (c.at(0).at(2) && c.at(1).at(1) && c.at(2).at(0)) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;
  return 0;
}


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

using namespace std;

int solve(int64_t k, const std::string& s) {
  int notOne = 0;
  for (; notOne < s.size(); notOne++) {
    if (s[notOne] != '1') {
      break;
    }
  }
  if (k <= notOne) {
    return 1;
  }
  return static_cast<int>(s[notOne] - '0');
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  int64_t k;
  std::cin >> s;
  std::cin >> k;
  std::cout << solve(k, s) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN printf("\n")
#define LL long long
inline LL read(){
	LL x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=-1;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return x*y;
}
int n;
int f[30005];
int a[1006],b[1006];
int main(){
	int h=read();n=read();
	for(R int i=1;i<=n;i++) a[i]=read(),b[i]=read();
	std::memset(f,0x3f,sizeof f);
	f[0]=0;
	for(R int i=1;i<=n;i++){
		for(R int j=1;j<=3e4;j++){
			if(j-a[i]>-1) f[j]=std::min(f[j],f[j-a[i]]+b[i]);
		}
	}
	int ans=1e9;
	for(R int i=h;i<=3e4;i++) ans=std::min(ans,f[i]);
	std::printf("%d",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int mod;
int F[50][maxn]; 
int f(int i, int j)
{
	if(~F[i][j]) return F[i][j];
	if(i == 0 && j == 0) return F[i][j] = 1;
	F[i][j] = 0;
	int s = (j == 0), e = min(i, 9);
	for(int k = s; k <= e; ++k)
		F[i][j] |= f(i - k, (j * 10 + k) % mod);
	return F[i][j];
}
int main()
{
	memset(F, -1, sizeof F);
	scanf("%d", &mod);
	for(int i = 1; i <= 46; ++i)
		if(f(i, 0))
		{
			printf("%d\n", i);
			return 0;
		}
	return 0;
}
	

Measured memory_bytes: 44032
import java.util.*;

public class Main {
    public static void main(String[] aa){
        int N;
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i=0; i<3*N; i++){
            a.add(scanner.nextInt());
        }
        Collections.sort(a);

        long sum = 0;
        for (int i=3*N-2, cnt = 0; cnt != N; i-=2, cnt++){
            sum += a.get(i);
        }
        System.out.println(sum);
    }
}


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

int pm(int x)
{
	if(x%2==1){
		return 1;
	}else{
		return -1;
	}
}


int compare_int(const void *a, const void *b)
{
	long *A = (long *)a;
	long *B = (long *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int i,j,k;
	long int x[1010];
	long int y[1010];
	long int z[1010];
	long int sum[1010];
	long int temp;
	long int max=0;
	
	//データの読み込み
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		scanf("%ld %ld %ld",&x[i],&y[i],&z[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	for(i=0;i<8;i++){
		for(j=0;j<n;j++){
			sum[j]=x[j]*pm(i)+y[j]*pm(i/2)+z[j]*pm(i/4);
		}
		qsort(sum, n, sizeof(long int), compare_int);
		temp=0;
		for(j=0;j<m;j++){
			temp=temp+sum[j];
		}
		if(temp>max){
			max=temp;
		}
	}
	
	
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	printf("%ld",max);
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
const ll MAXN=1e5+10;
#define MAX 2*1e9;
ll dp[MAXN],h[MAXN],i,j;
ll jump(ll  n,ll k)
{
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	REP(i,2,n)
	{	
		dp[i]=MAX;
		ll a=0;
		for(j=i-1;j>=max(a,i-k);j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}

	}
	return dp[n-1];
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n,k;
	cin>>n>>k;
	rep(i,n)
	cin>>h[i];
	cout<<jump(n,k);
	return 0;
}

Measured memory_bytes: 1792
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int low[123][123],req[12][12],remain[123][123];
int main(){
    std::ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int i,j;
    f(i,1,a+1){
    	f(j,1,b+1){
    		cin>>req[i][j];
    	}
    }
    rep(i,101){
    	rep(j,101){
    		remain[i][j]=1;
    		low[i][j]=0;
    	}
    }
    int val,p,q;
    f(i,1,a+1){
    	f(j,1,b+1){
    		rep(p,101){
    			rep(q,101){
    				val=i*p+j*q;
    				if(req[i][j]>val){
    					low[p][q]=max(low[p][q],req[i][j]-val);
    				}
    			}
    		}
    	}
    }
    int flag;
    f(i,1,a+1){
    	f(j,1,b+1){
    		flag=0;
    		rep(p,101){
    			rep(q,101){
    				val=i*p+j*q+low[p][q];
    				if(val==req[i][j]){
    					remain[p][q]=1;
    					flag=1;
    				}
    				
    			}
    		}
    		if(flag==0){
    			cout<<"Impossible"<<endl;
    			return 0;
    		}
    	}
    }
    int edg=0;
    cout<<"Possible"<<endl;
    cout<<202<<" "<<10401<<endl;
    cout<<201<<" "<<1<<" X"<<endl;
    edg++;
    f(i,1,100){
    	edg++;
    	cout<<i<<" "<<i+1<<" X"<<endl;
    }
    edg++;
    cout<<200<<" "<<202<<" Y"<<endl;
    f(i,101,200){
    	edg++;
    	cout<<i<<" "<<i+1<<" Y"<<endl;
    }
    f(i,1,101){
    	f(j,1,101){
    		edg++;
    		if(remain[i][j]==1)
    			cout<<i<<" "<<200-j+1<<" "<<low[i][j]<<endl;
    	}
    }
    f(i,1,101){
    	edg++;
    	if(remain[0][i]==1)
    		cout<<201<<" "<<200-i+1<<" "<<low[0][i]<<endl;
    }
    f(i,1,101){
    	edg++;
    	if(remain[i][0]==1)
    		cout<<i<<" "<<202<<" "<<low[i][0]<<endl;
    }
    edg++;
    cout<<201<<" "<<202<<" "<<low[0][0]<<endl;
    //cout<<edg<<endl;
    cout<<201<<" "<<202<<endl;

    return 0;  
    
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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


    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return 0;
}

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

int main ()
{
	vector<int> arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	int k;
	
	cin >> k;
	cout << arr[k - 1] << '\n';
	
	
	
	return 0;
}	

Measured memory_bytes: 256
from collections import *
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
n,m,k=map(int,input().split())
uf=UnionFind(n)
d=[0]*(n+1)
for _ in [0]*m:
  a,b=map(int,input().split())
  d[a]+=1
  d[b]+=1
  uf.unite(a,b)
to=[[]for _ in [0]*(n+1)]
for _ in [0]*k:
  a,b=map(int,input().split())
  to[a]+=[b]
  to[b]+=[a]
a=[]
b=dict(Counter([uf.find(i) for i in range(1,n+1)]))
for i,j in enumerate(d):
  if i==0:continue
  ans=b[uf.find(i)]-j-1
  for k in to[i]:
    if uf.same(i,k):ans-=1
  a+=[ans]
print(*a)

Measured memory_bytes: 121476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

double dist(vector<int> &x, vector<int> &y, int a, int b){
    double dx = x[a] - x[b];
    double dy = y[a] - y[b];
    return sqrt(dx * dx + dy * dy);
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    double ans = 0.0;
    int cnt = 0;
    vector<int> p(n);
    rep(i,n) p[i] = i;
    do {
        rep(i,n-1){
            ans += dist(x,y,p[i],p[i+1]);
        }
        cnt++;
    } while (next_permutation(p.begin(), p.end()));
    ans /= cnt;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; ll a[SZ],B,W,qz[SZ];
bool ok(ll t)
{
	ll mo=0;
	for(int i=2;i<=n-1;i+=2)
		if(qz[i-1]-mo>=t) mo=min(mo,qz[i]);
	return qz[n]-mo>=t;
}
ll calc()
{
	ll l=-1e18,r=1e18;
	while(l<r)
	{
		ll g=l+((r-l+1)>>1);
		if(ok(g)) l=g; else r=g-1;
	}
	return l;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		if(i%2==0) W+=a[i],qz[i]=qz[i-1]-a[i];
		else B+=a[i],qz[i]=qz[i-1]+a[i];
	}
	if(n%2==0)
	{
		printf("%lld %lld\n",max(W,B),min(W,B));
		return 0;
	}
	ll ans=W+calc();
	printf("%lld %lld\n",ans,B+W-ans);
}


Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int dp[100001];
int main()
{
	int n, d, x;
	int p[11][11];
	cin >> n >> d >> x;
	REP(i, 0, d) {
		REP(j, 0, n) {
			cin >> p[i][j];
		}
	}

	REP(i, 0, d - 1) {
		int max_x = x;
		REP(j, 0, x + 1) dp[j] = j;

		REP(j, 0, n) {
			REP(k, p[i][j], x+1) {
				dp[k] = max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
				max_x = max(max_x, dp[k]);
			}
		}
		x = max_x;
	}

	cout << x << endl;
    return 0;
}

Measured memory_bytes: 3148
#include<cstdio>
#include<map>
using namespace std;
typedef long long int ll;
int main(){
	map<ll,ll> mp;
	ll ans = 0;
	ll n;
	scanf("%lld",&n);
	ll a[200000];
	for(ll i=0;i<n;i++){
		scanf("%lld",a+i);
	}
	for(ll i=0;i<n;i++){
		ans += mp[-a[i]+i+1];
		mp[a[i]+i+1]++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 27596
#include <cstdio>

const int MAXN=2e5+5;

typedef long long int ll;

int N;
int A[MAXN];

ll fromL[MAXN];
ll fromR[MAXN];

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",A+i);

    for(int i=1;i<=N;i++){
        int next=i+A[i];
        if (next<=N) fromL[next]++;
    }

    for(int i=1;i<=N;i++){
        int prev=i-A[i];
        if (prev>0) fromR[prev]++;
    }

    ll ans=0;
    for(int i=1;i<=N;i++){
        ans+=fromL[i]*fromR[i];
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 5612
n = int(input())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n - 1, -1, -1):
    ans += (b[i] - (a[i] + ans) % b[i]) % b[i]

print(ans)

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

int main() {
  int64_t N;
  cin>>N;
  int Z=0,X=-1;
  while(N>=10){
    Z+=N%10;
    X+=9;
    N=N/10;
  }
  Z+=N;
  X+=N;
  cout<<max(Z,X)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var A = vals[0];
        var B = vals[1];

        var ks = new long[] { (A - B) / 2, (-A - B) / 2, (A + B) / 2 };
        foreach (var k in ks)
        {
            if (Math.Abs(A - k) == Math.Abs(B - k))
            {
                Console.WriteLine(k);
                return;
            }
        }

        Console.WriteLine("IMPOSSIBLE");
    }
}

Measured memory_bytes: 11348
n=gets.to_i
r=(1..n-1).map{gets.split.map(&:to_i)}

state=[1]+[0]*(n-2)+[2]
root=(r+r.map{|a,b|[b,a]}).group_by{|a,b|a}.sort_by{|k,v|k}.map{|k,v|v.map{|a,b|b-1}}

fen=root[0]
snu=root[-1]
while fen[0]||snu[0]
  fen=fen.select{|i|state[i]==0}.flat_map{|i|state[i]=1;root[i]}
  snu=snu.select{|i|state[i]==0}.flat_map{|i|state[i]=2;root[i]}
end

puts state.count(1)>n/2?"Fennec":"Snuke"


Measured memory_bytes: 38936
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	
	int a,b,c,sum=0,i=0,j=0;
	
	cin >> a >> b >> c;

	while(1){
	if(sum>=c){
	break;
	}
	i++;
	j++;
	sum+=a;
	if(i==7){
	sum+=b;
	i=0;
	}
	}
	cout << j << endl;
	
	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;


int main(void){
    double x,t;
    cin>>t>>x;

    cout<<fixed<<setprecision(10)<<t/x<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
	}
	
	public static void A(Scanner sc) {
		int n = sc.nextInt();
		int k = sc.nextInt()-1;
		String s = sc.next();
		System.out.println(s.substring(0,k)+Character.toLowerCase(s.charAt(k))+s.substring(k+1,n));
	}
	
	public static void B(Scanner sc) {
		String s = sc.next();
		if((Integer.valueOf(s.substring(0,2))==0 || Integer.valueOf(s.substring(0,2))>=13) && Integer.valueOf(s.substring(2,4))<=12 && Integer.valueOf(s.substring(2,4))>=1) System.out.println("YYMM");
		else if((Integer.valueOf(s.substring(2,4))>=13 ||Integer.valueOf(s.substring(2,4))==0)&& Integer.valueOf(s.substring(0,2))<=12 && Integer.valueOf(s.substring(0,2))>=1) System.out.println("MMYY");
		else if(Integer.valueOf(s.substring(2,4))<=12 && Integer.valueOf(s.substring(0,2))<=12 && Integer.valueOf(s.substring(2,4))>=1 && Integer.valueOf(s.substring(0,2))>=1) System.out.println("AMBIGUOUS");
		else System.out.println("NA");
	}
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    ll num[210000]={};
    rep(i,n){
        ll a; cin>>a;
        num[--a]++;
    }
    sort(num,num+n,greater<ll>());
    ll ans=0;
    rep(i,k) ans+=num[i];
    cout<<n-ans<<endl;
    return 0;
}

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

typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<ll> nums(N + 1, 0);
	vector<ll> addsums(N + 1, 0);
	vector<ll> xorsums(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> nums[i];
		addsums[i] += addsums[i - 1] + nums[i];
		xorsums[i] = xorsums[i - 1] ^ nums[i];
	}
	ll ans = 0;
	ll l = 1, r = 1;
	for (; r <= N; r++) {
		for (; l <= N && addsums[r] - addsums[l - 1] != (xorsums[r] ^ xorsums[l - 1]); l++);
		ans += r - l + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
sx,sy,tx,ty=map(int,input().split())
h=ty-sy
w=tx-sx
print('U'*h+'R'*w+'D'*h+'L'*w+'L'+'U'*(h+1)+'R'*(w+1)+'DR'+'D'*(h+1)+'L'*(w+1)+'U')

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  double a; cin>>a;
  coutd(2*a*PI);
}

Measured memory_bytes: 3796
def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        # for j in range(1, k + 1):
        #     if i - j < 0:
        #         break
        #     dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
double x[1100],y[1100],r[1100];
int tmp = 0;
double dist[1100];
const int INF = 1001001001001ll;
vector<pair<int,double>> graph[1100];
signed main(){
    double xs,ys,xg,yg;cin >> xs >> ys >> xg >> yg;
    int n;cin >>n;
    rep(i,n)cin >> x[i] >> y[i] >> r[i];
    rep(i,n){
        for(int j = i+1;j < n;j++){
            double hoge = sqrt((x[i] - x[j])*(x[i] - x[j])+(y[i] -y[j])*(y[i] - y[j]));
            graph[i].emplace_back(j,max((double)0,hoge -r[i] - r[j]));
            graph[j].emplace_back(i,max((double)0,hoge -r[i] - r[j]));
            
        }
        
    }
    rep(i,n){
        double hoge = sqrt((xs-x[i])*(xs - x[i]) + (ys - y[i])*(ys - y[i]));
        graph[n].emplace_back(i,max((double)0,hoge - r[i]));
        graph[i].emplace_back(n,max((double)0,hoge - r[i]));
        hoge = sqrt((xg-x[i])*(xg - x[i]) + (yg - y[i])*(yg - y[i]));
        graph[n+1].emplace_back(i,max((double)0,hoge - r[i]));
        graph[i].emplace_back(n+1,max((double)0,hoge - r[i]));

    }
    graph[n].emplace_back(n+1,sqrt((xs - xg)*(xs - xg)+(ys -yg)*(ys-yg)));
    graph[n+1].emplace_back(n,sqrt((xs - xg)*(xs - xg)+(ys -yg)*(ys-yg)));
    int s = n,g = n+1;
    priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> q;
    rep(i,n+2)dist[i] = INF;
    q.emplace(0,s);
    dist[s] = 0;
    while(q.size()){
        
        auto hoge = q.top();q.pop();
        int now = hoge.second;
        double d = hoge.first;
        if(dist[now] < d)continue;
        for(auto next:graph[now]){
            if(dist[next.first] > dist[now] + next.second){
                dist[next.first] = dist[now] + next.second;
                q.emplace(dist[next.first],next.first);
              
            }
        }
    }
    printf("%12.12lf",dist[g]);


    return 0;
}


Measured memory_bytes: 22660
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n <= 599) cout << 8 << endl;
    else if(n <= 799) cout << 7 << endl;
    else if(n <= 999) cout << 6 << endl;
    else if(n <= 1199) cout << 5 << endl;
    else if(n <= 1399) cout << 4 << endl;
    else if(n <= 1599) cout << 3 << endl;
    else if(n <= 1799) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
	
	int num1,num2,sum=0,i;
	while(scanf("%d %d",&num1,&num2)!=EOF){
	
	sum=num1+num2;
	
	for(i=0;sum>0;++i){
		sum=sum/10;
	}
	printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1028
main :: IO ()
main = do
  n <- readLn :: IO Int
  k <- readLn :: IO Int
  print $ solver n k

solver :: Int -> Int -> Int
solver n k = greedy n 1
  where
    greedy 0 x = x
    greedy i x = if a < b then greedy (i - 1) a else greedy (i - 1) b
      where
        a = x * 2
        b = x + k

Measured memory_bytes: 3776
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000000000000000LL
using namespace std;
long long prim(int V, vector<pair<long long, long long>> X[]) {
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long> > > Q;
	long long dist[101], color[101];
	for (int i = 0; i < V; i++) { dist[i] = INF; color[i] = WHITE; }
	dist[0] = 0; color[0] = GRAY; Q.push(make_pair(0, 0));
	while (!Q.empty()) {
		pair<long long, long long>pa = Q.top(); Q.pop();
		long long a1 = pa.first, a2 = pa.second; color[a2] = BLACK;
		for (int i = 0; i < X[a2].size(); i++) {
			long long to = X[a2][i].first, leng = X[a2][i].second;
			if (dist[to] > leng && color[to] < BLACK) {
				dist[to] = leng; Q.push(make_pair(dist[to], to));
			}
		}
	}
	long long sum = 0; for (int i = 0; i < V; i++) { sum += dist[i]; }//0-indexed
	return sum;
}
int n, m, u, v, w; vector<pair<long long, long long> > g[100];
int main() {
	while (scanf("%d", &n), n) {
		scanf("%d", &m);
		for (int i = 0; i < n; i++) g[i].clear();
		for (int i = 0; i < m; i++) {
			scanf("%d,%d,%d", &u, &v, &w);
			g[u].push_back(make_pair((long long)(v), (long long)(w / 100 - 1)));
			g[v].push_back(make_pair((long long)(u), (long long)(w / 100 - 1)));
		}
		cout << prim(n, g) << endl;
	}
}

Measured memory_bytes: 3348
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

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

vector<pair<ll,ll>> primeFactorDecomp(ll n){
      vector<pair<ll,ll>> ret;
      ll m=n;
      for(int i=2;i*i<=m;i++){
            if(n%i!=0) continue;
            int cnt=0;
            while(n%i==0){
                  cnt++;
                  n/=i;
            }
            ret.push_back({i,cnt});
      }
      if(n>1){
            ret.push_back({n,1});
      }
      return ret;
}
vector<pair<ll,ll>> fact_wa(vector<pair<ll,ll>>&a,ll n){
      ll m=n;
      for(int i=2;i*i<=m;i++){
            if(n%i!=0) continue;
            int cnt=0;
            while(n%i==0){
                  cnt++;
                  n/=i;
            }
            bool ok=false;
            for(auto &p:a){
                if(p.first==i){
                    ok=true;
                    p.second=p.second+cnt;
                }
            }
            if(!ok){
                a.push_back({i,cnt});
            }
      }
      if(n>1){
        bool ok=false;
            for(auto &p:a){
                if(p.first==n){
                    ok=true;
                    p.second++;
                }
            }
        if(!ok){
            a.push_back({n,1});
        }
      }
      return a;
}

int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<P> hoge=primeFactorDecomp(2);
    for(int i=3;i<=n;i++){
    hoge=fact_wa(hoge,i);
    }
    /*for(auto ans:hoge){
        cout<<ans.first<<" "<<ans.second<<endl;
    }*/
    int asss=0;
    rep0(i,hoge.size()-2){
        for(int j=i+1;j<=hoge.size()-2;j++){
            for(int k=0;k<hoge.size();k++){
                if(hoge[i].second>=4&&hoge[j].second>=4&&hoge[k].second>=2&&i!=k&&j!=k){
                    asss++;
                }
            }
        }
    }
    rep0(i,hoge.size()){
        rep0(j,hoge.size()){
            if(hoge[i].second>=14&&hoge[j].second>=4&&i!=j){
                asss++;
            }
        }
    }
    rep0(i,hoge.size()){
        rep0(j,hoge.size()){
            if(hoge[i].second>=24&&hoge[j].second>=2&&i!=j){
                asss++;
            }
        }
    }
    rep0(i,hoge.size()){
            if(hoge[i].second>=74){
                asss++;     
        }
    }

    cout<<asss<<endl;
    return 0;
}


Measured memory_bytes: 256
from statistics import mean

N = input()
a = [int(x) for x in input().split(' ')]

avg = mean(a)

tmp = []
result = []
for x in a:
    tmp.append(abs(x - avg))
    
tmp_min = min(tmp)
for i in range(len(tmp)):
    if tmp[i] == tmp_min:
        print(i)
        break

Measured memory_bytes: 5144
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputStr = scanner.nextLine();

        int inputVal = Integer.valueOf(inputStr);
        int ans = 0;

        while (inputVal > 0) {
            int length = String.valueOf(inputVal).length();
            if (length == 1) {
                ans += inputVal;
                inputVal = 0;
                continue;
            }
            int nextVal = 0;

            for (int i = 0; i < length -1; i++) {
                int a = (int)Math.pow(10, i) * 9;
                nextVal += a;
            }

            if (length % 2 == 1) ans += (inputVal - nextVal);
            inputVal = nextVal;
        }

        System.out.println(ans < 0? 0: ans);
    }
}

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

def main():
    n = int(input())
    G = [[0]*n for _ in range(n)]
    for _ in range(n):
        a = list(map(int, input().split()))
        u = a[0] - 1
        k = a[1]
        for i in range(k):
            v = a[2+i] - 1
            G[u][v] = 1
    for g in G:
        print(' '.join(list(map(str, g))))

if __name__ == '__main__': main()


Measured memory_bytes: 5680
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> ans;
    int cnt = 0, before_h; cin >> before_h;
    rep (i, 0, N-1) {
        int h; cin >> h;
        if (h > before_h) {
            ans.push_back(cnt);
            cnt = 0;
        } else {
            cnt++;
        }
        before_h = h;
    }
    ans.push_back(cnt);

    cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;




public class Main {
	   static int N=1010;
	   static int n;
	   static Double []x=new Double[N];
	   static Double []y=new Double[N];
	   static Double []r=new Double[N];
	   static Double []dist=new Double[N];
	   static Double [][]map1=new Double[N][N];
	   static int[] vis=new int[N];
	   
       public static void main(String[] args) {
          Scanner input=new Scanner( System.in);
          String string =input.next();
        
          int len=string.length();
          string+="       ";
          String s1="dream",s2="erase";
          int flag=1;
          for(int i=0;i<len;i++)
           {
        	  if(flag==0) break;
        	  
        	  if(string.charAt(i)=='d') {
        		  
        		  int j;
        		  for(j=i+1;j<=i+4;j++){
        			 if(string.charAt(j)!=s1.charAt(j-i)){
        				 flag=0;
        				 break;
        			 }
        		   }
        		  if(flag==0) break;
        		  i=j;
                  if(string.charAt(i)=='e'&&string.charAt(i+1)=='r')
                  {
                	  if(string.charAt(i+2)=='e'||string.charAt(i+2)=='d'||i+2==len)
                	  {
                		  i=i+1;
                	  }
                	  else i=j-1;
            
                  }
                  else
                	  i=j-1;
               }
        	  else if(string.charAt(i)=='e'){
        		  int j;
        		  for(j=i+1;j<=i+4;j++)
        		  {
        			 if(string.charAt(j)!=s2.charAt(j-i)){
        				 flag=0;
        				 break;
        			 }
        		   }
        		  if(flag==0) break;
        		  i=j;
        		  //System.out.println(i);
                  if(string.charAt(i)=='r')
                  {
                	  if(string.charAt(i+1)=='e'||string.charAt(i+1)=='d'||i+1==len)
                	  {
                		  i=i;
                	  }
                	  else i=j-1;
            
                  }
                  else i=j-1;
        	  }
        	  else {
        		 flag=0;
 				 break;
			  }
        	  //System.out.println(i);
        	  if(flag==0) break;
           }
          if(flag==0)
        	  System.out.println("NO");
          else
        	  System.out.println("YES");
     //  System.out.printf("%.10f",dist[2]);
          
	}

}


Measured memory_bytes: 30464
#include <bits/stdc++.h>
using namespace std;
int64_t kurikaesi (int64_t H){
	if(H == 1){
    	return 1;
    }
  	if(H != 1){
    	return 2*kurikaesi(H/2) +1;
    }
  
}


int main() {
int64_t H;
  cin >> H;
  cout << kurikaesi(H) << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	cin>>n>>m;
	cout<<n*m; 
}


Measured memory_bytes: 3636
s=input()
t=input()
ans=''
a=[]
count=0
while ans=='' and count<100:
    for i,j in zip(s,t):
        if i!=j:
            if j in a:
                ans='No'
            s=s.replace(i,'.').replace(j,i).replace('.',j)
            a.append(j)
            break
    else:ans='Yes'
    count+=1
print(ans)

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Entrance Examination
            var line = ReadLine();
            double t = line[0];
            double x = line[1];

            Console.WriteLine(t / x);
        }

        static List<double> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<double>();

            foreach (var s in array)
            {
                double num = double.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 13140
import std.stdio, std.range, std.conv, std.string, std.array, std.functional;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;

void main()
{
    auto N = readln().strip.to!(long);
    foreach(n; N..1000)
    {
        if(n%10 == n/10%10 && n%10 == n/100%10)
        {
            writeln(n);
            return;
        }
    }
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10**6)

n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)
num = [0 for _ in range(n)]
c = list(map(int, input().split()))
h = []
for i in range(n):
	heappush(h, -c[i])

def dfs(x):
	global h
	for v in adj[x]:
		if num[v] != 0:
			continue
		num[v] = -heappop(h)
		dfs(v)
	return

num[0] = -heappop(h)
dfs(0)
print(sum(c) - max(c))
print(*num)

Measured memory_bytes: 14576
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		double ans = 0;
		int[] v = new int[N];
		for(int i=0;i<N;i++) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		for(int i=0;i<N;i++) {
			if(i==0) {
				ans = v[i];
			} else {
				ans = (ans+v[i])/2.0;
			}
		}
		System.out.printf("%.5f",ans);


	}
}

Measured memory_bytes: 27396
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               //情况1
    else if(b>=0)puts("Zero");             //情况2
    else if((a&1)^(b&1))puts("Positive");  //情况3
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

typedef long long LL;
const int Mod = 998244353;
const int MN = 405;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int Fac[MN], iFac[MN];
void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}

int N, A[MN], B[MN], SA, SB;
int f[MN][MN], g[MN][MN], Ans;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
		scanf("%d%d", &A[i], &B[i]),
		SA += A[i], SB += B[i] - 1;
	Init(SB);
	SA = SB = 0;
	f[0][0] = Mod - 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= SA + A[i]; ++j)
			for (int k = 0; k <= SB + B[i] - 1; ++k)
				g[j][k] = 0;
		for (int j = 0; j <= SA; ++j) {
			int *G = g[j + A[i]];
			for (int k = 0; k <= SB; ++k)
				for (int x = 0, c = 1; x < B[i]; ++x, c = (LL)c * A[i] % Mod)
					G[k + x] = (G[k + x] + (LL)c * iFac[x] % Mod * f[j][k]) % Mod;
		}
		SA += A[i], SB += B[i] - 1;
		for (int j = 0; j <= SA; ++j)
			for (int k = 0; k <= SB; ++k) {
				f[j][k] -= g[j][k];
				f[j][k] += (f[j][k] >> 31) & Mod;
			}
	}
	for (int j = 1; j <= SA; ++j) {
		int v = qPow(j, Mod - 2);
		int c = (LL)SA * v % Mod;
		for (int k = 0; k <= SB; ++k, c = (LL)c * v % Mod)
			Ans = (Ans + (LL)Fac[k] * c % Mod * f[j][k]) % Mod;
	}
	printf("%d\n", Ans);
	return 0;
}

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

char s[1000123];
pair<int, int> x[1000123], y[1000123];

int main()
{
	int n, c = 0, d = 0;
	cin >> n;
	rep(i, n) {
		int a = 0, b = 0;
		scanf("%s", s);
		for(int j = 0; s[j]; ++j) {
			if(s[j] == '(') {
				++b;
			}
			else {
				if(b) --b;
				else ++a;
			}
		}
		if(a <= b) x[c++] = {a, b};
		else y[d++] = {-b, a};
	}
	sort(x, x+c);
	sort(y, y+d);
	int cnt = 0;
	rep(i, c) {
		if(cnt >= x[i].first) cnt += x[i].second - x[i].first;
		else {
			puts("No");
			return 0;
		}
	}
	rep(i, d) {
		if(cnt >= y[i].second) cnt += -(y[i].second + y[i].first);
		else {
			puts("No");
			return 0;
		}
	}
	if(cnt == 0) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 11456
import numpy as np
from itertools import product

H, W, K = map(int, input().split())
# C = [["."] * (W + 1)]
C = []

for _ in range(H):
    # c = ["."] + list(input())
    c = list(input())

    C.append(c)

C = np.array(C)
# print(C)
cnt = 0

chooseH = list(product([False, True], repeat=(H)))
chooseW = list(product([False, True], repeat=(W)))

for array_h in chooseH:
    for array_w in chooseW:
        D = np.copy(C)
        D[array_h, :] = "R"
        D[:, array_w] = "R"
        # print(array_h, array_w, D.flatten(), np.sum(D.flatten() == "#"))
        if np.sum(D.flatten() == "#") == K:
            cnt += 1


# for i in range(H + 1):
#     for j in range(W + 1):
#         D = np.copy(C)
#         D[i, :] = "R"
#         D[:, j] = "R"
#         print(i, j, D.flatten(), np.sum(D.flatten() == "#"))
#         if np.sum(D.flatten() == "#") == K:
#             cnt += 1

print(cnt)


Measured memory_bytes: 27312
/*************************************************************************
      > File Name: e.cpp
      > Author: Samuel
      > Mail: enminghuang21119@gmail.com
      > Created Time: Sat Apr  4 20:26:19 2020
    *************************************************************************/
     
    #include <bits/stdc++.h>
    using namespace std;
     
    int n, k, c;
    string s;
    int workL[200010], workR[200010];
    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cin >> n >> k >> c;
        cin >> s;
        int last = -1;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'x')
                continue;
            int now = i + 1;
            if (last == -1 || last + c < now) {
                last = now;
                workL[now] = ++cnt;
                if (cnt == k)
                    break;
            }
        }
        last = -1;
        cnt = k;
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == 'x')
                continue;
            int now = i + 1;
            if (last == -1 || last - c > now) {
                last = now;
                workR[now] = cnt--;
                if (cnt == 0)
                    break;
            }
        }
        for (int i = 1; i <= n; i++)
            if (workL[i] && workL[i] == workR[i])
                cout << i << '\n';
        return 0;
    }


Measured memory_bytes: 3348
def main():
    N = int(input())
    num_list = list(map(int, input().split()))
    
    num_list.sort(reverse=True)

    alice, bob = 0,0

    for i in range(N):
        if i % 2 == 0:
            alice += num_list[i]
        else:
            bob += num_list[i]

    print(alice-bob)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>

int main()
{
  int k,s;
  
  scanf("%d%d",&k,&s);
  
  int x,y,z;
  int ans=0;
  
  for(x=0;x<=k;x++)
  {
    for(y=0;y<=k;y++)
    {
      z=s-(x+y);
      if(0<=z&&z<=k)
      {
        ans++;
      }
    }
  }
  
  printf("%d\n",ans);
  return 0;
}
    

Measured memory_bytes: 128
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
      #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      }
    
int main()
{   
  // sublime();
   ll n,x,t;
   ll i;
   cin>>n;
   ll ans=0;
   ll arr[n];
   for(i=0; i<n; i++)
    cin>>arr[i];
  if(n==1)
  {
    cout<<0;
    return 0;
  }
  else
  {
    for(i=1; i<n; i++)
    {
      if(arr[i-1]>arr[i])
      {
        ans+=arr[i-1]-arr[i];
        arr[i]+=arr[i-1]-arr[i];
      }
    }
    cout<<ans;
  }
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll k, a, b;
    cin >> k >> a >> b;
    string ans("NG");
    for (ll i = 1; k * i <= b; i++) {
        ll t = i * k;
        if ((t >= a) && t <= b) {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N;
ll A[1 << 18];

void upd(pll &a, pll b) {
	pll r;
	if (a.first > b.first) r = pll(a.first, max(b.first, a.second));
	else r = pll(b.first, max(b.second, a.first));
	a = r;
}

pll B[1 << 18];
ll C[1 << 18];

int main() {
	scanf("%d", &N);
	rep(i, 1 << N) scanf("%lld", A + i);
	reverse(A, A + (1 << N));
	int M = 1 << N;
	rep(i, M) B[i] = pll(A[i], -1e18);
	for (int i = 0; i < N; i++) {
		rep(j, M) {
			int c = !!(1 << i & j);
			if (c == 0) upd(B[j], B[j + (1 << i)]);
		}
	}
	rep(i, M - 1) {
		C[i] = B[i].first + B[i].second;
	}
	reverse(C, C + M);
	ll ans = C[0];
	for (int i = 1; i < M; i++) {
		ans = max(ans, C[i]);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 11264
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
typedef pair<string, vi> P;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).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; }

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

    string s;
    cin >> s;

    int K;
    cin >> K;

    set<string> substrings;
    rep(i, s.size())
    {
        reple(k, 1, K) substrings.insert(s.substr(i, k));
    }

    auto itr = substrings.begin();
    rep(i, K - 1) ++itr;

    cout << *itr << endl;

    return 0;
}

Measured memory_bytes: 1664