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

using namespace std;
#define _GLIBCXX_DEBUG

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

    int N;
    cin >> N;

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

    int ans = 0;
    int num = H[0];
    for (int i = 0; i < N; i++)
    {
        if (num <= H[i])
        {
            num = H[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl

void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "\n[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod = 1e9 + 7;
//const int mod = 998244353;
int dp[21][(1ll<<21)], n, Data[25];

int go(int ind, int mask){
  if(ind >= n) return 1;
  int &x = dp[ind][mask];
  if(x!=-1)return x;
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(mask&(1ll<<i)){
      if(Data[ind]&(1ll<<i)){
        ans += go(ind+1, mask^(1ll<<i));
        ans%=mod;
      }
    }
  }
  return (x = ans);
}

void solve(){
   int x;
   cin >> n;
   memset(dp, -1, sizeof(dp));
   for(int i = 0; i < n; i++){
     int num = 0;
     for(int j = 0; j < n; j++){
       cin >> x;
       if(x){
         num|=(1ll<<j);
       }
     }
     Data[i] = num;
   }
   cout << go(0, (1ll<<n)-1) << '\n';
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
        clock_t t1 = clock();
  int t = 1; //cin >> t;
  while(t--){      
     solve();
  }
        clock_t t2 = clock();
  //cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;      
}


Measured memory_bytes: 344448
/*input
4 2
1 3
2 3
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}


void solve(){
	 int haha[5] = {0};
	 REP(i,3){
	 	int x,y;cin >> x >> y;
	 	haha[x]++;haha[y]++;
	 }
	 int mx = 0;
	 RE(i,4){
       remax(mx,haha[i]);
	 }
	 //cout << mx << endl;
	 if(mx < 3)cout << "YES";
	 else cout << "NO";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <unordered_map>
using namespace std;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()

priority_queue<ll> q;

int main()
{
	FIO;

	int n, m;
	cin >> n >> m;
	
	for(int i=1; i<=n; i++)
	{
		ll x;
		cin >> x;
		q.push(x);
	}

	while(m--)
	{
		ll f = q.top(); q.pop();
		q.push(f/2);
	}

	ll sum = 0;
	while(!q.empty())
	{
		sum = sum + q.top(); q.pop();
	}
	cout << sum << "\n";
	return 0;
	
}

Measured memory_bytes: 1400
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> II;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e5, INF = 1e18;

LL n, a[MaxN], x, y, z, m, s[MaxN];
vector<II> q[MaxN];

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

void Dijk(){
    fill(s, s + n, INF);
    s[0] = 0;
    priority_queue<II, vector<II>, greater<II> > pq;
    pq.push({0, 0});
    while(!pq.empty()){
        II temp = pq.top();
        pq.pop();
        LL u = temp.second;
        for(II v : q[u])
        if(s[u] + v.second < s[v.first]){
            s[v.first] = s[u] + v.second;
            pq.push({s[v.first], v.first});
        }
    }
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    read(n);
    read(m);
    for(int i = 0 ; i < m ; ++i){
        read(x);
        read(y);
        read(z);
        x--;
        y--;
        q[x].push_back({y, z});
        q[y].push_back({x, z});
    }
    for(int i = 1 ; i < n ; ++i) q[i].push_back({i - 1, 0});
    Dijk();
    if(s[n - 1] == INF) cout << -1 << endl;
    else cout << s[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 12792
x1, y1, x2, y2 = map(int, input().split())

diff_x = (x2-x1) 
diff_y = (y2-y1) 

x3 = x2-diff_y
y3 = y2+diff_x

x4 = x1-diff_y
y4 = y1+diff_x

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

double xa1, ya1,xa2, ya2, xb1, yb1, xb2, yb2;

int main(){
	while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
		if (xa1 <= xb2&&xb1 <= xa2&&ya1 <= yb2&&yb1 <= ya2)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1216
import numpy as np

N=int(input())

L=np.array(input().split(" "),dtype=np.int64)

cnt=0
for idx in range(N):
    for jdx in range(idx,N):
        for kdx in range(jdx,N):
            a=L[idx]
            b=L[jdx]
            c=L[kdx]
            if(a!=b and b!=c and a!=c):
                if(a+b>c and b+c>a and c+a>b):
                    cnt+=1

print(cnt)

Measured memory_bytes: 27160
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){
	int n;
	scanf("%d",&n);
	int l[n],max=0,sum=0;
	rep(i,n){
		scanf("%d",&l[i]);
		if(l[i]>max) max=l[i];
		sum+=l[i];
	}
	sum-=max;
	if(max<sum) printf("Yes\n");
	else printf("No\n");

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll k;
    cin >> k;
    vector<int> cnt;
    char c = s[0];
    int m = 1;
    for(int i = 1; i < n; i++){
        if(s[i] != c){
            cnt.push_back(m);
            m = 1;
            c = s[i];
        }else{
            m++;
        }
    }
    cnt.push_back(m);
    m = cnt.size();
    if(m == 1){
        cout << k * cnt[0] / 2 << endl;
    }else{
        if(s[0] != s[n-1]){
            ll ans = 0;
            for(int l : cnt){
                ans += (l / 2) * k;
            }
            cout << ans << endl;
        }else{
            ll ans = 0;
            for(int i = 1; i < m-1; i++){
                ans += (cnt[i] / 2) * k;
            }
            ans += cnt[0] / 2 + cnt[m-1] / 2;
            ans += (cnt[0] + cnt[m-1]) / 2 * (k-1);
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3636
count = int(input())
arr = input().split()
s1 = 0
s2 = 0
for i in arr:
  s2 += int(i)
minimum_diff = s2
for i in range(0, count):
  s1 += int(arr[i])
  s2 -= int(arr[i])
  minimum_diff = min(minimum_diff, abs(s1-s2))
  
print(minimum_diff)


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

#define rep(i,a) for(int i = 0;i < a; i++)

using namespace std;

struct expr;

struct term
{
  bool flg;
  string str;
  int n;
  expr *inner;

  term(bool flg, string str, int n, expr *inner);
  int length();
  char charAt(int pos);
};

struct expr
{
  vector<term> inner;

  expr(vector<term> inner) : inner(inner) {}

  int length() {
    int ret = 0;
    for (int i = 0; i < inner.size(); ++i)
      ret += inner[i].length();
    return ret;
  }

  char charAt(int pos) {
    int cur = 0;
    for (int i = 0; i < inner.size(); ++i) {
      int next = cur + inner[i].length();
      if (pos < next)
	return inner[i].charAt(pos - cur);
      cur = next;
    }
    return '0';
  }
};

term::term(bool flg, string str, int n, expr *inner)
  : flg(flg), str(str), n(n), inner(inner) {}

int term::length() {
  return flg ? min((long long) n * inner->length(), 100000000LL) : str.length();
}

char term::charAt(int pos) {
  return flg ? inner->charAt(pos % inner->length()) : str[pos];
}

int parsenum(string s, int pos, int& next)
{
  int ret = 0;
  while ('0' <= s[pos] && s[pos] <= '9') {
    ret *= 10;
    ret += s[pos] & 15;
    ++pos;
  }
  next = pos;
  return ret;
}

expr *parseexpr(string s, int pos, int& next);

term parseterm(string s, int pos, int& next)
{
  if ('0' <= s[pos] && s[pos] <= '9') {
    int n = parsenum(s, pos, next);
    if (s[next] == '(') {
      expr *inner = parseexpr(s, next + 1, next);
      ++next;
      return term(true, "", n, inner);
    } else {
      string str;
      str.push_back(s[next]);
      vector<term> inner;
      inner.push_back(term(false, str, 0, NULL));
      ++next;
      return term(true, "", n, new expr(inner));
    }
  } else {
    string ret;
    while ('A' <= s[pos] && s[pos] <= 'Z') {
      ret.push_back(s[pos]);
      ++pos;
    }
    next = pos;
    return term(false, ret, 0, NULL);
  }
}

expr *parseexpr(string s, int pos, int& next)
{
  vector<term> ret;
  while (pos < s.length() && s[pos] != ')') {
    term inner = parseterm(s, pos, next);
    ret.push_back(inner);
    pos = next;
  }
  return new expr(ret);
}

void solve(string s, int i)
{
  int dummy;
  expr *e = parseexpr(s, 0, dummy);
  cout << e->charAt(i) << endl;
}

int main()
{
  string s;
  int i;
  while (cin >> s >> i && s[0] != '0')
    solve(s, i);

  return 0;
}

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int a[100];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = 1000000;
    for (int i = -100; i <= 100; i++) {
        int cur = 0;
        for (int j = 0; j < N; j++) {
            cur += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/*
As the name of the class should be Solution, using Solution.java as the filename is recommended.
In any case, you can execute your program by running 'java Solution' command.
*/
public class Main
{

	public static void main(String args[]) throws Exception
	{
		/*
		   The method below means that the program will read from input.txt, instead of standard(keyboard) input.
		   To test your program, you may save input data in input.txt file,
		   and call below method to read from the file when using nextInt() method.
		   You may remove the comment symbols(//) in the below statement and use it.
		   But before submission, you must remove the freopen function or rewrite comment symbols(//).
		 */
		//System.setIn(new FileInputStream("res/input.txt"));

		/*
		   Make new scanner from standard input System.in, and read data.
		 */
		Scanner sc = new Scanner(System.in);
		/*
     			Read each test case from standard input.
     		*/		
			int n=sc.nextInt();
        int k=sc.nextInt();
            int []h=new int [n];
            int [] ans=new int [n];
            for(int i=0;i<n;i++)
            {
                h[i]=sc.nextInt();
                ans[i]=Integer.MAX_VALUE;
            }
            ans[0]=0;
        	ans[1]=ab(h[0]-h[1]);
        if(k>n)
            k=n;
        	for(int i=1;i<k;i++)
            {
                for(int j=1;j<=i;j++)
                {
                    ans[i]=min(ans[i],ans[i-j]+ab(h[i]-h[i-j]));
                }
            }
        
            for(int i=k;i<n;i++)
            {
                for(int j=k;j>=0;j--)
                {
                    ans[i]=min(ans[i],ans[i-j]+ab(h[i]-h[i-j]));
                }
            }	
            System.out.println(ans[n-1]);
    }
    public static int ab(int n)
    {
        if(n<0)
            return -n;
        return n;
    }
    public static int min(int a,int b)
    {
        if(a<b)
            return a;
        return b;
    }
   

}

Measured memory_bytes: 63212
using System;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {


        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List<string> resultList = new List<string>();

            for (int i = 0; i < n; i++)
            {
                resultList.Add(Console.ReadLine().Replace("Hoshino", "Hoshina"));
            }

            foreach (string s in resultList)
            {
                Console.WriteLine(s);
            }

        }

    }
}

