akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xxx         exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll a[3005],dp[105][100005],p[105][100005]; ll n;
//ll E(ll s, ll k)
//{
//	if(k==0) return 1;
//	if((k>0 || k<0) && s==-1) return 0;
//	if(dp[s][k] != -1) return dp[s][k];
//	ll ans = 0;
//	repi(i,0,min(k,a[s])) ans = ( ans + E(s-1,k-i) )%mod;
//	return dp[s][k] = ans;
//}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,k,l,m,h,w,val,K;
    	cin>>n>>K;
    	repi(i,1,n) cin>>a[i];
		repi(i,0,n) dp[i][0]=p[i][0]=1;
		repi(i,0,K) dp[0][i]=p[0][i]=1;
		repi(i,1,n)
		{
			repi(j,1,K)
			{
				w = (j-a[i]-1)>=0 ? p[i-1][j-a[i]-1] : 0;
				dp[i][j] = ( dp[i][j] + (p[i-1][j] - w + mod)%mod)%mod;
				p[i][j] = (p[i][j-1] + dp[i][j])%mod;
			}
		}
		cout<<dp[n][K];
	}
	return 0;
}

Measured memory_bytes: 161388
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	if (S == "keyence")
	{
		out << "YES" << std::endl;
		return 0;
	}
	rep(i, S.length())
	{
		for (int j = i; j < S.length(); ++j)
		{
			std::string res = S.substr(0, i);
			if (j < S.length() - 1) res += S.substr(j + 1, S.length() - j - 1);
			if (res == "keyence")
			{
				out << "YES" << std::endl;
				return 0;
			}
		}
	}
	out << "NO" << std::endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int MAX_N = 1000;

