akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n;
ld p[3002];
ld dp[3002][3002];
bool vis[3002][3002];

ld rec(int pos, int heads){
    if(pos >= n){
        if(heads > 0){
            return (ld)0;
        }
        return (ld)1;
    }
    if(vis[pos][heads])
        return dp[pos][heads];
    ld A = 0, B = 0;
    if(heads > 0) A = rec(pos + 1, heads - 1) * p[pos];
    B = rec(pos + 1, heads) * (1 - p[pos]);
    vis[pos][heads] = true;
    return dp[pos][heads] = A + B;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n;
    f(i, n) cin>>p[i];
    memset(vis, false, sizeof(vis));
    int to = (n + 1)/2;
    ld ans = 0;
    rep(i, to, n) ans += rec(0, i);
    cout<<setprecision(10)<<fixed<<ans;
    return 0;
}

Measured memory_bytes: 150016
#include <cstdio>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	int mini = 1145141919;
	int mindif = 1145141919;
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i <= 20000; i++){
		char a[16];
		sprintf(a, "%d", i);
		
		char b[16];
		strcpy(b, a);
		reverse(b, b + strlen(b));
		
		if (strcmp(a, b) == 0){
			if (mindif > abs(n - i)){
				mindif = abs(n - i);
				mini = i;
			}
		}
	}
	
	printf("%d\n", mini);
	
	return 0;
}

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

int h,w;
vector<string> s;

bool solve();
bool isvalid(int x,int y){
    return x >= 0 && x < h && y >= 0 && y < w;
}