Measured memory_bytes: 5420
#include<stdio.h>
int main(void){
 int n, m;
 int i;
 int a, b;
 int city[1000] = {0};

 scanf("%d%d",&n,&m);
 for(i = 0;i < m; ++i){
  scanf("%d%d", &a, &b);
  city[a] += 1;
  city[b] += 1;
 }
 for(i = 1;i <= n; i++) printf("%d\n", city[i]);
 return 0;
}

Measured memory_bytes: 128
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K, Q := getInt(), getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < Q; i++ {
		x := getInt() - 1
		a[x]++
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < N; i++ {
		if K+a[i]-Q <= 0 {
			fmt.Fprintln(w, "No")
		} else {
			fmt.Fprintln(w, "Yes")
		}
	}
}


Measured memory_bytes: 3140
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int bpow(int a, int b, int mod) {
    int res = 1;
    for (; b; b >>= 1) {
        if (b & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
    }
    return res;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}


void run() {
    int n;
    string s;
    cin >> n >> s;
    if (len(s) > n) {
        s = s.substr(0, n);
        s += "...";
    }
    cout << s << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a, b, c;
  set<int> s;
  int x;
  for(int i = 0; i < n; i++){
    cin >> x;
    c.push_back(x);
    if(i % 2 == 0){
      a.push_back(x);
      s.insert(x);
    }
    else{
      b.push_back(x);
    }
  }
  
  sort(c.begin(), c.end());
  
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) s.insert(c.at(i));
  }
  
  cout << s.size() - a.size() << '\n';
}

