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

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  // rep(i,n) cout << a[i] << endl;
  vector<pair<ll,ll>> bc(0);
  ll b,c;
  rep(i,m) {
    cin >> b >> c;
    bc.push_back({c,b});
  }
  sort(bc.begin(),bc.end());
  // rep(i,m) cout << bc[i].first << bc[i].second << endl;
  ll ans = 0;
  int nMax = n-1;
  rep(i,n) {
    if (m == 0) {
      ans += a[nMax];
      nMax--;
    }
    else if (a[nMax] > bc[m-1].first) {
      ans += a[nMax];
      nMax--;
    }
    else {
      ans += bc[m-1].first;
      bc[m-1].second--;
      if (bc[m-1].second == 0) {
        m--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6072
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <stack>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

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

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (s.compare(u) == 0) {
		cout << (a - 1) << " " << b << endl;
	} else {
		cout << a << " " << (b - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
N, Y = map(int, input().split())
def total(x,y,z):
  return 10000 * x + 5000 * y + 1000 * z

for x in range(N + 1):
  for y in range(N + 1):
    z = N - x - y
    if 0<= z <= N and total(x,y,z) == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)

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

int main() {
	vector<int> t(5);
	rep(i, 5) cin >> t[i];
	int sum = 0;
	rep(i, 5) sum += ((t[i] + 9) / 10) * 10;
	vector<int> s(5);
	rep(i, 5) {
		if (t[i] % 10 == 0) s[i] = 10;
		else s[i] = t[i] % 10;
	}
	sort(s.begin(), s.end());
	cout << sum - 10 + s[0] << endl;
}



Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0)+s(1),c=s(2)+s(3)
    Dim ans=If(a>c,"Left",If(a<c,"Right","Balanced"))
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 20304
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 2e5 + 8;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
}

int C(int n, int k) {
	return divv(f[n], mul(f[k], f[n - k]));
}

int sl(int n, int m) {
 	return C(n + m, n);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	init();

	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int i = h - a;
	int j = b - 1;
	int ans = 0;
	i--;
	j++;
	while (i >= 0 && j < w) {
		ans = add(ans, mul(sl(i, j), sl(h - 1 - i, w - 1 - j)));
		i--;
		j++;
	}
	cout << ans << endl;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long n,m;
	cin>>n>>m;
	cout<<((n*(n-1))/2) + ((m*(m-1))/2)<<endl;
	return 0;
}


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

int main(){
	int n;
	double xa,ya,ra,xb,yb,rb;
	double L;
	int i;
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		L = sqrt(pow(xa-xb,2) + pow(ya-yb,2));
		if(L > ra+rb){
			printf("0\n");
		}else if(L >= fabs(ra-rb)&&L <=ra+rb){
			printf("1\n");
		}else if(L < fabs(ra-rb)){
			if(ra > rb){
				printf("2\n");
			}else{
				printf("-2\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1048
if __name__ == "__main__":
    N = int(input())
    num_list = list(map(int, input().split()))
    ans = 1
    MAX = 1e18
    for i in num_list:
        ans = ans*i
        if ans > MAX:
            ans = -1
            break
    if 0 in num_list:
        print(0)
    else:
        print(ans)

Measured memory_bytes: 21700
K=int(input())

def NS(N):
  NS=0
  while(N>0):
    NS+=N%10
    N//=10
  return NS

answer,diff=0,1
for i in range(K):
  answer+=diff
  print(answer)
  
  if (answer+diff)/NS(answer+diff)>(answer+10*diff)/NS(answer+10*diff):
    diff*=10

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n; i++)

#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef long long ll;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6 + 13;
//=======================
vi g[N];
int a[N];
//=======================

void solve()
{
  int n;
  cin >> n;
  int a = 1000;
  while (a < n)
  {
    a += 1000;
  }
  cout << a - n << endl;
}

int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int t = 1;

  // cin >> t;

  while (t--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 50508
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int table[W][H];
    for (int i = 0; i < W; ++i) {
        fill(table[i], table[i] + H, 1);
    }
    
    //
    int x, y, a;
    for (int i = 0; i < N; ++i) {
        cin >> x >> y >> a;

        //
        if(a == 1){
            for (int j = 0; j < x; ++j) {
                for (int k = 0; k < H; ++k) {
                    table[j][k] = 0;
                }
            }

        }else if(a == 2){
            for (int j = x; j < W; ++j) {
                for (int k = 0; k < H; ++k) {
                    table[j][k] = 0;
                }
            }

        }else if(a == 3){
            for (int j = 0; j < W; ++j) {
                for (int k = 0; k < y; ++k) {
                    table[j][k] = 0;
                }
            }

        }else if(a == 4){
            for (int j = 0; j < W; ++j) {
                for (int k = y; k < H; ++k) {
                    table[j][k] = 0;
                }
            }
        }
    }


    //
//    for (int i = 0; i < W; ++i) {
//        for (int j = 0; j < H; ++j) {
//            cout << table[i][j];
//        }
//        cout << endl;
//    }


    //
    int num = 0;
    for (int i = 0; i < W; ++i) {
        for (int j = 0; j < H; ++j) {
            num += table[i][j];
        }
    }

    cout << num << endl;



    return 0;
}

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

int main(){

    int h,w;
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h){
        cin >> m[i];
    }
    int ans=0;
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    for(int x=0;x<w;x++){
        for(int y=0;y<h;y++){
            for(int gx=0;gx<w;gx++){
                for(int gy=0;gy<h;gy++){
                    if(x==gx&&gy==y)continue;
                    vector<vector<int>> t(h,vector<int>(w,-1));
                    if(m[y][x]!='#'){
                        deque<pair<int,int>> q;
                        q.push_back({x,y});
                        t[y][x]=0;
                        while(q.size()!=0){
                            int tx=q.front().first;
                            int ty=q.front().second;
                            q.pop_front();
                            rep(i,4){
                                int nx=tx+dx[i];
                                int ny=ty+dy[i];
                                if(ny<0||ny>=h||nx<0||nx>=w)continue;
                                if(t[ny][nx]==-1&&m[ny][nx]=='.'){
                                    q.push_back({nx,ny});
                                    t[ny][nx]=t[ty][tx]+1;
                                }
                            }
                        }
                    }
                    ans=max(ans,t[gy][gx]);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long 
#define r(i,n) for(ll i=0;i<n;i++)
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define ret return 
#define elif else if
ll inf=100001;
using namespace std;
int main(){
	while(1){
		ll n,x;cin>>n>>x;
		ll a[n];r(i,n)cin>>a[i];
		ll ans=0,p;
		r(i,n-1){
		p=a[i]+a[i+1];
		if(p<=x){continue;}
		if(a[i+1]>=p-x){ans+=(p-x);a[i+1]-=(p-x);}
		else{ans+=(p-x);
		a[i]-=((p-x)-a[i+1]);a[i+1]=0;
		}//else	
		}//rep
		cout<<ans<<endl;
		
		
		ret 0;
	}	
}

Measured memory_bytes: 1024
N,*H=`dd`.split.map &:to_i
d=[0,(H[0]-H[1]).abs]
(2...N).each{ |i|
  d << [d[i-2] + (H[i]-H[i-2]).abs, d[i-1] + (H[i]-H[i-1]).abs].min
}
p d[-1]

Measured memory_bytes: 12292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<Edge>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll P;
  cin>>P;
  ll A[P],B[P];
  REP(i,P){
    cin>>A[i];
    B[i]=0;
  }
  
  REP(i,P){
    if(A[i]==1){
      ll SIGN=1;
      B[0]+=1;
      
      for(int j=P-1; j>=0; --j){
        B[j]-=SIGN;
        SIGN*=i;
        B[j]%=P;
        if(B[j]<0) B[j]+=P;
        SIGN%=P;
      }
    }
  }
  
  REP(i,P) cout<<B[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);    
 	String s = sc.next();
    String result = "";
    
    if ("Sunny".equals(s)) {
      result = "Cloudy";
    } else if ("Cloudy".equals(s)) {
      result = "Rainy";
    } else if ("Rainy".equals(s)) {
      result = "Sunny";
    }
    
    
    System.out.println(result);
  }
}



Measured memory_bytes: 27028
#include<iostream>
#include<cmath>
#include<iomanip>
#define dis(a,b)sqrt(((a)+(b))*((a)+(b))-((a)-(b))*((a)-(b)))
using namespace std;
int n;double d[500],p[500];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>d[i];
	for(int i=0;i<n;i++)
	{
		p[i]=d[i];
		for(int j=0;j<i;j++)
		{
			double now=dis(d[j],d[i])+p[j];
			p[i]=max(p[i],now);
		}
	}
	double ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,p[i]+d[i]);
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}





    
void test_case() {

        string s, t;
        cin>>s>>t;

        int n = s.size();
        int m = t.size();


        int ans = m;

        for(int i=0; i<=n-m; i++) {
            string temp = s.substr(i,m);

            int cnt = 0;
            for(int j=0; j<m; j++) {
                if(temp[j] != t[j]) {
                    cnt++;
                }
            }

            ans = min(ans, cnt);
        }

        cout<<ans<<endl;
        


}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N= 5e4 +10;

string s;
int len;
int k;
vector<string> V;

int main() {
	cin>>s>>k;
	len=s.length();

	FOR(i, 0, len) {
		for(int j=1; j<=5; j++) {
			if (i+j-1>=len) continue;
			V.pb(string(s.begin()+i, s.begin()+i+j));
		}
	}
	sort(V.begin(), V.end());
	unique(V.begin(), V.end());
	// FOR(i, 0, V.size()) DBG(V[i]);
	cout<<V[k-1]<<endl;
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <list>

int main()
{
	std::list<int> list;

	for (int i = 0; i < 3; ++i)
	{
		int x = 0;
		std::cin >> x;
		list.emplace_back(x);
	}

	list.sort();

	for (auto itr = list.begin(); itr != list.end(); ++itr)
	{
		if (itr != list.begin()) std::cout << " ";
		std::cout << *itr;
	}
	std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3080
import sys
import bisect
input = sys.stdin.readline
import numpy as np

class Bisect(object):
    def bisect_max(self, reva, func,M):
        ok = 0 # exist
        ng = 2*(10**5)+1 # not exist
        while abs(ok-ng) > 1:
            cnt = (ok + ng) // 2
            if func(cnt,reva,M):
                ok = cnt
            else:
                ng = cnt
        return ok

def solve1(tgt,reva,M):
    res=0
    n = len(reva)
    if (n - bisect.bisect_left(reva,tgt-reva[n-1]))*n < M:
        return False
    for i in range(n):
        res += n - bisect.bisect_left(reva,tgt-reva[n-i-1])
        if M <= res:
            return True
    return False

N,M = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
reva = a[::-1]
bs = Bisect()
Kmax = (bs.bisect_max(reva,solve1,M))

r=np.zeros((N+1),dtype='int64')
np.cumsum(a,out=r[1:])
r = list(r)
res = 0
cnt = 0
t = 0
for i in range(N):
    tmp = bisect.bisect_left(reva,Kmax-reva[N-i-1])
    if t != 1:
        tmp2 = bisect.bisect_right(reva,Kmax-reva[N-i-1])
        if tmp!=tmp2:
            t = 1
    tmp = N - tmp
    cnt += tmp
    res += tmp*a[i]+r[tmp]
if t==1:
    res -= (cnt-M)*Kmax
print(res)


Measured memory_bytes: 23368
N, x = map(int, input().split())
A = list(map(int, input().split()))

val = A[:]
ans = 10 ** 18

for k in range(N):
    cost = x * k
    for i in range(N):
        val[i] = min(val[i], A[(i - k) % N])
    cost += sum(val)
    ans = min(cost, ans)

print(ans)

Measured memory_bytes: 9332
#include<stdio.h>

int main(void){
    int num1,num2,num3;

    scanf("%d %d %d",&num1,&num2,&num3);

    if(num1+num2+num3==17){
        if((num1==5&&num2==5)||(num2==5&&num3==5)||(num3==5&&num1==5)){
            printf("YES");
        }else{
            printf("NO");
        }
    }else{
        printf("NO");
    }
    return 0;

}

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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	int ans = 1 ;
	set<int>s ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(arr[i] != arr[n/2+1])
			s.insert(arr[i]) ;
	}
	while(s.size() > 0)
	{
		int a = *s.begin() ;
		int b = *s.rbegin() ;
		if(a == b)
			break ;
		ans += 2 ;
		s.erase(a) ;
		s.erase(b) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

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

int main()
{
  vector<int> v { istream_iterator<int>(cin), istream_iterator<int>() };

  int five_count = std::count(v.begin(), v.end(), 5);
  int seven_count = std::count(v.begin(), v.end(), 7);
  string answer = five_count == 2 && seven_count == 1 ? "YES" : "NO";

  cout << answer << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    a = [-1]
    for i in range(N):
        a.append(int(input()))

    count_num = 1
    next_num = a[1]
    done_num = set([1])
    while True:
        if next_num in done_num:
            print(-1)
            break
        elif next_num == 2:
            print(count_num)
            break

        count_num += 1
        done_num.add(next_num)
        next_num = a[next_num]


Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
int ant,lt,t,ops[100009],asp[100009],fin[100009];//fin[]存储最终结果 
long long ranking;
int main(){
	scanf("%d%d%d",&ant,&lt,&t);
	for(int i=1;i<=ant;i++)	scanf("%d%d",&ops[i],&asp[i]);
	for(int i=1;i<=ant;i++)
		if(asp[i]==1)	ranking=(long long)(ranking+((ops[i]+t)/lt))%ant;
		else{
			int add=ops[i]-t;
			add=(add-lt+1)/(-1*lt);
			ranking=(long long)ranking-add;
			if(ranking<0)	ranking=(long long)((-1*ranking+ant-1)/ant)*ant+ranking;
		}
	for(int i=1;i<=ant;i++)
		if(asp[i]==1)	fin[i]=(ops[i]+t)%lt;
		else{
			fin[i]=ops[i]-t;
			if(fin[i]<0)	fin[i]=((-1*fin[i]+lt-1)/lt)*lt+fin[i];
		}
	sort(fin+1,fin+1+ant);
	for(int i=1;i<=ant;i++){
		int now=i+ranking;
		if(now>ant)	now%=ant;
		printf("%d\n",fin[now]);
	}
	return 0;
}

Measured memory_bytes: 2304
from collections import Counter
n = int(input())
v = [int(_) for _ in input().split()]
v1 = []
v2 = []
for i in range(n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v_count = Counter(v)
v1_count = Counter(v1)
v2_count = Counter(v2)
# print("v1_count", v1_count)
# print("v2_count", v2_count)
v1_comm = v1_count.most_common(1)
v2_comm = v2_count.most_common(1)
sols = []
# print("v1_comm", v1_comm)
# print("v2_comm", v2_comm)
if len(v_count) == 1:
    print(n//2)
else:
    key1 = v1_comm[0][1]
    # print("v1_comm[0][0]", v1_comm[0][0])
    # print("v2_comm[0][0]", v2_comm[0][0])
    if v1_comm[0][0] == v2_comm[0][0]:
        # print("hoge")
        v2_comm = v2_count.most_common(2)
        key2 = v2_comm[1][1]
    else:
        key2 = v2_comm[0][1]
    sols.append(n-key1-key2)
    key1 = v2_comm[0][1]
    if v1_comm[0][0] == v2_comm[0][0]:
        v1_comm = v1_count.most_common(2)
        key2 = v1_comm[1][1]
    else:
        key2 = v1_comm[0][1]
    sols.append(n-key1-key2)
    print(min(sols))


Measured memory_bytes: 25300
H, W, K = map(int, input().split())
g = [input() for _ in range(H)]
ans = 0
for bit in range(2**(H + W)):
    cnt = 0
    for h in range(H):
        if (bit & (h << 1)):
            pass
        if ((bit >> h) & 1):
            #print(h,"cancel")
            continue
        for w in range(W):
            if (bit & (H + w << 1)):
                pass
            if ((bit >> H + w) & 1):
                continue
            if g[h][w] == '#':
                cnt += 1
                #print(h, w)
    if cnt == K:
        # print(bin(bit), "ok")
        # for i in range(H):
        #     print(g[i])
        ans += 1
print(ans)


Measured memory_bytes: 9200
if __name__ == '__main__':
    n, w = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(n)]

    sum_value = sum([v for (_, v) in wv])

    dp = [[10**9 + 7 for _ in range(sum_value + 1)] for _ in range(n + 1)]

    dp[0][0] = 0

    for i in range(n):
        for j in range(sum_value + 1):
            if j >= wv[i][1]:
                dp[i + 1][j] = min(dp[i][j - wv[i][1]] + wv[i][0], dp[i][j])
            else:
                dp[i + 1][j] = dp[i][j]

    a = sorted(range(sum_value + 1), reverse = True)

    for i in a:
        if dp[n][i] <= w:
            print(i)
            break


Measured memory_bytes: 171656
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    int N,K;
    cin>>N>>K;
    ll x[N+1];
    REP(i,N){
    	cin>>x[i];
    }

    int startid=-1;
    REP(i,N){
    	if(x[i]>0) {
    		startid=i;
    		break;
    	}
    }
    // cout<<startid<<endl;
    ll ans=2*abs(x[N])+2*abs(x[1]);
    if(startid==-1) {
    	ans=abs(x[N-K+1]);
    	// cout<<"No positive"<<endl;
    	cout<<ans<<endl;
    	return 0;
    } else {
    	if(startid+K-1<=N){
    		if(ans>x[startid+K-1]) {
	    		ans=x[startid+K-1];
	    		// cout<<"Right only"<<endl;
	    		// cout<<ans<<endl;
	    	}
    	}
    	if(startid-K>=1){
    		if(ans>abs(x[startid-K])) {
	    		ans=abs(x[startid-K]);
	    		// cout<<"Left only"<<endl;
	    		// cout<<ans<<endl;
    		}
    	}
    	FOR(i,1,N-startid+1){	//右に何個行くか
    		if(startid-K+i>=1 && K-i>=1){
    			if(ans>2*abs(x[i+startid-1])+abs(x[startid-K+i])) {
    				ans=2*abs(x[i+startid-1])+abs(x[startid-K+i]);
    				// cout<<endl;
    				// cout<<startid+i-1<<endl;
    				// cout<<startid-K+i+1<<endl;

    				// cout<<ans<<endl;
    				// cout<<endl;
    			}
    		}
    	}

    	FOR(i,1,startid-1){	//左に何個行くか
    		if(K-i>=1 && K-i+startid-1<=N){
    			if(ans>2*abs(x[startid-i])+abs(x[K-i+startid-1])) {
    				ans=2*abs(x[startid-i])+abs(x[K-i+startid-1]);
    				// cout<<ans<<endl;
    			}
    		}
    	}
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    //ll x;
    cin>>a>>b>>m;
    vector<ll> aa(a);
    vector<ll> bb(b);
    vector<ll> x(m);
    vector<ll> y(m);
    vector<ll> c(m);

    rep(i,a) cin>>aa[i];
    rep(i,b) cin>>bb[i];
    rep(i,m) cin>>x[i]>>y[i]>>c[i];
    mini=*min_element(aa.begin(),aa.end())+*min_element(bb.begin(),bb.end());
    rep(i,m) mini=min(mini,aa[x[i]-1]+bb[y[i]-1]-c[i]);
    cout<<mini<<endl;

  
    return 0;
}

Measured memory_bytes: 4224
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(len(table)-K):
    ans+=table[i][1]
  print(ans)


Measured memory_bytes: 39324
MOD = 10 ** 9 + 7
n = int(input())
ans10 = 10
ans9 = 9
ans8 = 8
for i in range(n - 1):
    ans10 = ans10 * 10 % MOD
    ans9 = ans9 * 9 % MOD
    ans8 = ans8 * 8 % MOD
ans = (ans10 - ans9 - ans9 + ans8) % MOD
ans = (ans + MOD) % MOD
print(ans)


Measured memory_bytes: 9104
#!/usr/bin/env ruby

s = gets.strip
words = ['dream', 'dreamer', 'erase', 'eraser']

while true do
  reduced = false
  words.each do |word|
    if s.end_with?(word) then
      s[-word.length, word.length] = ''
      reduced = true
    end
  end
  break unless reduced
end
puts s.empty? ? 'YES' : 'NO'

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0,c=0;
  for(int i=0;s[i];i++){
    if(s[i]=='R') ans=max(ans,++c);
    else c=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
  int a,n,d,c=0;
  cin >> n >> d;
  for(int i=0;i<n;i++) {
    cin >> a;
    if(a>d)c+=a-d;
  }
  if(c==0)cout << "kusoge" << endl;
  else cout << c << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}

ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
int a[26];
int b[26];
int main() {
    string s, t; cin >> s >> t;
    
    for(int i=0; i<s.size(); ++i) a[s[i]-'a']++;
    for(int i=0; i<t.size(); ++i) b[t[i]-'a']++;
    sort(a, a+26);
    sort(b, b+26);
    bool ok = true;
    for(int i=0; i<26; ++i){
        if(a[i]!=b[i]) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    double sum = 0;
    double[] x = new double[n];
    String[] u = new String[n];
    
    for(int i=0; i<n; i++) {
      String[] str = in.readLine().split(" ");
      x[i] = Double.parseDouble(str[0]);
      u[i] = str[1];
      if(u[i].equals("BTC"))
        x[i] = x[i]*380000.0;
      sum += x[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21332
#include<stdio.h>
int main()
{
	int i,a,b,n;
	scanf("%d%d%d",&n,&a,&b);
	for(i=a;i<=b;i++)
	{
		if(i%n==0)
		{
			printf("OK");
			return 0;
		}
	}
	printf("NG");
	return 0;
}

Measured memory_bytes: 1700
#include<stdio.h>
int main(void) {
	int a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, c1, c2, c3, c4, c5, c6, c7; 
	scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d",&a1,&b1,&a2,&b2,&a3,&b3,&a4,&b4,&a5,&b5,&a6,&b6,&a7,&b7);
	c1 = a1 - b1;
	c2 = a2 - b2;
	c3 = a3 - b3;
	c4 = a4 - b4;
	c5 = a5 - b5;
	c6 = a6 - b6;
	c7 = a7 - b7;
	printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",c1,c2,c3,c4,c5,c6,c7);
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

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

  vector<Pii> xy(n);
  for (int i = 0; i < n; i++) {
    cin >> xy[i].first >> xy[i].second;
  }

  map<Pii, int> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        continue;
      int x, y;
      x = xy[i].first - xy[j].first;
      y = xy[i].second - xy[j].second;
      m[make_pair(x, y)] += 1;
    }
  }

  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr){
    // cout << key.first << "," << key.second << ": " << value << endl;
    if (ans < itr->second)
      ans = itr->second;
  }

  cout << n - ans << endl;
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;



int main(){
  char str[1000];
  std::cin >> str;
  str[3]='8';
  std::cout << str << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int  A,B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) cout << -1 << endl;
    else cout << A*B << endl;
}


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

int main(){
  int n,k;
  vector<int> snake;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    snake.push_back(a);
  }
  sort(snake.begin(),snake.end(),greater<int>());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=snake[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<stdlib.h>
#include<iostream>
#include<stack>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
#define MST(vis,x) memset(vis,x,sizeof(vis))
#define maxn 200010
#define maxm 1010
#define INF 0x3f3f3f3f
int main()
{
    ll s1[60];
    ll k,n,x,temp,all;
    while(scanf("%lld",&k)!=EOF)
    {
        ll temp1=k/50;
        ll temp2=k%50;
        MST(s1,0);
        int change=50;
        for(int a=1;a<=50;a++)
            s1[a]=a-1;
        for(int a=temp2;a>=1;a--)
        {
            s1[a]=change--;
        }
        for(int a=1;a<=50;a++)
        {
            s1[a]+=temp1;
        }
        for(int a=temp2+1;a<=50;a++)
            s1[a]=s1[a]-temp2;
        printf("50\n");
        printf("%lld",s1[1]);
        for(ll a=2; a<=50; a++)
            printf(" %lld",s1[a]);
        printf("\n");
    }
    return 0;
}


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


#define MOD 1000000007

int a[1010];
int b[1010];

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

  for(int i = 0;i < n;i++) cin >> a[i+1];

  for(int j = 0;j < m;j++) cin >> b[j+1];

  a[0] = 0;
  b[0] = 0;
  sort(a, a+n+1);
  sort(b, b+m+1);


  for(int i = 0;i < n;i++){
    if(a[i] == a[i+1]){
      cout << 0 << endl;
      return 0;
    }
  }

  for(int i = 0;i < m;i++){
    if(b[i] == b[i+1]){
      cout << 0 << endl;
      return 0;
    }
  }

  long long ans = 1;
  long long aki = 0;
  for(int i = n*m;i >= 1;i--){
    long long np = lower_bound(a,a+n+1,i) - a;
    long long mp = lower_bound(b,b+m+1,i) - b;

    if(a[np] == i && b[mp] == i){
      aki += n-np + m-mp;
    }else if(a[np] == i){
      ans = (ans * (m-mp+1)) % MOD;
      aki += m-mp;
    }else if(b[mp] == i){
      ans = (ans * (n-np+1)) % MOD;
      aki += n-np;
    }else{
      ans = (ans * (aki)) % MOD;
      aki--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())
g = [list() for _ in range(n+1)]
for _ in range(m):
  a,b = map(int,input().split())
  g[a].append(b)
  g[b].append(a)
bw = [-1]*(n+1)
bw[1] = 0
q = [1]
f = 0
while q:
  v = q.pop()
  for x in g[v]:
    if bw[x] >= 0:
      if bw[x] == bw[v]:
        f = 1
        break
      continue
    else:
      bw[x] = 1-bw[v]
      q.append(x)
if f:
  print(n*(n-1)//2 - m)
else:
  b = sum(bw)+1
  w = n - b
  print(b*w-m)

Measured memory_bytes: 22064
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,Q=map(int,input().split())
*A,=map(int,input().split())

bit=Bit(N)
for i in range(1,N+1):
    bit.add(i,A[i-1])

abc=[list(map(int,input().split()))for _ in range(Q)]

for a,b,c in abc:
    if a:print(bit.sum(c)-bit.sum(b))
    else:bit.add(b+1,c)

Measured memory_bytes: 145716
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int n,m,fa[maxn],vis[maxn];
vector<int> g[maxn];
void bfs()
{
    queue<int> q;
    int cnt = 0;
    for(int v:g[1]){
        q.push(v);
        vis[v] = 1;
        fa[v] = 1;
    }
    while(!q.empty()){
        int u = q.front();q.pop();
        for(int v:g[u]){
            if(vis[v]) continue;
            vis[v]=1;
            q.push(v);
            fa[v] = u;
        }
    }
}
int main()
{
    fastio();
    cin>>n>>m;
    int u,v;
    memset(fa,-1,sizeof(fa));
    rep(i,1,m){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    bfs();
    int flag = 1;
    rep(i,2,n) if(fa[i]==-1) {flag=0;break;}
    if(!flag) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        rep(i,2,n) cout<<fa[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13648
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int N;
	int t[101][101];
	while(cin >> N, N){
		int W, H; cin >> W >> H;	
		memset(t, 0, sizeof(t));
		for(int i=0;i<N;i++){
			int x, y; cin >> x >> y;
			t[y][x] = 1;
		}
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				t[i][j] += t[i][j-1];
			}
		}
		int S, T; cin >> S >> T;
		int res = 0;
		for(int i=1;i+T<=H+1;i++){
			for(int j=1;j+S<=W+1;j++){
				int num = 0;
				for(int k=i;k<i+T;k++){
					num += t[k][j+S-1] - t[k][j-1];
				}
				res = max(res, num);
			}
		}
		cout << res << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  ll r=0;
  ll g=0;
  ll b=0;
  rep(i,N){
    if(s.at(i)=='R') r++;
    if(s.at(i)=='G') g++;
    if(s.at(i)=='B') b++;
  }
  ll ans=r*g*b;
  rep(i,N){
    rep(j,N){
   int k = j+j-i;
      if(j<k && k<N){
   if(s.at(k) != s.at(i) && s.at(i) != s.at(j) && s.at(k) != s.at(j)) ans--;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
struct s
{
    ll w, v;
};
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, toggle = 0, w;
    cin >> n >> w;
    vector 
 a(n);
    ll dp[2][w + 1];
    memset(dp, 0, sizeof dp);
    for(i = 0; i < n; i++)
        cin >> a[i].w >> a[i].v;
    for(i = 0; i <= w; i++)
        dp[toggle][i] = (a[0].w <= i ? a[0].v : 0);
    toggle = 1;
    for(i = 1; i < n; i++, toggle ^= 1)
    {
        for(ll j = 0; j <= w; j++)
        {
            dp[toggle][j] = dp[toggle ^ 1][j];
            if(a[i].w <= j)
                dp[toggle][j] = max(dp[toggle][j], a[i].v + dp[toggle ^ 1][j - a[i].w]);
        }
    }
    cout << dp[toggle ^ 1][w] << endl;
    return 0;
}

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

char s[600][600];

bool check(int n, int si, int sj){
    for(int i = 0; i< n; i++){
        for(int j =i; j<n; j++){    
            if(s[si+i][sj+j] != s[si+j][sj+i] )
                return false;
        }
    }
    return true;
}

int main()
{
    int n, ans;
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j =0; j<n; j++){
            char t;
            cin >> t;
            s[i][j] =t;
            s[i+n][j] = t;
            s[i][j+n] = t;
            s[i+n][j+n] = t;
        }
    }
    ans = 0;
    for(int i = 0; i< n; i++){
        if(check(n,i,0) == true)  ans += n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),k=nxtl();
    vector <ll> a(n);
    vector <ll> f(n);
    generate(all(a),nxtl);
    generate(all(f),nxtl);
    sort(a.begin(),a.end(),greater<int>());
    sort(f.begin(),f.end());
    ll l=0,r=1e12;
    ll test=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        ll c=0;
        for(int i=0;i<n;i++)
        {
            ll diff=max(0,a[i]*f[i]-mid);
            c+=(diff/f[i]);
            if(diff%f[i]>0)
                c++;
        }
        if(c<=k)
        {
            test=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }

    cout<<test<<endl;

    

    return 0;   
}


 
 


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

LL pow2(LL K){
  LL a = 1;
  REP(i, K)
  {
    a *= 2;
  }
  return a;
}

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

  LL M ,K;
  cin >> M >> K;

  if(K==0){
    REP(i,pow2(M)){
      if(i!=0){
        cout << " ";
      }
      cout << i SP i;
    }
    cout << endl;
  }else
  if(K<pow2(M)&&M%2==0){
    cout << 0 << " ";
    REP(i,pow2(M)){
      if(i!=0&&i!=K){
        cout << i << " ";
      }
    }
    cout << 0 << " ";
    cout << K << " ";
    REP(j,pow2(M)){
      LL i = pow2(M) - j-1;
      if (i != 0 && i != K)
      {
        cout << i << " ";
      }
    }
    cout << K << endl;
  }else
  if(K<pow2(M)&&M%2!=0&&(M!=1)){
    if((K==pow2(M)-1)){
      cout << 0 << " ";
      REP(i,pow2(M)){
        if(i!=0&&i!=K){
          cout << i << " ";
        }
      }
      cout << 0 << " ";
      cout << K << " ";
      REP(j,pow2(M)){
        LL i = pow2(M) - j-1;
        if (i != 0 && i != K)
        {
          cout << i << " ";
        }
      }
      cout << K << endl;
    }else{
      LL KK = pow2(M)-K-1;
      cout << 0 << " ";
      REP(i,pow2(M)-1){
        if(i!=0&&i!=KK){
          cout << i << " ";
        }
      }
      cout << 0 << " ";
      cout << pow2(M)-1<<" ";
      cout << KK << " ";
      LL xx=pow2(M);
      REP(j,xx-1){
        LL i = xx - j-2;
        if (i != 0 && i != KK)
        {
          cout << i << " ";
        }
      }
      cout << KK<<" ";
      cout << pow2(M)-1<<endl;
    }
  }
  else
  {
    cout << -1 << endl;
  }
}

// ->001
//
// 000
// ~~
// 000
// k
// 110
// ~~
// 110
// l


// 000
// 001
// 010
// 011
// 100
// 101
// 110
// 000
// 111
// 000
// 001
// 010
// 011
// 100
// 101
// 110
// 111



Measured memory_bytes: 1792
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


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

    int n,m; cin >> n >> m;
    int a[n]; int asum = 0; rep(i,n){
        cin >> a[i];
        asum += a[i];
    }
    int ans = 0;
    rep(i,n){
        if(a[i]*4*m >= asum) ans++;
    }
    if(ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	ll n;
	cin>>n;
	ll dp[100005];
	fill(dp,dp+100005,100005);
	dp[0]=0;

	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=i;j*=6){
			dp[i]=min(dp[i],dp[i-j]+1);
		}
		for(ll j=1;j<=i;j*=9){
			dp[i]=min(dp[i],dp[i-j]+1);
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, M = (N - 1) * 2;

struct E {
	int i, j, w;
} ee[M];

int xx[N], yy[N], ii[N], jj[N], ds[N];

int find(int i) {
	return ds[i] < 0 ? i : (ds[i] = find(ds[i]));
}

bool join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return false;
	if (ds[i] > ds[j])
		ds[i] = j;
	else {
		if (ds[i] == ds[j])
			ds[i]--;
		ds[j] = i;
	}
	return true;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> xx[i] >> yy[i];
		ii[i] = jj[i] = i;
	}
	sort(ii, ii + n, [] (int i, int j) { return xx[i] < xx[j]; });
	sort(jj, jj + n, [] (int i, int j) { return yy[i] < yy[j]; });
	int m = 0;
	for (int h = 1; h < n; h++) {
		int i, j, w;
		i = ii[h - 1];
		j = ii[h];
		w = xx[j] - xx[i];
		auto &e = ee[m++];
		e.i = i, e.j = j, e.w = w;
		i = jj[h - 1];
		j = jj[h];
		w = yy[j] - yy[i];
		auto &f = ee[m++];
		f.i = i, f.j = j, f.w = w;
	}
	sort(ee, ee + m, [] (auto &e, auto &f) { return e.w < f.w; });
	fill(ds, ds + n, -1);
	long long ans = 0;
	for (int h = 0; h < m; h++) {
		auto &e = ee[h];
		if (join(e.i, e.j))
			ans += e.w;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7948
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S,T;

int main(){
    cin>>S>>T;
    rep(i,S.length()){
        string temp="";
        repi(j,i,S.length()){
            temp+=S[j];
        }
        repi(j,0,i){
            temp+=S[j];
        }
        if(temp==T){
            out("Yes");
            return 0;
        }
    }
    out("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  vector<string> m;
  cin>>h>>w;
  m.resize(h);
  for(int i=0;i<h;i++)cin>>m[i];
  for(int i=0;i<h;i++){
    while(i<m.size()&&find(m[i].begin(),m[i].end(),'#')==m[i].end())m.erase(m.begin()+i);
    h=m.size();
  }
  for(int i=0;i<w;i++){
    bool t=false;
    for(int j=0;j<h;j++)if(m[j][i]=='#')t=true;
    if(!t)for(int j=0;j<h;j++)m[j][i]='x';
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char u=m[i][j];
      if(u=='x')continue;
      cout<<u;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256