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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define in(x, data) data.find(x) != data.end()

typedef long long ll;

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

    int N; cin >> N;
    bool F[101][10];
    REP(i,1,N+1) rep(j,10) cin >> F[i][j];
    int P[101][11]; REP(i,1,N+1) rep(j,11) cin >> P[i][j];

    ll ans = LONG_LONG_MIN;
    REP(i,1,1024) {
        int c[101] = {0};
        REP(k,1,N+1) {
            rep(j,10) {
                int p = (i>>j)&1;
                if(p && F[k][j]) c[k]++; // 自分とkが店を開くとき
            }
        }
        ll prof = 0;
        REP(j,1,N+1) prof += P[j][c[j]];
        // cout << prof << endl;
        ans = max(ans, prof);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int  N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int x[101], y[101];
 
	for (int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	for (int i = 1; i <= M; i++) {
		cin >> y[i];
	}
	sort(x + 1 , x + N + 1);
	sort(y + 1 , y + M + 1);
	if (x[N] < y[1] && x[N] > X && y[1] <= Y)cout << "No War";
	else cout << "War";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> ws(N);
    for (int i = 0; i < N; i++) {
        std::cin >> ws.at(i);
    }
    int sum1 = 0;
    int sum2 = std::accumulate(ws.begin(), ws.end(), static_cast<int>(0));
    std::vector<int> po{};

    po.emplace_back(std::abs(sum1 - sum2));
    for (int t = 0; t < N; t++) {
        sum1 += ws.at(t);
        sum2 -= ws.at(t);
        po.emplace_back(std::abs(sum1 - sum2));
    }
    std::sort(po.begin(), po.end());
    std::cout << po.at(0) << std::endl;

    return 0;
}

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


int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> list = {A, B, C};
  sort(list.begin(), list.end());
  int ans = list.at(2) - list.at(0);
  cout << ans << endl;
}




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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> d(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        d.at(a) += 1;
        d.at(b) += 1;
    }
    for (int i = 1; i <= n; ++i) {
        cout << d.at(i) << '\n';
    }
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
    var sub = ReadLine();

    if(sub[2].Equals(sub[3]) && sub[4].Equals(sub[5])){
    	Write("Yes");
    }else{
    	Write("No");
    }
    
    
  }
}

Measured memory_bytes: 17380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

string b;

int main(){
    cin>>b;

    rep(i,b.size()){
        if(b[i]=='A') b[i]='T';
        else if(b[i]=='T') b[i]='A';
        else if(b[i]=='G') b[i]='C';
        else if(b[i]=='C') b[i]='G';
    }

    cout<<b<<endl;
}

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

int SumofDigits(int a) {
  int ans = 0 ;
  while(a!=0){
    ans += a % 10 ;
    a /= 10 ;
  }
  return ans ;
}

int main () {
  int a ;
  cin >> a ;
  if( a % SumofDigits(a) == 0 ) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

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

int a, z;
string s;

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i)
    if(s[i] == 'A') {
      a = i;
      break;
    }
  for(int i = s.size() - 1; i >= 0; --i)
    if(s[i] == 'Z') {
      z = i;
      break;
    }
  cout << z - a + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 81
33 105 57
)");
#define cin input
#endif