Measured memory_bytes: 5752
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

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

    if (N % 2 == 1) {
        cout << "0" << endl;
        return 0;
    }

    lint c = 0;
    lint i = 10;
    while (N / i > 0) {
        c += N / i;
        i *= 5;
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}


int n;
map <pair <long long, long long>, int> M;
bool Seive[100005];

signed main()
{
	Fastio();
	Seive[1] = true;
	for(int i = 2; i * i <= 100000; i++)
	{
		if(Seive[i] == false)
		{
			for(int j = i * i; j <= 100000; j = j + i)
			{
				Seive[j] = true;
			}
		}
	}
	cin >> n;
	int ans = 0, t = 0;
	long long lll = 1;
	for(long long i = 4000; i >= 1; i--)
	{
		if(i * i * i <= 10000000000 and lll * i <= 10000000000)
		{
			lll *= i;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		long long temp, x = 1, y = 1, g;
		cin >> temp;
		g = temp;
		for(long long j = 2; j * j * j <= 10000000000ll; j++)
		{
			if(y >= 10000000000ll or x >= 10000000000ll)
			{
				break;
			}
			if(temp % j == 0)
			{
				int cnt = 0;
				while(temp % j == 0)
				{
					temp /= j;
					cnt++;
				}
				cnt %= 3;
				if(cnt == 0)
				{
					continue;
				}
				if(cnt == 1)
				{
					x *= j;
					y *= j * j;
				}
				if(cnt == 2)
				{
					x *= j * j;
					y *= j;
				}
			}
		}
		
		long long xx = sqrt(temp);
		if(xx * xx != temp and temp >= 100000)
		{
			ans++;
			continue;
		}
		if(x > 10000000000ll or y > 10000000000ll)
		{
			ans++;
			continue;
		}
		if(xx * xx == temp)
		{
			x *= xx * xx;
			y *= xx;
			temp = 1;
		}
		if(x > 10000000000ll or y > 10000000000ll)
		{
			ans++;
			continue;
		}
		if(temp <= 100000)
		{
			if(Seive[temp] == false)
			{
				x *= temp;
				y *= temp * temp;
			}
		}
		if(x > 10000000000ll or y > 10000000000ll)
		{
			ans++;
			continue;
		}
		if(x == y)
		{
			t++;
			continue;
		}
		M[mp(x, y)]++;
	}
	while(M.empty() == false)
	{
		auto xx = *M.begin();
		ans += max(xx.se, M[mp(xx.fi.se, xx.fi.fi)]);
		M.erase(xx.fi);
		M.erase(mp(xx.fi.se, xx.fi.fi));
	}
	cout << ans + (t > 0);
}

Measured memory_bytes: 8832
N = int(input())
ans = []

for i in range(1,N+1):
    if sum(range(1, i + 1)) < N:
        continue
    else:
        ans = [i - 1,sum(range(1, i + 1)) - N]
        break
for i in range(ans[0]+1):
    if i + 1 != ans[1]:
        print(i + 1)


Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<functional>
#include<limits.h>
#include<numeric>
using namespace std;
 
 
int n;
long long  dp[3100][3100];
long long  a[3100];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  cin>>n;
 for(int i=1;i<=n;i++)
 {
 	cin>>a[i];
 }
 
 for(int r=1;r<=n;r++)
 {
    for(int l=r;l>=1;l--){
      dp[r][l]=max(a[l]-dp[r][l+1],a[r]-dp[r-1][l]);
    }
 }
   
  
 
  cout<<dp[n][1]<<endl;
  return 0;
 
}

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

