akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;



struct cell
{

    int x;
    int y;

    int cost = 0;
};

typedef std::pair<ll, int> P;

int djk(vector<vector<vector<cell>>> G, vector<vector<int>> &visit, vector<vector<int>> &cost, cell C, int W)
{

    priority_queue<P, vector<P>, greater<P>> S;

    int start = C.x * W + C.y;

    S.push(make_pair(0, start));

    while (!S.empty())
    {
        P u = S.top();
        S.pop();

        int anx = u.second / W;

        int any = u.second % W;
        if (visit[anx][any] != 1)
        {
            visit[anx][any] = 1;

            cost[anx][any] = u.first;

            for (cell v : G[anx][any])
            {
                
                if (visit[v.x][v.y] == 0)
                {

                    ll acost = u.first + v.cost;

                    S.push(make_pair(acost, W * v.x + v.y));
                }
            }
        }
    }

    return 0;
}

int main()
{

    int H, W;

    cell C;
    cell D;
    cin >> H >> W;

    vector<vector<int>> A(H, vector<int>(W, 0));
    vector<vector<vector<cell>>> G(H, vector<vector<cell>>(W, vector<cell>(0)));

    cin >> C.x >> C.y;
    cin >> D.x >> D.y;

    C.x--;
    C.y--;
    D.x--;
    D.y--;

    for (int i = 0; i < H; i++)
    {

        for (int j = 0; j < W; j++)
        {

            char c;
            cin >> c;

            if (c == '.')
            {

                A[i][j] = 1;
            }
        }
    }





    for (int i = 0; i < H; i++)
    {

        for (int j = 0; j < W; j++)
        {
            

            if (A[i][j] == 1)
            {

                for (int ai = max(i - 2, 0); ai <= min(i + 2, H - 1); ai++)
                {
                    for (int aj = max(j - 2, 0); aj <= min(j + 2, W - 1); aj++)
                    {
                        if ((abs(ai - i) + abs(aj - j)) != 0)
                        {

                            if (A[ai][aj] == 1)
                            {

                                cell L;

                                L.x = ai;
                                L.y = aj;
                                L.cost = 1;

                                if ((abs(ai - i) + abs(aj - j)) == 1)
                                {

                                    L.cost = 0;
                                }

                                G[i][j].push_back(L);
                            }
                        }
                    }
                }
            }
        }
    }


    
    

    vector<vector<int>> visit(H, vector<int>(W, 0));
    vector<vector<int>> cost(H, vector<int>(W, -1));

    djk(G, visit, cost, C, W);

    cout << cost[D.x][D.y] << endl;

    return 0;
}

Measured memory_bytes: 240448
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, M,ans;
map<string, int> mp;
int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> M;
	FOR(i, 0, M) {
		string s;
		cin >> s;
		mp[s]--;
	}
	for (auto ite = mp.begin(); ite != mp.end(); ite++) {
		
		if (ite->second > ans) {
			ans = ite->second;
		}
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
ll a[105],dp[100005];
ll solve(ll k)
{
    for(ll j=1;j<=k;j++)
    {
        for(ll i=0;i<n;i++)
        {
            if((j-a[i])>=0 && dp[j-a[i]]==0)
            {
                dp[j]=1;
                break;
            }
        }
    }
    return dp[k];
}

int main()
{
	
    ll k,i;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(solve(k))
    {
        cout<<"First\n";
    }
    else
    {
        cout<<"Second\n";
    }
}

Measured memory_bytes: 1024
# 想定解法2

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ids = []
for x in range(1, X+1):
  for y in range(1, Y+1):
    if x*y > K:
        break
    for z in range(1, Z+1):
      if x*y*z <= K:
        ids.append((x-1, y-1, z-1))
      else:
        break
      
Ans = []
for x, y, z in ids:
  Ans.append(A[x]+B[y]+C[z])

Ans.sort(reverse=True)
Ans = Ans[:K]
for ans in Ans:
  print(ans)

Measured memory_bytes: 17936
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD st_ct<int>(1e9 + 7)
#define EPS 1e-9
#define deb1(x) cerr << #x << " -> " << x << endl;
#define deb2(x,y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ")" << endl;
#define deb3(x,y,z) cerr << "(" << #x << ", " << #y << ", " << #z << ") -> (" << x << ", " << y << ", " << z << ")" << endl;
#define debVV(V) cerr << #V << ":\n" << V << endl; // 2D

// 1D
template<typename T>
istream& operator>>(istream &is, vector<T> &A) {
    for (T &v: A)
        is >> v;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<T> &A) {
    for (T const &v: A)
        os << v << " ";
    return os;
}

template<typename T>
void vtrV(const vector<T> &A)
{ for (T const &val: A) cout << val << endl; }

// 2D
template<typename T>
istream& operator>>(istream &is, vector<vector<T>> &A) {
    for (vector<T> &i: A)
        for (T &j: i)
            is >> j;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            os << j << " ";
        os << endl;
    }
    return os;
}

