akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX(a,b) ((a>b)?(a):(b))

int main()
{
	char s[3002];
	char t[3002];
	scanf("%s",s);
	scanf("%s",t);
	int len_s = strlen(s);
	int len_t = strlen(t);
	
	int **dp;
	dp = (int **)malloc(3002*sizeof(int*));
	int index = 0;
	while (index < 3002)
	{
		dp[index] = (int *)malloc(3002*sizeof(int));
		index++;
	}
	int i, j;
	index = 0;
	//printf("debug1001\n");
	while (index < 3002)
	{
		dp[0][index] = 0;
		dp[index][0] = 0;
		index++;
	}
	//printf("debug0001\n");
	i = 1;
	j = 1;
	//printf("debug0001\n");
	
	while (i <= len_s)
	{
		j = 1;
		while( j <= len_t)
		{
			if(s[i-1] == t[j-1])
			{
				dp[i][j] = dp[i-1][j-1]+1;
				//printf("debug0002,dp;%d, i;%d,j;%d\n",dp[i][j],i,j);
			}
			else
			{
				dp[i][j] = MAX(dp[i-1][j],dp[i][j-1]);
				//printf("debug0003, dp;%d,i;%d,j;%d\n",dp[i][j],i,j);
			}
			j++;
		}
		i++;
	}
	char ans[3002];
	//printf("after ans def\n");
	index = 0;
	while (index < 3002)
	{
		ans[index] = '\0';
		//printf("%d\n",index);

		index++;
	}
	//printf("before len def\n");
	int len = dp[len_s][len_t];
	i = len_s;
	j = len_t;
	//printf("before ans while loop\n");
	while (len > 0)
	{
		if(s[i-1] == t[j-1])
		{
			ans[len-1] = s[i-1];
			i--;
			j--;
			len--;
		}
		else if(dp[i][j] == dp[i-1][j])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
	//printf("just before answer debug0001\n");
	printf("%s\n",ans);
	return (0);
}


Measured memory_bytes: 35456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, k;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>n>>k;
    ll ans=0;
    if(k==2){
        if(n%2==0){
            int temp=n/2;
            ans=(ll)2*temp*temp*temp;
        }
        else{
            int temp=n/2;
            ans=(ll)temp*temp*temp+(ll)(temp+1)*(temp+1)*(temp+1);
        }
    }
    else if(k==1){
        ans=(ll)n*n*n;
    }
    else{
        if(k%2==1){
        int numk=n/k;
        ans=(ll)numk*numk*numk;
        }
        else{
            int numk=n/k;
        if(n%k>=k/2){
            ans=(ll)numk*numk*numk+(ll)(numk+1)*(numk+1)*(numk+1);
        }
        else{
            ans=(ll)2*numk*numk*numk;
        }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
	*/
	int n;
	int count = 0;
	int num = 0;
	int ans = 0;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<int>a(n);
	rep0(i, n - 1) {
		a[i] = i + 1;
	}
	rep0(j, n - 1) {
		int save = a[j];
		if (a[j] % 2 == 0) {
			while (a[j] % 2 == 0) {
				a[j] /= 2;
				count++;
			}
			if (count > ans) {
				ans = count;
				num = save;
			}
			count = 0;
		}

	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
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 main() {
  int N, MAX, sum=0;
  cin >> N;
  vector<int> v(N);
  REP(i,N) {
    cin >> v.at(i);
    sum+=v.at(i);
  }
  sort ALL(v);
  reverse ALL(v);
  cout << sum-v.at(0)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 10005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size()-1];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

int main()
{
	std::uint32_t N, K;
	std::cin >> N >> K;

	std::uint64_t nof_multiple_K = (N / K);
	std::uint64_t count = nof_multiple_K * nof_multiple_K * nof_multiple_K;

	if (K % 2 == 0) {
		std::uint64_t nof_multiple_K_and_half = nof_multiple_K + (N / K * K + (K / 2) <= N ? 1 : 0);
		count += nof_multiple_K_and_half * nof_multiple_K_and_half * nof_multiple_K_and_half;
	}

	std::cout << count << std::endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.AbstractMap.SimpleEntry;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt();
                        long K = sc.nextLong();
                        List<SimpleEntry<Long, Long>>ab = new ArrayList<SimpleEntry<Long, Long>>(N);
                        for(int i = 0; i < N; i++){
                                ab.add(new SimpleEntry<Long, Long>(sc.nextLong(), sc.nextLong()));
                        }
                        Collections.sort(ab, new Comparator<SimpleEntry<Long, Long>>(){
                                @Override
                                public int compare(SimpleEntry<Long, Long>x, SimpleEntry<Long,Long>y){
                                        return (int)(x.getKey() - y.getKey());
                                }
                        });
                        int i = 0;
                        while(K>0){
                                K-=ab.get(i).getValue();
                                i++;
                        }
                        i--;
                        System.out.println(ab.get(i).getKey());
                }
        }
}

Measured memory_bytes: 98276
import sys

h,w = map(int,input().split())

# マップを生成する。####で囲う。"."をカウントしておく(white)
m = []
m.append('#'*(w+2))
white = 0
for i in range(h):
  s = input()
  m.append(list('#' + s + '#'))
  white += s.count('.')
m.append('#'*(w+2))

stack = set([(1, 1)])
dist = 0

# stackがある限りループ
while len(stack) > 0:
  
  #ゴールまでの距離をカウントしていく
  dist += 1
  
  # 空のセットを用意
  next_w = set()
  
  for y, x in stack:
    m[y][x] = dist
    
    # ゴールに到着したら
    if (y, x) == (h, w):
      print(white - dist)
      exit()
      
 	# 上下左右に移動。
    for dx,dy in [0,1],[0,-1],[1,0],[-1,0]:
      # "."なら移動可能
      if m[y-dy][x-dx] == '.':
        next_w.add((y-dy,x-dx))
  stack = next_w

print('-1')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define lim 100005
#define INF 1e13
int main()
 {
  
int ans=0;
string s;
cin>>s;
for(int i=0;i<s.length();i++)
if(s[i]=='1')
  ans++;
cout<<ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll test[12345678];
signed main() {
	ll n = 0, ok = 1000000000000, cnt = 0, ans1 = 0, ans2 = INF; cin >> n;
	vector<ll> v;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	for (int h = 0; h < n; h++) {
		v.push_back(abs(test[h] - (ok + h)));
		ans1 += v[h];
	}
	sort(v.begin(), v.end()); ans2 = min(ans1, ans2);
	for (int h = 0; h < n; h++) {
		//cout << ans1 << endl;
		ans1 -= (n - h) * (v[h] - cnt);
		ans1 += h * (v[h] - cnt);
		cnt = v[h];
		ans2 = min(ans1, ans2);
	}
	cout << ans2 << endl;
	return 0;
}

Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

void solve(){
  ini(N);
  vector<string> S(N); in(S);
  vvi dat(N,vi(26,0));
  rep(i,N){
    each(x , S[i]) dat[i][x - 'a']++;
  }
  rep(j,26){
    int cur = inf;
    rep(i,N) amin(cur , dat[i][j]);
    rep(hoge,cur) cout << char('a' + j);
  }
  out();
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;

        for (int i = 1; i <= N; i++) {
            String strN = String.valueOf(i);
            if (strN.length() % 2 != 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

#define MOD 1000000007

using namespace std;

int dfs(int u, vector<vector<int>> &links, vector<int> &vis, vector<int> &c) {
    vis[u] = 1;
    int cnt = 0;
    for (int v: links[u]) {
        if (vis[v] == 0) {
            cnt++;
        }
    }
    if (cnt >= c.size()) {
        return 0;
    }
    int res = c[cnt];
    for (int v: links[u]) {
        if (vis[v] == 0) {
            res = 1LL * res * dfs(v, links, vis, c) % MOD;
        }
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> c(1, 1);
    for (int i = k - 2; i >= 1; i--) {
        c.push_back(1LL * c.back() * i % MOD);
    }
    vector<vector<int>> links(n + 1, vector<int>());
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        links[x].push_back(y);
        links[y].push_back(x);
    }
    if (links[1].size() >= k) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 0; i < links[1].size() + 1; i++) {
        ans = 1LL * ans * (k - i) % MOD;
    }
    vector<int> vis(n + 1, 0);
    vis[1] = 1;
    for (int u: links[1]) {
        ans = 1LL * ans * dfs(u, links, vis, c) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        bool check = false;
        if(i%3==0){
            check = true;
        }
        int x = i;
        while(x){
            if(x % 10 == 3){
                check = true;
                x = 0;
            }
            else{
                x /= 10;
            }
        }
        if(check){
            cout << ' ' << i;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,Q;
    string S;
    char t[214514],d[214514];
    cin >> N >> Q;
    cin >> S;
    REP(i,Q){
        cin >> t[i] >> d[i];
    }
    
    int l=0,r=0;
    
    for(int i=Q-1;i>=0;--i){
        if(d[i]=='L'){
            if(S[l]==t[i])l++;
            if(r>=1 && S[N-1-r+1]==t[i])r--;
        }else{
            if(S[N-1-r]==t[i])r++;
            if(l>=1 && S[l-1]==t[i])l--;
        }
    }
    
    cout << max(N-l-r,0ll) << endl;
    return 0;
}


Measured memory_bytes: 1028
n , x = map(int, raw_input().split())
a = map(int, raw_input().split())

c = 0

for i in xrange(1, len(a)):
    while a[i] + a[i-1] > x:
        if a[i] > 0:
            c += min(a[i], a[i] + a[i-1] - x)
            a[i] -= min(a[i], a[i] + a[i-1] - x)
        else:
            c +=  a[i] + a[i-1] - x
            a[i-1] -=  a[i] + a[i-1] - x
print c

Measured memory_bytes: 11316
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++) 
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int c[16],n,v[200005],dp[1<<16];
int dfs(int x){
	if(dp[x]!=-1)RE dp[x];
	int re=1000000000;
	rep(i,1,16){
		if(x&(1<<i)){
			rep(j,i+1,16){
				if(x&(1<<j)){
					re=min(re,dfs(x^(1<<i)^(1<<j)^(1<<(i^j)))+((x&(1<<(i^j)))?2:1));
				}
			}
			break;
		}
	}
	RE dp[x]=re;
}
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n;
	int x,y,z;
	rep(i,1,n){
		cin>>x>>y>>z;
		v[x]^=z;v[y]^=z;
	}
	int ans=0;
	rep(i,0,n){
		c[v[i]]++;
	}
	FOR(i,1,15){
		ans+=c[i]/2;
		c[i]&=1;
	}
	int get=0;
	FILL(dp,-1);dp[0]=0;
	FOR(i,1,15)if(c[i])get^=(1<<i);
	cout<<dfs(get)+ans;
	RE 0;
}




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

int main(){
	int n,i,interest;
	int debt=100000;
	double temp1;
	int temp2;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		temp1 = 0.05*debt/1000.0;
		temp2 = 0.05*debt/1000.0;
		if (temp1>temp2)
			temp2=temp2+1;
		interest = temp2*1000;
		debt= debt + interest;
	}
	printf("%d\n",debt);
    return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
typedef unsigned long long llong;

#define MAX 1e18
const llong mod = 1000000000 + 7;

int main()
{
  llong N, K;
  llong prevN = MAX;
  scanf("%llu%llu", &N, &K);

  llong sub;
  if (N > K)
    N -= N / K * K;
  do
  {
    prevN = min(prevN, N);
    if (N > K)
      sub = N - K;
    else
      sub = K - N;

    N = sub;
  } while (N != prevN);

  printf("%llu\n", N);

  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  string s;
  cin>>s;
  vector<int> f(26);
  trav(x,s) f[x-'a']++;
  trav(x,f) {
    if(x%2 != 0) {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}



Measured memory_bytes: 256
// She is Pretty pretty!
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6 + 100;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    queue<string> q;
    for (int i = 1; i <= 9; i++) {
        q.push(to_string(i));
    }
    vector<ll> v;
    set<string> s;
    while (s.size() <= 2e5) {
        string top = q.front();
        q.pop();
        s.insert(top);
        char ch = top.back();
        if (ch == '0') {
            q.push(top + ch);
            ch++;
            q.push(top + ch);
        } else if (ch == '9') {
            q.push(top + ch);
            ch--;
            q.push(top + ch);
        } else {
            q.push(top + ch);
            ch--;
            q.push(top + ch);
            ch += 2;
            q.push(top + ch);
        }
    }
    for (auto it : s) {
        v.pb((ll)stoll(it));
    }
    sort(v.begin(), v.end());
    cout << v[k - 1];
    return 0;
}

Measured memory_bytes: 51064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+10;
int dp[maxn][maxn];

int main() {
	int k;
	cin>>k;
	int temp;
	temp=k/2;
	cout<<temp*(k-temp)<<endl;

	return 0;
}


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

int N, a[112];
long long int dp[112][21];

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &a[i]); }

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

	printf("%lld\n", dp[N - 2][a[N - 1]]);
	return 0;
}

Measured memory_bytes: 2668
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
	string S; cin >> S;
	set<char> c;
	char ans;
	bool count = false;
	rep(i,S.size()){
		c.insert(S[i]);
	}
	for(char i = 'a'; i <= 'z';i++){
		if(! count){
		if(! c.count(i)){
			ans = i;
			count = true;
		}
	}
	}
	if(count) cout << ans << endl;
	else cout << "None" << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define id(x) ((x)<=sqrtn?x:sqrtn+n/(x))
using namespace std;

typedef long long LL;
const int p=1000000007;
int n,k,m,sqrtn,a[30],b[30],f[100000],ans;

int power(int x,int k)
{
    int ret=1;
    for (; k; k>>=1,x=LL(x)*x%p)
        if (k&1)
            ret=LL(ret)*x%p;
    return ret;
}

void get()
{
    int x=n;
    for (int i=2; i*i<=x; ++i)
        if (!(x%i))
            for (a[++m]=i; !(x%i); x/=i,++b[m]);
    if (x>1)
        a[++m]=x,b[m]=1;
}

void dfs(int i,int x,int y)
{
    if (i>m)
    {
        if (x==y)
        {
            (f[id(x)]+=power(k,(x+1)/2))%=p;
            ans=(ans+LL(x&1?x:x/2)*f[id(x)])%p;
        }
        else
            (f[id(y)]+=p-f[id(x)])%=p;
        return;
    }
    int t=y;
    repu(j,0,b[i])
    {
        if (j)
            x*=a[i],t*=a[i];
        y=t;
        repu(k,j,b[i])
        {
            if (k>j)
                y*=a[i];
            dfs(i+1,x,y);
        }
    }
}

int main()
{
    scanf("%d%d",&n,&k),sqrtn=sqrt(n);
    get(),dfs(1,1,1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>
#include<deque>
#include<queue>
#include<bitset>
#include<functional>
#include<utility>
#include<list>
#include<iomanip>
#include<ctime>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int INF=1e9+1;
int a[100005],ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(i==n&&a[i]==i) swap(a[i],a[i-1]),ans++;
		else if(a[i]==i) swap(a[i],a[i+1]),ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int r;
    cin >> r;
    string s;
    if (r < 1200) s = "ABC";
    else if (r < 2800) s = "ARC";
    else s = "AGC";
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3604
mod = 1000000007;

def bin(b, m):
    a = b;
    n = m;
    res = 1;
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % mod;
        a = (a * a) % mod;
        n //= 2;
    return res;

def fact(x):
    res = 1;
    for i in range(1, x + 1):
        res = (res * i) % mod;
    return res;

def inv(x):
    return bin(x, mod - 2);

def cnk(n, k):
    res = 1;
    for i in range(n - k + 1, n + 1):
        res = (res * i) % mod;
    return (res * inv(fact(k))) % mod;

n, a, b  = (int(i) for i in input().split());

ans = (bin(2, n) - 1 - cnk(n, a) - cnk(n, b) + 3 * mod) % mod;
#print(bin(2, n), cnk(n, a), cnk(n, b));
print(ans);


Measured memory_bytes: 3064
from collections import Counter
C = Counter()
h, w = map(int, input().split())
for _ in range(h):
	C += Counter(input())
lim = (h // 2) * (w % 2) + (w // 2) * (h % 2)
cnt = flg = 0
for k, v in C.items():
	while v >= 4:
		v -= 4
	if v >= 2:
		cnt += 1
		if cnt > lim:
			print("No")
			exit()
	if v % 2:
		if flg or h % 2 == w % 2 == 0:
			print("No")
			exit()
		flg = 1
print("Yes")

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n;
    cin >> n;
    string s1[n];
    rep(i, n) { cin >> s1[i]; }
    int m;
    cin >> m;
    string s2[m];
    rep(i, m) { cin >> s2[i]; }

    // check
    // cout << endl;
    // rep(i, n) { cout << s1[i] << endl; }
    // rep(i, m) { cout << s2[i] << endl; }

    // 処理
    int maxV = 0;
    for (int i = 0; i < n - 1; i++) {
        int money = 0;
        for (int j = i; j < n; j++) {
            if (s1[i] == s1[j]) {
                money++;
            }
        }
        rep(j, m) {
            if (s1[i] == s2[j]) {
                money--;
            }
        }
        maxV = max(maxV, money);
    }

    // 出力
    cout << maxV << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int r;
  cin >> r;
  if (r < 1200) puts("ABC");
  else if (r < 2800) puts("ARC");
  else puts("AGC");


  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
int main(){
    ll h; cin >> h;
    ll ans=0;
    ll cnt=1;
    while(h>1){
        h/=2;
        ans+=cnt;
        cnt*=2;
    }
    ans+=cnt;
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] d = new int[m - 1];
        for (int i = 0; i < m - 1; i++) {
            d[i] = x[i + 1] - x[i];
        }
        Arrays.sort(d);
        if (n >= m) {
            System.out.println(0);
        } else {
            int sum = 0;
            for (int i = 0; i < n - 1; i++) {
                sum += d[m - 2 - i];
            }
            System.out.println(x[m - 1] - x[0] - sum);
        }
    }
}


Measured memory_bytes: 48292
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_101_C.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(14).
    01 INP2   PIC X(700000).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(2)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(2).

    01 X      PIC 9(6).
    01 R      PIC 9(6).

    01 NK1.
        03 NK11 OCCURS 2.
            05 NK PIC 9(6).

    01 ans    PIC X(6).
    01 ZS     PIC Z(6).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.
    ACCEPT INP2.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO NK(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

*> N <= K + (K - 1) * (G - 1)
*> (N - K) / (K - 1) + 1

    SUBTRACT NK(2) FROM NK(1).
    SUBTRACT 1 FROM NK(2).

    DIVIDE NK(2) INTO NK(1) GIVING X REMAINDER R.

    IF R NOT = 0 THEN
       ADD 1 TO X
    END-IF.

    ADD 1 TO X.
    MOVE X TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


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

int main() {
    int t;
    cin >> t;
    for(int i=0;i<t;i++){
        ll n,ans=0;
        cin >> n;
        vector<ll>k(n),l(n),r(n);
        vector<pair<int,int>> a,b;
        for(int i=0;i<n;i++){
            cin >> k[i] >> l[i] >> r[i];
            ans+=min(l[i],r[i]);
            if(l[i]>r[i]){
                a.push_back(make_pair(k[i],(l[i]-r[i])));
            }
            else{
                b.push_back(make_pair((n-k[i]),(r[i]-l[i])));
            }
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        priority_queue<ll,vector<ll>,greater<ll>>lpq,rpq;
        for(int i=0;i<a.size();i++){
            lpq.push(a[i].second);
            while(a[i].first<lpq.size()){
                lpq.pop();
            }
        }
        while(lpq.size()){
            ans+=lpq.top();
            lpq.pop();
        }
        for(int i=0;i<b.size();i++){
            rpq.push(b[i].second);
            while(b[i].first<rpq.size()){
                rpq.pop();
            }
        }
        while(rpq.size()){
            ans+=rpq.top();
            rpq.pop();
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 11836
#include<bits/stdc++.h>
#define ri register int
#define forn(i, n) for(int i = 1; i <= (n); i++)
typedef long long ll;
using namespace std;
/* Template_In_Programming_Contest */

void rd(int& u) {scanf("%d", &u);}
void rd2(int& u, int& v) {scanf("%d%d", &u, &v);}
void rd3(int& u, int& v, int& w) {scanf("%d%d%d", &u, &v, &w);}
void ptn(int u) {printf("%d\n", u);}
void pte(int u) {printf("%d ", u);}

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

int n, m;
int main(){
	cin >> n; int cnt = 0; 
	string s; cin >> s; s = s + "%";
	for(int i = 0; i < (int) s.size() - 1; i++)
		if(s[i] != s[i + 1]) ++cnt;
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && B == C){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
// Last Change: 03/24/2019 17:07:35.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

const char white = '.';
const char black = '#';

queue<pair<int, int>> blackPos;
vector<vector<char>> area;
vector<vector<char>> curArea;

int H, W;

const int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool Check(int x, int y) {
  bool ans = false;
  for (int i = 0; i < 4; ++i) {
    int nextX, nextY;
    nextX = x + dir[i][0];
    nextY = y + dir[i][1];
    if (nextX >= 0 and nextX < H and nextY >= 0 and nextY < W) {
      if (area[nextX][nextY] == black) {
        ans = true;
      }
    }
  }
  return ans;
}

int main() {
  cin >> H >> W;
  area.resize(H);

  for (int i = 0; i < H; ++i) {
    vector<char> tmp(W);
    for (int j = 0; j < W; ++j) {
      cin >> tmp[j];
      if (tmp[j] == black) {
        blackPos.push(pair<int, int>(i, j));
      }
    }
    area[i] = tmp;
  }

  bool ans = true;
  while (!blackPos.empty()) {
    pair<int, int> tmp = blackPos.front();
    blackPos.pop();

    if (!Check(tmp.first, tmp.second)) {
      ans = false;
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
listToTupleTwo []       = []
listToTupleTwo (x:y:xs) = (x,y) : (listToTupleTwo xs)

digitNumber :: Integer -> Integer
digitNumber 0 = 0
digitNumber n = (digitNumber (n`div`10)) + 1

sumTuple :: (Integer,Integer) -> String
sumTuple a = if digitNumber(fst a) > 80 || digitNumber(snd a) > 80 || digitNumber(fst a + snd a) > 80
                then "overflow"
                else show(fst a + snd a)

main = do{
    n <- getLine;
    getContents>>=mapM_ putStrLn.map sumTuple.listToTupleTwo.map (read::String->Integer).lines;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000000 + 5;
const ll mod = 1000000007;

int main()
{
    ll n,m;
    cin >> n >> m;
    if(n == 1 || m == 1)
    	cout << 1 << endl;
    else{
	    ll t1 = m / 2,t2 = m - t1;
	    ll ans = (n / 2) * m;
	    if(n % 2 == 1)
	    	ans += max(t1,t2);
	    cout << ans << endl;	
	}
    return 0;
}

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


void solve(long long H, long long W, long long M, std::vector<long long> h, std::vector<long long> w){
    map<long long, long long> hmap;
    map<long long, long long> wmap;
    set<pair<long long, long long> > s;
    for(int i = 0; i < M; ++i){
        hmap[h[i]] += 1;
        wmap[w[i]] += 1;
        s.emplace(h[i], w[i]);
    }
    long long hpos = 0;
    long long hval = 0;
    vector<long long> hvec;
    for(auto itr = hmap.begin(); itr != hmap.end(); ++itr){
        if(itr->second > hval){
            hval = max(itr->second, hval);
            hpos = itr->first;
        }
    }
    for(auto itr = hmap.begin(); itr != hmap.end(); ++itr){
        if(itr->second == hval) hvec.push_back(itr->first);
    }
    long long wpos = 0;
    long long wval = 0;
    vector<long long> wvec;
    for(auto itr = wmap.begin(); itr != wmap.end(); ++itr){
        if(itr->second > wval){
            wval = max(itr->second, wval);
            wpos = itr->first;
        }
    }
    for(auto itr = wmap.begin(); itr != wmap.end(); ++itr){
        if(itr->second == wval) wvec.push_back(itr->first);
    }
    
    long long ans = hval + wval;
    for(auto i : hvec){
        for(auto j : wvec){
            if(s.count(make_pair(i, j))) continue;
            cout << ans << endl;
            return; 
        }
    }
    ans--;
    cout << ans << endl;
    return;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> h(M);
    std::vector<long long> w(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&h[i]);
        scanf("%lld",&w[i]);
    }
    solve(H, W, M, std::move(h), std::move(w));
    return 0;
}


Measured memory_bytes: 72468
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = -100000000000000000;
int main(){
	int n,a,b;
	ll v[50];
	ll dp[51][51],tori[51][51];
	scanf("%d %d %d",&n,&a,&b);
	for(int i=0;i<n;i++) scanf("%lld",v+i);
	for(int i=0;i<=50;i++){
		for(int j=0;j<=n;j++){
			if(i==0){
				dp[i][j] = 0;
				tori[i][j] = 1;
			}else if(j==0){
				dp[i][j] = INF;
				tori[i][j] = 0;
			}else{
				ll t = dp[i-1][j-1] + v[j-1];
				if(dp[i-1][j-1]==INF){
					dp[i][j] = dp[i][j-1];
					tori[i][j] = tori[i][j-1];
				}
				else if(dp[i][j-1]<t){
					dp[i][j] = t;
					tori[i][j] = tori[i-1][j-1];
				}else if(dp[i][j-1]==t){
					dp[i][j] = t;
					tori[i][j] = tori[i][j-1] + tori[i-1][j-1];
				}else{
					dp[i][j] = dp[i][j-1];
					tori[i][j] = tori[i][j-1];
				}
			}
		}
	}
	int pos;
	ll cnt;
	for(int i=a;i<=b;i++){
		if(i==a||dp[pos][n]*i<dp[i][n]*pos){
			pos = i;
			cnt = tori[i][n];
		}
		else if(dp[pos][n]*i==dp[i][n]*pos) cnt += tori[i][n];
	}
	long double ans = ((long double)dp[pos][n]) / ((long double)pos);
	printf("%Lf\n%lld\n",ans,cnt);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int r[] = new int[n];
    for (int i = 0; i < n; i++) {
      r[i] = sc.nextInt();
    }

    int min = r[0];
    int sabun = Integer.MIN_VALUE;
    for (int i = 1; i < n; i++) {
      sabun = Math.max(sabun, r[i] - min);
      min = Math.min(min, r[i]);
    }

    System.out.println(sabun);
  }
}


Measured memory_bytes: 101016
import java.util.*;
import java.text.SimpleDateFormat;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        try {
          Date date = format.parse(sc.next());
          Date last = format.parse("2019/04/30");
    
		  // 出力
		  System.out.println(date.after(last) ? "TBD" : "Heisei");
        } catch (Exception e) {
        }
	}
}

Measured memory_bytes: 22096
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		boolean found = false;
		if(n==1) {
			System.out.print("Yes");
			found = true;
		}
		for(int i = 1;i<=9 && !found;i++) {
			if(n%i == 0) {
				for(int j = 2;j<=9;j++) {
					if(n/i % j == 0 && n/i<=9) {
						System.out.print("Yes");
						found = true;
						break;
					}
				}
			}
		}
		if(!found) {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, -1, 0, 1};
int main (void) {
    int H, W;

    cin >> H >> W;

    string A[H];
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int cnt = 0;
            for (int d = 0; d < 4; d++) {
                int ny = i + dy[d];
                int nx = j + dx[d];
                if (0 <= ny && ny < H && 0 <= nx && nx < W && A[ny][nx] == '#') {
                    cnt++;
                }
            }
            if (cnt > 1) {
                cout << "Impossible" << endl;
                return 0;
            }
            A[i][j] = '.';
        }
    }

    cout << "Possible" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int money,year;

int Fu(double p,int t){
	int ret = money;
	for(int i=0;i<year; i++)
		ret = (int)(ret * ( 1 + p)) - t;
	return ret;
}
int Ta(double p, int t)
{
	int z = money;
	int r =0;
	for(int i=0;i<year;i++)
	{
		r += (int)(z*p);
		z-= t;
	}

	return z+r;

}

int solve()
{
	int n;
	cin >> money >> year >> n;
	int rets[100];
	for(int i= 0; i <n; i++){
		int fukuri;
		double p;
		int t;
		cin >> fukuri >> p >> t;
		rets[i] = (fukuri)?Fu(p,t):Ta(p,t);
	}
	int ret = 0;
	for(int i=0;i<n;i++)
		if(ret <rets[i]) ret = rets[i];

	return ret;
}

int main()
{
	int m;
	cin >> m;
	for(int i=0;i<m;i++)
		cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] fb = new int[n + 1];
            fb[0] = fb[1] = 1;

            for (int i = 2; i <= n; i++) fb[i] = fb[i - 1] + fb[i - 2];

            Console.WriteLine(fb[n]);
        }
    }
}

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

int circle(
    int x1, int x2, int x3, 
    int y1, int y2, int y3, 
    double &cx, double &cy, double &r)
{
	double ox, oy;
    long  a, b, c, d ;
	double 	r1, r2, r3 ;
	int		stat ;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = -1 ;

	if  ((a * d - b * c != 0) && ((a && d) || (b && c))) {
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d)) 
            / (double)(a * d - b * c) / 2.0 ;
		if  (b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) 
                / (double)b / 2.0 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) 
                / (double)d / 2.0 ;
		}
		r1   = sqrt((ox - x1) * (ox - x1) + (oy - y1) * (oy - y1)) ;
		r2   = sqrt((ox - x2) * (ox - x2) + (oy - y2) * (oy - y2)) ;
		r3   = sqrt((ox - x3) * (ox - x3) + (oy - y3) * (oy - y3)) ;
		cx = ox ;
		cy = oy ;
		r  = (r1 + r2 + r3) / 3.0 ;
		stat = 0 ;
	}

	return stat ;
}

void Main()
{
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    
    double rmin = 100000;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            double cx, cy, r;
            cx = (x[i]+x[j])*0.5;
            cy = (y[i]+y[j])*0.5;
            r = sqrt((x[i]-cx)*(x[i]-cx)+(y[i]-cy)*(y[i]-cy));

            bool ok = true;
            for (int l = 0; l < n; l++)
            {
                if(l != i && l != j && 
                    (x[l]-cx)*(x[l]-cx)+(y[l]-cy)*(y[l]-cy) > r*r+1e-14) {
                        ok = false;
                    }
            }
            if(ok){
                rmin = min(rmin, r);
            }

            for (int k = j+1; k < n; k++)
            {
                int stat = circle(x[i], x[j], x[k], y[i], y[j], y[k], cx, cy, r);
                if(stat == -1) continue;

                ok = true;
                for (int l = 0; l < n; l++)
                {
                    if(l != i && l != j && l != k && 
                        (x[l]-cx)*(x[l]-cx)+(y[l]-cy)*(y[l]-cy) > r*r+1e-14) {
                            ok = false;
                        }
                }
                if(ok){
                    rmin = min(rmin, r);
                }
            }
        }
    }

    // (x-a)^2 + (y-b)^2 < r^2
    
    cout << std::fixed << std::setprecision(15) << rmin << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3792
// 2020-08-17 20:03:15
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int MX = 310;
const ll inf = 1e18;
ll dp[MX][MX][MX];
void answer() {
  int n, K;
  cin >> n >> K;
  vector<ll> h(n+1, 0);
  REPC(i, 1, n) cin >> h[i];
  repc(i, n) repc(j, n) repc(k, K) dp[i][j][k] = inf;
  dp[0][0][0] = 0;
  REPC(i, 1, n) {
    rep(j, i) {
      repc(k, K) {
        chmin(dp[i][i][k], dp[i-1][j][k] + max(h[i] - h[j], 0ll));
        if(k > 0) chmin(dp[i][j][k], dp[i-1][j][k-1]);
      }
    }
  }
  ll ans = inf;
  repc(j, n) repc(k, K) chmin(ans, dp[n][j][k]);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 224272
while True:
    N, X = map(int, input().split())
    if N == 0:
        break
    res = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            for k in range(j+1, N+1):
                if i + j + k == X:
                    res += 1
    print(res)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    register int x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')   ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x;
}
const int N=1e6+5;
const int P=998244353;
int n,m,now,a[N],b[N],c[N],vi[N];
long long f(int T){
    int k=m/T,sum=0,ans=0;
    for(int i=1;i<=k;i++)   sum=(sum+1LL*i*a[i*T])%P;
    for(int i=1;i<=k;i++){
        sum=(sum-1LL*i*a[i*T]%P+P)%P;
        ans=(ans+1LL*sum*i%P*a[i*T]%P)%P;
    }
    return ans;
}
int main(){
    n=read(),b[1]=1;
    for(int i=1,x;i<=n;i++)
        ++a[x=read()],m=max(m,x);
    for(int i=2;i<=m;i++){
        if(!vi[i])  c[++now]=i,b[i]=-1;
        for(int j=1;j<=now&&c[j]*i<=m;j++){
            vi[c[j]*i]=1;
            if(i%c[j]==0)   break;
            else    b[i*c[j]]=-b[i];
        }
    }
    for(int i=1;i<=m;i++)   c[i]=(P+b[i]*i)%P;
    for(int i=m;i;i--)
        for(int j=i*2;j<=m;j+=i)    c[j]=(c[j]+c[i])%P;
    long long ans=0;
    for(int i=1;i<=m;i++)   ans=(ans+1LL*a[i]*(a[i]-1)/2%P*i)%P;
    for(int i=1;i<=m;i++)   ans=(ans+i*f(i)%P*c[i])%P;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 15872