akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> a(X), b(Y), c(Z);
    for (ll &x : a) {
        cin >> x;
    }
    for (ll &x : b) {
        cin >> x;
    }
    for (ll &x : c) {
        cin >> x;
    }
    sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); sort(c.rbegin(), c.rend());
    vector<ll> sums;
    for (ll x : a) {
        for (ll y : b) {
            sums.push_back(x + y);
        }
    }
    sort(sums.rbegin(), sums.rend());
    vector<ll> finalSums;
    for (int i = 0; i < min(K, SZ(sums)); i++) {
        for (ll x : c) {
            finalSums.push_back(sums[i] + x);
        }
    }
    sort(finalSums.rbegin(), finalSums.rend());
    for (int i = 0; i < K; i++) {
        cout << finalSums[i] << "\n";
    }
}


Measured memory_bytes: 42984
s=list(input())
ans='AC'
a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s[0]=='A' and s[2:-1].count('C')==1 and s[1]!='C' and s[-1]!='C':
    s.remove('C')
    del s[0]
    for i in range(len(s)):
        if s[i] not in a:
            ans='WA'
            break
else:
    ans='WA'
print(ans)

Measured memory_bytes: 3188
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [n_m, ...rest] = stdin.split('\n')

const [N, M] = n_m.split(' ').map(Number)

const ab = rest.filter(e => e).map(e => e.split(' ').map(Number))

const sortedAB = ab.sort((p, c) => p[0] - c[0])

let i = 0
let cost = 0
let reqCount = M

while(1){
  if(reqCount > sortedAB[i][1]){
    reqCount -= sortedAB[i][1]
    cost += sortedAB[i][0] * sortedAB[i][1]
  } else {
    cost += sortedAB[i][0] * reqCount
    break
  }
  i++
}

console.log(cost)

Measured memory_bytes: 52212
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 2 * 1e5 + 2;

int n, k;
int h[N];
map<int, int> m;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> n;
  rep1(i,1,n) cin >> h[i];
  m[1 + h[1]]++;
  int res = 0;
  rep1(i,2,n){
    int x = i - h[i];
    res += m[x];
    m[i + h[i]]++;
  }
  cout << res << '\n';


	return 0;
}






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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

const int D = 80*160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;

int a[100][100];
bs dp[90][90];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  rep(i, 0, h) {
    rep(j, 0, w) {
      int x;
      cin >> x;
      a[i][j] = x;
    }
  }
  rep(i, 0, h) {
    rep(j, 0, w) {
      int y;
      cin >> y;
      a[i][j] = abs(a[i][j] - y);
    }
  }

  dp[0][0][D-a[0][0]] = 1;
  dp[0][0][D+a[0][0]] = 1;
  rep(i, 0, h) {
    rep(j, 0, w) {
      if (i) {
        dp[i][j] |= dp[i-1][j] << a[i][j];
        dp[i][j] |= dp[i-1][j] >> a[i][j];
      }
      if (j) {
        dp[i][j] |= dp[i][j-1] << a[i][j];
        dp[i][j] |= dp[i][j-1] >> a[i][j];
      }
    }
  }

  int ans = D2;
  rep(i, 0, D2) {
    if (dp[h-1][w-1][i]) {
      ans = min(ans, abs(i - D));
    }
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 24704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int times = Integer.parseInt(sc.nextLine());
		while (0 < times) {
			compare(sc, times);
			times = Integer.parseInt(sc.nextLine());
		}
	}
	
	private static void compare(Scanner sc, int times) {
		int a_total = 0, b_total = 0;
		int counter = 1;
		while (counter <= times) {
			String[] line = sc.nextLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			if (a > b) { a_total += a + b; }
			if (a < b) { b_total += a + b; }
			if (a == b) {
				a_total += a;
				b_total += b;
			}
			counter++;
 		}
		System.out.println(a_total + " " + b_total);
	}
}

Measured memory_bytes: 65380
import java.util.*;

public class Main{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        int N = Integer.valueOf(str);

        int sum = 0;
        for(int i=0;i<str.length();i++){
            sum += str.charAt(i) - '0';
        }

        System.out.println(N%sum==0?"Yes":"No");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  int YUNI = 0;
  cin >> A >> B >> C >> D;
  
  while(YUNI < 100){
    C -= B;
    A -= D;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    else if(A <= 0){
      cout << "No" << endl;
      break;
    }
    YUNI ++;
  }
}


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