template<typename T>
void vvtrNS(const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            cout << j;
        cout << endl;
    }
}

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
/* -------------------------------------------------------- */
/* -------------------------------------------------------- */

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed;
    cout<<std::setprecision(6); // default
    /* -------------------------------- */

    ll x {};
    cin >> x;
    for (ll i {-2000}; i <= 2000; ++i) {
    	for (ll j {-2000}; j <= 2000; ++j) {
    		if (i*i*i*i*i - j*j*j*j*j == x) {
    			cout << i << " " << j << endl;
    			return 0;
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=200010;

vector<ll> ar;
ll k;
ll dp[10001][2][101];
ll func(ll idx,ll t,ll m)
{
    if(idx<0){
        if(m==0){return 1;}
        return 0;
    }
    if(dp[idx][t][m]==-1){
    ll ans=0;
    ll kk=t==1?ar[idx]:9;
    for(ll i=0;i<=kk;++i)
    {
        ll nt=t&(i==ar[idx]);
        ans=(ans+func(idx-1,nt,(m+i)%k))%M;
    }
    dp[idx][t][m]=ans;
    }
    return dp[idx][t][m];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin>>s;
    cin>>k;
    for(ll i=0;i<s.length();++i)
    {
        ar.pb(s[i]-'0');
    }
    ll n=ar.size();
    reverse(ar.begin(),ar.end());
    memset(dp,-1,sizeof(dp));
    ll ans=(func(n-1,1,0)-1+M)%M;

    cout<<ans<<endl;

    return (0);
}


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

using Graph=vector<vector<int>>;
const int SIZE='z'-'a'+1;
bool solve(int n){
    vector<string> s(n);
    for(int i=0;i<n;i++) cin>>s[i];
    Graph g(SIZE);
    for(int i=0;i+1<n;i++){
        for(int j=0;j<=min(s[i].size(),s[i+1].size());j++){

            if(j==min(s[i].size(),s[i+1].size())){
                if(s[i].size()<=s[i+1].size()){
                    break;
                }
                else{
                    return false;
                }
            }
            if(s[i][j]!=s[i+1][j]){
                g[s[i][j]-'a'].push_back(s[i+1][j]-'a');
                break;
            }
        }
    }

    queue<int> que;
    vector<int> d(SIZE);
    for(int i=0;i<SIZE;i++) for(int j=0;j<g[i].size();j++) d[g[i][j]]++;
    for(int i=0;i<SIZE;i++) if(d[i]==0) que.push(i);
    int cnt=0;
    while(!que.empty()){
        int v=que.front(); que.pop();
        cnt++;
        for(int i=0;i<g[v].size();i++){
            d[g[v][i]]--;
            if(d[g[v][i]]==0){
                que.push(g[v][i]);
            }
        }
    }
    return cnt==SIZE;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<(solve(n) ? "yes" : "no")<<endl;
    }
    return 0;
}


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

int main() {
	int a,b;
	cin >> a >> b;
	if (a==b)
	cout << "Draw" << endl;
	else if (a==1)
	cout << "Alice" << endl;
	else if (b==1)
	cout << "Bob" << endl;
	else if(a>b)
	cout << "Alice" << endl;
	else 
	cout << "Bob" <<endl; 
	return 0;
}

Measured memory_bytes: 256
H,W,K = map(int, input().split())
a =[list(input()) for i in range(H)]
import copy


l=0

for i in range(2**W):
    q=str(format(i, '0{}b'.format(W)))
    
    #print(q)
    b=copy.deepcopy(a)
    
    for u in range(W):
        if q[u]=='1':
            for y in range(H):
                b[y][u]='&'
                
    for i in range(2**H):
        c=copy.deepcopy(b)
        num=0
        e=str(format(i, '0{}b'.format(H)))
        for t in range(H):
            if e[t]=='1':
                for y in range(W):
                    c[t][y]='.'
        
        num=0
        for h in range(H):
                for w in range(W):
                    if c[h][w]=='#':
                        num+=1
        if num==K:
            l+=1
print(l)

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

#define N 100
#define INF 0x3f3f3f3f

int main() {
	static int aa[N];
	int n, i, j, k, t, min;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	min = INF;
	for (t = 0; t < n - 1; t++) {
		int sum1, sum2;

		sum1 = 0;
		for (j = 0; j <= t; j++)
			sum1 += aa[j];
		sum2 = 0;
		for (k = t + 1; k < n; k++)
			sum2 += aa[k];
		if (min > abs(sum1 - sum2))
			min = abs(sum1 - sum2);
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  n <- readLn
  as <- readInts
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = go 0 0 as
 where
  go acc h0 [] = acc
  go acc h0 (a:as)
    | h0 <= a   = go acc (max h0 a) as
    | otherwise = go (acc + h0 - a) h0 as


Measured memory_bytes: 64232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    vi a(n);
    cin >> a[0];
    REPS(i, n-1){
        cin >> a[i];
        a[i] += a[i-1];
    }
    int ans = INF;
    REP(i, n-1){
        ans = min(abs(a[n-1]-a[i]*2), ans);
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=500000;
const int mod=998244353;
long long jc[N],inv[N],p[N],ans=0;

long long power(long long a,long long b=mod-2) {
    long long c=1;
    while(b) {
    if(b&1) c=c*a%mod;
    b /= 2; a=a*a%mod;
    }
    return c;
}

long long C(int x,int y) {return jc[x]*inv[y]%mod*inv[x-y]%mod;}
int n,m,k;


int main() {

    cin>>n>>m>>k;
    jc[0]=1;for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
    p[0]=1;for(int i=1;i<=n;i++) p[i]=p[i-1]*(m-1)%mod;
    inv[n]=power(jc[n]);for(int i=n;i;i--) inv[i-1]=inv[i]*i%mod;
    for(int i=0;i<=k;i++)
        (ans += C(n-1,i)*p[n-1-i]) %= mod;
    cout<<ans*m%mod<<endl;

}
/*
3 2 1
 */


Measured memory_bytes: 8224
#include<stdio.h>

int main()
{
  int n, m, t[101], p[101], x[101];
  int i, st=0;

  scanf("%d", &n);
  for( i=1; i<=n; i++){
  scanf("%d", &t[i]);
  st += t[i];
  }
  scanf("%d", &m);
  for(i=1; i<=m; i++){
  scanf("%d %d", &p[i], &x[i]);
  }

  for(i=1; i<=m; i++){
  printf("%d\n", st - t[p[i]] + x[i]);
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    ll h, m;
    cin >> h >> m;
    if(h == 1 || m == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (h * m + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <vector>

using namespace std;

struct Edge
{
	int kindOfTask;
	int runNum;
};


void solve()
{
	int N, M;
	cin >> N >> M;
	vector<Edge> a[10001];
	int s, t, e;
	while (cin >> s >> t >> e, s || t || e)
	{
		Edge edge;
		edge.kindOfTask = --t;
		edge.runNum = e;
		a[--s].push_back(edge);
	}
	int L;
	cin >> L;
	for (int i = 0; i < L; ++i)
	{
		vector<int> c(M);
		for (int j = 0; j < M; ++j)
		{
			cin >> c[j];
		}
		bool isFirst = true;
		for (int j = 0; j < N; ++j)
		{
			int salary = 0;
			for (int k = 0; k < a[j].size(); ++k)
			{
				Edge edge = a[j][k];
				salary += edge.runNum * c[edge.kindOfTask];
			}
			if (!isFirst)
			{
				cout << " ";
			}
			isFirst = false;
			cout << salary;
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 2276
a, b = map(int, input().split())
l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
A=l.index(a)
B=l.index(b)
if A > B:
  print("Alice")
elif A == B:
  print("Draw")
else:
  print("Bob")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String prefix = sc.next();
        String postfix = sc.next();

        int answser = 0;
        if(N>=prefix.length()+postfix.length()) {
            answser = N;
        }
        else{
            if(prefix.contains(postfix)||postfix.contains(prefix)){
                answser = Math.max(prefix.length(),postfix.length());
                if(answser<N) answser = N;
            }
            else {
                answser = prefix.length() + postfix.length();
                for (int i = 0; i < prefix.length() && i < postfix.length(); i++) {
                    String tmp = prefix.substring(prefix.length() - i - 1);
                    if(postfix.startsWith(tmp)){
                        answser = Math.min(answser,prefix.length() + postfix.length()-i-1);
                    }
                    if (answser == N) {
                        break;
                    }
                }
            }
        }

        System.out.println(answser);
        sc.close();

    }

 }


Measured memory_bytes: 9804
def main():
    n, k = map(int, input().split())
    a = sorted(int(i) for i in input().split())
    mod = 10**9 + 7
    comb = [1] * (n - k + 1)
    for i in range(n - k):
        comb[i + 1] = (comb[i] * (k + i) * pow(i + 1, mod - 2, mod)) % mod
    f = 0
    for i in range(n - k + 1):
        f = (f + a[k + i - 1] * comb[i] % mod) % mod
        f = (f - a[i] * comb[-1 - i] % mod) % mod
    print(f)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20116
# 蟻本1-6-1例題相当
# 今回は、xのみ確定した際、y,zの取りうる値の組の数を求める。
# よって1重のfor文で回してみる
# 最大で2500となる
# 今回は、xの取りうる範囲を考慮しない

k, s = map(int,input().split())
count = 0
for x in range(0, k+1):
  if 0 <= s-x and s-x <= k: #(y,z) = (0, s-x), ... ,(s-x, 0)
    count += s-x+1
  elif k <= s-x and s-x <= 2*k: #(y,z) = (s-x-k, k), ... ,(k, s-x-k)
    count += 2*k-(s-x)+1
print(count)

Measured memory_bytes: 2940
s = gets.chomp.split("")

if s[1] == s[0]
    if s[2] == s[3] && s[0] != s[2]
        puts "Yes"
    else
        puts "No"
    end
elsif s[2] == s[0]
    if s[1] == s[3] && s[0] != s[1]
        puts "Yes"
    else
        puts "No"
    end
elsif s[3] == s[0]
    if s[2] == s[1] && s[0] != s[1]
        puts "Yes"
    else
        puts "No"
    end
else
    puts "No"
end




Measured memory_bytes: 1788
int s[101],a,b,c,d;
int main(n)
{
	for(scanf("%d",&n);~scanf("%d%d%d%d",&a,&b,&c,&d);)c>d?s[a]+=3:c<d?s[b]+=3:(s[a]++,s[b]++);
	for(a=0;a++<n;printf("%d\n",c+1))for(b=c=0;b++<n;)c+=s[a]<s[b];
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,n) for(i=a;i<n;i++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}


void fun(){
	ll i,j;
	ld a,b,n;
	cin>>a>>b>>n;
	if(b<=n){
		ll qq=floor(ld(a*(b-1)/b));
		cout<<qq<<endl;
	}
	else{
		ll ww=floor(ld(a*n/b))-a*floor(ld(n/b));
		cout<<ww<<endl;
	}

}
int main(){
	fun();
//    ll t;
//    cin>>t;
//    while(t--){
// 	   fun();
//    }
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

inline bool valid(int y, int x) {
    return (0 <= y && y < 10 && 0 <= x && x < 10);
}

int main() {
	int paper[10][10] = {};
	int x, y, siz;
	char c;
	while (cin >> x >> c >> y >> c >> siz) {
		switch (siz) {
			case 3:
				if (valid(y-2, x)) paper[y-2][x] ++;
				if (valid(y, x-2)) paper[y][x-2] ++;
				if (valid(y, x+2)) paper[y][x+2] ++;
				if (valid(y+2, x)) paper[y+2][x] ++;
			case 2:
				if (valid(y-1, x-1)) paper[y-1][x-1] ++;
				if (valid(y-1, x+1)) paper[y-1][x+1] ++;
				if (valid(y+1, x-1)) paper[y+1][x-1] ++;
				if (valid(y+1, x+1)) paper[y+1][x+1] ++;
			case 1:
				if (valid(y-1, x)) paper[y-1][x] ++;
				if (valid(y, x-1)) paper[y][x-1] ++;
				if (valid(y,   x))   paper[y][x] ++;
				if (valid(y, x+1)) paper[y][x+1] ++;
				if (valid(y+1, x)) paper[y+1][x] ++;
		}
	}
	int empty = 0, mx = 0;
	for (int i=0; i<10; ++i) {
		for (int j=0; j<10; ++j) {
			empty += !paper[i][j];
			mx = max(mx, paper[i][j]);
		}
	}
	cout << empty << endl;
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 1160
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);

    if (a < b && b < c) {
        console.log('Yes');

    } else {
        console.log('No');

    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15512
import java.util.*;

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

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

string s;

int main() {
    fast_io;

    cin >> s;
    for(ll i = 1 ; i < s.size() ; i++){
        if(s[i] == s[i - 1])    return cout << "Bad" << endl , 0;
    }
    cout << "Good" << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int x; cin >> x;
    int aa, bb;
    bool gogo = false;
    for(ll a = -120; a <= 120; a++){
        for(ll b = -120; b <= 120; b++){
            ll ans = a*a*a*a*a - b*b*b*b*b;
            if(ans == x){
                aa = a; bb = b;
                gogo = true; break;
            }
        }
        if(gogo) break;
    }
    cout << aa << " " << bb << endl;
}



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

//関数
const long mod=1000000007;

long numbcha(char c){
    if(c=='A') return 0;
    if(c=='C') return 1;
    if(c=='G') return 2;
    if(c=='T') return 3;
}

long numberize(string S){//最後3桁を4進数に変換 
    int fir=numbcha(S.at(S.size()-3));
    int sec=numbcha(S.at(S.size()-2));
    int thi=numbcha(S.at(S.size()-1));
    return fir*16+sec*4+thi*1;
}

bool notC(long i){
    bool result=false;
    if(i/16 == numbcha('A') && (i%4 == numbcha('G') || (i/4)%4 == numbcha('G'))) result=true;
    if(i%4 == numbcha('A') && (i/4)%4 == numbcha('G')) result=true;
    if(i%4 == numbcha('G') && (i/4)%4 == numbcha('A')) result=true;
    return result;
}

bool notG(long i){
    bool result=false;
    if(i%4 == numbcha('C') && (i/4)%4 == numbcha('A')) result=true;
    return result;
}
    
    
    
//main関数
int main() {
    
    
    
    //入力
    int N;
    cin>>N;
    
    
    
    
    //計算
    vector<vector<long>> count(64, vector<long>(N+1));//0~2は無視
    count.at(numberize("TTT")).at(0)=1;
    
    for(int n=0;n<N;n++){
        for(int i=0;i<64;i++){
            count.at((i%16)*4+numbcha('A')).at(n+1)+=count.at(i).at(n);
            count.at((i%16)*4+numbcha('A')).at(n+1)%=mod;
            if(!notC(i)) count.at((i%16)*4+numbcha('C')).at(n+1)+=count.at(i).at(n);
            count.at((i%16)*4+numbcha('C')).at(n+1)%=mod;
            if(!notG(i)) count.at((i%16)*4+numbcha('G')).at(n+1)+=count.at(i).at(n);
            count.at((i%16)*4+numbcha('G')).at(n+1)%=mod;
            count.at((i%16)*4+numbcha('T')).at(n+1)+=count.at(i).at(n);
            count.at((i%16)*4+numbcha('T')).at(n+1)%=mod;
        }
    }
    
    long ans=0;
    
    for(int i=0;i<64;i++){
        ans+=count.at(i).at(N);
        ans%=mod;
    }
    
    
    //出力
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, 0, N) cin >> L.at(i);
    sort(all(L));
    int64_t ans = 0;
    int count = 0;
    rep(a, 0, N - 2){
        rep(b, a + 1, N - 1){
            int leng = L.at(a) + L.at(b);
            auto x = lower_bound(all(L), leng);
            ans += distance(L.begin(), x) - (b + 1);
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n,m,i,j,l,ss,ans=0;
    cin>>n>>m;
    vector<int> k(m); 
    vector<int> si(n);
    vector<int> p(m);
    vector<vector<int>> s(m,vector<int>(n));

    rep(i,m){
        cin>>k[i];
        rep(j,k[i]){
            cin>>si[j];
            s[i][si[j]-1]=1;
        }
    }
    rep(l,m){
        cin>>p[l];
    }
    

    rep(ss,1<<n){
        vector<int> counter(m);
        int count=0;
        rep(i,n){
            if(ss&1<<i){
                rep(j,m){
                    if(s[j][i]==1){
                        counter[j]++;
                    }
                }
            }
        }
        
        rep(l,m){
            if(counter[l]%2==p[l]){
                count++;
            }
        }
        if(count==m){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll ans = b - a + 1;
  ll tmpca = a + c - ((a-1) % c + 1), tmpcb = b - b % c;
  ans -= (tmpcb - tmpca) / c + 1;
  ll tmpda = a + d - ((a-1) % d + 1), tmpdb = b - b % d;
  ans -= (tmpdb - tmpda) / d + 1;
  ll e = lcm(c, d);
  ll tmpea = a + e - ((a-1) % e + 1), tmpeb = b - b % e;
  ans += (tmpeb - tmpea) / e + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

int n,a,b;
int arr[5005];
int pos[5005];

ll memo[5005][10005];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	memset(memo,127,sizeof(memo));
	
	cin>>n>>a>>b;
	for (int x=1;x<=n;x++) cin>>arr[x];
	for (int x=1;x<=n;x++) pos[arr[x]]=x*2;

	for (int x=0;x<=2*n;x++) memo[0][x]=0;
	
	for (int x=1;x<=n;x++){
		for (int y=1;y<=2*n+1;y++){
			if (y%2==0 && pos[x]==y){
				memo[x][y]=min(memo[x][y-1],memo[x-1][y]);
			}
			else{
				memo[x][y]=min(memo[x][y-1],memo[x-1][y]+(pos[x]<y?a:b));
			}
			//cout<<x<<" "<<y<<" "<<memo[x][y]<<endl;
		}
	}
	
	cout<<memo[n][2*n+1];
}

Measured memory_bytes: 391552
#include <cstdio>
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#define MAXN 13
int t;
int ans;
using namespace std;

void DFS(int sum, unsigned char ch){
    if(sum > t)
        return;
    if(ch == 07)
        ans++;
    if(sum<99999999){
        DFS(sum*10+3, ch|01);
        DFS(sum*10+5, ch|02);
        DFS(sum*10+7, ch|04);
    }

}
int main(){
    cin >> t;
    DFS(0,0);

    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> K;
    vi b(K + 1);
    REP(i, K) {
        cin >> A;
        b[A]++;
    }
    vi a;
    REP(i, K + 1) {
        if (b[i] > 0)
            a.push_back(b[i]);
    }
    sort(ALL(a));
    N = a.size();
    vi sum(N + 1);
    REP(i, N) {
        sum[i + 1] = sum[i] + a[i];
    }
    dump(a, sum);
    REPS(k, K) {
        int ng = sum[N] + 1;
        int ok = 0;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            int ind = lower_bound(ALL(a), mid) - a.begin();
            int tmp = (N - ind) * mid + sum[ind];
            if (tmp >= mid * k) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << ok << endl;
    }
}

Measured memory_bytes: 10032
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll h, w, k; cin >> h >> w >> k;
    vector<vector<string>> vec(h, vector<string>(w));
    map<ll, ll> mp;
    ll last_s = -1;
    rep(i, h){
        string s; cin >> s;
        bool flag = true;
        rep(j, w){
            vec[i][j] = s[j];
            if(vec[i][j] == "#"){
                flag = false;
            }
        }
        if(flag){
            mp[i]++;
        }else{
            last_s = i;
        }
    }

    ll num = 1;
    vector<ll> tmp;
    vector<vector<ll>> ans(h, vector<ll>(w, 0));

    rep(i, h){

        if(mp[i] == 1){
            tmp.push_back(i);
        }else{
            //printする
            bool first_flag = true;
            rep(j, w){
                if(vec[i][j] == "#"){
                    if(first_flag){
                        first_flag = false;
                    }else{
                        num++;
                    }
                }
                for(ll k = 0; k < tmp.size(); k++){
                    ans[tmp[k]][j] = num;
                }
                ans[i][j] = num;
            }
            num++;
            tmp.clear();
        }
    }

    if(last_s != h-1){
        for(ll i = last_s + 1; i < h; i++){
            rep(j, w){
                ans[i][j] = ans[last_s][j];
            }
        }
    }


    rep(i, h){
        rep(j, w){
            cout << ans[i][j] << " ";
        }
        br;
    }

}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int main(){

    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> c[i][j];

    int ans = 0;
    for(int hbit = 0; hbit < (1<<h)-1;hbit++){
        for(int wbit = 0; wbit < (1<<w)-1; wbit++){
            int black = 0;
            
            rep(i,h){
                rep(j,w){
                    if((hbit & (1<<i)) == 0 and (wbit & (1<<j)) == 0 and c[i][j] == '#'){
                        black++;
                    }
                }
            }

            if(black == k){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3636
s = str(input())

n = len(s)
ans = 'Yes'

for i in range(n//2):
    if s[i] != s[-1-i]:
        ans = 'No'
        break

if ans == 'Yes':
    for j in range(n//2//2):
        if s[j] != s[(n-1)//2 -j -1]:
            ans = 'No'
            break

print(ans)


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

long long u[40][40];
long long a[3][40];

int main(){
  int n, c; cin >> n >> c;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      cin >> u[i+1][j+1];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int k; cin >> k;
      a[(i+j)%3][k]++;
    }
  }
  long long ans = 1e18;
  for (int i = 1; i <= c; i++) {
    for (int j = 1; j <= c; j++) {
      if (i == j) continue;
      for (int k = 1; k <= c; k++) {
        if (j == k || i == k) continue;
        long long tmp = 0;
          for (int y = 1; y <= c; y++) {
            tmp += a[0][y] * u[y][i];
            tmp += a[1][y] * u[y][j];
            tmp += a[2][y] * u[y][k];
          }
        ans = min(ans, tmp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#gpgpgpで出し続ける。

s = str(input())
s_cnt = s.count("p")
ans = 0
#偶数
if len(s)%2 == 0:
    ans = len(s)//2 - s_cnt
#奇数
else:
    ans = len(s)//2 - s_cnt
    if ans < 0:
        ans = 0
        
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int n, y;
  cin >> n >> y;

  rep(i, 0, n + 1) rep(j, 0, n + 1) {
      int k = n - i - j;
      if(0 > k) continue;
      if(10000 * i + 5000 * j + 1000 * k == y) {
          cout << i << " " << j << " " << k << endl;
          return 0;
      }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
typedef vector<vector<ll> > matrix;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e5+5;
const int MAX_LOG=17;

int N, a, res=INT_MAX;
map<int,int>MP1, MP0;
vector<pi> odd, even;

inline int cal(pi a1, pi a2)
{
    if(a1.s==a2.s)
        return N-max(a1.f, a2.f);
    return N-a1.f-a2.f;
}

int main()
{
    N=in();
    MP0.clear();
    MP1.clear();
    Forn(i, N)
    {
        a=in();
        if(i&1)
           MP1[a]++;
        else
           MP0[a]++;
    }
    foreach(it, MP0)
    {
        odd.eb(mp(it->s, it->f));
        sort(odd.rbegin(), odd.rend());
        while(odd.size()>2)
            odd.pop_back();
    }
    foreach(it, MP1)
    {
        even.eb(mp(it->s, it->f));
        sort(even.rbegin(), even.rend());
        while(even.size()>2)
            even.pop_back();
    }
    foreach(it, odd)
        foreach(ii, even)
            res=min(res, cal(*it, *ii));
    printf("%d\n", res);
    return 0;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

ll dp[51][51][51 * 51];

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, A;
    cin >> N >> A;
    
    vector<ll> cards(N);
    for (auto&& c : cards) {
        cin >> c;
    }
    
    dp[0][0][0] = 1;
    for (ll j = 1; j <= N; j++) {
        ll c = cards[j - 1];
        for (ll k = 0; k <= j; k++) {
            for (ll s = 0; s <= N * 50; s++) {
                if (s < c) {
                    dp[j][k][s] = dp[j - 1][k][s];
                } else if (1 <= k){
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - c];
                }
            }
        }
    }
    
    ll ans = 0;
    for (ll k = 1; k <= N; k++) {
        ans += dp[N][k][k * A];
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll x;
    cin >> x;

    for(ll a=-3000; a<=3000; ++a) for(ll b=-3000; b<=3000; ++b) {
        if(a*a*a*a*a - b*b*b*b*b == x) {
            cout << a << " " << b << endl;
            return 0;
        }
    }
    assert(false);

    return 0;
}

Measured memory_bytes: 3652
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<map>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<string>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define For(i,N) for(ll i=0;i<N;i++)
int main()
{
    ll N;
    cin >> N;
    vector<ll>A(N);
    ll m = 0;
    ll m2 = 0;
    rep(N) {
        cin >> A[i];
        if (m < A[i]) {
            m2 = m;
            m = A[i];
        }
        else if (m2 < A[i])m2 = A[i];
    }
    rep(N) {
        if (A[i] == m)cout << m2 << endl;
        else cout << m << endl;
    }
}


Measured memory_bytes: 3200
N = int(input())

for i in range(1,3500):
    for j in range(1,3500):
        if 4 * i * j - N * i - N * j == 0:
            continue
        k = N * i * j / (4 * i * j - N * i - N * j)
        if k > 0 and k == int(k):
            print(i, j, int(k))
            exit()

Measured memory_bytes: 40796
using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var NT = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NT[0]; var T = NT[1];
            var A = new int[N + 1]; var B = new int[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                var AB = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                A[i] = AB[0]; B[i] = AB[1];
            }

            var DP = new int[N + 1, T, 2];
            for (int i = 1; i < N + 1; i++)
            {
                for (int j = 1; j < T; j++)
                {
                    if (j >= A[i])
                    {
                        DP[i, j, 0] = Math.Max(DP[i - 1, j - A[i], 0] + B[i], DP[i - 1, j, 0]);
                        DP[i, j, 1] = Math.Max(DP[i - 1, j - A[i], 1] + B[i], DP[i - 1, j, 1]);
                    }
                    else
                    {
                        DP[i, j, 0] = DP[i - 1, j, 0];
                        DP[i, j, 1] = DP[i - 1, j, 1];
                    }

                    DP[i, j, 1] = Math.Max(DP[i - 1, j, 0] + B[i], DP[i, j, 1]);
                }
            }
            Console.WriteLine(DP[N, T - 1, 1]);
        }
    }
}


Measured memory_bytes: 81248
N = int(input())
h_list = list(map(int, input().split()))

count = 0
max_count = 0
for i in range(N-1):
  if h_list[i+1] <= h_list[i]:
    count += 1
    max_count = max(max_count, count)
  else:
    count = 0
  
print(max_count)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>

static inline void rec(int t, int s, std::vector<std::pair<int, int>>& v, const std::vector<std::vector<int>>& tr) {
    if (v[t].second != 0) {
        return;
    }
    v[t].second = 1;
    v[t].first += s;
    s = v[t].first;
    for (const auto& tt: tr[t]) {
        rec(tt, s, v, tr);
    }
}

int main() {
    int n, q; std::cin >> n >> q;
    std::vector<std::vector<int>> t(n);
    for (int i = 0 ; i < n-1; i++) {
        int a, b; std::cin >> a >> b;
        a--; b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    std::vector<std::pair<int, int>> v(n, {0, 0});
    for (int i = 0; i < q; i++) {
        int p, x; std::cin >> p >> x;
        p--;
        v[p].first += x;
    }
    rec(0, 0, v, t);
    for (int i = 0; i < n; i++) {
        if (i != 0) {
            std::cout << " ";
        }
        std::cout << v[i].first;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 24728
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int M=2e5+5;
const int MO=1e9+7;

int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
int mul(int x,int y)
{
	return 1LL*x*y%MO;
}

int qp(int a,int n)
{
	int ans=1;
	while(n)
	{
		if(n&1) ans=mul(ans,a);
		a=mul(a,a);
		n>>=1;
	}
	return ans;
}

vector<int> g[M];
int sz[M];
int dfs1(int u,int fa)
{
	sz[u]=1;
	for(int v:g[u])
	{
		if(v==fa) continue;
		sz[u]+=dfs1(v,u);
	}
	return sz[u];
}

int ans=0;
int n;
void dfs2(int u,int fa)
{
	ans=add(ans,sub(qp(2,n-1),1));
	if(fa)
		ans=sub(ans,sub(qp(2,n-sz[u]),1));
	for(int v:g[u])
	{
		if(v==fa) continue;
		ans=sub(ans,sub(qp(2,sz[v]),1));
		dfs2(v,u);
	}
}

int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs1(1,0);
	dfs2(1,0);
	printf("%d\n",mul(ans,qp(qp(2,n),MO-2)));
	return 0;
}


Measured memory_bytes: 18688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, cnt = 0;
	bool s = false;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	a.push_back(0);
	vector<ll>b(n);
	rep(i, n)b[i] = abs(a[i]);
	rep(i, n) {
		if (a[i] == 0){cnt = 1; break;}
		if (a[i] < 0)cnt++;
		else continue;
	}
	ll sum = accumulate(all(b),0LL);
	cout << (cnt % 2 == 0 ? sum : sum - 2 * *min_element(all(b))) << endl;
}


Measured memory_bytes: 1792