akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(90000)
n,K=map(int,input().split())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b=map(int,input().split())
        kilist[a-1].append(b)
        kilist[b-1].append(a)
def search(P):
        searchedlist[P-1]=1
        visitedlist[P-1]=1
        flag=0
        for j in kilist[P-1]:
            if visitedlist[j-1]<0:
                visitedlist[j-1]=1
                flag+=1
                anslist[j-1]=anslist[P-1]+1
        else:
            pass

        if flag>0:    
            for k in kilist[P-1]:
                if searchedlist[k-1]==-1:
                    search(k)
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7) 
    return uselist
search(1)
power=find_power(100000)
invpower=find_inv_power(100000)
distancelist=[(i+1,anslist[i]) for i in range(n)]
distancelist=sorted(distancelist,key=lambda x:x[1])
answer=1
for some in distancelist:
    if some[1]==0:
        answer*=K
        howmuch=len(kilist[some[0]-1])   
        if K-1<howmuch:
            answer=0
            break
        else:
            answer=answer*power[K-1]*invpower[K-1-howmuch]
            answer=answer%(10**9+7)        
    else:
        howmuch=len(kilist[some[0]-1])-1
        if howmuch==0:
            pass
        else:
            if K-2<howmuch:
                answer=0
                break
            else:
                answer=answer*power[K-2]*invpower[K-2-howmuch]
                answer=answer%(10**9+7)
print(answer)


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<ll> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

struct D {
    int n, e, w, s, b, t;

    D north() {
        D d{t, e, w, b, n, s};
        return d;
    }

    D south() {
        D d{b, e, w, t, s, n};
        return d;
    }

    D west() {
        D d{n, b, t, s, w, e};
        return d;
    }

    D east() {
        D d{n, t, b, s, e, w};
        return d;
    }

    D roll(int to_e, int to_w, int to_s, int to_n) {
        D d = *this;
        rep(i, to_e) {
            d = d.east();
        }
        rep(i, to_w) {
            d = d.west();
        }
        rep(i, to_s) {
            d = d.south();
        }
        rep(i, to_n) {
            d = d.north();
        }
        return d;
    }

    D rotate(int i) {
        D d = *this;
        rep(j, i) {
            d = {w, n, s, e, b, t};
        }
        return d;
    }

    void print() {
        cout << t << s << e << w << n << b << endl;

    }

};

D check(int a, int b, const vector<D> &ds);

int main() {

    D d;
    cin >> d.t >> d.s >> d.e >> d.w >> d.n >> d.b;

    vector<D> ds;
    rep(j, 4) {
        rep(k, 4) {
            rep(l, 4) {
                ds.push_back(d.rotate(l).roll(j, 0, 0, k));
            }
        }
    }

    int n;
    cin >> n;
    rep(i, n) {
        int a, b;
        cin >> a >> b;

        D ans = check(a, b, ds);
        cout << ans.e << endl;
    }

}

D check(int a, int b, const vector<D> &ds) {
    rep(j, ds.size()) {
        if (ds[j].t == a && ds[j].s == b) {
            return ds[j];
        }
    }
    __throw_runtime_error("none");
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define f(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i > b;i--)
#define ll long long
#define fl(i,a,b) for(ll i = a; i < b; i++)
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VS vector<string>
#define VL vector<long long>
#define VC vector<char>
#define VF vector<float>
#define PB push_back
#define F first
#define S second
#define fa(i,skill) for(auto i : skill)
#define fr(i,skill) for(VI :: reverse_iterator i = skill.rbegin(); i != skill.rend(); i++)
using namespace std;
 void edit(VL &skill,ll n)
{
    fl(i,0,n)
        {
            ll x;
            cin >> x;
            skill.PB(x);
        }
}

void achilles()
{
    ll n; cin >> n;
    VL h; edit(h,n);
    ll ans = 0;
    fl(i,1,n)
    {
        if(h[i] < h[i-1])
        {
            ans += (h[i-1] - h[i]);
            h[i] = h[i-1];
        }
    }
    cout << ans << "\n";
}
int main()
{
    achilles();
    return 0;
}


Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;cin >>s>>t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t)puts("Yes");
    else puts("No");
}

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