int main(){
    cin >> h >> w;
    s.resize(h);
    for(int i = 0;i < h;++i)cin >> s[i];
    if(solve())cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

bool solve(){
    int cnt = 0,x = 0,y = 0,now = 1;
    for(int i = 0;i < h;++i)for(int j = 0;j < w;++j)cnt += s[i][j] == '#';
    while(x != h-1 || y != w-1){
        if(isvalid(x+1,y)&&isvalid(x,y+1)&&s[x+1][y] == s[x][y+1] && s[x][y+1] == '#')return 0;
        if(isvalid(x+1,y)&& s[x+1][y] == '#'){
            ++now;
            ++x;
            continue;
        }
        if(isvalid(x,y+1) && s[x][y+1] == '#'){
            ++now;
            ++y;
            continue;
        }
        return 0;
    }
    return  cnt == now;
}

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

namespace AtCorder
{
	public class Program
	{
		static long[] count;
		static List<int>[] to;
		static long[] adds;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int q = cin.Int();

			int max = 200001;
			to = new List<int>[max];
			for (int i = 0; i < max; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < n - 1; i++) {
				int a = cin.Int() - 1;
				int b = cin.Int() - 1;
				to[a].Add(b);
				to[b].Add(a);
			}

			adds = new long[max];
			for (int i = 0; i < q; i++) {
				int p = cin.Int() - 1;
				int x = cin.Int();
				adds[p] += x;
			}

			count = new long[max];

			dfs(0, -1);

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.Append($"{count[i]} ");
			}

			Console.WriteLine(sb.ToString());
		}

		static void dfs(int n, int parent)
		{
			count[n] = adds[n];
			foreach (int next in to[n]) {
				if (next != parent) {
					adds[next] += adds[n];
					dfs(next, n);
				}
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 74504
#include<bits/stdc++.h>
using namespace std;
int main()
{int a,b;
 cin>>a>>b;
 string s;
 s="";
 if(a>b)
 {
   for(int i=0;i<a;i++)
     s+=char(48+b);
 }
 else
 {for(int i=0;i<b;i++)
     s+=char(48+a);
 }
  cout<<s;
 return 0;
}

Measured memory_bytes: 256
import numpy as np
a, b= map(int, input().split())
if a % 2 ==0:
    start = a
    remain_before = 0
else:
    start = a+1
    remain_before = a

if b % 2 ==0:
    end = b-1
    remain_after = b
else:
    end = b
    remain_after = 0

if ((end+1-start) /2) %2 == 0:
    num = 0
else:
    num = 1

print(remain_before ^ num ^ remain_after)

Measured memory_bytes: 12500
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    bool nega = false, posi = false;
    if(a[0]<0)nega=true;
    if(a[n-1]>=0)posi = true;
    if(posi&&nega){
        vector<int> po, ne;
        ll ans = 0;
        rep(i,n){
            if(a[i]>=0)po.push_back(a[i]);
            else ne.push_back(a[i]);
            ans += abs(a[i]);
        }
        cout<<ans<<endl;
        while(po.size()>1){
            cout<<ne[0]<<" "<<po.back()<<endl;
            ne[0]-=po.back();
            po.pop_back();
        }
        while(ne.size()){
            cout<<po[0]<<" "<<ne.back()<<endl;
            po[0]-=ne.back();
            ne.pop_back();
        }
        return 0;
    }
    else if(posi){
        ll ans = 0;
        rep(i,n-1)ans+=a[i+1];
        cout<<ans-a[0]<<endl;
        rep(i,n-2){
            cout<<a[0]<<" "<<a[i+1]<<endl;
            a[0]-=a[i+1];
        }
        cout<<a[n-1]<<" "<<a[0]<<endl;
        return 0;
    }
    else {
        ll ans = 0;
        reverse(a.begin(), a.end());
        rep(i,n-1)ans-=a[i+1];
        cout<<ans+a[0]<<endl;
        rep(i,n-1){
            cout<<a[0]<<" "<<a[i+1]<<endl;
            a[0]-=a[i+1];
        }
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3192
S = list(input())

length_max = 0
for i in range(len(S)):
    if S[i] in ["A", "G", "C", "T"]:
        length = 1
        for j in range(i+1, len(S)):
            if S[j] in ["A", "G", "C", "T"]:
                length += 1
            else:
                break
        if length > length_max:
            length_max = length
print(length_max)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int a = 0, b = 0;
  REPx(x, s)
  {
    if (x == 'A') a++;
    else b++;
  }
  if (a && b) cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define id(x,lev) x*52+lev
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int mod = 998244353;
inline int mul(int x,int y){return 1ll*x*y%mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}
int n,su = 0,a[330],dp[90020] = {0},dp2[90020];
int main() {
	read(n);
	dp[0] = dp2[0] = 1;
	int ans = pow(3,n);
	for(int i=0;i<n;i++){
		read(a[i]);
		su+=a[i];
		for(int j=su;j>=0;j--){
			dp[j] = add(dp[j],dp[j]);
			if(j>=a[i]){
				dp[j] = add(dp[j],dp[j-a[i]]);
				dp2[j] = add(dp2[j],dp2[j-a[i]]);
			}
		}
	}
	for(int i=((su+1)/2);i<=su;i++){
		ans = sub(ans,mul(3,dp[i]));
	}
//	cout<<ans<<endl;
	if(su%2== 0){
		ans = add(ans,mul(dp2[su/2],3));
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    static const int64_t mod = 998244353;
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> S_vec(K);
    int L, R;
    for (int i = 0; i < K; ++i) {
        cin >> L >> R;
        S_vec.at(i) = {L, R};
    }
    vector<int64_t> dp(N + 1, 0);
    dp.at(1) = 1;
    dp.at(2) = -1;
    int64_t cnt = 1;
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < K; ++j) {
            L = S_vec.at(j).first;
            R = S_vec.at(j).second;
            if (i + L <= N)
                dp.at(i + L) += cnt;
            if (i + R < N)
                dp.at(i + R + 1) -= cnt;
        }
        cnt = (cnt + dp.at(i + 1)) % mod;
    }
    if (cnt < 0)
        cnt += mod;
    cout << cnt << endl;
}


Measured memory_bytes: 4840
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		while (stdin.hasNextLine()) {
			int tnum = stdin.nextInt();
			int hnum = stdin.nextInt();
			if (tnum == 0 && hnum == 0) break;
			int[] tarohands = new int[tnum];
			int[] hanahands = new int[hnum];
			for (int i = 0; i < tnum; i++){
				tarohands[i] = stdin.nextInt();
			}
			for (int i = 0; i < hnum; i++) {
				hanahands[i] = stdin.nextInt();
			}
			System.out.println(solve(tarohands, hanahands));
		}
		System.exit(0);
	}
	public static String solve(int[] taro, int[] hana) {
		int sumt = 0;
		int sumh = 0;
		for (int i = 0; i < taro.length; i++) {
			sumt += taro[i];
		}
		for (int i = 0; i < hana.length; i++) {
			sumh += hana[i];
		}
		if ((sumt + sumh) % 2 != 0) return "-1";
		// 基本的な考え方のみ．あとは，taro[i]-hana[j] > (sub/2)の場合ははhana[]にプラスするとか．
		int sub = sumt - sumh;
		Arrays.sort(taro);
		Arrays.sort(hana);
		for (int i = 0; i < taro.length; i++) {
			for (int j = 0; j < hana.length; j++) {
				if (taro[i] - hana[j] == (sub / 2)) {
					return Integer.toString(taro[i]) + " " + Integer.toString(hana[j]);
				}
			}
		}
		return "-1";
	}
}

Measured memory_bytes: 21128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String o = scanner.next(),e = scanner.next();
		String s = "";
		if(o.length() == e.length()){
			for(int i=0;i<o.length();i++){
				s += o.charAt(i);
				s += e.charAt(i);
			}
		}else{
			for(int i=0;i<o.length()-1;i++){
				s += o.charAt(i);
				s += e.charAt(i);
			}
			s += o.charAt(o.length()-1);
		}
		System.out.println(s);
	}

}


