akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)


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

  vector<PII> job;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    job.PB(MP(b, a));
  }
  SORT(job);
  LL n = 0;
  for (const auto& e : job) {
    n += e.second;
    if (e.first < n) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 2420
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, k;
	
	cin >> n >> k;
	
	if(n * 500 >= k){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int A, B, C;
ll K;

int main() {

	scanf("%d %d %d %lld", &A, &B, &C, &K);

	if (K % 2) printf("%d\n", B - A);
	else printf("%d\n", A - B);

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
S = input()
K = int(input())
if len(list(set(S))) == 1:
    print(len(S) * K // 2)
    exit()
l = []
SS = S * 2
s = SS[0]
cnt = 1
for i in range(1, len(SS)):
    if s != SS[i]:
        l.append(cnt)
        s = SS[i]
        cnt = 1
    else:
        cnt += 1
l.append(cnt)
ans = 0
if S[0] == S[-1]:
    for i in range(len(l)//2 + 1):
        # if i == 0 or i == len(l)//2:
        #     ans += l[i] // 2
        if i == 0:
            ans += l[i] // 2
        elif i == len(l) // 2:
            ans += l[i] // 2 * (K-1)
        else:
            ans += l[i] // 2 * K
    ans += l[-1] // 2
    # ans -= (l[0] + l[-1]) // 2
else:
    # print(l[:len(l)//2])
    for i in range(len(l)//2):
        ans += l[i] // 2 * K
print(ans)


Measured memory_bytes: 3064
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] ab = new int[n][2];

        for (int i=0; i<n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            ab[i][0] = a;
            ab[i][1] = b;
        }

        int[] dp = new int[h+20000];

        for (int i=1; i<=h; i++){
            int idx = i+10000;
            dp[idx] = Integer.MAX_VALUE;
            for (int j=0; j<n; j++){
                dp[idx] = Math.min(dp[idx], dp[idx-ab[j][0]]+ab[j][1]);
            }
        }

        System.out.println(dp[h+10000]);

    }
}






Measured memory_bytes: 26084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int max=b[n-1];
    for(int i=0;i<n;i++)
    {
        int k=a[i];
        if(max!=k)
         cout<<max;
         else
         {
             
            cout<<b[n-2]; 
         }
         cout<<"\n";
    }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define MAXV 2005
int n,k;
vector<int>edges[MAXV];
int vis[MAXV],level_num[MAXV],ans;
void addedge(int from,int to)
{
        edges[from].push_back(to);
        edges[to].push_back(from);
}
void dfs(int now,int n)
{
        vis[now] = 1;
        level_num[n]++;
        for(int i=0;i<edges[now].size();i++)
        {
                int v = edges[now][i];
                if(!vis[v])
                {
                        //cout<<v<<endl;
                        dfs(v,n+1);
                }
        }
}
int main ()
{
        int from,to,temp;
        cin>>n>>k;
        ans = 0x3f3f3f3f;
        for(int i=0;i<n-1;i++)
        {
                cin>>from>>to;
                addedge(from,to);
        }
        if(k%2)
        {
                for(int i=1;i<=n;i++)
                {

                        for(int j=0;j<edges[i].size();j++)
                        {
                                temp = 0;
                                memset(level_num,0,sizeof(level_num));
                                memset(vis,0,sizeof(vis));

                                vis[edges[i][j]] = 1;
                                dfs(i,0);
                                dfs(edges[i][j],0);
//                                cout<<"////////////"<<i<<"///////"<<edges[i][j]<<endl;
//                                for(int ii=0;ii<=6;ii++)
//                                {
//                                        cout<<ii<<" "<<level_num[ii]<<endl;
//                                }
                                for(int ii=(k-1)/2 + 1;ii<=n;ii++)
                                {
                                        if(!level_num[ii])        break;
                                        temp += level_num[ii];
                                }
                                ans = min(ans,temp);
                        }
                }
        }
        else
        {
                for(int i=1;i<=n;i++)
                {
                        temp = 0;
                        memset(level_num,0,sizeof(level_num));
                        memset(vis,0,sizeof(vis));
                        dfs(i,0);
                        for(int j=k/2 + 1 ;j<=n;j++)
                        {
                                if(!level_num[j])        break;
                                temp += level_num[j];
                        }
                        ans = min(ans,temp);
                }
        }
        cout<<ans<<endl;


}


Measured memory_bytes: 512
# AOJ ITP1_8_B

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        n = int(input())
        if n == 0: break
        sum = 0
        while n > 0:
            sum += n % 10
            n = n // 10
        print(sum)

if __name__ == "__main__":
    main()



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<30;

int main(){
  int N,K; cin >>N >>K;
  int h[N];
  for(int i=0;i<N;i++){
    cin >> h[i];
  }

  int dp[100010]; dp[0]=0; dp[1]=0;
  dp[2]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    dp[i+1] = INF;
    for(int j=0;j<K;j++){
      if(i-j>0){
        int cost = dp[i-j]+abs(h[i]-h[i-1-j]);
        if(dp[i+1]>cost) dp[i+1] = cost;
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , k;

int main() {

	_FastIO;
    cout.precision(12);
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i ++) {
		int m = i;
		double p = 1;
		while (m < k) {
			m *= 2;
			p /= 2;
		}
		ans += p / n;
	}
	cout << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}

vector<ll> vec;
ll N;
ll func(ll s) {
    ll c   = 0;
    ll sum = 0;
    for (ll i = 0; i < N; ++i) {
        bool isSign = (i % 2) == s;
        ll tmp      = sum + vec[i];
        if (isSign != (tmp > 0) || tmp == 0) {
            ll next = isSign ? 1 : -1;
            c += abs(tmp - next);
#ifdef SOURCE_TEST
            cout << sum << ":" << tmp << endl;
#endif

            sum = next;
        } else {
            sum = tmp;
        }
    }
    return c;
}
int main() {
    cin >> N;
    vec.resize(N);
    REP(i, N) {
        cin >> vec[i];
    }

#ifdef SOURCE_TEST

    for (auto v : vec) {
        cout << v << ",";
    }
    cout << endl;

#endif
    ll count = min(func(0), func(1));

    cout << count << endl;
    return 0;
}

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

int* d;
int n=1;

void initRSQ(int n) {
    for(int i=0; i<2*n-1; i++) d[i] = 0;
}

void add(int k, int a) {
    k += n-1;
    d[k] = d[k]+a;
    while(k > 0) {
        k = (k-1)/2;
        d[k] = d[k*2+1]+d[k*2+2];
    }
}

int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return d[k];

    return query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r);
}

int findSum(int a, int b) {
    return query(a, b, 0, 0, n);
}

int main() {
    int q, com, x, y, n_;
    cin >> n_ >> q;
    while(n < n_) n *= 2;
    d = new int[2*n-1];
    initRSQ(n);

    for(int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if(com) cout << findSum(x-1,y) << endl;
        else add(x-1,y);
    }

    delete[] d;
    return 0;
}




Measured memory_bytes: 3892
n=int(input())
k=n
keta=1
x=26
while k>x:
    k-=x
    keta+=1
    x*=26

book=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
l=[]

for i in reversed(range(1,keta)):
    s=(k-1)//(26**i)
    k-=s*(26**i)
    l.append(book[s])

l.append(book[k-1])
print("".join(l))

Measured memory_bytes: 9240
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

int main() {
	int H, W;
	cin >> H >> W;

	int MP[10][10] = {};
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> MP[i][j];
		}
	}

	for (int k = 0; k < 10; ++k) {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; j++) {
				if (MP[i][j] > MP[i][k] + MP[k][j])MP[i][j] = MP[i][k] + MP[k][j];
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int m;
			cin >> m;
			if (m >= 0)ans += MP[m][1];
		}
	}

	cout << ans << endl;

	return 0;
}

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