int main()
{
    int n;
    cin>>n;
    int *arr = new int[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int a = 1,b = 0,f=0;
    for(int i=0;i<n;i++){
        if(a!= arr[i]){
            b++;
        }
        else{
            f=1;
            a++;
        }
    }
    if(f!=0)
        cout<<b;
    else
        cout<<"-1";
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <math.h>
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  string s, t; cin >> s >> t;

  s += t;
  i64 a = stoi(s);

  i64 p = sqrt(a);
  if (p*p == a) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}



Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())

tmp = A.pop(0)

for _ in range(500):
    if tmp == "a":
        if not A:
            print("A")
            exit(0)
        tmp = A.pop(0)
    elif tmp == "b":
        if not B:
            print("B")
            exit(0)
        tmp = B.pop(0)
    else:
        if not C:
            print("C")
            exit(0)
        tmp = C.pop(0)

Measured memory_bytes: 61932
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
string ans = "";
ll a[35],s=0,n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    if (!n) ans="0";
    else {
        while (abs(n)>0) {
            if ((abs(n))&1) {
                ans += '1';
                n--;
            }
            else ans += '0';
            n /= (ll)(-2);
        }
        reverse(ans.begin(),ans.end());
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 15
ll dp2[1<<N], dp[1<<N][N];
ll n, m, g[N][N];

int main(){
	cin>>n>>m;
	ll sum = 0;
	rep(i, m){
		int a, b, c;
		cin>>a>>b>>c; a--; b--;
		g[a][b] = g[b][a] = c;
		sum += c;
	}
	dp2[0] = 0;
	rep(i, 1<<n){
		rep(j, n){
			if((i>>j)&1) continue;
			ll w = 0;
			rep(k, n){
				if((i>>k)&1) w += g[j][k];
			}
			dp2[i|(1<<j)] = dp2[i]+w;
		}
	}
	rep(i, n) fill(dp[i], dp[i]+(1<<n), -1e16);
	rep(i, 1<<n){
		if((i&1)&&!((i>>(n-1))&1)){
			dp[i][0] = dp2[i];
		}
	}
	for(int i = 1; i < 1<<n; i++){
		if(!(i&1)) continue;
		for(int j = (i-1)&i; j > 0; j=(j-1)&i){
			if(!(j&1)) continue;
			if((j>>(n-1))&1) continue;
			int j2 = i&(~j);
			if(((j2>>(n-1))&1)&&i!=(1<<n)-1) continue;
			rep(k, n){
				if(!((j>>k)&1)) continue;
				rep(k2, n){
					if(!((j2>>k2)&1)) continue;
					if(g[k][k2]) chmax(dp[i][k2], dp[j][k]+dp2[j2]+g[k][k2]);
				}
			}
		}
	}
	cout<<sum-dp[(1<<n)-1][n-1]<<endl;
	return 0;
}


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

int main()
{
	int N;
	int T, X, Y;
	int x = 0, y = 0, t = 0;
	bool flag = true;
	cin >> N;
	
	for ( int i = 0; i < N; i++ ) {
		cin >> T >> X >> Y;
		int dist = abs(X - x) + abs(Y - y);
		if ( dist <= T - t && (((T - t) ^ dist) & 1) == 0 ) {
			t = T, x = X, y = Y;
		} else {
			flag = false;
		}
	}
	if ( flag ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
x1, y1, x2, y2 = map(int,input().split())

x3 = x2 + y1 - y2
y3 = y2 - (x1 - x2)
x4 = x1 + y1 - y2
y4 = y1 - (x1 - x2)

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int dp[100010];
vector<vector<int> > graph;

int REC(int n) {
   if (dp[n]!=-1) return dp[n];
   eprintf("doint rec: %d\n", n);
   int res = 0;
   REP(i, SZ(graph[n])) {
      chmax(res, REC(graph[n][i])+1);
   }

   return dp[n] = res;
}

int main()
{
   eprintf("start");
   int N, M;
   cin >> N >> M;
   graph.assign(N, vector<int>());
   int x, y;
   REP(i, M) {
      cin >> x >> y;
      graph[x-1].pb(y-1);
   }
   REP(i, N) dp[i] = -1;
   int ans = 0;
   REP(i, N) {
      REC(i);
      chmax(ans, REC(i));
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>

using namespace std;

constexpr static int MAXN = 2002;

int n;
int a[MAXN];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);

    int64_t total = 0;
    for (int i = 0; i < n; i++)
        total += a[i];

    bitset <2000002> b;
    b[0] = true;
    for (int i = 0; i < n; i++)
        b |= (b << a[i]);

    int64_t val = 0;
    for (int j = total / 2; j >= 0; j--)
        if (b[j]) {
            val = j;
            break;
        }
    cout << total - val << endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}



int main(){
  ll n; cin >> n;
  
  set<string> gacha;
  
  rep(i,n){
    string s; cin >> s;
    gacha.insert(s);
  }
  
  cout << gacha.size() << endl;

  
}

Measured memory_bytes: 19140
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<long long> a(n),b(n);
    long long at=0, bt=0;
    for(auto& i:a)cin>>i,at+=i;
    for(auto&i:b)cin>>i, bt+=i;
    
  
    long long bsurp=0;
    for(int i=0; i<n; i++){
        if(b[i]<a[i]) bsurp+=(a[i]-b[i]);
    }
    
    //cout<<bsurp<<endl;
    
    for(int i=0; i<n; i++){
        if(a[i]<b[i]){
            bsurp-=(b[i]-a[i])/2;
        }
    }
    cout<<(bsurp>0?"No":"Yes");
    
    
    
    
  
    return 0;
}

Measured memory_bytes: 384
# PDF解説
N = int(input())
A = [int(a) for a in input().split()]

import fractions

L = []
# [gcd(0), gcd(0, A[0]), ... , gcd(0, A[0], A[1], ..., A[N-2])]
R = []
# [gcd(A[1], A[2], ... , A[N-1], 0), gcd(A[2], A[3], ... , A[N-1], 0), ... , gcd(0)]

L.append(0)
for i in range(0, N-1, 1):
  l = fractions.gcd(L[-1], A[i])
  L.append(l)

R.append(0)
for j in range(N-1, 0, -1):
  r = fractions.gcd(R[-1], A[j])
  R.append(r)
R.reverse()

ans = 0
for n in range(N):
  lr = fractions.gcd(L[n], R[n])
  ans = max(ans, lr)

print(ans)

Measured memory_bytes: 14436
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '7') {
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(5e5+5)

void solve()
{
    ll n;
    cin>>n;

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

    sort(a,a+n);
    sort(b,b+n);

    if(n&1)
    {
        ll minm = a[n/2] , maxm = b[n/2];
        cout<<maxm-minm+1;
    }
    else
    {
        int f = n/2 , s = n/2-1;
        ll minm = a[f]+a[s] , maxm = b[f]+b[s];
        double mn = double(double(minm)/2);
        double mx = double(double(maxm)/2);
        double ans = (mx-mn)*2 + 1;
        cout<<(ll)(ans);

    }
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

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

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

int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0; i<n; i++) cin >> h[i];

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    int maxd = 0, temp = 0;
    for(int i=n-1; i>0; i--){
        if(h[i-1] >= h[i]) temp++;
        else{
            maxd = max(maxd, temp);
            temp = 0;
        }
    }
    if (temp != 0) maxd = max(maxd, temp);
    cout << maxd << endl;
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';				

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const int N = 3000;
int n;
double dp[N][N];
bool vis[N][N];
double p[N];

double solve(int i,int h){

	if(i == n){
		return (1.0) * (h > n / 2);
	}
	if(vis[i][h])
		return dp[i][h];

	dp[i][h] = solve(i + 1, h + 1) * p[i] + solve(i + 1, h) * (1.0 - p[i]);
	vis[i][h] = 1;
	return dp[i][h];

}

int main(){

	memset(dp,0,sizeof dp);
	memset(vis,0,sizeof vis);
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> p[i];
	}
	decimal_digits;
	cout << solve(0,0) << '\n';
}

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

int main(){
  int n ,m;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    pair< char ,string > set[n];
    
    for( int i=0 ; i<n ; i++ ){ // 文字のセットの入力
      cin >> set[i].first >> set[i].second;
    }
    
    cin >> m;
    char c;
    
    for( int i=0 ; i<m ; i++ ){
      cin >> c;
      for( int j=0 ; j<n ; j++ ){
	if( c == set[j].first ){
	  cout << set[j].second;
	  break;
	}
	else if( j == n-1 ){
	  cout << c ;
	}
      }
    }
    cout << endl;
  }
}
    

