akhauriyash/Code-Regression huggingface dataset:
use proconio::marker::*;
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        l: [i64; n],
    };
    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                let a = l[i];
                let b = l[j];
                let c = l[k];
                if a != b && a != c && b != c && a + b > c && a + c > b && b + c > a {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
string s;
int w,i=0;
signed main()
{
	cin>>s>>w;
	while(1){
		cout<<s[i];
		i=i+w;
		if(i>=s.size()){
			break;
		}
	}
}

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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, x;
    cin >> n >> m >> x;

    vvi v(n, vi(m));
    vi c(n);

    for(int i = 0; i < n; ++i)
    {
        cin >> c[i];
        for(auto &z : v[i])
            cin >> z;
    }

    int mini = 1e9;

    for(int i = 0; i < (1<<n); ++i)
    {
        vi temp(m);
        int novac = 0;
        for(int j = 0; j < n; ++j)
        {
            if((i>>j)&1)
            {
                novac += c[j];
                for(int k = 0; k < m; ++k)
                    temp[k] += v[j][k];
            }
        }
        
        bool ok = 1;
        for(int j = 0; j < m; ++j)
            ok &= (temp[j] >= x);
        if(ok)
        {
            ckmin(mini, novac);
        }
    }

    cout << ((mini >= 1e9) ? -1 : mini) << "\n";
}


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

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

	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++)
		if (i % d == 0)
			cnt++;
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, k;
int a[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> k;
    REP (i, n) {
        cin >> a[i];
    }

    int ans = 0;

    for (int l=0; l<=n; l++) {
        for (int r=0; r<=n; r++) {
            if (l + r <= n && l + r <= k) {
                vector<int> hand;

                int sum = 0;
                REP (j, l) {
                    hand.eb(a[j]);
                    sum += a[j];
                }
                REP (j, r) {
                    hand.eb(a[n-1-j]);
                    sum += a[n-1-j];
                }
                sort(ALL(hand));
                debug(hand);

                debug(sum);

                REP (j, min(k-l-r, l+r)) {
                    if (hand[j] >= 0) {
                        break;
                    }
                    sum -= hand[j];
                }
                debug(sum);

                ans = max(ans, sum);

            }
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n = int(readline())
    ab = map(int, read().split())
    ab = list(zip(ab, ab))
    g = [[] for _ in range(n+1)]
    for a, b in ab:
        g[a].append(b)
        g[b].append(a)

    parent = [0]*(n+1)
    color, maxc = [0]*(n+1), 0
    stack = [1]
    while stack:
        p = stack.pop()
        children = g[p]
        c, notc = 1, color[p]
        for child in children:
            if child==parent[p]:
                continue
            parent[child] = p
            stack.append(child)

            c = c+1 if c==notc else c
            color[child] = c
            maxc = c if maxc<c else maxc
            c+=1

    print(maxc)
    for a, b in ab:
        if parent[a]==b:
            print(color[a])
        else:
            print(color[b])


if __name__ == "__main__":
    main()


Measured memory_bytes: 30896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll l,r;
	cin>>l>>r;
	if(l%r==0){
		cout << -1;
		return 0;
	}
	cout << l;
	return 0;
}

Measured memory_bytes: 256
N=input()

N_sqrt=int(N**0.5)+1

S=set()
S.add(1)
S.add(N)

for i in range(1,N_sqrt+1):
    if N%i==0:
        S.add(i)
        S.add(N/i)


ans=float("inf")
for x in S:
    y=N/x
    ans=min(ans,x+y-2)

print ans

Measured memory_bytes: 30700
#include<stdio.h>
int N;
char s[11] = "";
void nyan(int x, char y){
	if(x == N){
		puts(s);
		return;
	}
	for(char c='a'; c<=y; c++){
		s[x] = c;
		nyan(x+1, y+(c==y));
	}
	return;
}
int main(){
	scanf("%d", &N);
	nyan(0, 'a');
	return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)
#define FORR(I,A,B) for(int I=int(B-1);I>=int(A);--I)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,x;
	while(cin>>n>>x,n+x){
		int ans = 0;
		n++;
		FOR(i,1,n)FOR(j,i+1,n)FOR(k,j+1,n){
			if(i+j+k==x)ans++;
		}
		cout << ans << "\n";
	}
}



Measured memory_bytes: 3176
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
main() {
    int N,K; cin>>N>>K;
    string S; cin>>S;
    vector<pair<int,int>> xs;
    char prev='1';
    int left=-1;
    xs.push_back({0,0});
    for(int i=0; i<S.size(); ++i) {
        if(prev=='1' && S[i]=='0') left=i;
        if(prev=='0' && S[i]=='1') xs.push_back({left, i});
        if(i==S.size()-1 && S[i]=='0') xs.push_back({left, S.size()});
        prev=S[i];
    }
    xs.push_back({S.size(),S.size()});
    int max_=-1;
    for(int j=1; j<xs.size(); ++j) {
        int i=max(0, j-K-1);
        int left= xs[i].second;
        int right= xs[j].first;
        max_= max(max_, right-left);
    }
    cout<< max_ <<endl;
}

Measured memory_bytes: 1020
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

vector<int> g[100002];
int64 dp[100002][2];
void dfs(int u, int p){
    int64 black = 1, white = 1;
    for(int to : g[u]){
        if(to == p) continue;
        dfs(to, u);
        black = (black * dp[to][1]) % mod;
        white = (white * (dp[to][1] + dp[to][0]) % mod) % mod;    
    }
    dp[u][0] = black % mod;
    dp[u][1] = white % mod;
}
int main(){
    FAST
    //Do awesome things here
    int n, a, b;
    cin >> n;
    rp(i, n - 1){
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1, -1);
    cout << (dp[1][0] + dp[1][1]) % mod << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 14208
n = int(input())
h = list(map(int, input().split()))

l = 0
r = 0
cnt = 0

while True:
    l = 0
    fin = False

    while h[l] == 0:
        l += 1
        if l == n:
            fin = True
            break
    if fin:
        break

    r = l
    minval = h[l]
    while h[r] != 0:
        if h[r] < minval:
            minval = h[r]

        r += 1
        if r == n:
            break

    h = h[:l] + [val - minval for val in h[l:r]] + h[r:]
    cnt += minval

print(cnt)

Measured memory_bytes: 9204
#include <iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	int i;
	int cnt=0;
	for (i=0;i<n;i++){
		int m;
		cin>>m;
		//m????´???°????????????
		int j,flg=0;
		for (j=2;j*j<=m;j++){
			if (m%j==0){
				flg=1;
				break;
			}
		}
		if (!flg){
			//?´???°
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace ABC157
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[][] sc;
            sc = new int[nm[1]][]; int[] ans = Enumerable.Repeat(-1, nm[0]).ToArray(); ; int Ans = 0;
            for (int i = 0; i < nm[1]; i++)
            {
                sc[i]= Console.ReadLine().Split().Select(int.Parse).ToArray();
                if(ans[sc[i][0]-1]== -1) { ans[sc[i][0]-1] = sc[i][1]; }
                else if (ans[sc[i][0]-1] == sc[i][1]) { }
                else { Ans = -1; break; }
            }
            for (int i = 0; i < nm[0]; i++)
            {
                if (Ans == -1) { break; }
                if (ans[i] == -1) { ans[i] = i == 0 ? 1 : 0; }
                Ans = Ans * 10 + ans[i];
            }

            if (ans[0] == 0 && nm[0]!=1) { Ans = -1; }
            if (nm[0] == 1 && nm[1] == 0) { Ans = 0; }
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
 
int main()
{
  int n,q,i,x,j;
  int array_n[10000];
  int array_q[10000];
  int count=0;
 
  for(i=0;i<100;i++){
    array_n[i]=0;
    array_q[i]=0;
  }
 
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&array_n[i]);
  }
 
  scanf("%d",&q);
  for (i=0;i<q;i++){
    scanf("%d",&x);
    for (j=0;j<n;j++){
      if (array_n[j]==x){
        count++;
        break;
      }
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 636
import java.util.*;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int[] list = { 1, 2, 4, 8, 16, 32, 64 };
      	
		int size = list.length;
      	int right = size;
      	int left = 0;
      	while (left + 1 != right) {
          if (n >= (list[(right + left) / 2])) left = (right + left) / 2;
          else right = (right + left) / 2;
        }
      	System.out.println(list[left]);
    }
}

Measured memory_bytes: 23764
n = int(input())
S = {}
for _ in range(n):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

m = int(input())
T = {}
for _ in range(m):
    t = input()
    if t in T:
        T[t] += 1
    else:
        T[t] = 1

ans = 0
for k in S.keys():
    if k in T:
        ans = max(ans, S[k]-T[k])
    else:
        ans = max(ans, S[k])
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int main(){
  int N,Y;
  cin >>N >>Y;
  bool ans =true;
  for(int i =0; i<=N ;i++){
    for(int j=0; j <=N; j++){
      if( N-i-j>=0 &&1000*N + 9000*i +4000*j ==Y){
        cout<< i <<" " << j << " "<<N-i-j <<endl;
        ans =false;
        
      }
      if(ans){
        continue;
      }
      else{
        break;
      }
      
    }
    if(ans){
      continue;
    }
    else{
        break;
    }  
  }
  if(ans){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, i, h[101], s, j, x;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&h[i]);

  x=1;
  for(i=1;i<n;i++){
        s=0;
        for(j=i-1;j>=0;j--)
                if(h[j]<=h[i]) {
                        s++;
                }
        if(s==i) x++;
        }
  printf("%d\n",x);
  return 0;
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long A, long long B) {
  cout << (A-1) * (B-1) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long A;
  std::cin >> A;
  long long B;
  std::cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplit();
            YESOrNO(ABC[0].Last() == ABC[1].First() && ABC[1].Last() == ABC[2].First());
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e)
        {
            if (e) Println("YES");
            else Println("NO");
        }

        static void YesOrNo(bool e)
        {
            if (e) Println("Yes");
            else Println("No");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main(){
	IOS;
	int x, a;
	cin >> x>>a;
	if (x>=a)cout<<10;
	else cout<<0;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <memory.h>
#include <time.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cassert>
#include <string>
#include <cstring>
using namespace std;
#define oo 2000000000
#define mod 1000000007
const int N = 100010;
int n, x, arr[N];
int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	sort(arr, arr + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x < arr[i]) break;
		x -= arr[i];
		ans++;
	}
	if (ans == n && x != 0)
		ans = n - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
a = 0
for i in range(n):
    if i == 0:
        a += ls[i]
    else:
        a += (2 ** (i - 1)) * ls[i]

b = a / (2 ** (n - 1))
print(b)


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

int main(){
    int N,C;
    cin>>N>>C;
    vector<vector<int>>d(C,vector<int>(C)),c(N,vector<int>(N));
    rep(i,C)rep(j,C)cin>>d[i][j];
    rep(i,N)rep(j,N){
        cin>>c[i][j];
        c[i][j]--;
    }
    int ans=1001001001;
    vector<vector<int>>sum(C,vector<int>(3));
    rep(i,C){
        int cnt1=0,cnt2=0,cnt3=0;
        rep(a,N)rep(b,N){
            if((a+b)%3==0)cnt1+=d[c[a][b]][i];
            if((a+b)%3==1)cnt2+=d[c[a][b]][i];
            if((a+b)%3==2)cnt3+=d[c[a][b]][i];
        }
        sum[i][0]=cnt1;
        sum[i][1]=cnt2;
        sum[i][2]=cnt3;
    }
    rep(i,C)rep(j,C)rep(k,C){
        if(i==j||j==k||k==i)continue;
        int cnt=sum[i][0]+sum[j][1]+sum[k][2];
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	vector<int> a(5);
	rep(i, 5) cin >> a[i];
	int k;
	cin >> k;

	int jj = 0;

	rep(i,4)
		for (int j = i + 1; j < 5; ++j) {
			if (abs(a[j] - a[i]) > k) { ++jj; }
		}
	if (jj > 0) { cout << ":(" << endl; }
	else { cout << "Yay!" << endl; }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> A, vector<ll> B) {
  ll c = 0;
  for (int i = N - 1; i >= 0; --i) {
    ll a = A[i] + c;
    ll r = (-a % B[i] + B[i]) % B[i];
    c += r;
  }
  cout << c << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	vector<ll> B(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	  scanf("%lld", &B[i]);
	}
	solve(N, A, B);
	return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    string N;
    cin >> N;
    char fin = N[N.size() -1];
    if(fin == '3') puts("bon");
    else if(fin == '0' or fin == '1' or fin == '6' or fin == '8') puts("pon");
    else puts("hon");
}


Measured memory_bytes: 3568
# coding: utf-8
n,k = map(int,input().split())
a_num = [0 for _ in range(10**5+1)]
for i in range(n):
    a,b = map(int,input().split())
    a_num[a] += b

for i in range(len(a_num)):
    k -= a_num[i]
    if k <= 0:
        print(i)
        exit()

Measured memory_bytes: 5928
import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

Measured memory_bytes: 15700
#include <bits/stdc++.h>
using namespace std;
const int N=2020;
const int mod=1e9+7;
int inv[N*N],fac[N*N];
int f[N][N];
int n, k;
inline int C(int n, int m) {return 1ll * fac[m] * inv[n] % mod * inv[m - n] % mod;}
inline int power(int a, int b) 
{
    a %= mod; int ans = 1;
    while(b) {
        if(b & 1) ans = 1ll * ans * a % mod;
        a = 1ll * a * a % mod; b >>= 1;
    }
    return ans%mod;
}
int main() {
    scanf("%d%d", &n, &k);
    if(k==1) {puts("1"); return 0;}
    fac[0] = 1;
    for(int i = 1; i < N * N; ++i) 
        fac[i] = 1ll * fac[i - 1] * i % mod;
    for(int i = 0; i < N * N; ++i) 
        inv[i] = power(fac[i], mod - 2);
	f[0][0]=1;
    for(int i = 1; i <= n; ++i)
        for(int j = 0; j <= i; ++j) {
            f[i][j] = f[i - 1][j];
			if(!j) continue;
            (f[i][j] += 1ll * (n - j + 1) * f[i][j - 1] % mod * C(k - 2, n * k - i - (j - 1) * (k - 1) - 1) % mod) %= mod;
            f[i][j]=(f[i][j]+mod)%mod;
        }
    printf("%d\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, indMin, indMax, znak[N], tab[N], res, indPlu, lastPlu, lastMin, act, i;

int main() {
scanf("%d", &n);
indMin = 0;
indMax = 0;
for (i=0;i<n;i++) {
	scanf("%d", &tab[i]);
	if (tab[i] < tab[indMin]) indMin = i;
	if (tab[i] > tab[indMax]) indMax = i;
	if (tab[i] >= 0) znak[i] = 1; else znak[i] = -1;
}
if (tab[indMin] >= 0) znak[indMin] = -1;
if (tab[indMax] < 0) znak[indMax] = 1;
res = 0;
for (i=0;i<n;i++) res += znak[i] * tab[i];
printf("%d\n", res);
for (i=0;i<n;i++) if (znak[i] == 1) {
	indPlu = i;
	break;
}
for (i=0;i<n;i++) if (znak[i] == -1) {
	indMin = i;
	break;
}
for (i=n-1;i>=0;i--) if (znak[i] == 1) {
	lastPlu = i;
	break;
}
for (i=n-1;i>=0;i--) if (znak[i] == -1) {
	lastMin = i;
	break;
}
if (indMin == lastMin && indPlu < lastPlu) {
	printf("%d %d\n", tab[indMin], tab[indPlu]);
	act = tab[indMin] - tab[indPlu];
} else {
	printf("%d %d\n", tab[indPlu], tab[indMin]);
	act = tab[indPlu] - tab[indMin];
}
while(indMin < lastMin) {
	while (true) {
		indMin++;
		if (znak[indMin] == -1) break;
	}
	if (indMin == lastMin && indPlu < lastPlu) {
		printf("%d %d\n", tab[indMin], act);
		act = tab[indMin] - act;
	} else {
		printf("%d %d\n", act, tab[indMin]);
		act = act - tab[indMin];
	}
}
while (indPlu < lastPlu) {
	while (true) {
		indPlu++;
		if (znak[indPlu] == 1) break;
	}
	if (indPlu == lastPlu) {
		printf("%d %d\n", tab[indPlu], act);
	} else {
		printf("%d %d\n", act, tab[indPlu]);
		act = act - tab[indPlu];
	}
}
return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <fstream>
#include<iomanip>
#define endl "\n"
#define ll long long
#define countBit1(x) __builtin_popcountll(x)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l, r , x;
    cin >> l >> r >> x;
    int res= 0;
    for(int i = l; i <= r; i++)
    {
        i % x == 0 ? ++res : 0;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
//繰り返し二乗法
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
//xCy
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int f(int x) {
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
struct edge { int to, cost; };
int n;
int a[114514];
int memo[3];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 1;
	for (int i = 0; i < n; i++) {
		int p = 0;
		for (int j = 0; j < 3; j++) {
			if (memo[j] == a[i])p++;
		}
		ans *= p;
		ans %= mod;
		for (int j = 0; j < 3; j++) {
			if (memo[j] == a[i]) {
				memo[j]++;
				break;
			}
		}
		p = 0;
	}
	cout << ans % mod << endl;
	ggr
}


Measured memory_bytes: 1024
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/10/ITP1_10_B
#include <iostream>
#include <cmath>
#include <bits/stdc++.h> //M_PIを使うためにインクルード

int main()
{
    double a, b, c, C;
    double S, L, h;

    std::cin >> a >> b >> C;
    // c^2=a^2 + b^2 - a*b*cosC
    S = a * b * sin(C * M_PI / 180.) / 2.;
    c = sqrt(a * a + b * b - 2. * a * b * cos(C * M_PI / 180.));
    L = a + b + c;
    h = b * sin(C * M_PI / 180.);

    // printf("%.5lf %.5lf %.5lf %.5lf\n", a, b, C, c);
    // printf("%f\n%f\n%f\n", S, L, h);
    printf("%.9f\n%.9f\n%.9f\n", S, L, h);
}


Measured memory_bytes: 3436
#include <stdio.h>

int main () {
    char S[4];
    scanf("%s", S);
    char prev = 0;
    int i = 0;
    while(S[i]) {
        if (prev == S[i]) {
            printf("Bad\n");
            return 0;
        }
        prev = S[i];
        i++;
    }
    printf("Good\n");
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  int r0,w0,c,r;
  while(true){
      cin>>r0>>w0>>c>>r;
      if(r==0) break;
      if(r0>=c*w0) cout<<0<<endl;
      else{
          cout<<((c*w0-r0)-1)/r+1<<endl;
      }
  }
  return 0;
}

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

int main(void) {
	int A, B;
	string s;
	cin >> A >> B >> s;

	if (s[A] != '-') {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (i == A) { continue; }
		if (!('0' <= s[i] && s[i] <= '9')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
coordinate = list(map(int, input().split()))
result = 0
resultl = 0
 
for j in range(N):
    result += (1-coordinate[j])**2
    
for i in range(1,101):
    for k in range(N):
        resultl += (i-coordinate[k])**2
 
    if resultl < result:
        result = resultl
    resultl = 0
    
print(result)

Measured memory_bytes: 3060
import Control.Monad
import Control.Monad.ST
import Data.List
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Array.Unboxed
import Data.Array.ST

import qualified Data.ByteString.Char8 as B

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseChar :: Parser Char
parseChar = StateT $ \bs ->
    case B.span (not.isSpace) $ B.dropWhile isSpace bs of
        (c,bs') -> Just(B.head c,bs')

parseInt3 :: Parser (Int,Int,Char)
parseInt3 = liftM3 (,,) parseInt parseInt parseChar

main = do
    (n:k:_)<-map read.words<$>getLine::IO[Int]
    xycs<-unfoldr (runStateT parseInt3) <$> B.getContents::IO[(Int,Int,Char)]
    --
    let sm = mk k xycs
    print $ maximum ([cal1 sm k i j | i<-[0..k-1], j<-[0..k-1]] ++ [cal2 sm k i j | i<-[0..k-1], j<-[0..k-1]])
--
mk :: Int->[(Int,Int,Char)]->UArray (Int,Int) Int
mk k xycs = runSTUArray $ do
    ar <- newArray ((0,0),(k*2-1,k*2-1)) 0::ST s (STUArray s (Int,Int) Int)
    forM_ xycs $ \(x,y,c) -> do
        let xx = flip mod (k*2) $ if c=='B' then x+k else x
        let yy = y `mod` (k*2)
        writeArray ar (xx,yy) =<< (+1) <$> readArray ar (xx,yy)
    forM_ [(i,j)|i<-[0..k*2-1],j<-[1..k*2-1]] $ \(i,j) ->
        writeArray ar (i,j) =<< (+) <$> readArray ar (i,j) <*> readArray ar (i,j-1)
    forM_ [(i,j)|i<-[1..k*2-1],j<-[0..k*2-1]] $ \(i,j) ->
        writeArray ar (i,j) =<< (+) <$> readArray ar (i,j) <*> readArray ar (i-1,j)
    return ar
--
cal1 :: UArray (Int,Int) Int -> Int -> Int -> Int -> Int
cal1 sm k i j = r1 - r2 - r3 + r4 + r5 + r6*2 - r7*2 - r8*2 + r9*2
    where
        r1 = sm ! (k*2-1, k*2-1)
        r2 = sm ! (k*2-1, j+k-1)
        r3 = sm ! (i+k-1, k*2-1)
        r4 = if j==0 then 0 else sm ! (k*2-1, j-1)
        r5 = if i==0 then 0 else sm ! (i-1, k*2-1)
        r6 = sm ! (i+k-1, j+k-1)
        r7 = if i==0 then 0 else sm ! (i-1, j+k-1)
        r8 = if j==0 then 0 else sm ! (i+k-1, j-1)
        r9 = if i==0 || j==0 then 0 else sm ! (i-1, j-1)

cal2 :: UArray (Int,Int) Int -> Int -> Int -> Int -> Int
cal2 sm k i j = r2 + r3 - r4 - r5 - r6*2 + r7*2 + r8*2 - r9*2
    where
        r2 = sm ! (k*2-1, j+k-1)
        r3 = sm ! (i+k-1, k*2-1)
        r4 = if j==0 then 0 else sm ! (k*2-1, j-1)
        r5 = if i==0 then 0 else sm ! (i-1, k*2-1)
        r6 = sm ! (i+k-1, j+k-1)
        r7 = if i==0 then 0 else sm ! (i-1, j+k-1)
        r8 = if j==0 then 0 else sm ! (i+k-1, j-1)
        r9 = if i==0 || j==0 then 0 else sm ! (i-1, j-1)


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

int main() {
	int N;
	cin >> N;
	int A_max = 0;
	int last_B = 0;
	for (int i = 0; i < N; i++) {
		int a, b = 0;
		cin >> a >> b;
		if (a > A_max) {
			A_max = a;
			last_B = b;
		}
	}
	cout << A_max + last_B << endl;
}

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

#define ntest 0

using namespace std;
const int mod = 1e9 + 7;
int s;
int dp[2005];
void solve() {
    cin >> s;
    dp[0] = 1;
    for (int i = 3; i <= s; ++i) {
        for (int j = 3; j <= i; ++j) dp[i] = (dp[i] + dp[i-j]) % mod;
    }
    cout << dp[s];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 600011

int n, k, i, l, r, inv;
char s[maxN];
int act[maxN];

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%d\n%s", &n, &k, s + 1);
    for (i = 1; i <= n; i++) act[i] = s[i] - 'A';
    l = 1; r = n; inv = 0;

    while (l <= n + 2 && k > 0) {
        k--;

        if ((act[l] ^ inv) == 0) {
            act[l] ^= 1;
        } else {
            l++; r++;
            inv ^= 1;
            act[r] = inv;
        }
    }


    if (n % 2 == 1)
        act[l] ^= k & 1;

    for (i = l; i <= r; i++)
        printf("%c", 'A' + (act[i] ^ inv));



    return 0;
}


Measured memory_bytes: 2176
N=int(input())
if N%10==3:
    print('bon')
if N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print('pon')
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print('hon')

Measured memory_bytes: 9124
#include <cstdio>
#include <algorithm>
using namespace std;
long long d,n,m,place[100005],tre[100005],sum=0;
int main(){
	while(1){
	scanf("%lld %lld %lld",&d,&n,&m);
	if(d==0){ break;}
	place[0]=0;
	for(int i=1;i<n;i++){
		scanf("%lld",&place[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%lld",&tre[i]);
	}
	sort(place,place+n);
	for(int i=0;i<m;i++){
		int qw=upper_bound(place,place+n,tre[i])-place;
		if(qw==n){
			sum+=min(tre[i]-place[n-1],d-tre[i]);
		}else{
			sum+=min(tre[i]-place[qw-1],place[qw]-tre[i]);
		}
	}
	printf("%d\n",sum);
	sum=0;
	}
return 0;
}

Measured memory_bytes: 1904
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a,b,c,d=map(int,input().split())
x=int(b//c)-int((a-1)//c) +int(b//d) -int((a-1)//d) -int(b//lcm(c,d)) + int((a-1)//lcm(c,d))
print(b-a+1-x)

Measured memory_bytes: 5048
#include<stdio.h>

int main()
{
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

	if (r <= x && x <= W - r) {
		if (r <= y && y <= H - r)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else printf("No\n");
		
	return 0;

}

Measured memory_bytes: 584
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    //cout << "Hello world" << endl;
    int N,W;
    cin >> N >> W;
    VLL W_vec;
    VLL V_vec;
    REP(i,N){
        int w,v;
        cin >> w >> v;
        W_vec.PB(w);
        V_vec.PB(v);
    }
    VLL dp_old;
    REP(w,W_vec[0]){
        dp_old.PB(0);
    }
    CREP(w,W_vec[0],W){
        dp_old.PB(V_vec[0]);
    }
    VLL dp_new = dp_old;
    CREP(i,1,N-1){
        CREP(w,0,W){
            if (w-W_vec[i] < 0){
                dp_new[w] = dp_old[w];
                continue;
            }
            dp_new[w]=max(dp_old[w- W_vec[i]]+V_vec[i],dp_old[w]);
        }
        dp_old = dp_new;
    }
    cout << dp_new[W]<< endl;
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int r;
	cin >> r;
	cout << r*r << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

int n, ans, ave = 0;
vector<int> a;

int f(int x) {
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += (a[i] - x)*(a[i] - x);
	return ans;
}

int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave = ave / n;
	int b[3];
	b[0] = f(ave - 1);
	b[1] = f(ave);
	b[2] = f(ave + 1);
	ans = min(b[0], b[1]);
	ans = min(ans, b[2]);
	cout << ans << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
  
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    long n = in.readLong();
	    long m = in.readLong();
	    long ans = 0; 
	    if((2*n < m)) {
	    	m = m - 2*n; 
	    	ans += n; 
	    	ans += m/4; 
	    }
	    else ans = m/2; 
	    System.out.println(ans); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

long long pow2(long long x, long long n, int mod=0) {
  if (n == 0) return 1;
  if (mod) {
    if (n & 1) return x * pow2(x, n - 1, mod) % mod;
    long long y = pow2(x, n / 2, mod);
    return y * y % mod;
  } else {
    if (n & 1) return x * pow2(x, n - 1);
    long long y = pow2(x, n / 2);
    return y * y;
  }
}

int MOD = 1e9 + 7;
int U = 1e5;
vector<unsigned long long> fac(U + 1);
vector<unsigned long long> ifac(U + 1);
vector<unsigned long long> n_choose(U + 1);
void make_tables(int n=1e9, int p=MOD) {
  fac[0] = 1;
  for (int i = 0; i < U; i++) fac[i+1] = fac[i] * (i + 1) % p;
  ifac[U] = pow2(fac[U], p - 2, p);
  for (int i = U; i > 0; i--) ifac[i-1] = fac[i] * i % p;
  n_choose[0] = 1;
  for (int i = 0; i < U; i++) n_choose[i+1] = n_choose[i] * (n - i) % p;
  for (int i = 0; i < U + 1; i++) n_choose[i] = n_choose[i] * ifac[i] % p;
}

int mod_choose(int n, int r, int p=MOD) {
  if (r > n || r < 0) return 0;
  return fac[n] * ifac[r] % p * ifac[n-r] % p;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  make_tables();
  int n, m;
  cin >> n >> m;
  int ans;
  int d = abs(n - m);
  if (d >= 2) ans = 0;
  else if (d == 1) ans = fac[n] * fac[m] % MOD;
  else ans = fac[n] * fac[m] * 2 % MOD;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] count = line.split(" ");
		int a = Integer.parseInt(count[0]);
		int b = Integer.parseInt(count[1]);
		int c = Integer.parseInt(count[2]);

		int n = 0;

		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				n++;
			}
		}
		System.out.println(n);

	}

}


Measured memory_bytes: 26224