int main(void){
    int x;
    int y;
    int z;
    int k;
    cin >> x >> y >> z >> k ;
    
    vector<long int> a(x);
    vector<long int> b(y);
    vector<long int> c(z);
    vector<long int> w(k*k);
    vector<long int> v(k*k);
    
    for(int i = 0; i <x ; ++i){
        cin >> a.at(i) ;
    }
    for(int i = 0; i <y ; ++i){
        cin >> b.at(i) ;
    }
    for(int i = 0; i <z ; ++i){
        cin >> c.at(i) ;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());

    
    for(int i = 0; i <min(k,x) ; ++i){
        for(int j = 0; j <min(k,y) ; ++j){
            w.at(i*min(k,x)+j)=a.at(i)+b.at(j);
        }
    }
    
    sort(w.begin(),w.end());
    reverse(w.begin(),w.end());
    
    for(int i = 0; i <k ; ++i){
        for(int j = 0; j <min(k,z) ; ++j){
            v.at(i*k+j)=w.at(i)+c.at(j);
        }
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    for(int i = 0; i <k ; ++i){
        cout << v.at(i) << endl;
    }
}

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

int H, W, A, B;

#define N 200005

int fac[N] = {1, 1}, rfac[N] = {1, 1}, inv[N] = {0, 1};

const int mod = 1e9 + 7;

int C(int n, int m) {
	return 1ll * fac[n] * rfac[n-m] % mod * rfac[m] % mod;
}

void sub(int &a, int b) {
	a -= b;
	if (a < 0) a += mod;
}
int mul(int x, int y) {return 1ll * x * y % mod;}

int main() {
    for (int i = 2; i < N; i ++) {
        inv[i] = 1ll * (mod / i) * (mod - inv[mod%i]) % mod;
        fac[i] = 1ll * fac[i-1] * i % mod;
        rfac[i] = 1ll * rfac[i-1] * inv[i] % mod;
    }
    scanf("%d %d %d %d", &H, &W, &A, &B);
    int ans = C(H+W-2, W-1);
    for (int i = H-A+1; i <= H; i ++) {
        sub(ans, mul(C(i-1+B-1, B-1), C(H-i+W-B-1, H-i)));
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6132
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  sc.scan(N);

  int[] L = new int[N];

  foreach (i; 0 .. N)
    sc.scan(L[i]);

  sort(L);
  reverse(L);

  if (L[0] < sum(L[1 .. $]))
    writeln("Yes");
  else
    writeln("No");
}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	
	vector< int > A(N), B(N);
	for (int i=0; i<N; ++i) cin >> A[i];
	for (int i=0; i<N; ++i) cin >> B[i];
	
	vector< pii > p;
	for (int i=0; i<N; ++i) p.push_back(pii(B[i], A[i]));
	sort(allof(p));
	
	set< pii > memo;
	for (int i=0; i<N; ++i) {
		A[i] = p[i].second;
		B[i] = p[i].first;
		memo.insert(pii(A[i], i));
	}
	
	int cnt = 0;
	for (int i=0; i<N; ++i) {
		memo.erase(pii(A[i], i));
		if (B[i] < A[i]) {
			auto it = memo.lower_bound(pii(B[i], i));
			if (it == memo.end() || (*it).first > B[i]) {
				if (it == memo.begin()) {
					puts("No");
					return 0;
				}
				--it;
			}
			
			if ((*it).first > B[i]) {
				puts("No");
				return 0;
			}
			
			int j = (*it).second;
			memo.erase(it);
			A[j] = A[i];
			memo.insert(pii(A[j], j));
			++cnt;
		}
	}
	
	puts(cnt <= N-2 ? "Yes" : "No");
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        char c[3];
        rep(i,3)
        {
                cin>>c[i];
                if(c[i]=='1')c[i]='9';
                else if(c[i]=='9')c[i]='1';
        }
        rep(i,3)cout<<c[i];
        cout<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int  check = 0;
    double rectangle, width, height, point_x, point_y, max_area = 0.0;
    Scanner sc = new Scanner(System.in);
    width = Double.parseDouble(sc.next());
    height = Double.parseDouble(sc.next());
    point_x = Double.parseDouble(sc.next());
    point_y = Double.parseDouble(sc.next());
    rectangle = height * width;
    max_area = rectangle / 2.0;
    if(point_x == width / 2.0 && point_y == height / 2.0) check = 1;
    System.out.println(max_area + " " + check);
  }
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 1000000007
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	int n, k;
	h >> n >> k;
	vector< double > v(n);
	f(i, 0, n, 1){
		h >> v[i];
		v[i] = (1 + v[i]) / 2;
	}
	f(i, 1, n, 1)
		v[i] += v[i - 1];
	vector< double > ans(n);
	f(i, 0, n, 1){
		if (i < k)
			ans[i] = v[i];
		else
			ans[i] = v[i] - v[i - k];
	}
	double ok = *max_element(all(ans));
	g << fixed << setprecision(10) << ok;
	
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}



Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	int a[200000];
	ll sum_x, sum_y;

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

	sum_y = 0;
	for(int i = 1; i < N; i++){
		sum_y += a[i];
	}
	sum_x = a[0];
	ll ans = abs(sum_x - sum_y);
	for(int i = 1; i < N - 1; i++){
		sum_x += a[i];
		sum_y -= a[i];
		if(abs(sum_x - sum_y) < ans) ans = abs(sum_x - sum_y);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double theta = 2*M_PI*M/60 - 2*M_PI*(H+M/60)/12;
    cout << setprecision(20) <<sqrt(A*A+B*B-2*A*B*cos(theta));
}


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