Measured memory_bytes: 1192
s = input()
nums = [int(v) for v in s]

l = len(s)

ans = 0
for i in range(1 << (l-1)):
    tmp = s[0]
    for j in range(l-1):
        if i & 1 << j:
            tmp += '+'+s[j+1]
        else:
            tmp += s[j+1]
    ans += eval(tmp)
print(ans)


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

#define nl '\n'
#define op ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void func()
{
  int aa;
  cin>>aa;
  if(aa==0)
    cout<<1<<nl;
  else
    cout<<0<<nl;
}

int main()
{
    op;
    func();
    return 0;
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(),a.end());
  if(a.at(0) == a.at(1)){
    cout << a.at(2) << endl;
  }else{
    cout << a.at(0) << endl;
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> abc = new ArrayList<>();
        abc.add(sc.nextInt());
        abc.add(sc.nextInt());
        abc.add(sc.nextInt());
        Collections.sort(abc);

        int count = 0;
        int diff21 = abc.get(2) - abc.get(1);
        abc.set(0, abc.get(0) + diff21);
        abc.set(1, abc.get(1) + diff21);
        count += diff21;

        int diff10 = abc.get(1) - abc.get(0);
        if (diff10 % 2 == 0) {
            count += diff10 / 2;
        } else {
            count += (diff10 + 1) / 2 + 1;
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,N;
    cin >> N >> A >> B;
    auto ikkai=A+B;
    auto n = N / ikkai;//何回割れるか試す
    auto m = N % ikkai;//最後に割ったときのあまり
    auto a = min(A,m);
    cout << A*n+a;



    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
using namespace std;
lli t,n,u,x,y,m;
const lli N = 100001;
int main(){
    fast
     t=1;
   // cin>>t;
    while(t--){
        cin>>n;
        vl a(n),b(n);
        lli ans=0;
        for(int i=0;i<n;++i){
            cin>>x>>y;
            a[i]=x+y;
            b[i]=x-y;
        }
        sort(all(b));
        sort(all(a));
        ans=max(abs(a[0]-a[n-1]),abs(b[0]-b[n-1]));
        cout<<ans<<endl;
        
    }
}

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

using namespace std;

int main()
{
    map <pair <int, int>, int> A;
    vector <long long> res(10);
    int h, w, n;
    cin >> h >> w >> n;
    res[0] = (long long) (h - 2) * (w - 2);

    for (int x = 0; x < n; x++) {
        int a, b;
        cin >> a >> b;
        
        for (int i = max(1, a - 2); i <= min(a, h - 2); i++) {
            for (int j = max(1, b - 2); j <= min(b, w - 2); j++) {
                res[A[make_pair(i, j)]]--;
                A[make_pair(i, j)]++;
                res[A[make_pair(i, j)]]++;
            }
        }
    }
    
    for (int i = 0; i < 10; i++) {
        cout << res[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
#define int long long
// iteration and input/output stream
#define rep(i,a,b) for(int i = a;i<=b;i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
 
typedef long long ll; // 64 bit integer
typedef unsigned long long ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
 
vi h;
vi dp;
int n,k;

int f(int i)
{
    if(i<=0)return INT_MAX;
    if(dp[i]!=-1) return dp[i];
    if(i==1)
    {
        return dp[i] = 0;
    }
    else
    {
        // return dp[i] = min(abs(h[i]-h[i-1])+f(i-1),abs(h[i]-h[i-2])+f(i-2));
        int cur = INT_MAX;
        for (int ptr = i-1; ptr>=i-k ; ptr--)
        {
            if(ptr<1) break;
            cur = min(cur,abs(h[i]-h[ptr])+f(ptr)); 
        }
        return dp[i] = cur;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    cin>>n>>k;
    dp.resize(n+1,-1);
    h.resize(n+1,0);
    for (int i = 1; i <= n; i++)
    {
        cin>>h[i];
    }
    cout<<f(n)<<"\n";
    return 0;
}

Measured memory_bytes: 11040
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

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

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

int main() {
  int N;
  RI(N);
  vector<int> v;
  REP(i, 2 * N) {
    int x;
    RI(x);
    v.PB(x);
  }
  sort(ALL(v));
  ll ans = 0;
  REP(i, N) ans += min(v[i<<1], v[i<<1|1]);
  PL(ans);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	//char ch[10];
	//scanf(" %[^\n]", ch);
	int a, b;
	a=b=0;
	scanf("%d %d", &a, &b);
	printf("%d\n", a*b);
	return 0;
}


Measured memory_bytes: 3836
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
Scanner as = new Scanner(System.in);
		
		int n=as.nextInt();
		int i,j,k;
		int b,f,r,v;
		
		int house[][][];
		house = new int[4][3][10];
		String str;
		
		for(i=0;i<n;i++){
			
			b=as.nextInt();
			f=as.nextInt();
			r=as.nextInt();
			v=as.nextInt();
			house[b-1][f-1][r-1]=house[b-1][f-1][r-1]+v;
			
		}
		
		for(i=0;i<4;i++){
			for(j=0;j<3;j++){
				for(k=0;k<10;k++){
					str=" "+house[i][j][k];
					System.out.print(str);
				}
				System.out.println();
			}
			if(i != 3){
				str="####################";
				System.out.println(str);
			}
		}

	}

}

Measured memory_bytes: 29352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

// 素数判定O(√n)
bool is_prime(int n){
for(int i=2;i*i<=n;i++){
	if(n%i==0) return false;
}
return n!=1; //1の場合は除外
}

// 約数の列挙O(√n)
vector<ll> divisor(int n){
	vector<ll> res;
	for(ll i=1LL;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i) res.push_back(n/i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

// 素因数分解O(√n)
map<int,int> prime_factor(int n){
	map<int,int> res;
	for(int i=2;i*i<=n;i++){
		while(n%i==0){
			++res[i];
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	return res;
}

int prime[100010];     // i番目の素数
bool isprime[100010];   // isprime[i]がtrueならiは素数

// n以下の素数の数を返す
int eratos(int n){
	int p=0;
	for(int i=0;i<=n;i++) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=2;i<=n;i++){
		if(isprime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i) isprime[j]=false;
		}
	}
	return p;
}


int main(){
	int x;
	cin>>x;
	while(1){
		if(is_prime(x)){
			cout<<x<<endl;
			return 0;
		}
		x++;
	}
	
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n); 
    int per = 1;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        per *= i + 1;
    }

    double distance = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            distance += per / n * 2 * sqrt(pow(x[i] - x [j], 2) + pow(y[i] - y[j], 2));
        }
    }

    printf("%.10f", distance / per);


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll bit[400010];
ll bit2[400010];
ll u;
void bitinit(ll n){
    rep(i,0,69){
        ll y=pow(2,i);
        if(y>=n){
            u=y;
            break;
        }
    }
    fill(bit,bit+u+10,0);
    fill(bit2,bit2+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
    }
}
void add2(ll n,ll x){
    ll i=n;
    bit2[i]+=x;
    while(i<u){
        i+=i&(-i);
        bit2[i]+=x;
    }
}
ll summ(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
ll summ2(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit2[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    bitinit(100000);
    ll t;
    rep(i,0,100000){
        if(i*i>n){
            t=i-1;
            break;
        }
        
    }
    ll dp[k+1][t+1][2];
    rep(i,0,k+1)rep(j,0,t+1)rep(l,0,2)dp[i][j][l]=0;
    ll ko[t+1];
    rep(i,1,t){
        ko[i]=n/i-n/(i+1);
    }
    ko[t]=n/t-t;
    
    rep(i,1,t+1){
        dp[1][i][0]=1;
        dp[1][i][1]=ko[i];
        add(i,dp[1][i][1]);
        add2(i,dp[1][i][0]);
        
    }
   // cout<<ko[1]<<endl;
    //cout<<summ(1)<<" ";
    rep(i,1,k){
        ll sa[t+1],sa2[t+1];
        rep(j,1,t+1){
            sa[j]=-dp[i][j][0];
            dp[i+1][j][0]+=summ2(t)+summ(t)-summ(j-1)+mod;
            dp[i+1][j][0]%=mod;
            sa[j]+=dp[i+1][j][0];
            sa[j]=(sa[j]+mod)%mod;
            dp[i+1][j][1]+=ko[j]*summ2(j);
            dp[i+1][j][1]%=mod;
            sa2[j]=dp[i+1][j][1]-dp[i][j][1]+mod;
            sa2[j]%=mod;
            
        }
        rep(j,1,t+1){
            add(j,sa2[j]);
            add2(j,sa[j]);
            //cout<<sa[j]<<" "<<sa2[j]<<endl;;
            
        }
        //cout<<endl;
    }
    ll ans=0;
    rep(i,1,t+1){
        ans+=dp[k][i][0]+dp[k][i][1];
        ans%=mod;
    }
    cout<<ans<<endl;
    rep(i,1,k+1){
       // rep(j,1,t+1)cout<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
    }
}


Measured memory_bytes: 56192
#include<iostream>

using namespace std;

int main(){
    char c[4][5];
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    bool ans = true;
    for(int i=0;i<3;i++){
        if(c[0][i]!=c[1][2-i]){
            ans=false;
        }
    }
    if(ans){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  string s;
  cin >> N >> s;

  int ans = 0;
  REP(i, 1000){
    int cnt = 0;
    string num = to_string(i);
    while(num.size() < 3) num = '0'+num;
    REP(j, s.size()){
      if(s[j] == num[cnt]){
        cnt++;
        if(cnt == 3){
          ans++;
          break;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

ll dp[105][100005];
int value[105];
int weight[105];
ll inf = 1e14L;

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, w; cin>>n>>w;
    for(i = 0; i < n; i++) cin>>weight[i]>>value[i];
    for(i = 0; i < n; i++){
        for(j = 0; j <= 1e5; j++){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    dp[0][ value[0] ] = weight[0];
    for(i = 1; i < n; i++){
        for(j = 0; j <= 1e5; j++){
            dp[i][j] = dp[i-1][j];
            if(value[i] <= j) dp[i][j] = min(dp[i][j], dp[i-1][j - value[i]] + weight[i]);
        }
    }
    int ans = 0;
    for(i = 0; i <= 1e5; i++){
        if(dp[n-1][i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int a[100001];
int d1[100001];
int d[100001];

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int n, n1;
	cin >> n1;
	if (n1 == 1) {
		cout << 1;
		return 0;
	}
	int kol = 0, kol1 = 0;
	int ok = 1;
	for (int i = 1;i <= n1;i ++) {
		int x;
		cin >> x;
		if (a[n] != x) {
			n ++;
			a[n] = x;
		}
	}
	for (int i = 1;i <= n;i ++) {
		if (n == i) {   
			d[i] = d[i - 1];
			continue;
		}
		if (a[i] < a[i + 1]) {
			d[i] = 1;
		}
		else d[i] = -1;
	}
	for (int i = 1;i <= n;i ++) {
		if (d[i] != d[i - 1] && d[i - 1] != 2) {
			kol ++;
		//	cout << i << ' ';
			if (i != 1) 
				d[i] = 2;
		}
	}
	cout << kol;
	return 0;                     
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

typedef pair<int, pair<int, int>> STATE;

const int INF = INT_MAX / 4;

int main(void) {
	int c, n, m, s, d;

	while (cin >> c >> n >> m >> s >> d, c) {
		s--; d--;

		VVI es(n, VI(n, INF));
		for (int i = 0; i < m; i++) {
			int a, b, f;
			cin >> a >> b >> f;
			es[a - 1][b - 1] = f;
			es[b - 1][a - 1] = f;
		}

		VVI distance(n, VI(c + 1, INF));	// node, ticket
		distance[s][c] = 0;
		priority_queue<STATE> q; // cost, node, ticket
		q.push(STATE(0, make_pair(s, c)));

		while (q.size()) {
			int cost = q.top().first;
			int node = q.top().second.first;
			int ticket = q.top().second.second;
			q.pop();

			if (cost > distance[node][ticket]) {
				continue;
			}

			for (int i = 0; i < n; i++) if (es[node][i] != INF) {
				int next_cost;

				// not use ticket
				next_cost = distance[node][ticket] + es[node][i];
				if (distance[i][ticket] > next_cost) {
					distance[i][ticket] = next_cost;
					q.push(STATE(next_cost, make_pair(i, ticket)));
				}

				// ticket - 1
				if (ticket) {
					next_cost = distance[node][ticket] + es[node][i] / 2;
					if (distance[i][ticket - 1] > next_cost) {
						distance[i][ticket - 1] = next_cost;
						q.push(STATE(next_cost, make_pair(i, ticket - 1)));
					}
				}
			}
		}

		cout << *min_element(distance[d].begin(), distance[d].end()) << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int p[1010];//n!を素因数分解したときiはp[i]乗
void prime(int n){
  for(int i=2; i<=n; i++){
    while(n%i==0){
      n /= i;
      p[i]++;
    }
  }
}
int main(){
  int n;
  cin >> n;
  for(int i=0; i<1010; i++){
    p[i] = 0;
  }
  for(int i=2; i<=n; i++){
    prime(i);
  }
  long long int ans=1;
  for(int i=2; i<=n; i++){
    ans = (ans*(p[i]+1))%1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll i,j;
    ll X;
    cin >> X;
    for(i=-1000;i<=1000;i++){
        for(j=-1000;j<1000;j++){
            if(pow(i,5)-pow(j,5)==X){
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){


    ll n;
    cin >> n;


    vector<ll> v;

    while (n > 0){
        ll r = n % 26;
        if(r == 0) r = 26;
        v.push_back( r );
        n = (n - r) / 26;

    }

    reverse(all(v));
    for(int i = 0; i < v.size(); i++){
        /*
        if( v[i + 1] == 0 && v[i] == 1){
            cout << 'z';
            i++;
        }
        else{
            cout << char( 'a' + v[i] - 1 ) ;
        } 
        */   

            cout << char( 'a' + v[i] - 1 ) ;

    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3604
"use strict";

const main = arg => {
  const input = arg.trim();

  const N = parseInt(input);
  const ary = [...Array(N)].map(_ => 0);

  const m = Math.floor(Math.sqrt(N - 1) - 1);

  for (let x = 1; x <= m; x++) {
    for (let y = 1; y <= m; y++) {
      for (let z = 1; z <= m; z++) {
        const f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= N) {
          ary[f - 1]++
        }
      }
    }
  }

  console.log(ary.join('\n'));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33076
a, b = map(int, input().split())
ans = 0

for i in range(a, b + 1):
    if i % 10  == i // 10000:
        if (i % 100 - i % 10) // 10 == i // 1000 - i // 10000 * 10:
            ans += 1

print(ans)


Measured memory_bytes: 2940
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		String strArr[] = str.split(" ");

		int numArr[] = new int[3];
		int tmp;


		for(int i=0; i<numArr.length; i++){
			numArr[i] = Integer.parseInt(strArr[i]);
		}

		for(int i=0; i<numArr.length; i++){
			for(int t=i; t<numArr.length; t++){
				if(numArr[i] > numArr[t]){
					tmp = numArr[i];
					numArr[i] = numArr[t];
					numArr[t] = tmp;
				}
			}
		}

		System.out.println(numArr[0] + " " + numArr[1] + " " + numArr[2]);


	}
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define MAX_V 10000
#define INF 1e9
using namespace std;

struct edge{int to, cap,cost,rev;};
int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  while(f>0){
    fill(dist,dist+V,INF);
    dist[s]=0;
    bool update = true;
    while(update){
      update = false;
      for(int v=0; v<V ;v++){
	if(dist[v]==INF) continue;
	for(int i=0; i<G[v].size(); i++){
	  edge &e = G[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v]+e.cost) {
	    dist[e.to] = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[t]==INF) return res;

    int d = f;
    for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d*dist[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int n,A[1001],B[1001];
  cin>>n;
  set<int> S;
  for(int i=0;i<n;i++){
    cin>>A[i]>>B[i];
    S.insert(A[i]),S.insert(B[i]);
  }
  vector<int> num;
  for(set<int>::iterator it=S.begin();it!=S.end();it++) num.push_back(*it);
  
  int s=3*n+num.size(),t=s+1;
  for(int i=0;i<n;i++){
    int a=lower_bound(num.begin(),num.end(),A[i])-num.begin();
    int b=lower_bound(num.begin(),num.end(),B[i])-num.begin();
    add_edge(s,i,1,0);
    add_edge(i,n+i*2,1,0);
    add_edge(i,n+i*2+1,1,0);
    add_edge(n+i*2,3*n+a,1,-B[i]);
    add_edge(n+i*2+1,3*n+b,1,-A[i]);
  }
  for(int i=0;i<num.size();i++)add_edge(3*n+i,t,1,0);

  V = 3*n+num.size()+2;
  int r,ans=0;
  while((r=min_cost_flow(s,t,1))<0)ans+=r;
  cout<<-ans<<endl;

  return 0;
}

Measured memory_bytes: 3900