int 
gcd ( int a, int b )
{
  int c;
  while ( a != 0 ) {
     c = a; a = b%a;  b = c;
  }
  return b;
}

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

	int r = 0;
	REP (i, n)
	{
		int a;
		cin >> a;
		a -= x;
		a = abs(a);
		r = r ? gcd(r, a) : a;
	}

	cout << r << endl;

	return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int N,M,A[1000];
    float m,sum=0,flag=0;

    cin>>N>>M;
    m=M;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }

    sort(A,A+N,greater<int>());
    
    if(A[M-1]<(sum/(4*M))){
        flag=1;
    }


    if(flag==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long H=gl();
         long W=gl();

         long ans=0;
         if(H%3!=0 && W%3!=0) {
        	 ans=Integer.MAX_VALUE;

        		 for(long i=1; i<W;i++) {
        			 long o=H*i;
        			 long t;
        			 if(H%2==0) {
        				 t=(W-i)*H/2;
        				 long s=Math.abs(o-t);
        				 ans=Math.min(ans, s);
        			 } else {
        				 t=(W-i)*(H-1)/2;
        				 long t2=(W-i)*(H+1)/2;
        				 long ma=Math.max(o, t2);
        				 long mi=Math.min(o, t);
        				 ans=Math.min(ans, ma-mi);
        			 }
        		 }

        		 for(long i=1; i<H;i++) {
        			 long o=W*i;
        			 long t;
        			 if(W%2==0) {
        				 t=(H-i)*W/2;
        				 long s=Math.abs(o-t);
        				 ans=Math.min(ans, s);
        			 } else {
        				 t=(H-i)*(W-1)/2;
        				 long t2=(H-i)*(W+1)/2;
        				 long ma=Math.max(o, t2);
        				 long mi=Math.min(o, t);
        				 ans=Math.min(ans, ma-mi);
        			 }
        		 }
        		 
        		 ans=Math.min(ans, Math.min(H, W));
         }
         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35752
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = [readInt() for i in range(n)]

visited= [0]*(10**5+1)
b = 1
ans = 1
while 1:
  if a[b-1]==2:
    break
  elif visited[a[b-1]]==0:
    visited[a[b-1]]=1
    ans += 1
    b = a[b-1]
  else:
    print(-1)
    exit()

print(ans)

Measured memory_bytes: 13912
#include <stdio.h>
 
long gcd(long a, long b)
{
    if (a % b == 0){
        return b;
    }
     
    gcd(b, a % b);
}
 
int main(void)
{
    long a, b, c, g;
     
    while (scanf("%ld %ld", &a, &b) != EOF){
        if (a < b){
            c = a;
            a = b;
            b = c;
        }
        g = gcd(a, b);
        printf("%ld\n", g);
    }   
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5+10;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    set<char> st;
    for(int i=1;i<=n;i++){
        char c;cin>>c;
        st.insert(c);
    }
    if(st.size()==3)
        cout<<"Three";
    else
        cout<<"Four";
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;

    bool ok = regex_match(s, regex("A?KIHA?BA?RA?"));

    puts(ok ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

int main()
{
    double a, b, c, d;
    
    std::cin >> a >> b >> c >> d;
    
    std::cout << std::fixed << std::setprecision(5);
    std::cout << (sqrt(pow(a - c, 2) + pow(b - d, 2))) << std::endl;
    
    
    return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vec< int > a(N);
  vec< int > b(N, 0);
  REP(i, N) { cin >> a[i]; }
  int countM = 0;
  REPR(i, N - 1) {
    int id = i + 1;
    int sum = a[i];
    for (int j = 2 * id; j <= N; j += id) {
      sum += b[j - 1];
      sum %= 2;
    }

    b[i] = sum;
    if (b[i])
      countM++;
  }
  print(countM);
  REP(i, N) {
    if (b[i])
      cout << i + 1 << "\n";
  }
  // print();
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    
    //for odd
    
    int odd=(m*(m-1))/2;
    
    //for even
    
    int even= (n*(n-1))/2;
    
    int total=even+odd;
    
    cout<<total;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
 
struct Card{ char suit, value; };
 
void bubble(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        for (int j = N - 1; j > i; j--){
            if (A[j].value < A[j - 1].value){
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}
 
void selection(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}
 
void print(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if (i > 0) putchar(' ');
        printf("%c%d", A[i].suit, A[i].value);
    }
    putchar('\n');
}
 
int isStable(struct Card C1[], struct Card C2[], int N){
    for (int i = 0; i < N; i++){
        if (C1[i].suit != C2[i].suit) return 0; 
    }
    return 1; //not stable
}
 
int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
 
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%*c%c%d", &C1[i].suit, &C1[i].value);
    }
 
    for (int i = 0; i < N; i++)C2[i] = C1[i];
 
    bubble(C1, N);
    selection(C2, N);
 
    print(C1, N);
    puts("Stable");
    print(C2, N);
    if (isStable(C1, C2, N)){
        puts("Stable");
    }
    else{
        puts("Not stable");
    }
 
    return 0;
     
}
 
 

Measured memory_bytes: 2708
let [| n; m; |] = stdin.ReadLine().Split() |> Array.map int
let abs = [|for _ in 1..n -> stdin.ReadLine().Split() |> Array.map int64|]

abs |> Array.sort 
|> Array.fold (fun (totalN,totalPrice) [|a;b|] ->
    match totalN with
    | x when x = int64 m -> (x, totalPrice)
    | x when int64 m - b < x  -> (int64 m, totalPrice + a * (int64 m - x)) 
    | x ->(x + b, totalPrice + a * b)) (0L, 0L)
|> fun (_, totalPrice) -> totalPrice
|> stdout.WriteLine

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

int main(){
    string o,e;
    cin >>o>>e;
    int d=o.size()-e.size();
    for(int i=0;i<e.size();i++){
        cout<<o[i]<<e[i];
    }
    int s=o.size();
    if(d)cout<<o[s-1];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int x = j / 10;
            int y = j % 10;
            if(x < 2 || y < 2){
                continue;
            }
            if(x * y == i){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
/* ABC122 */
/* A. Double Helix */
#include <iostream>
#include <string>
using namespace std;

int main(void){

    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;

    int rem;
    rem = (H-h) * (W-w);
    cout << rem << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define str string
#define p(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define all(v) v.begin(), v.end()
#define test cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	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
}
int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//kehsihba();
	str s;ll k;
	cin>>k>>s;
	ll n=s.length();
	if(n>k){
		cout<<s.substr(0,k)<<"...";
	}
	else{
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

static const double pi = 3.141592653589793;
int main(){
 double A,B,H,M;
  cin >>A>>B>>H>>M;
  double TM = H*60+M;
  	
  double kaku =((TM/720)-(M/60)) * 2*pi;
  double C2 = A*A + B*B - 2*A*B*cos(kaku);
  double C = sqrt(C2);
  cout << fixed << setprecision(10);
  cout <<C <<endl;
}

Measured memory_bytes: 4260
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 3100;
int a[maxn];
vi e[maxn];

bool win(int v) {
    for (int u: e[v]) if (!win(u)) return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    forn(i, n) cin >> a[i];
    forn(i, n - 1) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        if (a[x] > a[y]) e[x].pb(y);
        if (a[x] < a[y]) e[y].pb(x);
    }

    forn(i, n) if (win(i)) cout << i + 1 << ' ';
    cout << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 512
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

bool compare_F(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}

bool compare_S(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second > b.second;
  } else {
    return a.first > b.first;
  }
}

template <typename T>
void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cin >> *itr;
  }
}
template <typename T>
void ArrayPut(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cout << *itr << " ";
  }
  cout << endl;
}

bool JudgePrime(uint64_t N);
int main() {
  uint64_t X;
  cin >> X;
  if (X == 2) {
    cout << 2 << endl;
    return 0;
  }
  X |= 1;
  while (!JudgePrime(X)) {
    X += 2;
  }
  cout << X << endl;

  return 0;
}

bool JudgePrime(uint64_t N) {
  for (uint64_t i = 3; i * i <= N; i += 2) {
    if (N % i == 0) return false;
  }
  return true;
}

Measured memory_bytes: 256
# include<bits/stdc++.h>
# include<ext/pb_ds/assoc_container.hpp>
# include<ext/pb_ds/tree_policy.hpp>
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
# pragma GCC optimize ("Ofast")

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

# define int long long
# define S second
# define F first
# define kill(x) return(cout << x << '\n', 0LL)
# define debug(x) cerr<< #x << " = " << (x) << endl
# define ddebug(x, y) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << endl
# define tdebug(x, y, z) cerr<< #x << " = " << (x)  << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
# define bin(x) cerr<< #x << " : " << bitset<4>(x) << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define uop(x, y) pii(min(x, y), max(x, y))
# define MP(x, y) make_pair(x, y)

const int MOD = 1000 * 1000 * 1000 + 7;
int dp[1000 * 1000 + 20];

int _pow(int a, int p)
{
	if (!p)
		return 1;
	return _pow(sq(a) % MOD, p >> 1) * (p & 1 ? a : 1) % MOD;
}

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

	int n, k;
	cin >> n >> k;

	int ans = 0;
	for (int i = k; i >= 1; i --)
	{
		dp[i] = _pow(k / i, n);

		for (int j = i * 2; j <= k; j += i)
		{
			dp[i] -= dp[j];
			dp[i] = (dp[i] % MOD + MOD) % MOD;
		}

		ans += dp[i] * i % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	

	return 0;
}


Measured memory_bytes: 4288
//
// Created by Nivras on 2017/5/25.
//

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int MAXN = 550000;
const int INF = 1000000007;

int cnt = 0;
int leftNum[MAXN], rightNum[MAXN];
int num[MAXN];

void merge(int num[], int left, int mid, int right) {
    for (int i = 0; i < mid - left; i++) {
        leftNum[i] = num[left + i];
    }
    leftNum[mid - left] = INF;

    for (int i = 0; i < right - mid; i++) {
        rightNum[i] = num[mid + i];
    }
    rightNum[right - mid] = INF;

    int leftpre = 0;
    int rightpre = 0;
    for (int i = 0; i < right - left; i++) {
        cnt++;
        if (leftNum[leftpre] <= rightNum[rightpre]) {
            num[left + i] = leftNum[leftpre];
            leftpre++;
        }
        else {
            num[left + i] = rightNum[rightpre];
            rightpre++;
        }
    }
}

void mergeSort(int num[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(num, left, mid);
        mergeSort(num, mid, right);
        merge(num, left, mid, right);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    cnt = 0;
    mergeSort(num, 0, n);

    for (int i = 0; i < n; ++i) {
        if (i != 0) {
            printf(" ");
        }
        printf("%d", num[i]);
    }
    puts("");
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 6596
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define co(x) cout << x << endl
#define ce(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion
void solve() {
	string S, T; cin >> S >> T;
	cout << T << S << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target int, list []int) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}
func abs(i int64) int64 {
	if i < 0 {
		return -i
	}
	return i
}

func f(n int) int {
	if n%2 == 0 {
		return n / 2
	}
	return 3*n + 1
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }
	n := nextInt()
	x := nextInt()

	var a []int
	var wa int
	var cnt int
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}

	sort.Ints(a)

	for _, val := range a {
		if wa+val <= x {
			wa += val
			cnt++
		} else {
			fmt.Println(cnt)
			return
		}
	}
	if wa < x {
		fmt.Println(cnt - 1)
	} else if wa == x {
		fmt.Println(cnt)
	}

}


Measured memory_bytes: 1788
//THIS IS THE AATMANIRBHAR SOLUTION I FOUND..!!!!!
#include<bits/stdc++.h>
using namespace std ;
#define int long long
// #define int double
// #define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define P push
#define vvi vector<vector<int>>
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define pii vector<pair<int, int>>
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define sort(v) sort(all(v))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(j,a,b) for(int j=a-1;j>=b;j--)
#define binod ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e9 + 7 , N1 = 1e7 + 5 , N2 = 1e6 + 3, N3 = 1e5 + 3;
#define IX INT_MAX
#define IM INT_MIN


void solve()
{
    string s;
    cin>>s;
    int n=sz(s);
    if(s[n-1]=='s')cout<<s<<"es";
    else cout<<s<<"s";
}


signed main(){
    binod;
    int t1=1;
    // cin>>t1;
    // cout<<fixed<<setprecision(9);
    while(t1--){
        solve();
        cout<<endl;
    }
}

                                                                            //Don't judge me or anyone
                                                                            //this is life,
                                                                            //not a reality show



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll w;
    cin >> n >> w;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    map<ll, ll> dp[2];
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(auto p : dp[i & 1]) {
            ll j = p.first;
            chmax(dp[(i + 1) & 1][j], p.second);
            if(j + a[i] <= w) {
                chmax(dp[(i + 1) & 1][j + a[i]], dp[i & 1][j] + b[i]);
            }
        }
        dp[i & 1].clear();
    }
    ll ans = -LLINF;
    for(const auto &p : dp[n & 1]) {
        if(p.first <= w) {
            chmax(ans, p.second);
        }
    }
    print(ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N; ll x;
    cin >> N >> x;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i+1] <= x) continue;
        ll tmp = a[i+1];
        a[i+1] = max(0LL, x - a[i]);
        ans += tmp - a[i+1];
        if (x - a[i] < 0) ans += -(x - a[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
import math
import itertools
n = int(input())
p_n = [list(map(int, input().split()))for i in range(n)]
l = list(itertools.permutations(range(n), n))
r = []
for _l in l:
    _r = []
    for i in range(len(_l)-1):
        _r.append(math.sqrt(((p_n[_l[i]][0]-p_n[_l[i+1]][0])**2)+((p_n[_l[i]][1]-p_n[_l[i+1]][1])**2)))
    r.append(sum(_r))

print(sum(r)/len(r))

Measured memory_bytes: 9332
N = int(input())
AB = []
for n in range(N):
  AB.append([int(ab) for ab in input().split()])
AB.sort(key=lambda x:(x[1], x[0]))

T = 0
for n in range(N):
  T += AB[n][0]
  T_limit = AB[n][1]
  if T > T_limit:
    print("No")
    break
else:
  print("Yes")

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    int n, k = 0, count = 0, h = 0;
    cin >> n;
    vector<int> data(n);
    rep(i,n) cin >> data.at(i);
    while(true) {
         k = data.at(h);
        count++;
        if(k == 2) {
            break;
        }
        if(count > 1e5) {
            cout << -1 << endl;
            return 0;
        }
        h = k - 1;
    }

    cout << count << endl;
}

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

int main(void) {
  vector<char> N(4);
  for (int i = 0; i < 4; i++) {
    cin >> N[i];
  }
  bool flag = true;
  flag &= find(N.begin(), N.end(), '1') != N.end();
  flag &= find(N.begin(), N.end(), '9') != N.end();
  flag &= find(N.begin(), N.end(), '7') != N.end();
  flag &= find(N.begin(), N.end(), '4') != N.end();
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
m = input()
for a in range(int(m)):
    b = set()
    s = input()
    for i in range(1,len(s)):
        t1 = s[:i]
        t2 = s[i:]
        b.add(t1+t2)
        b.add(t1+t2[::-1])
        b.add(t1[::-1]+t2)
        b.add(t1[::-1]+t2[::-1])
        b.add(t2+t1)
        b.add(t2+t1[::-1])
        b.add(t2[::-1]+t1)
        b.add(t2[::-1]+t1[::-1])
    print(len(b))



Measured memory_bytes: 5628
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class Segment_Tree {
public:
	vector<long long int>v;
	int num;
	long long int ret;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		v[place] = min(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		v.resize(num, N-1);
	}
	int Get(int place) {
		ret = N - 1;
		place += v.size() / 2;
		while (place) {
			ret = min(ret, v[place]);
			place /= 2;
		}
		return ret;
	}
	void TopDown() {
		Update(1);
	}
	void Modify(int a, int b,long long int c) {
		b++;
		for (a += num / 2, b += num / 2; a < b; a >>= 1, b >>= 1) {
			if (a & 1) {
				v[a] = min(v[a], c);
				a++;
			}
			if (b & 1) {
				b--;
				v[b] = min(v[b], c);
			}
		}
	}
};

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

	cin >> N >> K;
	Segment_Tree xsg(N);
	Segment_Tree ysg(N);
	long long int sum = (N - 2)*(N - 2);
	while (K--) {
		cin >> L;
		if (L == 1) {
			int x;
			cin >> x;
			x--;
			int box = xsg.Get(x);
			sum -= max(0, box - 1);
			ysg.Modify(1, box - 1, x);
		}
		else {
			int y;
			cin >> y;
			y--;
			int box = ysg.Get(y);
			sum -= max(0, box - 1);
			xsg.Modify(1, box - 1, y);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 11384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char str[110];
string A[110];
string B[110];
int main(){
	int a,b;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",str);A[i]=str;
	}
	scanf("%d",&b);
	for(int i=0;i<b;i++){
		scanf("%s",str);B[i]=str;
	}
	int ret=0;
	for(int i=0;i<a;i++){
		int tmp=0;
		for(int j=0;j<a;j++){
			if(A[i]==A[j])tmp++;
		}
		for(int j=0;j<b;j++){
			if(A[i]==B[j])tmp--;
		}
		ret=max(ret,tmp);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
bool dp[101][10001];//dp[i + 1][j] : i番目まで見たときjが作れるか否か
int main() {
    int N; cin >> N;
    int s[N];rep(i, N) cin >> s[i];
    rep(i, N + 1)dp[i][0] = true;
    rep(i, N){
        rep(j, 10001){
            dp[i + 1][j] = dp[i][j];
            if(j >= s[i]){
                dp[i + 1][j] |= dp[i][j - s[i]];
            }
        }
    }
    rep(i, 10001) {
        if(i % 10 != 0 && dp[N][10000 - i]){
            cout << 10000 - i << endl;return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int high = sc.nextInt();
        int row = sc.nextInt();
        int nuruHigh = sc.nextInt();
        int nuruRow = sc.nextInt();

        int whiteHigh = high - nuruHigh;
        int whiteRow = row - nuruRow;

        System.out.println(whiteHigh * whiteRow);
    }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  char c = s[0];
  int cnt = 1;
  for(int i=1; i<n; i++){
    // 前の文字と同じでない
    if( s[i] != c ){
      cnt ++;
      c = s[i];
    }
  }
  cout << cnt << endl;
  return 0;
}
      

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

typedef long long ll;
typedef pair<ll, int> pli;
const int N = 2e5 + 10;
int n, a[N], b[N];
ll tot, suma, sumb, sum, res;
pli all[N];
bool vis[N];

int main() {
    cin >> n;
    rep(i, 1, n) {
        scanf("%d%d", &a[i], &b[i]);
        tot += a[i] + b[i];
        suma += a[i], sumb += b[i];
        all[i * 2 - 1] = make_pair(a[i], i);
        all[i * 2] = make_pair(b[i], i);
    }
    sort(all + 1, all + (n << 1) + 1);
    bool ff = 0;
    res = min(suma, sumb);
    rep(i, 1, n) {
        if (vis[all[i].second]) {
            ff = 1;
        }
        vis[all[i].second] = 1;
        sum += all[i].first;
    }
    if (ff) {
        res = min(res, sum);
    } else {
        rep(i, n + 1, n << 1) {
            if (all[n].second == all[i].second)
                res = min(res, sum + all[i].first - all[n - 1].first);
            else
                res = min(res, sum + all[i].first - all[n].first);
        }
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 7832
class PriorityQueue
  attr_reader :data
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end


n, m = gets.chomp.split.map(&:to_i)
alist = gets.chomp.split.map(&:to_i)

queue = PriorityQueue.new
alist.each do |a|
  queue.push(-a)
end

m.times do
  pop = queue.pop
  queue.push(-(-pop / 2).floor)
end

puts queue.data.inject(0){|sum, tmp| sum + (-tmp.to_i)}


Measured memory_bytes: 14612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int x;
	cin>>x;
	int ans = x*x*x;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
  int N, W;
  cin >> N >> W;
  long long int w[N], mod = 1000000007;
  for(int i = 0; i < N; ++i){
    cin >> w[i];
  }
  sort(w,w+N);
  long long int dp[N+1][W+1][2];
  for(int i = 0; i <= N; ++i){
    for(int j = 0; j <= W; ++j){
      for(int k = 0; k < 2; ++k){
	dp[i][j][k] = 0LL;
      }
    }
  }
  dp[N][0][0] = 1LL;
  for(int i = N-1; i >= 0; --i){
    for(int j = 0; j <= W; ++j){
      dp[i][j][0] = (dp[i+1][j][0] + dp[i+1][j][1])%mod;
      if(j >= w[i]){
	dp[i][j][1] += (dp[i+1][j-w[i]][0] + dp[i+1][j-w[i]][1])%mod;
	dp[i][j][1] %= mod;
      }
    }
  }
  /*
  for(int k = 0; k < 2; ++k){
    for(int i = 0; i <= N; ++i){
      for(int j = 0; j <= W; ++j){
	cout << dp[i][j][k] << " ";
      }cout << endl;
    }cout << "-------------------------------------------------------" << endl;
  }
  */
  long long int ans = 0, t = 0;
  for(int i = 0; i <= N; ++i){
    //cout << "i,  W-t-w[i]+1, W-t = " << i << " " << W-t-w[i]+1 << " " << W-t <<endl;
    for(int j = max(0LL,W-t-w[i]+1); j <= W-t; ++j){
      ans += dp[i][j][0];
      ans %= mod;
    }
    if(i < N) t += w[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34500
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
int ans;
int N;
bool check(long long n){
  bool use3 = false;
  bool use5 = false;
  bool use7 = false;
  while(n>0){
    if (n%10==3){
      use3=true;
    } else if (n%10==5){
      use5=true;
    } else if (n%10==7){
      use7 = true;
    }
    n = n/10;
  }
  if (use3 && use5 && use7){
    return true;
  } else {
    return false;
  }
}

void dfs(long long n){
  if (n>N){
    return;
  }
  if (check(n)){
    //printf("n=%lld\n", n);
    ans++;
  }
  if (n<=N){
    dfs(10*n+3);
    dfs(10*n+5);
    dfs(10*n+7);
  }
  return;
}

int main(){
  scanf("%d", &N);
  ans = 0;
  dfs(0);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[305][33][305],ans=0,all;
int p[7],a[7],n,c;
inline int max(int a,int b)
{return a>b?a:b;}
inline int min(int a,int b)
{return a<b?a:b;}
inline void solve()
{int i,j,k;
for (i=0;i<n*c;i++)
{int o=p[i%n];
for (j=0;j<(1<<(n-1));j++)
{for (k=i;k<=n*c;k++)
{if (!dp[i][j][k]) continue;
dp[i+1][j][k]+=dp[i][j][k];
if (o&&(!((1<<(o-1))&j)))
{dp[i+1][j|(1<<(o-1))][max(k,min(n*c,i+a[o]*n))]+=dp[i][j][k];}
}
}
}
ans+=dp[n*c][(1<<(n-1))-1][n*c];
return;
}
int main (){
	int i;
	scanf ("%d%d",&n,&c);
	for (i=1;i<=n;i++)
	{scanf ("%d",&a[i]);}
	sort(a+1,a+n+1);
	for (i=1;i<=n-1;i++) p[i]=i;
	int num=0;
	do
	{memset (dp,0,sizeof(dp));
	dp[0][0][a[n]*n]=1;solve();
	num++;
	}while (next_permutation(p+1,p+n));
	all=1;
	for (i=1;i<=n-1;i++)
	{all*=((ll)(c));}
	all*=((ll)(num));
	double res=((double)(ans))/((double)(all));
	printf ("%.12lf\n",res);
	return 0;
}

Measured memory_bytes: 24192
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int k;
    k=0;
    int a[20];
    for(int i=0;i<20;i++){
        a[i]=0;
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b[50];
    for(int i=0;i<50;i++){
        b[i]=0;
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int c[20];
    for(int i=0;i<20;i++){
        c[i]=0;
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        k+=b[i];
        if(a[i]==a[i+1]-1){
            k+=c[a[i]-1];
        }
    }

    cout<<k;
    return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;
const ll inf = 1e18;

int n;
ll k;
vector <ll> pos, neg;
ll zeros = 0;

ll cal(ll lim)
{
    //Count number of pairs which have product less than or equal to lim
    if (lim > 0)
    {
        ll res = 0;
        int l = 0, r = pos.size() - 1;
        while (l < r)
        {
            if (pos[l] * pos[r] <= lim)
            {
                res += r - l;
                ++l;
            }
            else
            {
                --r;
            }
        }
        res += zeros * (n - zeros) + zeros * (zeros - 1) / 2;
        l = 0, r = neg.size() - 1;
        while (l < r)
        {
            if (neg[l] * neg[r] <= lim)
            {
                res += r - l;
                --r;
            }
            else
            {
                ++l;
            }
        }
        res += (ll)pos.size() * neg.size();
        return res;
    }
    else
    {
        ll res = 0;
        int l = 0, r = 0;
        while (l < (int)neg.size() && r < (int)pos.size())
        {
            if (neg[l] * pos[r] <= lim)
            {
                res += pos.size() - r;
                ++l;
            }
            else
            {
                ++r;
            }
        }
        if (lim == 0)
        {
            res += zeros * (n - zeros) + zeros * (zeros - 1) / 2;
        }
        return res;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, n)
    {
        ll a;
        cin >> a;
        if (a == 0)
        {
            ++zeros;
        }
        else if (a < 0)
        {
            neg.eb(a);
        }
        else
        {
            pos.eb(a);
        }
    }
    sort(all(pos));
    sort(all(neg));
    ll l = -inf, r = inf;
    //binary searck the maximum x which number of pairs smaller or equal than x to be strictly smaller tham k
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        if (cal(mid) < k)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    cout << l + 1;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	double T, X;
	double a;
	cin >> T >> X;
	a = T / X;
	cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#define MAX_N 2000000
#define MAX_V 10001

int a[MAX_N];
int c[MAX_V] = { 0 };

int
main(int argc, char** argv)
{
	int t;
	int n;
	int i, j;

	scanf("%d", &n);
	int max = 0;
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &t);
		a[i] = t;
		c[t]++;
		if (t > max)
			max = t;
	}

	const char* sep = "";
	for (i = 0; i <= max; ++i)
	{
		for (j = 0; j < c[i]; ++j)
		{
			printf("%s%d", sep, i);
			sep = " ";
		}
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 8456