using namespace std;

int main(){
    int dp[18][310];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;
    for(int i=1; i <= 17; i++){
        for(int j=0; j < 300; j++){
            if(i*i <= j) dp[i][j] = dp[i][j-i*i];
            dp[i][j] += dp[i-1][j];
        }
    }

    int n;
    while(cin >> n, n) cout << dp[17][n] << endl;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////
int N, M;
vector<vector<pii>>V(100100, vector<pii>());
bool b[100100];
int x[100100];
bool dfs(int n) {
	b[n] = 1;
	for (auto a : V[n]) {
		if (b[a.first]) {
			if (x[a.first] != x[n] + a.second) {
				return 0;
			}
			continue;
		}
		else {
			x[a.first] = x[n] + a.second;
			if (!dfs(a.first)) {
				return 0;
			}
		}
	}
	return 1;
}
int main() {
	cin >> N >> M;
	memset(b, 0, sizeof(b));
	for (int i = 0; i < M; ++i) {
		int L, R, D;
		cin >> L >> R >> D;
		V[R].push_back({ L,-D });
		V[L].push_back({ R,D });
	}
	for (int i = 1; i <= N; ++i) {
		if (b[i])continue;
		if (!dfs(i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define _ pair<pair<int,int>,int>
using namespace std;
vector<_> A,B,C,D,v1,v2;
pair<int,int> a[200005];
_ b[200005],c[200005];
int cnt1,cnt2,n,i,j,x,y,m,k;
char kitu;
int T(_ x)
{
    return x.first.first+x.first.second;
}
bool cmp(_ x,_ y)
{
    if (T(x)==T(y)) return x.first.first>y.first.first;
    return T(x)<T(y);
}
void xuly()
{
    //if (A.empty() || B.empty()) return;
    //cout<<A.size()<<' '<<B.size()<<endl;
    C.clear();
    int i,j;i=j=0;
    while (i<A.size() && j<B.size())
    {
        if (A[i].first.first>B[j].first.first) {C.push_back(A[i]);i++;}
        else {C.push_back(B[j]);j++;}
    }
    while (i<A.size()) {C.push_back(A[i]);i++;}
    while (j<B.size()) {C.push_back(B[j]);j++;}
    D.clear();
    for (int i=0;i<A.size();++i) D.push_back(A[i]);
    for (int j=0;j<B.size();++j) D.push_back(B[j]);
    for (int i=0;i<C.size();++i) a[D[i].second].second=C[i].second;
}
void tach()
{

    if (x%2==0)
    {

        A.clear();B.clear();
        for (int i=0;i<v1.size();++i) if (v1[i].first.first%2==0) A.push_back(v1[i]);
        for (int i=0;i<v2.size();++i) if (v2[i].first.first%2==0) B.push_back(v2[i]);
        xuly();
        A.clear();B.clear();
        for (int i=0;i<v1.size();++i) if (v1[i].first.first%2) A.push_back(v1[i]);
        for (int i=0;i<v2.size();++i) if (v2[i].first.first%2) B.push_back(v2[i]);
        xuly();
    }
    else
    {
        A.clear();B.clear();
        for (int i=0;i<v1.size();++i) if (v1[i].first.first%2==0) A.push_back(v1[i]);
        for (int i=0;i<v2.size();++i) if (v2[i].first.first%2) B.push_back(v2[i]);
        xuly();
        A.clear();B.clear();
        for (int i=0;i<v1.size();++i) if (v1[i].first.first%2) A.push_back(v1[i]);
        for (int i=0;i<v2.size();++i) if (v2[i].first.first%2==0) B.push_back(v2[i]);
        xuly();
    }

}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m>>k;
    for (int i=1;i<=k;++i)
    {
        cin>>y>>x;
        cin>>kitu;
        if (kitu=='S')
        {
            a[i].first=m-x;
            b[++cnt1]={{x,y},i};
        }
        else
        {
            a[i].first=n-y;
            c[++cnt2]={{x,y},i};
        }
        a[i].second=i;
    }
    sort(b+1,b+cnt1+1,cmp);
    sort(c+1,c+cnt2+1,cmp);
    i=1;j=1;
    while (i<=cnt1)
    {
        v1.clear();
        v2.clear();
        v1.push_back(b[i]);x=T(b[i]);
        i++;
        while (i<=cnt1 && T(b[i])==x) {v1.push_back(b[i]);i++;}
        while (j<=cnt2 && T(c[j])<x) j++;
        while (j<=cnt2 && T(c[j])==x)
        {
            v2.push_back(c[j]);j++;
        }

    tach();
    }
   // for (int i=1;i<=k;++i) cout<<a[i].first<<' '<<a[i].second<<endl;
    sort(a+1,a+k+1);
    for (int i=1;i<=k;++i) cout<<a[i].second<<'\n';
    return 0;
}



Measured memory_bytes: 20680
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int r=sc.nextInt();
		if(n>=10){
			System.out.println(r);
		}else{
			System.out.println(r+(100*(10-n)));
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	list<char> ans;
	rep(i, s.size()){
		ans.push_back(s[i]);
	}
	int q;
	cin >> q;
	bool flag = true;//true:zyunsetu false:gyaku
	rep(i, q){
		int t;
		cin >> t;
		if(t == 1){
			flag ^= 1;
		}else{
			int f;
			cin >> f;
			char ad;
			cin >> ad;
			if((f == 1 && flag == true) || (f == 2 && flag == false)){
				ans.push_front(ad);
			}else{
				ans.push_back(ad);
			}
		}
	}
	if(flag == true){
		repit(itr, ans){
			cout << *itr;
		}
		cout << endl;
	}else{
		repitr(ritr, ans){
			cout << *ritr;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
using namespace std;

int main() {
  char c[82];
  int p;
  stack<double> st;
  double a,b,d,n,f;
  while(gets(c)!=NULL) {
   n=0; f=0; d=1;
   for (p=0;p<strlen(c);p++) {
	   if (c[p]=='-' && c[p+1]>='0' && c[p+1]<='9') { d=-1; continue;}
	   if (c[p]>='0' && c[p]<='9') { 
		   if (f==0) n=n*10+c[p]-'0'; 
		   else { n+=(c[p]-'0')*f; f*=0.1;}
		   continue;
	   }
	   if (c[p]=='.') { f=0.1; continue;}
	   if (c[p]==' ') { st.push(n*d); f=0; n=0 ; d=1; continue;}
	   b=st.top(); st.pop(); a=st.top(); st.pop();
	   if (c[p]=='+') st.push(a+b);
	   if (c[p]=='-') st.push(a-b);
	   if (c[p]=='*') st.push(a*b);
	   if (c[p]=='/') st.push(a/b);
	   p++;
	    }
   if (st.size()==0) st.push(n);
   printf("%6lf\n",st.top());
   st.pop();
  }
  return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        struct Point
        {
            internal int x;
            internal int y;
        }

        static void Main()
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                char[][] map = new char[12][];

                map[0] = input.ToCharArray();

                for (int i = 1; i < 12; i++)
                {
                    map[i] = Console.ReadLine().ToCharArray();
                }

                int count = 0;

                for (int i = 0; i < 12; i++)
                {
                    for (int j = 0; j < 12; j++)
                    {
                        if (map[j][i] == '1')
                        {
                            SearchIsland(map, j, i);
                            count++;
                        }
                    }
                }
                sb.AppendLine(count.ToString());
                Console.ReadLine();
            }
            Console.Write(sb);
        }

        static void SearchIsland(char[][] map, int x, int y)
        {
            int[] moveX = new int[] { -1, 0, +1, 0 };
            int[] moveY = new int[] { 0, +1, 0, -1 };

            Stack<Point> stk = new Stack<Point>();

            Point willPush;
            willPush.x = x;
            willPush.y = y;
            stk.Push(willPush);

            while (stk.Count > 0)
            {
                Point temp = stk.Pop();
                map[temp.x][temp.y] = '3';

                for (int i = 0; i < 4; i++)
                {
                    willPush.x = temp.x + moveX[i];
                    willPush.y = temp.y + moveY[i];

                    if (IsValid(willPush.x, willPush.y) && map[willPush.x][willPush.y] == '1')
                    {
                        stk.Push(willPush);
                    }
                }
            }
        }

        static bool IsValid(int x, int y)
        {
            if (x < 0) return false;
            if (x > 11) return false;
            if (y < 0) return false;
            if (y > 11) return false;
            return true;
        }
    }
}

Measured memory_bytes: 10044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

long long GCD(long long m, long long n){
    if(n == 0) return m;
    else return GCD(n, m % n);
}

signed main(){
    int tt;
    cin >> tt;
    while(tt--){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        if(a < b || d < b){
            cout << "No" << endl;
            continue;
        }
        ll t = GCD(b, d);
        if(a % t <= c && b - c <= t){
            cout << "Yes" << endl;
            continue;
        }else{
            cout << "No" << endl;
            continue;
        }
    }
    return 0;
}

Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,4);
  if(input[0] <= 9 && input[1] <= 9){
     myout(input[0] * input[1]);
     }else{
     myout("-1");
     }
}

Main(myin());


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

ruiseki_A = [0]
ruiseki_B = [0]

for i in range(len(A)):
    ruiseki_A.append(ruiseki_A[i]+A[i])
for i in range(len(B)):
    ruiseki_B.append(ruiseki_B[i]+B[i])
#print(ruiseki_A)

ans = 0
for i in range(len(ruiseki_A)):
    tmp = K - ruiseki_A[i]
    if tmp < 0:
        continue
    r = len(ruiseki_B)
    l = 0
    while r-l > 1:
        mid = (r + l) // 2
        if ruiseki_B[mid] <= tmp:
            l = mid
        else:
            r = mid
    ans = max(ans, i+l)

print(ans)

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

int main () {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  if (A+B > C+D) cout << "Left" << endl;
  else if (A+B == C+D) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const int bits = 35;
const string pat = "LDUR";

int parity(ll x) { return (x % 2 + 2) % 2; }

int main() {
  int N;
  while (cin >> N) {
    vector<ll> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    bool ok = true;
    for (int i = 0; i < N; i++)
      ok &= parity(X[i] + Y[i]) == parity(X[0] + Y[0]);
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    vector<ll> d;
    vector<string> w(N);
    if (parity(X[0] + Y[0]) == 0) {
      d.push_back(1);
      for (int i = 0; i < N; i++) {
        w[i] = "L";
        ++X[i];
      }
    }
    ll sum = 0;
    for (int j = 0; j < bits; j++) {
      d.push_back(1ll << j);
      sum += 1ll << j;
    }
    for (int i = 0; i < N; i++) {
      ll u = X[i] + Y[i];
      ll v = X[i] - Y[i];
      ll ur = (u + sum) / 2;
      ll vr = (v + sum) / 2;
      for (int j = 0; j < bits; j++) {
        int uk = (ur >> j) & 1;
        int vk = (vr >> j) & 1;
        int k = (uk << 1) | vk;
        w[i].push_back(pat[k]);
      }
    }
    cout << d.size() << endl;
    for (ll x : d) cout << x << " ";
    cout << endl;
    for (auto& x : w) cout << x << endl;
  }
  return 0;
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

map<ll, ll> m;
void decomposit(ll n){
    ll a= 2;
    while(n >= a*a){
        if(n%a == 0){
            m[a]++;
            n /= a;
        }else{
            a++;
        }
    }
    m[n]++;
}
void solve() {
    ll N;
    cin >> N;
    if(N == 1) {
        out(0);
        return;
    }
    decomposit(N);
    ll ans=0;
    for(const auto& i : m){
        ll count=0;
        ll delta=0;
        ll lim=0;
        while(true){
            delta++;
            lim += delta;
            if(lim > i.second) break;
            count++;
        }
        ans += count;
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

bool check(LL n){
	if(n%3==0 || n%5==0) return false;
	return true;
}

int main(){
	LL n;
	cin>>n;
	LL res = 0;
	for(int i=1;i<=n;i++){
		if(check(i)) res+=i;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; 
    int K;
    cin >> s >> K;
    vector<string> v;
    rep(i,0,SZ(s)){
        reps(j,1,K){
            if(i+j>SZ(s)) break;
            v.pb(s.substr(i,j));
        }
    }
    sort(all(v));
    unique(all(v));
    cout << v[K-1] << enld;
    return 0;
}


Measured memory_bytes: 4276
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}
ll const int maxsize = (1 << 15);
ll int dp[maxsize + 1][5] = {0}; //dp[i][j] := ????¨?i???j+1?????§??????????????????

void calc(){
	dp[0][0] = 1;
	for(int i=1;i*i<=maxsize;i++){
    	for(int k=1;k<=4;k++){
			for(int j=i*i;j<=maxsize;j++){
				dp[j][k] += dp[j-i*i][k-1];
			}
		}
	}
}
int main(){
	calc();
	int n;
	while(cin >> n,n){
		ll int ans = 0;
		REP(i,4) ans += dp[n][i+1];
		cout << ans << endl;
	}
}

Measured memory_bytes: 2436
#include<stdio.h>
int main()
{
    int n,temp=0;
    double ans;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)
    {
        if(i%2==1)
            temp++;
    }
        
        ans=(double)temp/n;
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  for (auto &v : vec)
    cin >> v;

  bool flag = true;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (vec[i][j] == '.')
        continue;
      bool flag2 = false;
      vector<int> dis = { -1, 1, 0, 0};
      vector<int> djs = { 0, 0, -1, 1};
      for (int k = 0; k < 4; ++k) {
        int i2 = i + dis[k];
        int j2 = j + djs[k];
        if (i2 < 0 || h <= i2 || j2 < 0 || w <= j2)
          continue;
        if (vec[i2][j2] == '#')
          flag2 = true;
      }
      if (flag2 == false)
        flag = false;
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




def b():
    k = int(input())
    s = input()
    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + '...')

# def c():
    

# def d():


b()

Measured memory_bytes: 9188
N, K = map(int,input().split())

def probability(p):
    if p >= K:
        return 1
    cnt = 0
    while(p < K):
        p = p * 2
        cnt += 1
    return 1 / (2 ** cnt)

ans = 0

for i in range(1, N+1):
    ans += probability(i)
    
ans /= N

print(ans)

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

int main(){
    int64_t A, B, N;
    cin >> A >> B >> N;
    int64_t x;
    if(N >= (B-1)) x = B-1;
    else x = N;
    cout << (int)((double)x / (double)B * A) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    REP(i,1000){
        string X;
        if(i < 10) X = "00" + to_string(i);
        if(10 <= i && i < 100) X = "0" + to_string(i);
        if(100 <= i) X = to_string(i);
        int snum = 0;
        REP(j,N){
            if(S[j] == X[snum]){
                snum++;
                if(snum == 3){ans++;break;}
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

int main() {
    int n; std::cin >>n;
    int a[201],i;
    int min=200,tmp;
    for(i=0;i<n;i++)
        std::cin>>a[i];
    for(i=0;i<n;i++){
        tmp=0;
        while(a[i]%2 == 0 &&a[i]!=0) {
            tmp += 1;
            a[i]/=2;
        }
        if(min>tmp) min = tmp;
    }
    std::cout << min;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int best_suma = 1e7;
	for (int mask = 0; mask < (1 << N); mask++) {
		vector<int> S(M, 0);
		int suma = 0;
		for (int i = 0; i < N; i++) {
			if ((1 << i) & mask) {
				suma += C[i];
				for (int j = 0; j < M; j++) {
					S[j] += A[i][j];
				}
			}
		}
		bool isGood = true;
		for (int j = 0; j < M; j++) {
			if (S[j] < X) isGood = false;
		}
		if (isGood && suma < best_suma) {
			best_suma = suma;
		}
	}
	if (best_suma == 1e7) {
		cout << -1 << endl;
	} else {
		cout << best_suma << endl;
	}
}



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

using namespace std;

long long inf=1000000007;

int main(){
	long long n,p;
	cin>>n>>p;

	set<long long> yakusu;

	for(long long i=1;i*i<=p;i++){
		if(p%i==0){
			yakusu.insert(i);
			yakusu.insert(p/i);
		}
	}

	long long ans=1;

	for(auto a:yakusu){
		if(a==1) continue;

		long long cnt=0;
		long long pre=p;

		while(pre%a==0){
			cnt++;
			pre/=a;
		}

		if(cnt>=n){
			ans=a;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

int main(){
  int price,yen1;
  cin >> price >> yen1;
  
  price = price % 500;
  
  if(price <= yen1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll 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 vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
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;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    sort(a.rbegin(), a.rend());
    int tmp = N;
    if (tmp & 1) {
        ans += a[tmp / 2];
    }
    REP(i, (tmp / 2)) {
        ans += a[i] * 2;
    }
    cout << ans - a[0] << endl;
}

Measured memory_bytes: 4048
from collections import deque

# input
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]

# bfs
bfs = [[-1 for j in range(W)] for i in range(H)]
que = deque()
for i in range(H):
    for j in range(W):
        if(A[i][j] == '#'):
            que.append((i, j))
            bfs[i][j] = 0
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
while(len(que)):
    p = que.popleft()
    for i in range(4):
        if(0 <= p[0]+dx[i] < H and 0 <= p[1]+dy[i] < W):
            if(bfs[p[0]+dx[i]][p[1]+dy[i]] == -1):
                que.append((p[0]+dx[i], p[1]+dy[i]))
                bfs[p[0]+dx[i]][p[1]+dy[i]] = bfs[p[0]][p[1]] + 1

# print ans
print(max([max(l) for l in bfs]))


Measured memory_bytes: 122844
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    X, Y = map(int, rl().split())
    
    for i in range(X + 1):
        if 2 * i + 4 * (X - i) == Y:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  ll n;cin>>n;
  ll a;
  ll ans=1000000000001;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      a=n/i;
      chmin(ans,a+i-2);
    }
  }
  cout<<ans<<endl;
}

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

int main(){
  string S;
  cin>>S;
  
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  if(S=="Rainy"){
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
x,k,d = map(int, raw_input().split(' '))
if x>=k*d:
	print x-k*d
elif x<=-k*d:
	print -x-k*d
else:
	x=abs(x)
	r = x%d
	q = x//d
	if r<d-r and (k-q)%2==0:
		print r
	elif r<d-r:
		print d-r
	elif r>d-r and (k-q)%2==1:
		print d-r
	else:
		print r

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

int main(){
  int a,b,n;
  while(cin>>a>>b>>n){
    int sum=0;
    if(a<b) a*=10;
    else{
      a=a-a/b*b;
      a*=10;
    }
    for(int i=0;i<n;i++){
      if(a<b) a*=10;
      else{
	sum+=a/b;
	a=a-a/b*b;
	a*=10;
      }
    }
    cout<<sum<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
int n,k;
int d[105];
int a[105][105];
int sunuke[105];
int sum=0;
scanf("%d %d",&n,&k);
for(int i=0;i<k;i++){
    scanf("%d",&d[i]);
    for(int j=0;j<d[i];j++){
        scanf("%d",&a[i][j]);
    }
}

for(int i=0;i<105;i++){
    sunuke[i]=0;
}



for(int i=0;i<k;i++){
    for(int j=0;j<d[i];j++){
        sunuke[a[i][j]]++;
    }
}

for(int i=1;i<=n;i++){
    if(sunuke[i]==0){sum++;}
}

printf("%d\n",sum);
}

Measured memory_bytes: 1752
n,k=map(int,input().split())
ab=[list(map(int,input(). split())) for _ in range(n)]
bk=list(bin(k)[2:])
if '0' not in bk:
  t=k
  ans=0
  for a,b in ab:
    if a<=t:ans+=b
  print(ans)
else:
  ks=[k]
  for i in range(len(bk)):
    if bk[i]=='1':
      if i==0:
        ks.append(int('1'*(len(bk)-1),2))
      else:
        ks.append(int(''.join(bk[:i])+'0'+'1'*(len(bk)-i-1),2))
  ans=[0]*len(ks)
  for a,b in ab:
    for i in range(len(ks)):
      if a&ks[i]==a:ans[i]+=b
  print(max(ans))
      




Measured memory_bytes: 90216
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int h,a,b;
    cin >> h >> a >> b;
    int cnt=0;
    for(int i=a;i<=b;i++){
        if(h%i==0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3088