akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {    
    public static void main(String[] args){        
           
        Scanner sc = new Scanner(System.in);                 
         
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                 int Z = S - x - y;
                 if(Z >= 0 && Z <= K)
                       ans++;
            }            
        }
        
        System.out.println(ans);
       
    }            
}

Measured memory_bytes: 23764
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var localInput = input;
  var f = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ];
  
  var len = localInput.length - 1;
  while(len--){
    var l = localInput[len];
    var ix = parseInt(l[0]) + 2;
    var iy = parseInt(l[2]) + 2;
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  while(y--){
    var x = 10;
    while(x--){
      var fyx = f[y+2][x+2];
      nd += !fyx;
      md = mx(fyx, md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 return a - ((a-b) & ((a-b) >> 31));
}

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, K;
    cin >> N >> K;
    int A[N];
    ll B[N];
    rep(i, N) cin >> A[i] >> B[i];
    ll ans = 0;
    rep(i, N){
        if((K|A[i]) == K) ans += B[i];
    }
    rep(i, 30){
        //i桁目が1でそこを0にする場合の総和
        if(K&(1<<i)){
            ll tmp = 0;
            rep(j, N){
                if(((K>>i)|(A[j]>>i)) == K>>i && !(A[j]&(1<<i))){
                    tmp += B[j];
                }
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
	int i, j, n;
	char s[100];
	scanf("%d",&n);
	for(i=0; i<n ; i++){
		scanf("%s",&s[i]);
	}
	for(i=0,j=0; i<n ; i++){
		if(s[i]=='R') j++;
		else if(s[i]=='B') j--;
	}
	if(j>0) printf("Yes");
	else printf("No");
}
	

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int main(){
  int A,B;
  cin >> A >> B;
  
  if(A%3 == 0 || B%3 == 0 || (A+B) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c, d = MAP()
print(max(a*c, a*d, b*c, b*d))


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

int main() {
	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
#define F(x,z)L x(L f){return z;}
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
F(M,f?B[f]+M(f^f&-f):0)
F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))))
//L M(L i){return i?B[i]+M(i^i&-i):0;}
//L K(L f){return a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33472
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		
		while(true){
			int upCnt = sn.nextInt(), downCnt = sn.nextInt();
			if(upCnt == 0 && downCnt == 0) break;
			ArrayList<Integer> times = new ArrayList<Integer>();
			for(int i = 0; i < upCnt; i++) times.add(sn.nextInt());
			for(int i = 0; i < downCnt; i++) times.add(sn.nextInt());
			times.add(0); // テッツシツ静ァツァツ津」ツ?凝」ツつ嘉・ツァツ凝」ツつ?」ツつ?
			Collections.sort(times);
			int max = 0;
			for(int i = 0; i < times.size()-1; i++){
				max = Math.max(  Math.abs(times.get(i) - times.get(i+1)) , max);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 67364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  return i;
}

void solve(){
  ll n,b,a;
  cin >> n >> a >> b;
  ll c = n/(a+b)*a;
  ll d = min(n%(a+b), a);
  cout << c+d << endl;
}


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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;                       
typedef long long ll;

 int main()
 {   int a[105]={0};
     int b[105];
	 int n,k,t,t1,sum=0;
	  cin>>n>>k;
	  for(int i=1;i<=k;i++)
	  {  cin>>t;
	      for(int j=1;j<=t;j++)
	        {  cin>>t1;
	           a[t1]++;
	       }
	   }
	     for(int i=1;i<=n;i++)
	      {  if(a[i]==0)
	          sum++;
		  }
		  cout<<sum<<endl;
	}
		   

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans;
  ans.reserve(N*2);
  for(int i = 0; i < N; ++i) {
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fl '\n'
#define vi vector<int>
#define sz size
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

bool mk[1001];
bool can(int x){
    for(;x>0;x/=10){
        if(mk[x%10])return false;
    }
    return true;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int x;cin>>x;mk[x]=1;
    }

    while(!can(n))n++;
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split(" ")))

ans = 10 ** 9
for i in range(1, n):
    s1 = sum(w[0:i])
    s2 = sum(w[i:])
    diff = abs(s1 - s2)
    if ans > diff:
        ans = diff
print(ans)

Measured memory_bytes: 3060
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <limits>
#include <utility>

namespace n91 {

u64 rsub(const u64 l, const u64 r) { return l < r ? r - l : 0; }

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const usize t = scan<usize>();
  struct dish_t {
    usize a;
    u64 b;
  };
  std::vector<dish_t> dish(n);
  for (auto &e : dish) {
    std::cin >> e.a >> e.b;
  }
  std::vector<u64> dp0(t), dp1(t);
  for (const auto &e : dish) {
    for (const usize i : revrep(e.a, t)) {
      chmax(dp1[i], dp1[i - e.a] + e.b);
    }
    for (const usize i : rep(0, t)) {
      chmax(dp1[i], dp0[i] + e.b);
    }
    for (const usize i : revrep(e.a, t)) {
      chmax(dp0[i], dp0[i - e.a] + e.b);
    }
  }
  std::cout << dp1[t - 1] << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int dir[][2] = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};

void solve(vector<string> &v, int x, int y){
    const int width = v[0].size();
    const int height = v.size();

    deque< pair<int,int> > q;
    q.push_back(mp(x,y));
    v[y][x] = '0';

    while(!q.empty()){
        x = q.front().first;
        y = q.front().second;
        q.pop_front();

        REPEAT(r,1,3){
            REP(i,4){
                int nx = x + dir[i][0]*r;
                int ny = y + dir[i][1]*r;
                if(nx < 0 || nx >= width || ny < 0 || ny >= height) continue;
                if(v[ny][nx] == '1'){
                    q.push_back(mp(nx,ny));
                    v[ny][nx] = '0';
                }
            }
        }
    }
    FOREACH(it, v) cout << *it << endl;
}

int main(){
    int n;
    cin >> n;
    REP(i,n){
        printf("Data %d:\n", i+1);
        vector<string> v;
        REP(j,8){
            string s;
            cin >> s;
            v.push_back(s);
        }
        int x, y;
        cin >> x >> y;
        solve(v, x-1, y-1);
    }
    return 0;
}

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

int a,b,c;

void read_input(){
    cin >> a >> b >> c;
}

int main(void){
    read_input();
    if (b-a == c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int x,y,z,i;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int board[4][4];

bool check() {
    for (int i = 0; i < 3; ++i) {
        if (board[i][0] == board[i][1] &&
            board[i][1] == board[i][2]) {
            return true;
        }
    }

    for (int j = 0; j < 3; ++j) {
        if (board[0][j] == board[1][j] &&
            board[1][j] == board[2][j]) {
            return true;
        }
    }

    return (board[0][0] == board[1][1] && board[1][1] == board[2][2]) ||
           (board[2][0] == board[1][1] && board[1][1] == board[0][2]);

}

int main() {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> board[i][j];
        }
    }

    int n;
    cin >> n;
    while (n--) {
        int k;
        cin >> k;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (board[i][j] == k) {
                    board[i][j] = -1;
                }
            }
        }
        if (check()) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,m; cin>>n>>m;
  auto v=make_v(m,priority_queue<ll>{});
  rep(i,n){
    ll a,b; cin>>a>>b;
    if(a>m) continue;
    a--;
    v[a].push(b);
  }
  ll ans=0,chosen=0;
  priority_queue<pll> queue{};
  rep(i,m){
    if(!v[i].empty()){
      ll b=v[i].top();
      v[i].pop();
      queue.emplace(b,i);
    }
    if(!queue.empty()){
      pll p=queue.top();
      queue.pop();
      ans+=p.fi;
      chosen=p.se;
    }
    if(!v[chosen].empty()){
      ll b=v[chosen].top();
      v[chosen].pop();
      queue.emplace(b,chosen);
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 6400
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a[101010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
  }  
  int res = 1;
  for(int i=1;i<=n;i++){
    if(2e18/a[i]<res){
      cout << -1 << endl;
      return 0;
    }
    res = res*a[i];
  }
  if(res>1000000000000000000){
    cout << -1 << endl;
  }
  else cout << res << endl;

return 0;
}
///....


Measured memory_bytes: 4444
n=int(input())
a=list(map(int,input().split()))
dp=[10**9]*(n)
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]))
    if i==1:
        continue
    dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2])) 