int main() {
	int N,K;
	int ans = 1000000000;
	cin >> N >> K;
	vector<int> height(N);
	for(int i = 0; i < N; i++){
		cin >> height.at(i);
	}
	sort(height.begin(),height.end());
	for(int i = 0; i <= N - K; i++){
		int now = height.at(i + K - 1) - height.at(i);
		if(now < ans){
			ans = now;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int NINF = -999999;
int len;
char str[200005];
int dp[200005][2];

int main(){
	scanf("%s", str);
	len = strlen(str);
	dp[0][0] = 1;
	dp[0][1] = NINF;
	for(int i = 1; i < len; i++){
		// length 1
		dp[i][0] = NINF;
		if(str[i] != str[i - 1]){
			dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
		}
		dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1);
		// length 2
		if(i == 1){
			dp[i][1] = 1;
		}else{
			dp[i][1] = NINF;
		}
		if(i > 1){
			dp[i][1] = max(dp[i][1], dp[i - 2][0] + 1);
		}
		if(i > 2 && str[i] != str[i - 2] && str[i - 1] != str[i - 3]){
			dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
		}
	}
	printf("%d\n", max(dp[len - 1][0], dp[len - 1][1]));
	return 0;
}

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

bool parity(int n){
  if(n*n*n*n%10 == 1)
    return true;
  else
    return false;
}

int power(int x, int y){
  int64_t n = 1ll;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int64_t x, int y){
  return x%power(10,y+1)/power(10,y);
}

int main() {
  
  int a,b;
  cin >> a >> b;
  if(a < 10 && b < 10)
    cout << a*b << endl;
  else
    cout << -1 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 0;
    ll cur = 1;
    REP(i,N){
        ll a; cin >> a;
        if(i == 0){
            ans += a - 1;
        }
        else if(a == cur + 1) cur++;
        else if(a > cur + 1){
            ans += (a - 1) / (cur + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define chmax(a,b) (a) = max((a),(b));
using namespace std;

const int inf = -1e9;

inline int cal(int a, int b){
  int dif = abs(a-b);
  return dif * (dif - 30) * (dif - 30);
}

int main(){
  int n,m;
  while(cin >> n >> m, n){
    vector<int> a(n), b(m);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int j=0;j<m;j++)cin >> b[j];

    vector< vector<int> > dp(n+1, vector<int>(1<<m,inf));
    dp[0][0] = 0;

    for(int i=0;i<n;i++){
      for(int use=0;use<(1<<m);use++){
	if(dp[i][use] == inf)continue;

	chmax(dp[i+1][use], dp[i][use]);
	for(int j=0;j<m;j++){
	  if( (use>>j)&1 )continue;
	  chmax(dp[i+1][use | (1<<j)], dp[i][use] + cal(a[i],b[j]));
	}
      }
    }

    int ans = inf;
    for(int use=0;use<(1<<m);use++){
      chmax(ans,dp[n][use]);
    }
    cout << ans << endl;
  }
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll a[510][510];

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

int main() {
	int N; cin >> N;
	if (N == 2) {
		puts("4 7");
		puts("23 10");
		return 0;
	}

	vector<ll> vec;
	const int MX = 100000;
	vector<int> pr(MX);

	for (int i = 2; i < MX && vec.size() <= N * 3; ++i) {
		if (!pr[i]) {
			vec.pb(i);
			for (int j = i * 2; j < MX; j += i) {
				pr[j] = 1;
			}
		}
	}

	rep(i, N) {
		rep(j, N) {
			if ((i + j) & 1) continue;
			a[i][j] = vec[(i+j)/2] * vec[(i-j+N)/2+N];
		}
	}

	rep(i, N) {
		rep(j, N) {
			if (a[i][j] == 0) {
				ll t = 1;
				rep(dir, 4) {
					int ni = i + dx[dir], nj = j + dy[dir];
					if (ni >= 0 && nj >= 0 && ni < N && nj < N) {
						ll d = __gcd(t, a[ni][nj]);
						t = t / d * a[ni][nj];
					}
				}
				a[i][j] = t + 1;
			}
		}
	}

	rep(i, N) {
		rep(j, N) {
			cout << a[i][j] << (j == N-1 ? '\n' : ' ');
		}
	}


	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[5001][5002];
void init() {
	dp[0][0] = 1;
	rep1(i, 5000) {
		dp[i][0] = (dp[i - 1][0] + 2*dp[i - 1][1]) % mod;
		rep1(j, i) {
			dp[i][j]=(dp[i-1][j-1]+2*dp[i-1][j+1])%mod;
		}
	}
}
int main() {
	init();
	int n; cin >> n;
	string s; cin >> s;
	int m = s.length();
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 193920
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int t = a % 10;
		if (t == 3) {
			System.out.println("bon");
		} else if (t== 0 || t== 1 || t== 6|| t==8) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35716
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 200200;
const long long mod = 2000000033;
int a[maxn], b[maxn], c[maxn];
long long dp0[maxn], dp1[maxn];
int main(){
    int n;
    scanf("%d", &n);
    for(int e = 0; e < n; e++) cin >> a[e];
    for(int e = 0; e < n; e++) cin >> b[e];
    for(int e = 0; e < n; e++) cin >> c[e];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for(int e = 0; e < n; e++) dp0[e] = n - (lower_bound(c, c + n, b[e] + 1) - c);
    for(int e = n-1; e >= 0; e--) dp0[e] += dp0[e+1];
    long long ans = 0;
    for(int e = 0; e < n; e++) ans += dp0[lower_bound(b, b + n, a[e] + 1) - b];
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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




/* main */
int n;
vec<vi> arr(17, vi(17, 0));

int dp[1 << 16];

int dfs(int s){

    if(dp[s] > -1) return dp[s];

    if(s == (1 << n) - 1){
        return 0;
    }

    int ret = inf;

    rep(i,0,n){
        if(!(s & (1 << i))){
            int ind = 0;
            int val = arr[i][0];

            rep(j,0,n){
                if((s & (1 << j)) && arr[i][j + 1] < val){
                    ind = j;
                    val = arr[i][j + 1];
                }
            }

            chmin(ret, val + dfs(s + (1 << i)));
        }
    }

    return dp[s] = ret;

}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    while(true){
        n = input();

        if(n == 0) return 0;

        rep(i,0,n){
            rep(j,0,n + 1){
                arr[i][j] = input();
            }

        }
        memset(dp, -1, sizeof(dp));

        print(dfs(0));

    }



    





    


    

}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ll long long int
#define mod int(1e9+7)
#define N int(1e6+1)
using namespace std;
ll power(ll x, ll n) {
	if (n == 0ll)
		return 1ll;
	ll y = power(x, n / 2ll);
	y = (y * y) % mod;
	if (n % 2ll)
		return (x * y) % mod;
	return y;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	ll n;
	cin >> n;
	if (n < 2ll) {
		cout << 0ll << endl;
		return 0;
	}
	ll ans = power(10ll, n);
	ans = (ans - (2ll * power(9ll, n)) % mod);
	if (ans < 0ll)
		ans += mod;
	ans = (ans + power(8ll, n)) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(a <= b)
    out("un");
  out("safe");
  memi;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, r, d, x);
  rep(y, 10) {
    x = x * r - d;
    out(x);
  }
}


Measured memory_bytes: 3516
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	string s; cin >> s;
	if (s[0] == 'S') {
		cout << "Cloudy" << endl;
	}
	else if (s[0] == 'C') {
		cout << "Rainy" << endl;
	}
	else cout << "Sunny" << endl;






	return 0;
}


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

int main () {
	int N;
	int T;
	int minc = 1001;

	scanf ("%d %d", &N ,&T);
	for (int i=0; i<N; i++) {
		int tmpc, tmpt;
		scanf ("%d %d", &tmpc, &tmpt);
		if (tmpt<=T && tmpc < minc)
			minc = tmpc;
	}

	if (minc == 1001) {
		printf ("TLE\n");
	} else {
		printf ("%d\n", minc);
	}
	return 0;
}


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

int main()
{
	int n,k;
	string s;
	char resident;
	cin  >> n >> s >> k;
	resident = s[k-1];
	for (int i = 0; i < n; i++) {
		if (s[i] != resident) {
			s[i] = '*';
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, l=9999, r=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        l = min(l, x);
        r = max(r, x);
    }
    cout << (r-l+1)/2 << endl;
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
const int MAX=510000;
const int MOD=1e9+7;
long long fac[MAX],finv[MAX],inv[MAX];
void COMBinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    } 
}
long long COMB(int n, int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) %MOD;
}
int main(){
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    int x1=B,y1=H-A-1;
    int x2=W-B-1,y2=A-1;
    COMBinit();
    ll ans=0;
    for(x1; x1<W; x1++,x2--){
        ans+=(COMB(x1+y1,max(x1,y1)) * COMB(x2+y2,max(x2,y2))) % MOD;
    }
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k, flag = 0;
	cin >> n >> m >> k;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {	
			if(k == i * m + j * n - 2 * i * j) {
				flag = 1;
				break;
			}
		}
		if(flag) break;
	}
	if(flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a <= b && b <= c) {
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c && c <= b) {
		cout << a << " " << c << " " << b << endl;
	}
	else if (b <= c && c <= a) {
		cout << b << " " << c << " " << a << endl;
	}
	else if (b <= a && a <= c) {
		cout << b << " " << a << " " << c << endl;
	}
	else if (c <= b && b <= a) {
		cout << c << " " << b << " " << a << endl;
	}
	else {
		cout << c << " " << a << " " << b << endl;
	}
}


Measured memory_bytes: 3104
N,M = [int(i) for i in input().split(" ")]
check_list = []

for _ in range(M):
    check_list.append([int(i) for i in input().split(" ")])

for i in range(10 ** N):
    i = str(i)
    if len(i) != N:
        continue

    for j in check_list:
        if i[j[0] - 1] != str(j[1]):
            break
        else:
            continue
    else:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

vector<mint> frac, ifrac;
void finit(ll X) {
	frac.assign(X + 1, 1);
	ifrac.assign(X + 1, 1);

	repn(i, X) {
		frac[i] = frac[i - 1] * i;
		ifrac[i] = ifrac[i - 1] / i;
	}

}

mint com(ll n, ll m) {
	if (n < 0 || m < 0 || n < m) { return 0; }
	return frac[n] * ifrac[m] * ifrac[n - m];
}

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N + 1, 0), B(N + 1, 0);
	repn(i, N) {
		string S;
		cin >> S;
		rep(j, S.size()) {
			if (S[j] == '(') { A[i]++; }
			else { A[i]--; }
			B[i] = min(B[i], A[i]);
		}
		//cout << A[i] << " " << B[i] << endl;
	}

	vector<pair<ll, ll>> p1, p2;

	repn(i, N) {
		if (A[i] > 0) { p1.push_back({ -B[i], i }); }
		else { p2.push_back({ B[i] - A[i],i }); }
	}
	sort(p1.begin(), p1.end());
	sort(p2.begin(), p2.end());

	p1.insert(p1.end(), p2.begin(), p2.end());

	string ans = "Yes";
	ll kakko = 0;
	rep(i, N) {
		ll x = p1[i].second;
		//cout << x << endl;

		if (kakko + B[x] < 0) { ans = "No"; break; }
		kakko += A[x];
	}
	if (kakko != 0) { ans = "No"; }

	cout << ans << endl;
	system("PAUSE");

}

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

int main(void){
    int n, k, s;
    while(cin>>n>>k>>s, n){
        ll ans=0;
        for(int i=0; i<(1<<n); i++){
            int sum=0, count=0;
            for(int j=0; j<n; j++){
                if((1&i>>j)==1) {
                    sum+=j+1;
                    count++;
                }
            }
            if(count==k&&sum==s) ans++;
        }
        cout << ans << "\n";
    }

}



Measured memory_bytes: 3072
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int a, b;
	int multi;

	cin >> a >> b;

	multi = a*b;

	if(multi % 2 == 0){
		cout << "Even" << endl;
	}
	else{
		cout << "Odd" << endl;
	}

}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long int llint;
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	string N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (N[i] == '2')ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,K = i_map()
    s = list(input())

    l = []
    if s[0] == "0":
        l.append(0)

    for i,k in itertools.groupby(s):
        l.append(len(list(k)))
    if s[-1] == "0":
        l.append(0)

    l = list(itertools.accumulate(l))

    ans = 0
    if len(l) < 2*K:
        ans = max(l)
        print(ans)
        exit()

    for i in range(0,n,2):
        if i+2*K >= len(l):
            break
        if i == 0:
            ans = max(ans, l[(i+2*K)])
        else:
            ans = max(ans, l[(i+2*K)] - l[i-1])
    print(ans)






if __name__=="__main__":
    main()


Measured memory_bytes: 87268
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	string S, T;
	cin >> S >> T;
	vector< int > accS(S.size() + 1), accT(T.size() + 1);
	accS[0] = 0;
	accT[0] = 0;
	rep(i, S.size()) {
		accS[i + 1] = accS[i] + (S[i] == 'A' ? 1 : 2);
	}
	rep(i, T.size()) {
		accT[i + 1] = accT[i] + (T[i] == 'A' ? 1 : 2);
	}
	cin >> Q;
	while (Q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		string ans;
		int tmp = (accS[b] - accS[a - 1]) - (accT[d] - accT[c - 1]);
		tmp = (tmp % 3 + 3) % 3;
		if (tmp == 0)
			ans = "YES";
		else
			ans = "NO";
		cout << ans << endl;
	}
	//cout << accS << accT;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
const int INF = 1e9;

struct WarshallFloyd{
    int n;
    const int INF = 1e6;
    vector<vector<int> > d;
    WarshallFloyd(int _n){
        n = _n;
        d.resize(n, vector<int>(n));
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
    }
    void build(){
        for(int k = 0; k < n; k++){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }
};

int n, m, r;
int d[1010][210];

int main(){
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        WarshallFloyd wfl(n), wfs(n);
        rep(i, 0, m){
            int x, y, t; char c;
            cin >> x >> y >> t >> c;
            x--; y--;
            if(c == 'L'){
                wfl.d[x][y] = t;
                wfl.d[y][x] = t;
            }else{
                wfs.d[x][y] = t;
                wfs.d[y][x] = t;
            }
        }
        cin >> r;
        vector<int> z(r);
        rep(i, 0, r){
            cin >> z[i];
            z[i]--;
        }
        wfl.build();
        wfs.build();
        rep(i, 0, r) rep(j, 0, n) d[i][j] = INF;
        d[0][z[0]] = 0;
        rep(i, 1, r){
            rep(j, 0, n){
                if(d[i - 1][j] >= INF) continue;                
                rep(k, 0, n){
                    int tmp = wfl.d[z[i - 1]][j] + wfs.d[j][k] + wfl.d[k][z[i]];
                    if(j == k) tmp = wfl.d[z[i - 1]][z[i]];
                    d[i][k] = min(d[i][k], d[i - 1][j] + tmp);
                }
            }
        }
        int ans = INF;
        rep(i, 0, n) ans = min(ans, d[r - 1][i]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 4068
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int[] num = new int[5];
		for(int i = 0;i < num.length;i++){
			num[i] = saori.saori_hayami();
		}
		int k = saori.saori_hayami();
		boolean flg = true;
		for(int i = 0;i < num.length-1;i++){
			for(int j = i+1;j < num.length;j++){
				if(num[j] - num[i] > k){
					flg = false;
					break;
				}
			}
			
		}
		if(flg){
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

int n, ans = INF;
vector<int> num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void f(int x){
    if(x >= n){
        ans = min(ans, x);
        return;
    }
    REP(i, num.size()){
        int tmp = x;
        tmp = x * 10 + num[i];
        if(tmp == 0) continue;
        f(tmp);
    }

}

signed main(void){
    int k; cin >> n >> k;
    REP(i, k){
        int tmp = in();
        for(auto it = num.begin(); it != num.end();){
            if(*it == tmp){
                it = num.erase(it);
            }else{
                it++;
            }
        }
    }

    f(0);
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
def resolve():
    input()
    A = [int(i) for i in input().split()]
    Q = int(input())
    for _ in range(Q):
        q = [int(i) for i in input().split()]
        if q[0] == 0:
            print(min(A[q[1]:q[2]]))
        else:
            print(max(A[q[1]:q[2]]))


resolve()


Measured memory_bytes: 5632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> t, vector<ll> x, vector<ll> y) {
  bool ok = true;
  int px = 0, py = 0, pt = 0;
  REP(i,N) {
    int d = abs(px - x[i]) + abs(py - y[i]);
    int dt = t[i] - pt;
    if (!(d <= dt && d % 2 == dt % 2)) ok = false;
    px = x[i]; py = y[i]; pt = t[i];
  }
  cout << ok << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> y(N-1+1);
	vector<ll> t(N-1+1);
	vector<ll> x(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &t[i]);
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	}
	solve(N, t, x, y);
	return 0;
}


Measured memory_bytes: 4992
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;
    auto K = readln.chomp.to!int;

    auto dp = new int[][][](N, N, K+1);
    foreach (i; 0..N) dp[i][i][0] = 1;
    if (K > 0) foreach (i; 0..N-1) dp[i][i+1][S[i]!=S[i+1]] = 2;
    else foreach (i; 0..N-1) if (S[i] == S[i+1]) dp[i][i+1][0] = 2;

    foreach (len; 1..N+1) {
        foreach (il; 0..N-len+1) {
            foreach (k; 0..K+1) {
                int ir = il + len - 1;
                if (il > 0) dp[il-1][ir][k] = max(dp[il-1][ir][k], dp[il][ir][k]);
                if (ir < N - 1) dp[il][ir+1][k] = max(dp[il][ir+1][k], dp[il][ir][k]);
                if (il > 0 && ir < N - 1) {
                    int cost = S[il-1] != S[ir+1];
                    if (k + cost <= K) {
                        dp[il-1][ir+1][k+cost] = max(dp[il-1][ir+1][k+cost], dp[il][ir][k] + 2);
                    }
                }
            }
        }
    }

    dp[0][N-1].reduce!max.writeln;
}


Measured memory_bytes: 191612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t;
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char a[maxn];
stack<char>p;
int main()
{
    int i,j;
    scanf("%s",&a);
    for(i=0;a[i];i++)
    {
        if(!p.empty()&&p.top()=='S'&&a[i]=='T')p.pop();
        else p.push(a[i]);
    }
    printf("%d\n",p.size());
    //system("Pause");
    return 0;
}


Measured memory_bytes: 640
import itertools

while 1:
    n = int(input())
    k = int(input())
    if n == k == 0:
        break
    a = []
    for i in range(n):
        a.append(input())
    
    b = []
    p = list(itertools.permutations(a, k))
    for i in p:
        b.append(''.join(i))
    c = list(set(b))
    print(len(c))


Measured memory_bytes: 7056
#1行目
n = gets.chomp.to_i

unchi = 0

if n < 10 #1桁
  unchi = n
elsif n >= 10 and n < 100
  unchi = 9
elsif n >= 100 and n < 1000
  unchi = n - 99 + 9
elsif n >= 1000 and n < 10000
  unchi = 909
elsif n >= 10000 and n < 100000
  unchi = n -9999 + 909
else
  unchi = 90909
end

print unchi

Measured memory_bytes: 1788
N=int(input())
A=list(int(x) for x in input().split())

def gcd (m,n):
	if n>m:
		return gcd(n,m)
	if n==0:
		return m
	return gcd(n,m%n)

L=[0 for i in range(N+1)]
R=[0 for i in range(N+1)]
for i in range(N):
	L[i+1]=gcd(L[i],A[i])
for i in range(N,0,-1):
	R[i-1]=gcd(R[i],A[i-1])

ans=[0 for i in range(N)]
for i in range(N):
	ans[i]=gcd(L[i],R[i+1])

print(max(ans))

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S,T,U;
    cin >> S>>T>>U;
    cout << 'A' << T.at(0) << 'C' << endl;
    return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i64 a, b, c;
    cin >> a >> b >> c;
    i32 d = c - a - b;
    if (d > 0 && 4 * a * b < d * d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define ll long long
#define ar array

const int mxN=2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];

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

	cin >> n >> m >> k;
	for(int i=0; i<n; ++i) {
		cin >> a[i+1];
		a[i+1]+=a[i];
	}
	for(int i=0; i<m; ++i) {
		cin >> b[i+1];
		b[i+1]+=b[i];
	}
	int ans=0;
	for(int i=0, j=m; i<=n; ++i) {
		if(a[i]>k)
			break;
		while(a[i]+b[j]>k)
			--j;
		ans=max(i+j, ans);
	}
	cout << ans;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    int n,i,j,k,q,mi,ma,x;
    cin>>n>>k>>q;
    int a[n],c[n];
    REP(i,0,n-1) cin>>a[i],c[i]=a[i];
    sort(c,c+n);
    int ans=c[q-1]-c[0];
 	multiset<int> s;
    REP(i,0,n-k-q){
    	s.clear();
    	vi v;
    	REP(j,0,n-1){
    		if(a[j]<=c[i]){
    			if(sz(v)>=k){
    				sort(all(v));
    				REP(x,0,sz(v)-k) s.insert(v[x]);
    			}
    			v.clear();
    		}else v.EB(a[j]);
    	}	
    	if(sz(v)>=k){
    		sort(all(v));
    		REP(x,0,sz(v)-k) s.insert(v[x]);
    	}
    	if(sz(s)<q) break;
    	mi=MX;
    	ma=0;
    	auto it=s.begin();
    	REP(j,1,q){
    		mi=min(mi,*it);
    		ma=max(ma,*it);
    		it++;
    	}
    	ans=min(ans,ma-mi);
    }
    cout<<ans;
   	return 0;   
} 

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<int> adj[200005];
bool visited[200005];

int dfs (int u) {
	int ans = 0;
	if (!visited[u]) {
		visited[u] = true;
		ans++;
		for (auto v : adj[u]) {
			ans += dfs(v);
		}
	}
	return ans;
}

signed main()
{
	int n, m;
	cin >> n >> m;
	
	memset (visited, false, sizeof (visited));
	
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back (b);
		adj[b].push_back (a);
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!visited[i + 1]) {
			ans = max (ans, dfs(i + 1));
		}
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 20884