int main()
{
    // スペース区切りの整数の入力
    long long M,N;
    cin >> N >> M;

    int number[MAX_N];
    long long total = 0;


    for (int i = 0; i < N; i++)
    {
        cin >> number[i];
        total += number[i];
    }

    int tmp;

    for (int i=0; i<N; ++i) {
       for (int j=i+1; j<N; ++j) {
         if (number[i] < number[j]) {
           tmp =  number[i];
          number[i] = number[j];
          number[j] = tmp;
          }
        }
    }

    double b;

    b = total / 4.0 / double(M);

    if (number[M-1] < b)
    {
        cout << "No" << endl;
    }else
    {
        cout << "Yes" << endl;
    }



    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#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> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

int main() {
	ll T1,T2,A1,A2,B1,B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	if (A1 < B1) {
		swap(A1, B1);
		swap(A2, B2);
	}

	ll u = B1 * T1 + B2 * T2 - (A1 * T1 + A2 * T2);

	if (u == 0) {
		puts("infinity");
		return 0;
	}
	if (u < 0) {
		puts("0");
		return 0;
	}

	ll ans = 0;

	if (u < 0) {
		ans = 0;
	} else {
		ans = T1 * (A1 - B1) / u;
	}

	ll ans2 = 0;
	ll d = A1 * T1 - B1 * T1;
	//dump(d);
	//dump((A2 - B2) * T2);
	ll r = ((A2 - B2) * T2 + d) / u;
	ll r2 = d / u;
	if (((A2 - B2) * T2 + d) % u == 0) {
		++r;
	}
	if (d % u == 0) --r2;
	//dump(r);
	//dump(r2);
	ans2 = r2 - r + 1;

	//dump(ans);
	//dump(ans2);
	cout << ans + ans2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next().trim();
        String b = sc.next().trim();
        
        int len = b.length() - a.length();
        
        if (len == 1 && b.startsWith(a)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26828
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int w,h;
	while(cin>>w>>h,w){
		vvi a(h,vi(w));
		vi c(4);
		for(auto&&l:a)for(auto&&i:l)cin>>i;
		for(auto&&i:c)cin>>i;
		
		using node=tuple<int,int,int,int>;
		
		auto cmp=[](node a,node b){return get<0>(a) > get<0>(b);};
		priority_queue<node,vector<node>,decltype(cmp)> q(cmp);
		q.emplace(0,0,0,0);
		vector<vvi> ans(4,vvi(h,vi(w,INT_MAX)));
		while(!q.empty()){
			int cost,v,y,x;
			tie(cost,v,y,x)=q.top();
			q.pop();
			if(ans[v][y][x]!=INT_MAX) continue;
			//cout<<v<<" ("<<y+1<<","<<x+1<<") ="<<cost<<endl;
			ans[v][y][x]=cost;
			if(y==h-1 and x==w-1){
				cout<<cost<<endl;
				break;
			}
			int vec[2][4]={{0,1,0,-1},{1,0,-1,0}};
			for(int i=0;i<4;i++){
				int j=(v+i+4)%4;
				int ny=y+vec[0][j], nx=x+vec[1][j];
				if(ny<0 or nx<0 or ny>=h or nx>=w or ans[j][ny][nx]!=INT_MAX) continue;
				if(a[y][x]==i){
					q.emplace(cost,j,ny,nx);
				}else{
					q.emplace(cost+c[i],j,ny,nx);
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3296
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main(){
   int X;
   cin >> X;
  
   auto tri = [&](int n){
      return n*(n+1)/2;
   };
   
  int i=1; 
  while(1){
    if(tri(i)>=X){
       cout << i <<endl;
      break;
    }
    i++;
  }
 
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DGridGame {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int h,w,n,x,y,m=0;
        in>>h>>w>>n;
        vector<unordered_map<int,bool>> mp(h);
        vector<int> mn(h,w);
        fr(i,n){
            in>>x>>y;
            mp[--x][--y]=true;
            mn[x]=min(mn[x],y);
        }
        Fr(i,h-1){
            if(mn[i]<=m){
                out<<i<<endl;
                return;
            }
            if(!mp[i][m+1]&&m<w-1) ++m;
        }
        out<<h<<endl;
    }
};

int main() {
    DGridGame solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 30592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l; cin>>n>>l;
  vector<string> v(n);
  for(int i=0;i<n;i++) cin>>v.at(i);
  sort(v.begin(), v.end());
  for(int j=0;j<n;j++) cout<<v.at(j);
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	char a; cin >> a;
	a++;
	cout << a << endl;



	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), a, b, c;
ll n, cnt, ans, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a >> b >> c;
  rep(i, n) {
    set<char> st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    if (Size(st) == 1)
      continue;
    else if (Size(st) == 2)
      ans++;
    else
      ans += 2;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    int[] numYakusu = new int[n+1];
    Arrays.fill(numYakusu, 0);

    for(int i = 1; i<n+1; i++){
      for(int j=1; j<n+1; j++){
        if(i * j < n + 1){
          numYakusu[i * j]++;
        }else{
          break;
        }
      }
    }

    long total = 0;
    for(int i=1; i<n+1; i++){
      // System.out.println(i + " : " + numYakusu[i]);
      total += (long)i * numYakusu[i];
    }

    System.out.println(total);

  }
}

Measured memory_bytes: 75368
#include <iostream>

int main(){
    int n;
    
    std::cin >> n;
    int k, p;
    while(n--){
        std::cin >> k >> p;
        
        auto l = k % p;
        
        if(l == 0) l = p;
        
        std::cout << l << std::endl;
    }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int a;
	cin >> a;
	print(a + a * a + a * a*a);
}

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



int main() {
	int n;
	cin >> n;
	hei(ll) a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = a[n - 1];
	int x = INF;
	ll s;
	rep(i, 0, n - 1) {
		if (x > abs((ans / 2) - a[i])) {
			s = a[i];
			x = abs((ans / 2) - a[i]);
		}
		if (x > abs(((ans + 1) / 2) - a[i])) {
			s = a[i];
			x = abs(((ans + 1) / 2) - a[i]);
		}
	}
	cout << ans << " " << s << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var s int
	for i := 0; i < 3; i++ {
		var a int
		fmt.Scan(&a)
		s += a
	}
	if s >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <queue>
#include <list>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 1ULL << 31 - 1;
const ll linf = 1ULL << 63 - 1;
const string nilstr("");

char encode(char c) {
    return c >= 'A' && c <= 'Z' ? c - 'A' : c - 'a' + (char) 26;
}

char decode(char i) {
    return i < 26 ? i + 'A' : i - (char) 26 + 'a';
}

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

int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += x - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def abc057_c():
    from itertools import combinations

    def prime_decomposition(num):
        i = 2
        table = []
        while i * i <= num:
            while num % i == 0:
                num /= i
                table.append(i)
            i += 1
        if num > 1:
            table.append(int(num))
        return table

    n = int(input())
    primes = prime_decomposition(n)
    a = 1
    b = n

    for i in range(len(primes) // 2 + 1):
        comb = set(combinations(primes, i))
        for seq in comb:
            tmp_a = 1
            for v in seq:
                tmp_a *= v
            tmp_b = n // tmp_a
            if max(tmp_a, tmp_b) < max(a, b):
                a = tmp_a
                b = tmp_b

    ans = max(len(str(a)), len(str(b)))
    print(ans)


abc057_c()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(i>=2&&s[i]==s[i-2]){
            cout << i-2+1 << " " << i+1 << endl;
            return 0;
        }
        if(i>0&&s[i]==s[i-1]){
            cout << i-1+1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define int ll
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=52,inf=1e9;
ll m[N];
int dp[N*N*N],jj[N*N*N],p[N],sz[N],sum,q[N*N*N];
bool cmp(int a,int b){
	return sz[a]*m[b]>sz[b]*m[a];
}
signed main(){
	int n=read();ll x=read(); int d=read();
	m[1]=read();
	For(i,2,n){
		m[i]=read(); p[i]=read();
	}
	Rep(i,n,1){
		m[p[i]]+=m[i]; sz[p[i]]+=++sz[i];
	}
	For(i,1,N*N*N-1)dp[i]=x+1;
	For(i,1,n){
		int t=i>1?min(d,n):n;
		sum+=sz[i]*t;
		For(j,0,sz[i]-1){
			int l=1,r=0;
			for(int k=j;k<=sum;k+=sz[i]){
				if(q[l]+t*sz[i]<k)l++;
				//cout<<k<<" "<<dp[k]<<" "<<sz[i]<<" "<<m[i]<<" "<<l<<" "<<r<<" "<<dp[q[r]]<<" "<<dp[k]<<endl;
				while(l<=r&&dp[q[r]]>dp[k]-(k-q[r])/sz[i]*m[i])r--;
				q[++r]=k;
				jj[k]=dp[q[l]]+(k-q[l])/sz[i]*m[i];
			}
			for(int k=j;k<=sum;k+=sz[i])dp[k]=jj[k];
		}
	}
	For(i,1,n)q[i]=i;
	sort(q+1,q+n+1,cmp); 
	while(dp[sum]>x)sum--;
	int dq=0,ans=sum;
	For(i,1,n){
		int jb=q[i]==1?inf:d-min(d,n);
		while(jb&&sum>=0){
			int jj=min((ll)jb,(x-dp[sum])/m[q[i]]);
			dq+=jj*sz[q[i]];
			x-=jj*m[q[i]]; jb-=jj;
			//out<<dq<<" "<<sum<<" "<<dp[sum]<<" "<<x<<" "<<jj<<" "<<q[i]<<" "<<m[q[i]]<<endl;
			ans=max(ans,dq+sum); if(jb)sum--;
		}
	}
	//For(i,0,sum)wri(dp[i]); puts(""); cout<<q[1]<<endl;
//	cout<<(1000000000-1000000*m[3])/m[1]*sz[1]+3000000<<" "<<(1000000000-1000000*m[3])%m[1]<<" "<<dp[41]<<endl;
	cout<<ans<<endl;
}

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

using ll = long long;
using pint = pair<int, int>;

const ll INF = 1e12;

ll A, B, C, D;

ll gcd(ll a, ll b)
{
    return (b ? gcd(b, a % b) : a);
}

int main()
{
    cin >> A >> B >> C >> D;
    --A;
    ll g = gcd(C, D);
    ll l = C / g * D;
    ll right = B - B / C - B / D + B / l;
    ll left = A - A / C - A / D + A / l;
    cout << right - left << endl;
}

Measured memory_bytes: 256
import decimal
n, k = map(int, input().split())

cnt = 0
sumcl = []

for i in range(1,n+1) :
    pro = i
    while True :
        if pro < k :
            pro *= 2
            cnt += 1
        else :
            if i == 1 :
                top = cnt
                sumcl.append(1)
            else :
                sumcl.append(2**(top-cnt))
            cnt = 0
            break


print(decimal.Decimal(sum(sumcl)/(n*(2**top))))

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

const ll mod = 1000000007;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ret = 1;
    for(ll i = 0; i < b; i++) {
        ret *= (a - i);
        ret %= mod;
        ret *= beki(i + 1, mod - 2);
        ret %= mod;
    }
    return ret;
}


int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    init_combination();

    ll ans = beki(2, n) - 1 - combination(n, a) - combination(n, b);
    ans += 3 * MOD;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 234624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		q.push(a);
	}
	for (int i = 0; i < m; i++) {
		int a = q.top();
		//cerr << a << endl;
		q.pop();
		q.push(a/2);
	}

	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += q.top();
		q.pop();
	}

	cout << sum << endl;

	return 0;
}

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

const int N = 1010;
int n , a[2][N];

int main(){


scanf("%d",&n);
for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
        scanf("%d",&a[i][j]);
for(int i=1;i<=n;i++)a[0][i]+=a[0][i-1];
for(int i=n-2;i>=0;i--)a[1][i]+=a[1][i+1];

int ans=0;
for(int i=0;i<n;i++)ans=max(ans,a[0][i]+a[1][i]);
printf("%d\n",ans);

return 0;
}


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

int32_t main()
{
    int n;
    cin >> n;
    vector<int>v(n,0);
    for(int i=0;i<n;i++)cin >> v[i];
    int cnt=1;
    for(int i=1;i<n;i++)
    {
        if(v[i]<v[i-1]){
            v[i]=v[i-1];continue;
        }
        cnt++;
    }
    cout<<cnt<<"\n";
    
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

firstWin = [None] * (K + 1)

firstWin[0] = False

for k in range(K + 1):
    for a in A:
        if k - a >= 0:
            if firstWin[k - a] == False:
                firstWin[k] = True
                break
    else:
        firstWin[k] = False

if firstWin[K]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(void){
    int i,j,k,n,x,anc,sum;
    while(1){
        cin >> n >> x ;
        if(n==0 && x==0) break;
        anc=0;
        for(i=1;i<n-1;i++){
            for(j=i+1;j<n;j++){
                for(k=j+1;k<=n;k++){
                    sum=i+j+k;
                    if(sum==x) {
                        anc++;
                        continue;
                    }
                }
            }
        }
        cout << anc << endl;
    }
    
}


Measured memory_bytes: 3116
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, q = map(int, input().split())
s = list(input())

ss = ""
b = [0] * n
for i in range(n):
    if s[i] == "A":
        ss = s[i]
    elif s[i] == "C":
        ss += s[i]
    else:
        ss = ""
    if ss == "AC":
        b[i] += b[i - 1] + 1
        ss = ""
    else:
        if i > 0:
            b[i] = b[i - 1]
for i in range(q):
    x, y = map(int, input().split())
    print(b[y - 1] - b[x - 1])



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

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> num(7);
		for(int i = 0; i < n; ++i)
		{
			int a;
			cin >> a;
			if(a < 10)
			{
				++num[0];
			}
			else if(a < 20)
			{
				++num[1];
			}
			else if(a < 30)
			{
				++num[2];
			}
			else if(a < 40)
			{
				++num[3];
			}
			else if(a < 50)
			{
				++num[4];
			}
			else if(a < 60)
			{
				++num[5];
			}
			else
			{
				++num[6];
			}
		}
		for(int i = 0; i < 7; ++i)
		{
			cout << num[i] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
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), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  ll tmp = 0;
  rrep(i, N) {
    tmp += (A[i]+tmp+B[i]-1)/B[i]*B[i]-(A[i]+tmp);
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>


int main(){
	int n,k;
	
	scanf("%d%d",&n,&k);
	long long int termscore[n+100];
	long long int score[n+100];
	for(int i =0;i<=n+100;i++){
	 termscore[i] = 1;
	 score[i]=0;	
	}
	int first = 1;
	int index = k+1;
	for(int i = 1;i<=n;i++){
		scanf("%lld",&score[i]);
		if(i<=k) termscore[k] +=score[i];
		else if(k<i){
			termscore[i] = termscore[i-1] - score[first] + score[i];
			first++; index++;
		}
	}
	for(int i = k;i<n;i++){
		//printf("Termscore[%d] : %d\n",i,termscore[i]);
		if(termscore[i]<termscore[i+1]) printf("Yes\n");
		else printf("No\n");
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 4768
from functools import lru_cache


def solve(string):
    h, w, k = map(int, string.split())
    c = [1, 1]
    for _ in range(1, 7):
        i, j = c[-2:]
        c.append(i + j)

    @lru_cache(h * w)
    def rec(pos, depth):
        if depth == h:
            return 1 if pos == 1 else 0
        ans = rec(pos, depth + 1) * c[pos - 1] * c[w - pos]
        if pos < w:
            ans += rec(pos + 1, depth + 1) * c[pos - 1] * c[w - pos - 1]
        if pos > 1:
            ans += rec(pos - 1, depth + 1) * c[pos - 2] * c[w - pos]
        return ans

    return str(rec(k, 0) % (10**9 + 7))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3940
n = int(input())
string = input()
l = []
for i in range(n):
    l.append(int(string.split()[i]))

maxl = 0
for i in range(n):
    if l[i] > maxl:
        maxl = l[i]
if sum(l) > 2 * maxl:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
<?php
/**
 * ABC123
 * B - Five Dishes
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

$last_i = 0;
$last_1 = 9;

for ($i = 0; $i < 5; $i++) {
    fscanf(STDIN, "%d", $d[$i]);
    $d_1 = $d[$i] % 10;
    if ($d_1 !== 0 and $d_1 < $last_1 ) {
        $last_i = $i;
        $last_1 = $d_1;
    }
}

$time = 0;

for ($i = 0; $i < 5; $i++) {
    if ($i === $last_i) {
        $time += $d[$i];
    } else {
        $time += ceil($d[$i] / 10) * 10;
    }
}

echo $time, PHP_EOL;


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    for (int i = 0; i < H; i++)
        cin >> field[i];

    vector<vector<int>> U(H, vector<int>(W));
    vector<vector<int>> D(H, vector<int>(W));
    vector<vector<int>> L(H, vector<int>(W));
    vector<vector<int>> R(H, vector<int>(W));

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '#') cnt = 0;
            else cnt++;
            L[i][j] = cnt;
        }
    }

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = W - 1; j >= 0; j--) {
            if (field[i][j] == '#') cnt = 0;
            else cnt++;
            R[i][j] = cnt;
        }
    }

    for (int i = 0; i < W; i++) {
        int cnt = 0;
        for (int j = 0; j < H; j++) {
            if (field[j][i] == '#') cnt = 0;
            else cnt++;
            U[j][i] = cnt;
        }
    }

    for (int i = 0; i < W; i++) {
        int cnt = 0;
        for (int j = H - 1; j >= 0; j--) {
            if (field[j][i] == '#') cnt = 0;
            else cnt++;
            D[j][i] = cnt;
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int t = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3;
            res = max(res, t);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 67200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

int n;
string p;

Int dp[3300][3300];
Int dp_sum[3300][3300];

int main(){
    cin >> n;
    cin >> p;
    dp[0][0] = 1;
    for(int i = 1;i < n;i++){

        for(int j = 0;j <= i-1;j++){
            dp_sum[i-1][j] = dp[i-1][j];
            if(j-1 >= 0)dp_sum[i-1][j] += dp_sum[i-1][j-1];
            dp_sum[i-1][j] %=MOD;
        }

        for(int j = 0;j <= i;j++){
            if(p[i-1] == '<'){

                //if(j)dp[i][j] = dp_sum[i-1][j-1];

                if(j)dp[i][j] = dp_sum[i-1][j-1];


                //for(int k=0; k<j; k++){
                //  dp[i][j] += dp[i-1][k];
                //}

            }else{

                //dp[i][j] = dp_sum[i-1][i-1];
                //if(j) dp[i][j] -= dp_sum[i-1][j-1];

                dp[i][j] = dp_sum[i-1][i-1];
                if(j)dp[i][j] -= dp_sum[i-1][j-1];

                //for(int k=j; k<=i-1; k++){
                //  dp[i][j] += dp[i-1][k];
                //}
            }
            dp[i][j] %= MOD;
        }
    }
    
    Int ans = 0;
    for(int i = 0;i < n;i++){
        ans += dp[n-1][i];
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;

  return 0;

rep(i, n){
  rep(j, n)cout<<dp[i][j]<<' ';
  cout<<endl;
}
cout<<"---"<<endl;
rep(i, n){
  rep(j, n)cout<<dp_sum[i][j]<<' ';
  cout<<endl;
}

    return 0;
}


Measured memory_bytes: 97288
/*No.1153 Equal Total Scores*/
#include <stdio.h>

int trade_and_add(int *taro,int n,int *hanako,int m,int a,int b);

int main(void){

  int i,j;
  int m; /*???????????????????????°*/
  int n; /*??±????????????????????°*/
  int check;
  int min_sum;  
  int taro_change;
  int hanako_change;

  while(1){
    int taro_cards[101]={0};
    int hanako_cards[101]={0};

    char counter=0;

    scanf("%d%d",&m,&n);
    if(m==0 && n==0){break;}

    for(i=0;i<m;i++){
      scanf("%d",&taro_cards[i]);
    }

    for(i=0;i<n;i++){
      scanf("%d",&hanako_cards[i]);
    }

    for(i=0;i<m;i++){
      for(j=0;j<n;j++){

	check=trade_and_add(taro_cards,m,hanako_cards,n,i,j);

	if(check!=0 && counter==0){
	  taro_change=taro_cards[i];
	  hanako_change=hanako_cards[j];
	  min_sum=check;
	  counter++;
	}
	else if(check!=0 &&counter!=0){
	  if(min_sum >check){
	    taro_change=taro_cards[i];
	    hanako_change=hanako_cards[j];
	    min_sum=check;
	  }
	}
      }
    }

    if(counter==0){
      printf("-1\n");
    }
    else if(counter!=0){
      printf("%d %d\n",taro_change,hanako_change);
    }
  }
  return 0;
}

int trade_and_add(int *taro,int m,int *hanako,int n,int i,int j){
  int temp;
  int k;
  int taro_sum=0;
  int hanako_sum=0;
  int taro_cpy[101]={0};
  int hanako_cpy[101]={0};

  for(k=0;k<m;k++){
    taro_cpy[k]=taro[k];
  }

  for(k=0;k<n;k++){
    hanako_cpy[k]=hanako[k];
  }

  temp=taro_cpy[i];
  taro_cpy[i]=hanako_cpy[j];
  hanako_cpy[j]=temp;

  for(k=0;k<m;k++){
    taro_sum+=taro_cpy[k];
  }

  for(k=0;k<n;k++){
    hanako_sum+=hanako_cpy[k];
  }

  if(taro_sum==hanako_sum){
    return taro_sum;
  }

  else{
    return 0;
  }

}

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

using namespace std;
#define int long long


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

#define arr (int)(4e3)

int f[arr];
int rf[arr];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[arr-1]=powmod(f[arr-1],MOD-2, MOD);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

signed main(void)
{
	IOS;
	int n;
	cin>>n;
	vi a(n); vi b(n);
	for(int  i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < n; i++)
		cin>>b[i];
	vi c=a; vi d=b;
	int cnt=0;
	while(1) {
		int no=0;
		for(int i = 0; i < n; i++) {
			if(d[i]!=a[i]) {
				no=1;
				break;
			}
		}
		if(!no) {
			cout<<cnt<<endl;
			return 0;
		}
		if(!next_permutation(all(d))) {
			break;
		}
		cnt++;
	}
	cnt=0;
	while(1) {
		// for(int i: c)
		// 	cout<<i<<" ";
		// cout<<endl;
		// for(int i: b)
		// 	cout<<i<<" ";
		// cout<<endl;
		int no=0;
		for(int i = 0; i < n; i++) {
			if(c[i]!=b[i]) {
				no=1;
				break;
			}
		}
		if(!no) {
			cout<<cnt<<endl;
			return 0;
		}
		if(!next_permutation(all(c))) {
			break;
		}
		cnt++;
	}


	// int cnt=0;
	// int n; cin>>n;
	// string s; cin>>s;
	// for(int i = 0; i <= n-3; i++) {
	// 	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
	// 		cnt++;
	// 	}
	// }
	// cout<<cnt<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater <int>());
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            alice += A[i];
        } else {
            bob += A[i];
        }
    }
    cout << alice - bob <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define P pair<int,int>
#define N 10005
#define x first
#define y second
using namespace std;
int m, n;
char c;
P cord[N];
struct edge {
    int p, q;
    double t;
} e[N * N / 2];
bool cmp(edge a, edge b) {
    return a.t > b.t;
}
int p[N];
int find(int x) {
    return p[x] < 0 ? x : (p[x] = find(p[x]));
}
inline void merge(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (p[x] > p[y]) p[x] = y;
    else {
        p[y] = x;
        if (p[x] == p[y])--p[x];
    }
}
inline bool same(int x, int y) {
    return find(x) == find(y);
}
int main() {
    while ((~scanf("%d %d", &n, &m)) && m && n) {
        for (int i = 1; i <= n; ++i) scanf("%d %d", &cord[i].x, &cord[i].y);
        for (int i = 0; i < m; ++i) {
            scanf("%d %d", &e[i].p, &e[i].q);
            e[i].t = sqrt((cord[e[i].p].x - cord[e[i].q].x) *
                          (cord[e[i].p].x - cord[e[i].q].x) * 1.0
                          + (cord[e[i].p].y - cord[e[i].q].y) *
                          (cord[e[i].p].y - cord[e[i].q].y));
        }
        for (int i = 1; i <= n; ++i) p[i] = -1;
        sort(e, e + m, cmp);
        double ans = 0.0;
        for (int i = 0; i < m; ++i) {
            if (!same(e[i].p, e[i].q)) merge(e[i].p, e[i].q);
            else ans += e[i].t;
        }
        printf("%.3f\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3236
import java.util.Scanner;

public class Main{
	static boolean check(String s) {
		if(s.charAt(0) != 'A') return false;
		if(s.substring(2, s.length() - 1).indexOf('C') != s.substring(2, s.length() - 1).lastIndexOf('C') || s.substring(2, s.length() - 1).indexOf('C') == -1) {
			return false;
		}
		char[] str = s.toCharArray();
		str[0] = 'a';
		str[s.substring(2, s.length() - 1).indexOf('C') + 2] = 'c';
		return String.valueOf(str).equals(s.toLowerCase());
	}
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(check(S)) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}
	}
}


Measured memory_bytes: 23636
h, w = gets.chomp.split.map(&:to_i)

chars = ""

h.times do |i|
  chars << gets.chomp
end

ec = ("a".."z").map do |c|
  chars.count(c)
end

x4 = (h/2) * (w/2)
x2 = (h%2) * (w/2) + (h/2) * (w%2)
x1 = (h%2) * (w%2)

res = true

ec.each do |c|
  hoge = c

  s4 = [((hoge/4)), x4].min
  x4 -= s4
  hoge -= s4 * 4
  s2 = [((hoge/2)), x2].min
  x2 -= s2
  hoge -= s2 * 2
  s1 = [((hoge)), x1].min
  x1 -= s1
  hoge -= s1 * 1

  res = false if hoge>0
end

res = false if x4 > 0 or x2 > 0 or x1 > 0

puts (res ? "Yes" : "No")

Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  unordered_map<long, long> mp;
  rep (i, N) {
    long a;
    cin >> a;
    mp[a]++;
  }
  vector<long> foo;
  for (auto it: mp) {
    rep(i, it.second / 2) foo.push_back(it.first);
  }
  sort(foo.rbegin(), foo.rend());
  if (foo.size() < 2) cout << 0 << endl;
  else cout << foo[0] * foo[1] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 4388
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    set<int> st;
    int over = 0;
    rep(i, n) {
        int a; cin >> a;
        if (a >= 3200) ++over;
        else st.insert(a/400);
    }

    int maxi = (int)st.size() + over;
    int mini = 0;
    if (st.size() == 0) mini = 1;
    else mini = (int) st.size();

    cout << mini << " " << maxi << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	
	if(0<=S<86400)
	h = S/3600;
	m = (S-h*3600)/60;
	s = (S-h*3600-m*60);
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
import math 
A,B,H,M= map(int, input().split())
pi=3.1415926535
a=((60*H+M)/720)*2*math.pi
b=(M/60)*2*math.pi
#print(A*B*math.cos(-a+b))
#print(A*A+B*B-2*(A*B*math.cos(-a+b)))
s=math.sqrt(A*A+B*B-2*(A*B*math.cos(-a+b)))
print(s)


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

long long n, m, res = 1;
vector<bool> red;
vector<int> cnt;

int main() {
  cin >> n >> m;
  red.assign(n, 0);
  red[0] = 1;
  cnt.assign(n, 1);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --y, --x;
    if (red[x]) {
      res += !red[y];
      red[y] = 1;
    }
    if (--cnt[x] == 0) {
      res -= red[x];
      red[x] = 0;
    }
    ++cnt[y];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>

using namespace std;

int main(void) {
    int n;
    cin >> n;

    n = n % 10;
    if (n == 3) {
        cout << "bon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else
        cout << "hon" << endl;
    return 0;
}

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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int K;
    cin>>K;
    string S;
    cin>>S;

    int N = (int)S.size();
    long long M = 1000000007;
    vector<long long> F(N+K+1);
    F[0] = 1;
    for (int i=1; i<=N+K; i++)
        F[i] = F[i-1]*i%M;

    auto C = [&](long long a, long long b)
    {
        return F[a]*powmod(F[b], M-2, M)%M*powmod(F[a-b], M-2, M)%M;
    };

    long long ans = 0;
    for (int i=N; i<=N+K; i++)
        ans += C(N+K, i)*powmod(25, N+K-i, M)%M,
        ans %= M;
    cout<<ans<<endl;
}


Measured memory_bytes: 19596
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a =sc.nextInt();
    int b =sc.nextInt();
    int c =sc.nextInt();
    int d =sc.nextInt();
    System.out.println(Math.abs(a-c)<=d||(Math.abs(b-c)<=d && Math.abs(a-b)<=d)?"Yes":"No");
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      string s;cin >> s;
      int n = s.length();
      string ans = "";
      for(int i = 0;i < n;i++){
            if(s[i] == 'B' && ans.length() > 0)ans.pop_back();
            else if(s[i] != 'B')ans += s[i];
      }
      cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func parseInt(s string) int {
	return int(parseInt64(s))
}

func parseInt64(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

var reader *bufio.Reader

func readLine() string {
	if reader == nil {
		reader = bufio.NewReader(os.Stdin)
	}
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

func readFields() []string {
	return strings.Fields(readLine())
}

func readIntFields() []int {
	var result []int
	for _, token := range readFields() {
		result = append(result, parseInt(token))
	}
	return result
}

func max(a, b T) T {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b T) T {
	if a < b {
		return a
	} else {
		return b
	}
}

func sum(a []T) T {
	var result T
	for _, x := range a {
		result += x
	}
	return result
}

type T int

var CYCLE T = 1000000007

// Template end

var tt [1000000 + 1]bool
var aa [200000]int

func main() {
	f := readFields()
	n := parseInt(f[0])
	f = readFields()
	for i := 0; i < n; i++ {
		aa[i] = parseInt(f[i])
	}
	sort.Ints(aa[:n])

	r := 0
	for i := 0; i < n; i++ {
		a := aa[i]
		if !tt[a] {
			for j := a; j < 1000000+1; j += a {
				tt[j] = true
			}
			if i < n-1 && aa[i] == aa[i+1] {
				// skip
			} else {
				r += 1
			}
		}
	}

	fmt.Println(r)
}


Measured memory_bytes: 11904
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

int main() {
	int N,A,B;
	cin >> N;
	cin >> A >> B;

	int tmpA = A / N;
	int tmpB = B / N;
	bool result = false;
	if (B < N) {
		result = false;
	}
	else if (A % N == 0 || B % N == 0) {
		result = true;
	}
	else {
		if (tmpA == tmpB) {
			result = false;
		}
		else {
			result = true;
		}
	}

	cout << (result ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void execute(int test, istream &in) {
    int k; string s;
    in >> k >> s;
    if (s.size() > k) {
        s.resize(k);
        s += "...";
    }
    printf("%s\n", s.c_str());
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        execute(test, f);
    }
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> s(n), t(n), x(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> x[i];
    }

    vector<pair<int, int>> sx(n), tx(n);
    for (int i = 0; i < n; i++) {
        sx[i] = make_pair(s[i] - x[i], x[i]);
        tx[i] = make_pair(t[i] - x[i], x[i]);
    }

    sort(sx.begin(), sx.end());
    sort(tx.begin(), tx.end());

    multiset<int> u;
    vector<pair<int, int>>::iterator isx = sx.begin(), itx = tx.begin();

    for (int i = 0; i < q; i++) {
        int d;
        cin >> d;

        for (; isx != sx.end() && isx->first <= d; isx++) {
            u.insert(isx->second);
        }
        for (; itx != tx.end() && itx->first <= d; itx++) {
            u.erase(u.lower_bound(itx->second));
        }

        cout << (u.size() == 0 ? -1 : *u.begin()) << endl;
    }
}


Measured memory_bytes: 16128
import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
a=input()
b=input()
 
a=sorted(a)
b=sorted(b)
cnt=0
 
if a==b:
	print("No")
	sys.exit()
 
for i in range(min(len(a),len(b))):
	if a[i]<b[-(i+1)]:
		print("Yes")
		break
	
	elif a[i]==b[-(i+1)]:
		cnt+=1
		continue
		
	else:
		print("No")
		break
		
if cnt==min(len(a),len(b)) and len(a)<len(b):
	print("Yes")
	
elif cnt==min(len(a),len(b)) and len(a)>len(b):
	print("No")

Measured memory_bytes: 3064