print(dp[n-1])

Measured memory_bytes: 13924
n = int(input())
ha = list(map(int,input().split()))


if n == 0 and ha[0] == 1:
    print(1)
elif ha[0] != 0:
    print(-1)
else:
    oya = [[0,0] for i in range(n+1)]
    ten = [[0,0] for i in range(n+1)]
    ten[n] = [ha[n],ha[n]]
    for i in reversed(range(n)):
        oya[i] = [int((ten[i+1][0]+1)/2),(ten[i+1][1])]
        ten[i] = [oya[i][0] + ha[i], oya[i][1] + ha[i]]

    if 1 < oya[0][0] or oya[0][1] < 1 or 1 < ten[0][0] or ten[0][1] < 1:
        print(-1)
    else:
        oya[0] = 1
        ten[0] = 1
        for i in range(1,n+1):
            ten[i] = min(oya[i-1]*2, ten[i][1])
            oya[i] = ten[i]-ha[i]
        print(sum(ten))

Measured memory_bytes: 41364
import random

D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

for d in range(D):
    i = imax(S[d])
    i = random.randint(0, 25)
    print(i + 1)


Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  ll n,h;
  cin >> n >> h;
  vll a(n);
  vll b(n);
  rep(i,n){
    ll p,q;
    cin >> p >> q;
    a[i] = p;
    b[i] = q;
  }
  sort(ALL(a));
  sort(ALL(b));
  ll r = upper_bound(ALL(b),a[n-1]) - b.begin();
  ll sum = 0;
  rep2(i,r,n){
    sum += b[i];
  }
  //cout << (h-sum)/a[n-1] << " " << n-r << endl;
  if(sum<h)cout << ((h-sum)+a[n-1]-1)/a[n-1] + n-r << endl;
  else{
    ll kamo = 0;
    for(ll i = n-1;i>=r;i--){
      kamo+=b[i];
      if(kamo>=h) {
        cout << n-i << endl;
        return 0;
      }
    }
  }
  
}




Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
a, b, c = map(int,input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    tmp1 = ((a//2+1) - a//2) * b * c
    tmp2 = ((b//2+1) - b//2) * a * c
    tmp3 = ((c//2+1) - c//2) * a * b
    print(min(tmp1, tmp2, tmp3))


Measured memory_bytes: 2940
import numpy as np
N = int(input())
p = np.array([0.0] + list(map(float, input().split())))

# コインnまでを投げたとき、表がx枚でる確率
dp = np.zeros((N + 1, N + 1), np.float64)
dp[0, 0] = 1
dp[:, 0] = np.cumprod(1 - p).T

for i in range(1, N + 1):
    dp[i][1:] = dp[i - 1][:-1] * p[i] + dp[i - 1][1:] * (1 - p[i])

print(dp[-1][(N + 1) // 2:].sum())

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

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

int main(){

  ll n,k;
  cin >> n >> k;

  vector<ll> cnt(50,0);
  vector<ll> two(50,1);
  rep(i,49){
    two[i+1] = two[i]*2;
  }
  rep(i,n){
    ll a;
    cin >> a;
    rep(j,50){
      if(a>>j&1){
        cnt[j]++;
      }
    }
  }

  vector<vector<ll>> dp(51, vector<ll>(2));
  for(ll i = 49; i >= 0 ;i--){
    ll d = two[i];

    if(k>>i&1){
      dp[i][1] = dp[i+1][1] + (n-cnt[i])*two[i];
    }else{
      dp[i][1] = dp[i+1][1] + cnt[i]*two[i];
    }

    if(dp[i+1][0]>0){
      dp[i][0] = dp[i+1][0] + max(cnt[i], n-cnt[i])*two[i];
    }
    if(k>>i&1){
      dp[i][0] = max(dp[i][0], dp[i+1][1]+cnt[i]*two[i]);
    }
  }

  cout << max(dp[0][0], dp[0][1]) << endl;

  return 0;
} 

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        if(i&1 && a&1)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
    string S,T,ans="Yes";
    cin>>S;
    cin>>T;
    if(S.size()==1){
        if(S.at(0)==T.at(0)){
            cout<<"Yes"<<endl;
            exit(0);
        }else{
            cout<<"No"<<endl;
            exit(0);
        }
    }
    for(int i=0;i<S.size()-1;i++){
        if(S.at(i)!=T.at(i)){
            ans="No";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
########################################
mxn =  10**7
divs = [0]*(mxn + 11)
for i in range(1,mxn+1):
	for j in range(0, mxn+1,i):
		divs[j]+=1

n = int(input())
ans = 0
for i in range(1,n+1):
	ans+=i*divs[i]
print(ans)




Measured memory_bytes: 152256
N=int(input())
xy=[list(map(int,input().split())) for i in range(N)]

import itertools
NP=list(itertools.permutations(range(N)))

a=[[0]*(len(NP[0])-1) for i in range(len(NP))]
for i in range(len(NP[0])-1):
    for j in range(len(NP)):
        a[j][i] = ((xy[int(NP[j][i])][0]-xy[int(NP[j][i+1])][0])**2 + (xy[int(NP[j][i])][1]-xy[int(NP[j][i+1])][1])**2)**0.5

b=[0]*(len(a))
for i in range(len(a)):
    b[i]=sum(a[i])

print(sum(b)/len(b))

Measured memory_bytes: 21364
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    int main(){
        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif  

        fast;
        int n,m;
        cin>>n>>m;
        int a[n];
        double s=0;
        rep(i,0,n){
            cin>>a[i];
            s+=a[i];
        }
        s/=(4*m*1.0);
        //cout<<s;
        int c=0;
        rep(i,0,n){
            if(a[i]>=s) c++;
        }
        cout<<((c>=m)?"Yes":"No");
        return 0;  
    }       
 
 
    //keep it simple stupid


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define mp make_pair
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
const ll INF = 1e18;
int main()
{
    int i,j,n,a;
    in(n);
    vi ar(n);
    vi v(n);
    read(ar,i,n);
    vii asc;
    v[0]=ar[0];
    asc.pb(v[0],0);
    vector<ll> ans(n,0),bit(n+1,0);
    ii temp;
    lp(i,1,n)
    {
        v[i]=max(ar[i],v[i-1]);
        if(v[i]>v[i-1])
            asc.pb(v[i],i);
        else
        {
            temp=make_pair(ar[i],n);
            j=upper(asc,temp);
            bit[0]++,bit[j]--;
            if(j>0)
                ans[asc[j].S]+=(ar[i]-asc[j-1].F);
            else
                ans[asc[j].S]+=(ar[i]);
        }
    }
    int m=asc.size();
    lp(i,1,m)
        bit[i]+=bit[i-1];
    rep(i,m)
        bit[i]+=(m-i);
    lp(i,1,m)
        bit[i]*=(asc[i].F-asc[i-1].F);
    bit[0]*=asc[0].F;
    rep(i,m)
        a=asc[i].S,ans[a]+=bit[i];
    rep(i,n)
        llout(ans[i]);
}





Measured memory_bytes: 4340
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, P) = get!(usize, i64);
    let A = get!(Vec<usize>);

    // Aがすべて偶数ならば (1-P) 2^N
    // そうでなければ 2^{N-1}
    let ans = if A.iter().all(|a| a % 2 == 0) {
        (1 - P) * 2_i64.pow(N as u32)
    } else {
        2_i64.pow((N - 1) as u32)
    };

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  vector<int> a(3);
  rep(i,3) cin >> a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(2) * 10 + a.at(1) + a.at(0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> cost(m, vector<int>(m));
    for (auto &vi: cost) for (auto &vij: vi) cin >> vij;
    vector<vector<int>> cnt(3, vector<int>(m));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
        int c; cin >> c, c--;
        cnt[(i + j) % 3][c]++;
    }
    int mi = INF;
    #define rep(i, n) for (int i = 0; i < n; i++)
    rep(i, m) rep(j, m) if (i != j) rep(k, m) if (i != k && j != k) {
        int tmp = 0;
        rep(c, m) tmp += cnt[0][c] * cost[c][i];
        rep(c, m) tmp += cnt[1][c] * cost[c][j];
        rep(c, m) tmp += cnt[2][c] * cost[c][k];
        mi = min(mi, tmp);
    }
    cout << mi << endl;
    return 0;
}


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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  string S=to_string(N);
  int sum=0;
  rep(i,S.size()) sum+=S[i]-'0';
  if(N%sum) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
max=A.max
dp=array(N*max+1,false)
dp[0]=true
A.each do|a|
    (max*N).downto(a) do|x|
        dp[x]=true if dp[x-a]
    end
end
Q=gets.to_i
M=get_i
M.each do|m|
    puts yn_judge(dp[m],"yes","no")
end



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

int main() {
  int n;
  std::cin >> n;
  string color;
  string ans = "Three";
  for (int i = 0; i < n; i++) {
    std::cin >> color;
    if (color == "Y") {
      ans = "Four";
      break;
    }
  }
  std::cout << ans << '\n';
}


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

#define ll long long

void self_max(ll& a, ll b){
    a = max(a, b);
}

int main(){

    int n, w;scanf("%d%d", &n, &w);
    vector <ll> dp(w + 1);
    for(int i = 0; i <n; i++){
        int weight, value; scanf("%d%d", &weight, &value);
        for(int wa = w - weight; wa>=0; wa--){
            // dp[wa+weight] = max(dp[wa+weight], dp[wa] + value);
            self_max(dp[wa+weight], dp[wa] + value);
        }
    }
    ll big = 0;
    for(int i = 0; i <= w ; ++i){
        self_max(big, dp[i]);
    }
    printf("%lld", big);
    return 0;
}

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

signed main() {
    int n;
    scanf("%d%*c", &n);
    for(int i=0; i<n; ++i) {
        string s;
        getline(cin, s);
        regex re("Hoshino");
        cout << regex_replace(s, re, "Hoshina") << endl;
    }
    return 0;
}

Measured memory_bytes: 3232
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
c = [0] * (N + 1)
C = [0] * K
D = [0] * K
uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    c[a] += 1
    c[b] += 1
for i in range(K):
    C[i], D[i] = map(int, input().split())


for i in range(1,N + 1):
    c[i] = uf.size(i-1) - c[i] - 1
for i in range(K):
    if uf.same(C[i]-1, D[i]-1):
        c[C[i]] -= 1
        c[D[i]] -= 1

for i in range(1, N+1):
    print(c[i], end=" ")

Measured memory_bytes: 83296
#!/usr/bin/env python3

from itertools import chain, combinations

def subsets(iterable, low=0, high=None):
    "subsets([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    if high is None:
        high = len(s)
    return chain.from_iterable(combinations(s, r) for r in range(low, high+1))

H, W, K = input().split(' ')

H = int(H)
W = int(W)
K = int(K)

A = []

for _ in range(H):
    row = input()
    A += [row]

# print(f"A={A}")

ret = 0

def ok(rows, cols, A):
    A = [list(row) for row in A]
    for x in rows:
        for y in range(W):
            A[x][y] = '.'
    for y in cols:
        for x in range(H):
            A[x][y] = '.' 
    
    return K == sum(sum(1 for r in row if r == '#') for row in A)

for h in subsets(range(0, H)):
    for w in subsets(range(0, W)):
        if ok(h, w, A):
            ret += 1        
            # print(f"{h} {w}")

print(ret)

Measured memory_bytes: 70364
#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>;
const double PI = acos(-1);

int main() {
int a;
cin >> a;
cout << 3*a*a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  cin >> N;

  vector<ll> T, A;
  rep (i, N) {
    ll t, a;
    cin >> t >> a;
    T.push_back(t);
    A.push_back(a);
  }
  ll t = T[0], a = A[0];
  repr (i, 1, N) {
    ll t1 = ceil((ld) a / (ld) A[i]) * T[i];
    ll t2 = ceil((ld) t / (ld) T[i]) * T[i];
    t = max(t1, t2);
    a = t / T[i] * A[i];
  }
  cout << a + t << "\n";

}

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

using namespace std;

typedef long long ll;

int main(){
  ll x; cin >> x; ll y; cin >> y;
  ll a = (x + 2 * y) / 3;
  ll b = (y + 2 * x) / 3;
  if(a == b){
    cout << "Brown\n";
  }
  else cout << "Alice\n";
}


Measured memory_bytes: 256
import math


def IsPrime(x):
    i=2
    while(i<=math.sqrt(x)):
        if(x%i==0):
            return False
        i+=1
    return True

a=[]
n=int(input())
nn=n
i=0
while(n>i):
    b=int(input())
    if(not IsPrime(b)):
        nn-=1
    i+=1
print(nn)

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
int N,T,c,t,cost=10000;
int main(){
  cin >> N >> T;
  for(int i=0;i<N;i++){
    cin >> c >> t;
    if(t>T);
    else{
      cost = min(cost,c);
    }
  }
  if(cost==10000) cout << "TLE" << endl;
  else{
    cout << cost << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main () {
  std::string N;
  std::cin >> N;
  int sub = atoi(N.c_str());
  
  // Nについて考える.
  int waru = 0;
  for (int i = 0; i < N.size(); i++) {
    waru += (int) N[i] - 48;
  }

  if (sub % waru == 0) {
    std::cout << "Yes" << std::endl;  
  }
  else {
    std::cout << "No" << std::endl;  
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_X 2000
#define MAX_Y 2000

//sはグローバル変数なので 宣言時に0に初期化される
int s[MAX_X][MAX_Y];

int main() {
    int i, j, k, c = 0;
    int x, y, w, h;
    for ( k=0; k<2; ++k ) {
	scanf("%d %d %d %d", &x, &y, &w, &h);
	for ( i=x; i<x+w; ++i ) 
	    for ( j=y; j<y+h; ++j ) ++s[i][j];
    }
    
    for ( i=0; i<MAX_X; ++i ) 
	for ( j=0; j<MAX_Y; ++j ) 
	    if ( s[i][j] == 1 ) ++c;

    printf("%d\n", c);

    return 0;
}



Measured memory_bytes: 17380
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
   ll n;
   cin>>n;
   
   ll a[n];
   
   for(ll i=0;i<n;i++)
   cin>>a[i];
    
    
   ll res=0;
   ll sum=a[0];
   
   for(ll i=1;i<n;i++){
       res=(res+sum*a[i])%mod;
       
       sum+=a[i];
       
       sum%=mod;
   }
   
   cout<<res<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 5124
D, G = gets.split.map(&:to_i)
PCs = readlines.map{|l| l.split.map(&:to_i)}

a = PCs.map.with_index(1){|(p, c), i| [100*i * p + c, 100*i, p - 1]}
ans = 10 * 100
[true, false].repeated_permutation(D) do |s|
  c, g, = 0, G
  (0 ... D).select{|i| s[i]}.each do |i|
    c += PCs[i][0]
    g -= a[i][0]
  end
  next if c >= ans
  if g > 0
    j = (D - 1).downto(0).find{|i| !s[i]}
    x = a[j][1]
    d = (g + (x - 1)) / x
    next if d > a[j][2]
    c += d
  end
  ans = c if c < ans
end
puts ans

Measured memory_bytes: 3836
def f(n):
    return (4 ** n - 1) // 3


n = int(raw_input())

if n < 0:
    m = 0
    while -2 * f(m) > n:
        m += 1
else:
    m = 0
    while f(m) < n:
        m += 1

if m == 0:
    print '0'
else:
    mask = sum(2 * 4 ** j for j in xrange(m))
    print bin((n + 2 * f(m)) ^ mask)[2:]


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

using namespace std;

int main() {
    int N, i = 0, t;

    cin >> N;

    double a[N], ans = 0, ans_l;

    for (i = 0; i < N; i++) {
        cin >> t;
        a[i] = t;
    }

    for (i = 0; i < N; i++) {
        ans += (1.000 / a[i]);
    }

    ans_l = 1.000 / ans;

    cout << ans_l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<int> sum, sumr;
int n, b = 0;

string changeTo2(int n){
   string s;
   while(n){
       if(n % 2) s += '1';
       else s += '0';
       n /= 2;
   }
   reverse(s.begin(), s.end());
   return s;
}

bool f(int m, int left){
    int wa = sum[m + 1] - sum[left];
    bool res = true;
    int off = (1LL <<20);
    // int war = (off + sumr[m + 1] - sumr[left]) % off;
    int war = 0;
    rep(i, 0, 20){
        bool f1 = sumr[m + 1] & (1LL << i);
        bool f2 = sumr[left] & (1LL << i);
        if(f1 != f2) war += (1LL << i);
    }
    // cout << m << ' ' << left << ' ' << wa << " " << war << endl;    
    // rep(i, 0, 20){
    //     if(wa & (1LL << i)){
    //         bool f1 = (sumr[m + 1] & (1LL << i));
    //         bool f2 = (sumr[left] & (1LL << i));
    //         if(f1 == f2) res = false;
    //     }
    // }
    // return res;
    // int war = sumr[m + 1] - sumr[left];
    return wa == war;
}

signed main(){
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, 21) b += (1LL << i);
    a.push_back(b);
    n++;
    sum.resize(n + 1); sumr.resize(n + 1);
    rep(i, 1, n + 1) sum[i] = sum[i - 1] + a[i - 1];
    rep(i, 1, n + 1) sumr[i] = sumr[i - 1] ^ a[i - 1];
    int ans = 0;
    // rep(i, 0, n){
    //     string t = changeTo2(a[i]);
    //     while(t.size() < 20) t = "0" + t;
    //     cout << t << endl;
    // }
    rep(i, 0, n - 1){
        int l = i, r = n;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(f(mid, i)) l = mid;
            else r = mid;
        }
        // cout << i << ' ' << r << endl;
        ans += r - i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6500