int main ()
{
    int N,K,i,j;
    cin >> N >> K;
    vector <int> mark(K);
    for (i = 0 ; i < K ;i++)
        cin >> mark[i];
    int curr = N;
    while (true)
    {
        int copy = curr;
        int keta =0;
        vector <int> digits(5);
        while (copy>0)
        {
            digits[keta] = copy%10;
            copy /= 10;
            keta++;
        }
        bool judge = true;
        for ( i = 0 ;i < keta ;i++)
            if (count (mark.begin(),mark.end(),digits[i])) judge = false;
        if (judge)
        {
            cout << curr;
            break;
        }
        curr++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int a, b, ans=0;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        string s, rs;
        s = to_string(i);
        rs = to_string(i);
        reverse(all(rs));
        if(s == rs)ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
n,t=map(int, input().split())
x=[]
y=[]
m=[]
for i in range(n):
    a,b=map(int, input().split())
    x.append(a)
    y.append(b)
    m.append([a,b])
x.sort()
y.sort()
ans=float('inf')
for i in range(n-1):
    for j in range(i,n):
        if i>=j:continue
        for k in range(n-1):
            for l in range(k,n):
                if k>=l:continue
                count=0
                for a,b in m:
                    if x[i]<=a<=x[j] and y[k]<=b<=y[l]:
                        count+=1
                if count>=t:
                    ans=min(ans,(x[j]-x[i])*(y[l]-y[k]))
print(ans)

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

int main(void){
int i,n,m,a,b,count=0;
vector<int> h(N_SIZE);
vector<bool> ok(N_SIZE,true);
cin >> n >> m;
rep(i,n){
cin >> h.at(i);
}

rep(i,m){
    cin >> a >> b;
    a--;
    b--;
    if(h.at(a) > h.at(b)){
    ok.at(b)=false;  
    }
    else if(h.at(a) < h.at(b)){
    ok.at(a)=false;  
    }
    else{
    ok.at(a)=false;
    ok.at(b)=false;
    }
}
rep(i,n){
    if(ok.at(i))
    count++;
}
cout << count << endl;

}

Measured memory_bytes: 3604
/*
氏名 鈴木啓太
学籍番号 180441073
概要 1つの整数の整数xを読み込んで、xの3乗を計算し結果を出力するプログラム
*/

#include<stdio.h>
int main(void)
{
	int x=0;//入力する変数をxとする

	((1 <= x) && (x <= 100));//xの範囲を1から100にする
	
	scanf("%d", &x);//xを入力

	x = x*x*x;//xを3乗する

	printf("%d\n", x);//3乗したxを表示

	return 0;

}//終了


Measured memory_bytes: 2076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
#include <sys/time.h>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ( (a)/__gcd((a),(b))*(b) )

template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

long long dp[100030];
long long dp2[100030];

int gen5(){
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	dp[4] = 8;
	dp[5] = 16;
	for(int i = 6 ; i < 100010 ; i++){
		dp[i] = (2 * dp[i-1] - dp[i-6]+100000007)%100000007;
		if(dp[i] < 0) cout << dp[i] << endl;
	}
}
int gen3(){
	dp2[0] = 0;
	dp2[1] = 1;
	dp2[2] = 2;
	dp2[3] = 4;
	for(int i = 4 ; i < 100010 ; i++){
		dp2[i] = (2*dp2[i-1]-dp2[i-4]+100000007)%100000007;
	}
}
int main(int a,char *b[]){

	gen5();
	gen3();
	string s;
	while(cin >> s && s[0] != '#'){
		s += "~";
		long long c = 1;
		long long ans = 1;
		for(int i = 1 ; i < s.size() ; i++){
			if(s[i] != s[i-1]){
				if(s[i-1] != '0' && s[i-1] != '8'){
					ans = ( ans * dp[c] )  % 100000007;
				}else{
					ans = ( ans * dp2[c])  % 100000007;
				}
				c = 1;
			}else{
				c++;
			}
		}
		cout << ans%100000007 << endl;
	}
}

Measured memory_bytes: 2712
#include <stdio.h>
#include <string.h>

int main(){
  char s[100], t[100], tmp;
  scanf("%s", s);
  scanf("%s", t);
  int len=strlen(s), i, j, start=len+1, or=0, sousa=1;
  for(i=0;i<2;i++){
    for(j=0;j<len;j++){
      if(or==0){
        if(s[j]==t[0]){
          or++;
          if(j==0){
            start=len-1;
          } else {
            start=j;
          }
        }
      } else {
        if(s[j]==t[sousa]){
          sousa++;
          if(j==start-1){
            puts("Yes");
            return 0;
          }
        } else {
          sousa=1;
          or--;
          start=len+1;
        }
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
/*
	Look, if you had, one shot, or one opportunity
		To seize everything you ever wanted. In one moment
			Would you capture it,or just let it slip ?
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
        ll n;cin>>n;
	ll ans=0;
	ans+=(n*(n-1)*(n-2));
	
	ans+=n*(n-1)*3;

	ans+=n;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  int p[51];

  cin>>n;
  rep(i,1,n) cin>>p[i];

  int wrong=0;
  rep(i,1,n){
    if(p[i]!=i) wrong++;
  }

  if(wrong==2 || !wrong) cout<<"YES";
  else cout<<"NO";
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    vector<vector<int>> b(h,vector<int>(w));
    queue<pair<int,int>> q;
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            cin >> a[i][j];
            if (a[i][j]=='#') {
                b[i][j]=0;
                q.push(make_pair(i,j));
            }
        }
    }
    int di[4]={0,-1,0,1};
    int dj[4]={-1,0,1,0};
    while (!q.empty()) {
        int i=q.front().first;
        int j=q.front().second;
        q.pop();
        for (int k=0;k<4;k++) {
            int ni=i+di[k];
            int nj=j+dj[k];
            if (ni>=0 && ni<h && nj>=0 && nj<w) {
                if (a[ni][nj]=='.') {
                    a[ni][nj]='#';
                    q.push(make_pair(ni,nj));
                    b[ni][nj]=b[i][j]+1;
                }
            }
        }
    }
    int ans=0;
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            ans=max(ans,b[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
package main
import(
  "fmt"
)
func main(){
  var a, b, c, x, i, j, k int
  ans:=0
  fmt.Scan(&a, &b, &c, &x)
  for i=0;i<=a;i++{
    for j=0;j<=b;j++{
      for k=0;k<=c;k++{
        if i*500+j*100+k*50==x{
          ans++
        }
      }
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
/*
    ||S|A|M|R|A|T||
    Author:codingsamrat
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long 
#define ld long double
#define INF LONG_MAX
#define pb push_back
#define gcd __gcd
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<int>
#define vll vector<long long>
typedef long long  ll;

ll bpow(ll a, ll b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
	int c5=0;
	int c7=0;
	int a;
	f(i,0,3)
	{
	cin>>a;
	if(a==5)
	c5++;
	else if(a==7)
	c7++;
	}
	
	if(c5==2 && c7==1)
	cout<<"YES\n";
	else
	cout<<"NO\n";
	
     
return 0;

}


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

long long a[5000];

int main(){
	int n;
	while(cin >> n && n){
		long long ans = -1e9;
		for(int i = 0 ; i < n ; i++) cin >> a[i] , ans = max(ans, a[i]);
		long long sub = 0;
		for(int i = 0 ; i < n ; i++){
			sub += a[i];
			if( sub < 0 ){
				sub = 0;
			}else{
				ans = max(ans,sub);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int n = sc.nextInt();
			final long T = sc.nextLong();
			
			long answer = 0;
			long prev_time = -1;
			for(int i = 0; i < n; i++){
				final long t = sc.nextLong();
				
				if(prev_time >= 0){
					answer += Math.min(T, t - prev_time);
				}
				
				prev_time = t;
			}
			
			System.out.println(answer + T);
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 44212
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):

    result = 0
    for i in range(0, 9 + 1):
        first = S.find(str(i))
        if first == -1:
            # print(i)
            continue

        for j in range(0, 9 + 1):
            second = S.find(str(j), first + 1)
            if second == -1:
                # print(j)
                continue

            for k in range(0, 9 + 1):
                if S.find(str(k), second + 1) != -1:
                    result += 1

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 1; ; i++ {
		a, b := nextInt(), nextInt()
		if a == 0 && b == 0 {
			break
		}
		if b < a {
			a, b = b, a
		}
		fmt.Printf("%d %d\n", a, b)
	}

}



Measured memory_bytes: 1100
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		String ans = "";
		while(N != 0) {
			int rem = Math.abs(N % 2);
			if(N > 0) N = -(N / 2);
			else N = (N - 1) / (-2);
			ans = rem + ans;
		}
		System.out.println((ans.isEmpty()) ? 0 : ans);
	}
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll n = S.size();
    ll ans = 1;
    ll pos = 0;
    bool flag = false;
    while(pos < n)
    {
        if (flag)
        {
            if (pos + 1 < n)
            {
                ans++;
            }
            flag = false;
        }
        else
        {
            if (pos + 1 < n)
            {
                if (S[pos] == S[pos + 1])
                {
                    if (pos + 2 < n)
                    {
                        flag = true;
                        ans++;
                        pos++;
                    }
                }
                else
                {
                    ans++;
                }
            }
        }
        pos++;
    }

    cout << ans << endl;
}


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

int main()
{
	int k, j;

	for (k = 1; k <= 9; k++)
	{
		for (j = 1; j <= 9; j++)
		{
			cout << k << "x" << j << "=" << k*j << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3000
def d(n):
   divisors = []
   for i in range(1, int(n**0.5)+1):
     if n % i == 0:
       divisors.append(i)
       if i != n // i:
         divisors.append(n//i)
 
   divisors.sort()
   return divisors

x = d(int(input()))

if len(x) % 2 == 1:
    print(x[len(x)//2] * 2 - 2)
else:
    print(x[len(x)//2-1] + x[len(x)//2] -2)

Measured memory_bytes: 39152
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int g=x+y;
		if(g<x*y)
			g=x*y;
		if(g<x-y) {
			g=x-y;
		}
		System.out.println(g);
	}

}

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

int main(int argc, char const *argv[]) {
    int x, n;
    cin >> x >> n;
    vector<int> p;
    for (int i = 0; i < n; i++) {
        int pi;
        cin >> pi;
        p.push_back(pi);
    }
    sort(p.begin(), p.end());

    int d=0;
    while(true){
        if (!binary_search(p.begin(), p.end(), x-d)) {
            cout << x-d << endl;
            return 0;
        }
        if (!binary_search(p.begin(), p.end(), x+d)) {
            cout << x+d << endl;
            return 0;
        }
        d++;
    }
    return 0;
}


Measured memory_bytes: 3604
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()

a = nil()
a.sort()
ans = 0

for i in range(n):
    ans += a[(-i*2) - 2]
print(ans)

Measured memory_bytes: 37084
#include<iostream>
#include<stdio.h>
#include<queue>
#include<vector>
#define ll long long
using namespace std;
const int inf=31630;
const int maxn=101;
const int mod=1e9+7;
int dp[maxn][2*inf];
struct node {
	int x,y;
};
vector<node>a;
void add(int x,int y){
	x+=y;
	while(x>=mod)x-=mod;
}
int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	int x=1,y;
	a.push_back((node)<%0,0%>);
	while(x<=n){
		int t=n/x;
		y=n/t;
		a.push_back((node)<%x,y%>);
		x=y+1;
//		printf("x : %d,y : %d\n",x,y);
	}
	int tot=a.size()-1;
	for(int i=1; i<=tot; i++) {
		dp[1][i]=a[i].y-a[i].x+1;
		dp[1][i]+=dp[1][i-1];
	}
	for(int i=2;i<=k;i++)
		for(int j=1;j<=tot;j++)
			dp[i][j]=(1LL*dp[i-1][tot-j+1]*(a[j].y-a[j].x+1)%mod+dp[i][j-1]%mod)%mod;
	ll ans=1LL*dp[k][tot];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 25592
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    s = gets.chomp

    if s[0] == s[2]
      puts "Yes"
    else
      puts "No"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if( y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key; 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u != NIL){
    if(u->left != NIL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NIL) inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }
  }
  
  return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

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

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};

typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

ll mod = 1e9 + 7;
bool sieve[1001];
int cnt[1001];

void make_sieve(void) {
  rep(i, 1001) sieve[i] = true;
  sieve[0] = sieve[1] = false;
  for (int i = 2; i * i <= 1000; i++) {
    if (!sieve[i]) continue;
    for (int j = i + i; j <= 1000; j += i)
      sieve[j] = false;
  }
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N; cin >> N;

  make_sieve();
  REP(i, 1, N+1) {
    int tmp = i;
    for (int j = 2; j <= i; j++) {
      if (!sieve[j]) continue;
      while (tmp != 1 && tmp % j == 0) {
        tmp /= j;
        cnt[j]++;
      }
    }
  }

  ll res = 1;
  REP(i, 1, N+1) {
    if (!sieve[i]) continue;
    res = (res * (cnt[i] + 1)) % mod;
  }

  cout << res << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ll i,b,c,n,q,s;
 s=0;
 cin >> n;
 ll a[n];
 map<ll,ll> m;
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  s+=a[i];
  m[a[i]]++;
 }
 cin >> q;
 while(q--)
 {
  cin >> b >> c;
  if(m.find(b)!=m.end())
  {
   s-=b*m[b];
   s+=c*m[b];
   m[c]+=m[b];
   m.erase(b);
  }
  cout << s << '\n';
 }
 return 0;
}

Measured memory_bytes: 8236
import java.util.*;

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

        int num = 1;
        for (int i = 0; i < N; i++){
            int plus = num + K;
            int mul = num * 2;
            if (plus > mul){
                num = mul;
            } else {
                num = plus;
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 35688