Measured memory_bytes: 20948
N, W = map(int, input().split())
goods = [list(map(int, input().split())) for i in range(N)]
v_sum = sum([i[1] for i in goods])
dp = [float("inf") for i in range(v_sum + 1)]
dp[0] = 0
for i in range(N):
    for j in range(v_sum, -1, -1):
        dp[j] = min(dp[j - goods[i][1]] + goods[i][0], dp[j])

for i in range(v_sum, -1, -1):
    if dp[i] <= W:
        print(i)
        break


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, LIM; scanf("%d %d", &N, &LIM);
  vector<int> W(N), V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &W[i], &V[i]);
  }

  vector<vector<int>> dp(N + 5, vector<int>(305, 0));

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int diff = W[i] - W[0];
    sum += diff;
    for (int j = sum; j >= 0; --j) {
      if (j - diff < 0) { continue; }
      for (int p = i + 1; p >= 1; --p) {
        dp[p][j] = max(dp[p][j], dp[p - 1][j - diff] + V[i]);
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= sum; ++j) {
      if (1LL* i * W[0] + j <= LIM) {
        ans = max(ans, dp[i][j]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main()
{
    int x_1, y_1, x_2, y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;

    double r = sqrt(pow(x_1 - x_2, 2.0) + pow(y_1 - y_2, 2.0));
    double x_3 = x_1 + ((x_2 - x_1) - (y_2 - y_1));
    double y_3 = y_1 + ((x_2 - x_1) + (y_2 - y_1));
    double x_4 = x_1 + (x_3 - x_2);
    double y_4 = y_1 + (y_3 - y_2);
    cout << (int)x_3 << " "
         << (int)y_3 << " "
         << (int)x_4 << " "
         << (int)y_4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s;
  cin >> s;
  int gcnt = 0, pcnt = 0, score = 0;
  for(int i = 0; i < s.size(); i++){
    if(gcnt > pcnt){
      if(s[i] == 'g') score++;
      pcnt++;
    }else{
      if(s[i] == 'p') score--;
      gcnt++;
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	int i;
	cin>>s;
	for(i=0;s[i]!='\0';i++);
	if(s[i-1]!='s')
	cout<<s<<"s"<<endl;
	else
	cout<<s<<"es"<<endl;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rrep(i,n) for(int i = 1;i < (n);++i)
constexpr int mod = 1000000007;

int modPow(long long a, long long n, long long p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

int main() {
	int n, a, b; cin >> n >> a >> b;
	ll res1 = modPow(2, n, mod);
	ll res2 = comb(n, a);
	ll res3 = comb(n, b);
	ll ans = ((res1 - res2 - res3 - 1) % mod + mod) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf (1000000000000000000LL)
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
LL n,a,b,c,d;
map<LL,LL>dp;
LL dfs(LL dep){
	if(dep==0)return 0;
	if(dp.count(dep))return dp[dep];
	LL &ans=dp[dep];
	ans=(Inf)/dep<d?Inf:dep*d;
	ans=min(ans,dfs(dep/2)+a+(dep%2)*d);
	ans=min(ans,dfs(dep/3)+b+(dep%3)*d);
	ans=min(ans,dfs(dep/5)+c+(dep%5)*d);
	ans=min(ans,dfs(dep/2+1)+a+(2-dep%2)*d);
	ans=min(ans,dfs(dep/3+1)+b+(3-dep%3)*d);
	ans=min(ans,dfs(dep/5+1)+c+(5-dep%5)*d);
	return ans;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n>>a>>b>>c>>d;
		dp.clear();
		cout<<dfs(n)<<endl;
	}
	return 0;
}


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

int main() {
    // input
    int N;
    string S;
    cin >> N >> S;

    // solve
    int ans = 0, x = 0;
    for (int i = 0; i < N; ++i) {
        switch (S[i]) {
        case 'I':
            x += 1;
            if (ans < x) ans = x;
            break;
        case 'D':
            x -= 1;
            break;
        }
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::f64;

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}
fn trial_division(mut n: usize) -> HashMap<usize, usize> {
    let mut primes = HashMap::new();
    let mut i = 2;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            if primes.contains_key(&i) {
                let x = primes.get_mut(&i).unwrap();
                *x += 1;
            } else {
                primes.insert(i, 1);
            }
        }
        i += 1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    if n > 1 {
        if primes.contains_key(&n) {
            let x = primes.get_mut(&n).unwrap();
            *x += 1;
        } else {
            primes.insert(n, 1);
        }
    }
    primes
}

fn main() {
    input! {
        n : usize,
    }
    let x = trial_division(n);
    let mut counter = 0;
    for map in x.iter() {
        let mut n = *(map.1);

        let mut coll: Vec<u64> = Vec::new();

        let mut sub: u64 = 1;
        while n >= sub as usize {
            if !coll.contains(&sub) {
                coll.push(sub);
                n -= sub as usize;
                sub += 1;
            } else {
                break;
            }
        }
        counter += coll.len();
    }
    println!("{}", counter);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int calc(int h, int w, int k, vector<string>& s, vector<bool> cut) {
	int tmp = 0;
	int cnt = 1;
	rep(i, h) {
		if (cut[i]) cnt++;
	}
	V rem(cnt, 0);
	rep(i, w) {
		V zeros(cnt, 0);
		int pos = 0;
		rep(j, h) {
			zeros[pos] += s[j][i];
			if (zeros[pos] > k) tmp = upper; // あ　ほ　く　さ
			if (cut[j]) pos++;
		}
		bool valid = true;
		rep(m, cnt) {
			if (rem[m] + zeros[m] > k) valid = false;
		}
		if (valid) {
			rep(m, cnt) rem[m] += zeros[m];
		}
		else {
			tmp++;
			rep(m, cnt) rem[m] = zeros[m];
		}
	}
	return tmp;
}
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	rep(i, h) rep(j, w) {
		s[i][j] -= '0';
	}
	int ans = upper;
	rep(bit, (1 << (h - 1))) {
		int tmp = 0;
		vector<bool> cut(h, false);
		rep(i, h) {
			if (bit & (1 << i)) {
				cut[i] = true;
				tmp++;
			}
		}
		chmin(ans, tmp + calc(h, w, k, s, cut));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.ets", "r", stdin );
	int n, m;

	while (cin >> n >> m && n && m){
		vector <int> taro (n, 0 );
		for (int i = 0; i < n; ++i ){
			cin >> taro[i];
		} // end for
		vector <int> hanako (m, 0 );
		for (int j = 0; j < m; ++j ){
			cin >> hanako[j];
		} // end for
		sort (taro.begin(), taro.end() );
		sort (hanako.begin(), hanako.end() );
		
		int res = INT_MAX;
		P res_p;

		for (int i = 0; i < n; ++i ){
			for (int j = 0; j < m; ++j ){
				vector <int> t = taro;
				vector <int> h = hanako;
				P p (t[i], h[j] );
				int temp = t[i];
				t[i] = h[j];
				h[j] = temp;
				int sum_t = accumulate (t.begin(), t.end(), 0 );
				int sum_h = accumulate (h.begin(), h.end(), 0 );
				
				if (sum_t == sum_h ){
					if (res > t[i] + h[j] ){
						res = t[i] + h[j];
						res_p = p;
					} // end if
				} // end if
			} // end for
		} // end for

		if (res == INT_MAX ){
			cout << "-1" << endl;
		}else{
			cout << res_p.first << ' ' << res_p.second << endl;
		} // end if
	} // end loop
		
	return 0;
}

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

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

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

string S;

bool which() {
    if(S[5] == '1') return 0;
    if(S[6] < '4') return 1;
    if(S[6] > '4') return 0;
    if(S[8] < '3') return 1;
    if(S[9] == '0') return 1;
    return 0;
}

int main() {
    cin >> S;
    cout << (which() ? "Heisei" : "TBD") << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
	N = int(input())
	s = []
	for i in range(N):
		s.append(input())
	M = int(input())
	t = []
	for i in range(M):
		t.append(input())

	s_uniq = list(set(s))
	s_dict = {}
	for i in range(len(s_uniq)):
		s_dict[s_uniq[i]] = s.count(s_uniq[i])
	t_uniq = list(set(t))
	t_dict = {}
	for i in range(len(t_uniq)):
		t_dict[t_uniq[i]] = t.count(t_uniq[i])

	u_list = []
	for i in range(len(s_uniq)):
		if s_uniq[i] in t_dict.keys():
			u_list.append(s_dict[s_uniq[i]] - t_dict[s_uniq[i]])
		else:
			u_list.append(s_dict[s_uniq[i]])
	if max(u_list) < 1:
		print(0)
	else:
		print(max(u_list))

if __name__ == '__main__':
    main()

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

using namespace std;

string s;
int N;

int main() {
  cin >> N;
  while ( N-- ) {
    cin >> s;
    vector<int> data[10000];
    int now = 0;
    for ( int i = 0; i < s.size(); i++ ) {
      if ( s[i] == '[' ) now++;
      else if ( s[i] == ']' ) {
	if ( data[now].size() ) {
	  sort(data[now].begin(), data[now].end());
	  int tmp = 0;
	  for ( int j = 0; j < (data[now].size() + 1) / 2; j++ ) {
	    tmp += data[now][j];
	  }
	  data[now].clear();
	  data[now - 1].push_back(tmp);
	}
	now--;
      }
      else {
	int tmp = 0;
	for(; s[i] != ']'; i++) {
	  tmp *= 10;
	  tmp += s[i] - '0';
	}
	i--;
	data[now].push_back((tmp + 1) / 2);
      }
    }

    cout << data[0][0] << endl;
  }
}

Measured memory_bytes: 3436
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) ((int)(c).size())
#define all(c) (c).begin(),(c).end()
#define m0(a) memset(a,0,sizeof(a))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
#ifdef LOCAL
#define debug(...) debug_vars(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
const int INF = 1 << 28;
const double EPS = 1e-8;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M;
bool ab[10][10];
int cond;
ll ans = 0;

ll rec(int cur, int pass) {
    if (pass == cond) return 1;
    ll cnt = 0;
    rep(i, 1, N + 1) {
        if (ab[cur][i] == 0) continue;
        if ((pass >> (i - 1)) % 2) continue;
        cnt += rec(i, pass | (1 << (i - 1)));
    }
    return cnt;
}

int main()
{
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        ab[a][b] = ab[b][a] = true;
    }
    cond = 0xFFFFFFFF >> (32 - N);
    ans = rec(1, 1);
    write(ans);
}

Measured memory_bytes: 256
N=int(input())
l=len(str(N))
if l==1:
  print(N)
elif l==2:
  print(9)
elif l==3:
  print(N-90)
elif l==4:
  print(909)
elif l==5:
  print(N-9090)
elif l==6:
  print(90909)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np


def main():
    # 入力処理
    # M = int(input())
    N, M = map(int, input().split())
    sA = ''.join([input() for i in range(N)])
    sB = ''.join([input() for i in range(M)])
    A = np.array([s for s in sA]).reshape(N,N)
    B = np.array([s for s in sB]).reshape(M,M)

    # アルゴリズム本体
    result = np.zeros((N-M+1,N-M+1), dtype=bool)
    for i in range(N-M+1):
        for j in range(N-M+1):
            result[i,j] = (A[i:i+M, j:j+M] == B).all()

    # 出力
    if result.any():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 20668
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#include <bitset>
#include <cstring>
using namespace std;

#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
int r, c;
char a[1000][1000];
ll dp[1000][1000];
ll f(int i, int j) {
	if (i == r - 1 && j == c - 1)
		return 1;
	else if (a[i][j] == '#' || i >= r || j >= c)
		return 0;
	else if (dp[i][j] != -1)
		return dp[i][j];
	else
		return dp[i][j] = (f(i + 1, j) % mod + f(i, j + 1) % mod) % mod;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> r >> c;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
			cin >> a[i][j];
	}
	memset(dp, -1, sizeof(dp));
	cout << f(0, 0) << endl;
	return 0;
}

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


int main() {
  int N,K;
  int n = 1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if((2*n)>(n+K)){
        n += K;
    }
    else{
        n *= 2;
    }
  }
  cout << n << endl;
 }

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int M = nextInt();

        String ans = N == M ? "Yes" : "No";
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }

    public static double nextDouble() throws Exception {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 24916
# -*- coding: utf-8 -*-
"""
"""
import sys


def solve(d, w, h, holes):
    result = []
    diagonal_len = (w**2 + h**2)**0.5
    for r in holes:
        if r*2 > diagonal_len:
            result.append('OK')
        else:
            result.append('NA')
    # ???????????\????????£?????¢???1????????????: ????????????r x 2**0.5
    #for r in holes:
    #    side_max = max(w, h)
    #    if r*2**0.5 >= side_max:
    #       result.append('OK')
    #    else:
    #        result.append('NA')
    return result


def main(args):
    while True:
        #d, w, h = 10, 6, 8
        #holes = [4, 8, 6, 2, 5]
        d, w, h = [int(x) for x in input().strip().split(' ')]
        if d == 0 and w == 0 and h == 0:
            break
        num = int(input())
        holes = [int(input().strip()) for _ in range(num)]
        result = solve(d, w, h, holes)
        for r in result:
            print(r)


if __name__ == '__main__':
    main(sys.argv[1:])

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

using namespace std;

int main(){
    int n;
    int a[111];
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", a + i);
    }
    sort(a, a + n);
    printf("%d\n", a[n - 1] - a[0]);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535898
int main()
{
    int l,h,v;
    double k; 
    double a;
    scanf("%d %d %d",&l,&h,&v);
    if(v>=l*l*h/2){
        k=2.0*(l*l*h-v)/(l*l);
        a=l/k;
    }
    else{
        k=2.0*v/(l*h);
        a=k/h;
    }
    double result;
    result=atan(a);
    result*=180/PI;
    result=90-result;
    printf("%.10f",result);
    return 0;
}


Measured memory_bytes: 128
def shellsort(A):
    def insertionSort(A, g):
        cnt = 0
        for i in xrange(g, len(A)):
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v:
                A[j + g] = A[j]
                j = j - g
                cnt += 1
            A[j + g] = v
        return cnt
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G = G[::-1]
    print len(G)
    print " ".join(map(str, G))
    for i in G:
        cnt += insertionSort(A, i)
    print cnt

n = int(raw_input())
A = [int(raw_input()) for i in xrange(n)]
shellsort(A)
for i in A:
    print i

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

int main() {
    int n; cin >> n;
    bool isY = false;
    for(int i = 0; i < n; i++) {
        char s; cin >> s;
        if(s == 'Y') isY = true;
    }
    if(isY) cout << "Four" << endl;
    else cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  int sum=0;
  cin >> N;
  rep(i, N) {
    int l, r;
    cin >> l >> r;
    sum+=(r-l+1);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
long long int s;
void check(long long int a,long long int m){
	s+=m+a;
	for(long long int i=10;i<a;i*=10){
		check(a/i,m+a%i);
	}
}

int main(){
	long long int a;
	int n,m;
	int i,j,k;
	cin>>a;
	check(a,0);
	cout<<s<<endl;
}
	
	

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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;



int main()
{
	// USE_IOSTREAM;
	ll aI, aO, aT, aJ, aL, aS, aZ;
	cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;
	ll ans = 0;
	
	int bOddI, bOddJ, bOddL;
	bOddI = aI % 2;
	bOddJ = aJ % 2;
	bOddL = aL % 2;
	
	int tot = bOddI + bOddJ + bOddL;
	ans = aO * 2;
	if (tot <= 1)
	{
		ans += (aI / 2 + aJ / 2 + aL / 2) * 4;
	}
	else if (tot == 2)
	{
		ans += (aI / 2 + aJ / 2 + aL / 2) * 4;
		if (bOddI)
		{
			if (bOddJ && aL || bOddL && aJ)
			{
				ans += 2;
			}
		}
		else
		{
			if (aI)
			{
				ans += 2;
			}
		}
	}
	else
	{
		ans += (aI / 2 + aJ / 2 + aL / 2) * 4;
		ans += 6;
	}
	
	cout << ans / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, k, c, ans;
int main() {
	ll i, j;
	cin >> n;
	k = n;
	for(i=2; i*i<=n; i++) {
		c = 0;
		while(k%i==0) c++, k/=i;
		for(j=1; c>0; j++) {
			c -= j;
			if(c>=0) ans++;
		}
	}
	if(k>1) ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3672
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2e5 + 5;

int k,n;
int arr[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>k>>n;
    REP(i,1,n)cin>>arr[i];
    arr[0] = arr[n] - k;
    arr[n+1] = arr[1] + k;

    int ans = OO;
    REP(i,1,n){
    	ans = min(ans, k - (arr[i]-arr[i-1]));
    	ans = min(ans, k - (arr[i+1]-arr[i]));
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n, tl;
    scanf("%d%d",&n,&tl);
    int c[n], t[n];
    int min = 1001;
    for(int i=0; i<n; i++){
        scanf("%d%d",&c[i], &t[i]);
        if(t[i] <= tl && c[i] < min){
            min = c[i];
        }
    }
    if(min != 1001){
        printf("%d\n", min);
    }else{
        printf("TLE\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll T1, T2, A1, A2, B1, B2;

signed main(){
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    if(A1 > B1){
        swap(A1, B1);
        swap(A2, B2);
    }
    if(A1 == B1 && B1 > B2){

    }
    if(A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2){
        PRINT("infinity");
        return 0;
    }
    if(A1 * T1 + A2 * T2 < B1 * T1 + B2 * T2){
        PRINT(0);
        return 0;
    }
    ll d = A1 * T1 + A2 * T2 - (B1 * T1 + B2 * T2);
    ll m = T1 * (B1 - A1);
    ll n = m / d;
    PRINT(2 * n + (n * d != m));
    return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,x;

int main(){
    cin >> n >> x; x/=1000;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(x==i+5*j+10*(n-i-j)){
                cout << n-i-j << ' ' << j << ' ' << i << '\n';
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
# a, b, c = list(map(int, input().split()))

# 1整数
n = int(input())
k = int(input())
x = int(input())
y = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()


if n <= k:
    print(x * n)
else:
    print((x * k) + (y * (n - k)))


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    int cnt = 0;
    cin >> h >> w;
    char b[h][w];
    int d[h][w];
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    rep (i, h) {
        rep (j, w) {
            cin >> b[i][j];
            if (b[i][j] == '#') {
                d[i][j] = -1;
                cnt++;
            } else {
                d[i][j] = Inf;
            }
        }
    }

    queue<pair<int, int> > q;
    d[0][0] = 1;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int x, y;
        x = p.first, y = p.second;
        rep (i, 4) {
            int nx, ny;
            nx = x + dx[i], ny = y + dy[i];
            if (nx >= h || nx < 0 || ny >= w || ny < 0) continue;
            if (d[nx][ny] != Inf) continue;
            d[nx][ny] = d[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    if (d[h - 1][w - 1] == Inf) cout << "-1" << endl;
    else cout << h * w - cnt - d[h - 1][w - 1] << endl;

    return 0;
}



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

int main(){
    int x;
    cin >> x;
    set<int> exp;
    exp.insert(1);
    for(int i = 2; i <= sqrt(1000); i++)
    {
        int temp = i*i;
        while(temp <= x){
            exp.insert(temp);
            temp *= i;
        }
    }
    cout << *max_element(exp.begin(), exp.end()) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  int n;
  cin >> n;
  bool Y = false;
  rep(i, n)
  {
    char c;
    cin >> c;
    if (c == 'Y')
      Y = true;
  }
  cout << (Y ? "Four" : "Three") << endl;
  return 0;
}


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

using namespace std;

int main() {
	long long int K, T;
	cin >> K >> T;
	vector<long long int>a( T );
	priority_queue<pair<long long int, long long int>, vector<pair<long long int, long long int>>>que;
	for( size_t i = 0; i < T; i++ ) {
		cin >> a[i];
		que.push( make_pair( a[i], i ) );
	}
	long long int prev = -1;
	int f = 0;
	long long int ans = 0;
	while( que.size() ) {
		pair<long long int, long long int> now = que.top(); que.pop();
		//cout<<now.second<<endl;
		if( now.second == prev ) {
			if( que.size() ) {
				pair<long long int, long long int> next = que.top(); que.pop();
				next.first--;
				prev = next.second;
				if( next.first != 0 ) {
					que.push( next );
				}
				if( now.first != 0 ) {
					que.push( now );
				}
			} else {
				ans = now.first;
				break;
			}
		} else {
			now.first--;
			prev = now.second;
			if( now.first != 0 ) {
				que.push( now );
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256