akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 1000000;
int f[maxn + 1];
char s[maxn + 2];
struct node{
    int maxv, minv, addv;
}t[maxn << 2];
#define ls (v << 1)
#define rs ((ls) | 1)
#define tm ((tl + tr) >> 1)
void update(int v){
    t[v].maxv = max(t[ls].maxv, t[rs].maxv);
    t[v].minv = min(t[ls].minv, t[rs].minv);
}
void add(int v, int x){
    t[v].maxv += x;
    t[v].minv += x;
    t[v].addv += x;
}
void push_down(int v){
    add(ls, t[v].addv);
    add(rs, t[v].addv);
    t[v].addv = 0;
}
void build(int v, int tl, int tr){
    if(tl == tr){
        t[v].maxv = t[v].minv = f[tm];
        t[v].addv = 0;
    }
    else{
        build(ls, tl, tm);
        build(rs, tm + 1, tr);
        update(v);
    }
}
void update(int v, int tl, int tr, int L, int R){
    if(tl >= L and tr <= R) add(v, 2);
    else{
        push_down(v);
        if(L <= tm) update(ls, tl, tm, L, R);
        if(R > tm) update(rs, tm + 1, tr, L, R);
        update(v);
    }
}
int query(int v, int tl, int tr, int L, int R){
    if(tl >= L and tr <= R) return t[v].maxv;
    push_down(v);
    if(L > tm) return query(rs, tm + 1, tr, L, R);
    if(R <= tm) return query(ls, tl, tm, L, R);
    return max(query(ls, tl, tm, L, R), query(rs, tm + 1, tr, L, R));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //min{max(2s[x]-x)-min(2s[x]-x)}
    cin >> (s + 1);
    int n = strlen(s + 1);
    for(int i = 1; i <= n; i += 1){
        f[i] = f[i - 1] - 1;
        if(s[i] == '1') f[i] += 2;
    }
    build(1, 0, n);
    int top = t[1].maxv;
    int ans = top - t[1].minv;
    for(int i = 1; i <= n; i += 1) if(s[i] == '?'){
        int maxv = query(1, 0, n, i, n);
        if(maxv + 2 <= top){
            update(1, 0, n, i, n);
            ans = min(ans, t[1].maxv - t[1].minv);
        }
    }
    build(1, 0, n);
    for(int i = 1; i <= n; i += 1) if(s[i] == '?'){
        int maxv = query(1, 0, n, i, n);
        if(maxv + 2 <= top + 1){
            update(1, 0, n, i, n);
            ans = min(ans, t[1].maxv - t[1].minv);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 33124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

ll n, A[MX], B[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i]>>B[i];
    ll inc=0;
    for(int i=n; i>=1; i--){
        A[i]+=inc;
        ll x=(B[i]-A[i]%B[i])%B[i];
        // cout<<x<<'\n';
        inc+=x;
    }
    cout<<inc;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define c1 s[i]
#define c2 s[i+d]
#define c3 s[i+d+d]
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   //IOS;
   int n;
   cin >> n;
   string s;
   cin >> s;
   int r=0,g=0,b=0;
   rep(i,0,s.length()-1){
       if(s[i]=='R') ++r;
       else if(s[i]=='G') ++g;
       else ++b;
   }
   ll ans=1LL*r*g*b;
   rep(i,0,n-2){
       for(int d=1;i+d+d<n;d++){
           if(c1!=c2 and c1!=c3 and c2!=c3)
                -- ans;
       }
   }
   cout << ans;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define sz(x)  (int)x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , 0x3f , sizeof(x))
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
const int mod = 1e9 + 7 ;
const int maxn = 2e6 + 10 ;
const int inf = 0x3f3f3f3f ;
const double eps = 1e-6 ; 
mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ; 
int k ;
ll ans = 0 ;
string s ;
ll fac[maxn] ;
ll inv[maxn] ;
void init() 
{
   fac[0] = fac[1] = inv[0] = inv[1] = 1 ;
   for(int i = 2 ; i <= 2e6 ; i ++)
   {
     fac[i] = fac[i - 1] * i % mod ;
     inv[i] = -inv[mod % i] * (mod / i) % mod ;
     while(inv[i] < 0) inv[i] += mod ;
   }
   for(int i = 2 ; i <= 2e6 ; i ++)  
     inv[i] = inv[i] * inv[i - 1] % mod ;
}
ll C(int n , int m)
{
	return fac[n] * inv[m] % mod * inv[n - m] % mod ;
}
ll qpow(ll a , ll b)
{
	if(b < 0)  return 0 ;
	ll ans = 1 ; 
	a %= mod ;
	while(b)
	{
		if(b & 1)  ans = (ans * a) % mod ;
		b >>= 1 , a = (a * a) % mod ;
	}
	return ans % mod ;
}
int main()
{
	ios ;
	cin >> k >> s ;
	init() ;
	int n = sz(s) ;
	rep(i , n , n + k)  ans += C(i - 1 , n - 1) * qpow(25 , i - n) % mod * qpow(26 , n + k - i) % mod , ans %= mod ;
	cout << ans << '\n' ;
	return 0 ;
}

Measured memory_bytes: 35676
n, m = map(int, input().split())

MOD = 10 ** 9 + 7

if m == 1:
    print('1')
    exit()

factor = []
temp = 0
x = 2
while m > 1:
    if m % x == 0:
        m //= x
        temp += 1
    elif temp > 0:
        factor.append(temp)
        temp = 0
        x += 1
    else:
        x += 1
factor.append(temp)

nCr = {}
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;
    if (n, r) in nCr: return nCr[(n, r)]

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p;
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    nCr[(n, r)] = result
    return result;

ans = 1
for x in factor:
    ans *= cmb(x + n - 1, n - 1)
    ans %= MOD

print(ans)

Measured memory_bytes: 40044
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = 60;
const ll INF = numeric_limits<ll>::max();

ll x[Maxn], y[Maxn], xs[Maxn], ys[Maxn];

int n, k;

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
     */
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xs[i] = x[i], ys[i] = y[i];
    }
    sort(xs, xs + n);
    sort(ys, ys+ n);

    ll ans = INF;
    for (int x1 = 0; x1 < n; ++x1) {
        for (int x2 = x1; x2 < n; ++x2) {
            for (int y1 = 0; y1 < n; ++y1) {
                for (int y2 = y1; y2 < n; ++y2) {
                    int cnt = 0;
                    for (int i = 0; i < n; ++i) {
                        if (xs[x1] <= x[i] && x[i] <= xs[x2] && ys[y1] <= y[i] && y[i] <= ys[y2]) {
                            ++cnt;
                        }
                        if (cnt >= k) {
                            ans = min(ans, (xs[x2] - xs[x1]) * (ys[y2] - ys[y1]));
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x, y int
	fmt.Scanf("%d %d %d", &n, &x, &y)
	printDistance(n, x-1, y-1)
}

func printDistance(n, x, y int) {
	distanceMap := make(map[int]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			distance := min(j-i, abs(x-i)+abs(y-j)+1)
			distanceMap[distance]++
		}
	}

	for i := 1; i < n; i++ {
		fmt.Println(distanceMap[i])
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 768
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int, readline().split())

M = 2*10**5+2
Uy = [[] for _ in range(M)]
Dy = [[] for _ in range(M)]

Rx = [[] for _ in range(M)]
Lx = [[] for _ in range(M)]

d1U = {} # 右上、x+y UR
d1R = {} # 右上、x+y UR
d2U = {} # 左上、x-y UL
d2L = {} # 左上、x-y UL
d3L = {} # 左下、x+y LD
d3D = {} # 左下、x+y LD
d4D = {} # 右下、x-y DR
d4R = {} # 右下、x-y DR

for _ in range(n):
    x,y,z = readline().split()
    x = int(x); y = int(y)
    if z=="U":
        Uy[x].append(y)
        dp,dn = d1U,d2U
    elif z=="D":
        Dy[x].append(y)
        dp,dn = d3D,d4D
    elif z=="R":
        Rx[y].append(x)
        dp,dn = d1R,d4R
    elif z=="L":
        Lx[y].append(x)
        dp,dn = d3L,d2L
    
    v = x+y
    if v in dp: dp[v].append(x)
    else: dp[v] = [x]
    v = x-y
    if v in dn: dn[v].append(x)
    else: dn[v] = [x]

def get(a,b):
    v = INF
    lb = len(b)
    j = 0
    for ai in a:
        while j < lb and b[j] < ai:
            j += 1
        if j < lb:
            v = min(v,b[j]-ai)
    return v

def syoumen(lst1,lst2):
    v = INF
    for i in range(M):
        if lst1[i] and lst2[i]:
            lst1[i].sort()
            lst2[i].sort()
            v = min(v,get(lst1[i],lst2[i]))
    return v*5

def naname(d1,d2):
    v = INF
    for i in range(-2*M,2*M):
        if i in d1 and i in d2:
            d1[i].sort()
            d2[i].sort()
            v = min(v,get(d1[i],d2[i]))
    return v*10

INF = 1<<30
ans = INF

ans = min(ans,syoumen(Uy,Dy))
ans = min(ans,syoumen(Rx,Lx))

ans = min(ans,naname(d1R,d1U))
ans = min(ans,naname(d2U,d2L))
ans = min(ans,naname(d3D,d3L))
ans = min(ans,naname(d4R,d4D))

if ans == INF:
    print("SAFE")
else:
    print(ans)



Measured memory_bytes: 196420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	int N;
	cin >> N;
	int cnt[N+5][27];
	memset(cnt,0,sizeof cnt);
	for(int i=1;i<=N;i++){
		string x;
		cin >> x;
		for(int j=0;j<x.size();j++){
			char y = x[j];
			int a  = (int)(y - 'a');
			cnt[i][a]++;
		}
	}
	string gg = "";
	for(int i=0;i<26;i++){
		int mini = 1e9;
		for(int j=1;j<=N;j++){
			mini = min(mini,cnt[j][i]);
		}
		for(int j=1;j<=mini;j++){
			gg = gg + (char)('a' + i);
		}
	}
	cout << gg << "\n";
}



Measured memory_bytes: 256
#include <stdio.h>
int map[6],temp;
int catch(char dir[]){
    if(dir[0]=='N'){
        temp=7-map[1];
        map[0]=map[1];
        map[1]=map[4]=map[2];
        map[2]=temp;
    }
    if(dir[0]=='E'){
        temp=7-map[4];
        map[5]=map[4];
        map[4]=map[1]=map[3];
        map[3]=temp;
    }
    if(dir[0]=='W'){
        temp=7-map[4];
        map[3]=map[4];
        map[4]=map[1]=map[5];
        map[5]=temp;
    }
    if(dir[0]=='S'){
        temp=7-map[1];
        map[2]=map[1];
        map[1]=map[4]=map[0];
        map[0]=temp;
    }
    if(dir[0]=='R'){
        temp=map[2];
        map[2]=map[5];
        map[0]=7-map[2];
        map[3]=temp;
        map[5]=7-map[3];
    }
    if(dir[0]=='L'){
        temp=map[2];
        map[2]=map[3];
        map[3]=map[0];
        map[5]=temp;
        map[0]=7-map[2];
    }
    return map[1];
}
int main(void){
    int num,i,sum;
    char dir[6];
    for(;sum=1,scanf("%d",&num),num;){
        map[0]=5;map[1]=1;map[2]=2;map[3]=4;map[4]=1;map[5]=3;
        for(i=0;i<num;i++){
            scanf("%s",dir);
            sum+=catch(dir);
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& a){return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }

main()
{
  string N;
  while(cin >> N, N != "0000") {
    if(count(N.begin(), N.end(), N[0]) == 4) {
      cout << "NA" << endl;
    } else {
      int ret = 0;
      for( ; N != "6174"; ret++) {
        string Sort1 = N, Sort2 = N;
        sort(Sort1.rbegin(), Sort1.rend());
        sort(Sort2.begin(), Sort2.end());
        int Value = atoi(Sort1.c_str()) - atoi(Sort2.c_str());
        stringstream sss; sss << Value;
        N = sss.str();
        while(N.size() < 4) N = "0" + N;
      }
      cout << ret << endl;
    }
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  ll count = 0;
  int right = 0;
  ll sum = 0;
  ll xorsum = 0;
  for (int left = 0; left < N; left++) {
    while (right < N && sum + A[right] == (xorsum ^ A[right])) {
      sum += A[right];
      xorsum ^= A[right];
      right++;
    }
    
    count += (right - left);
    
    if (right == left) right++;
    else {
      sum -= A[left];
      xorsum ^= A[left];
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1024
n = int(input())
a = []
for i in range(n):
    a.append(list(input().split()))
    a[i][1] = 100-int(a[i][1])
    a[i].append(i+1)

a.sort(key=lambda x:(x[0],x[1]))

for i in range(n):
    print(a[i][2])

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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

const int mod = 1e9+7;

int N;
auto dp = vectors(111, 9, 9, 9, 0);

bool isAGC(vector<int> C) {
  return C[0] == 0 and C[1] == 1 and C[2] == 2;
}


signed main() {
  cin >> N;
  int M = 4;

  // 初期化
  // dp[0][3][3][3] = 1;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        if (i == 0 and j == 1 and k == 2) continue;
        if (i == 0 and j == 2 and k == 1) continue;
        if (i == 1 and j == 0 and k == 2) continue;
        dp[3][i][j][k] = 1;
      }
    }
  }

  for (int i = 3; i < N; i++) {
    for (int c3 = 0; c3 < M; c3++) { // iの3文字前
      for (int c2 = 0; c2 < M; c2++) { // iの2文字前
        for (int c1 = 0; c1 < M; c1++) { // iの1文字前
          for (int now = 0; now < M; now++) { // 新しく選ぶ文字
            // AGC文字列になるかどうかの判定
            bool ok = true;
            vector<int> t = {c3, c2, c1, now};
            if (isAGC({c3, c2, c1}) or isAGC({c2, c1, now})) ok = false;

            for (int j = 0; j < t.size()-1; j++) {
              vector<int> tt = t;
              swap(tt[j], tt[j+1]);
              if (isAGC({tt[0], tt[1], tt[2]}) or isAGC({tt[1], tt[2], tt[3]})) ok = false;
            }

            // AGC文字列にならないなら遷移させる
            if (ok) {
              Add(dp[i+1][c2][c1][now], dp[i][c3][c2][c1]);
            }
          }
        }
      }
    }
  }

  int ans = 0;
  for (int c3 = 0; c3 < M; c3++) {
    for (int c2 = 0; c2 < M; c2++) {
      for (int c1 = 0; c1 < M; c1++) {
        Add(ans, 1LL*dp[N][c3][c2][c1]); // これはNでできる。
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.lang.*;

// class Pair implements Comparable<Pair>{
//   long a;
//   int cnt;
//   public Pair(long i, int j){
//     this.a = i;
//     this.cnt = j;
//   }
//   public int compareTo(Pair p){
//     if(this.cnt>=2 && p.cnt >=2 && this.a<p.a) return -1;
//     if(this.cnt<2 && p.cnt>=2) return -1;
//     return 1;
//   }
// }

class Main{
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      int M = Integer.parseInt(sc.next());
      boolean[] ar = new boolean[N];
      boolean[] br = new boolean[N];
      for(int i = 0; i<M; i++){
        int s = Integer.parseInt(sc.next())-1;
        int g = Integer.parseInt(sc.next())-1;
        if(s == 0) ar[g] = true;
        else if(g == N-1) br[s] = true;
      }
      for(int i = 0; i<N; i++){
        if(ar[i] && br[i]){
          System.out.println("POSSIBLE");
          return;
        }
      }
      System.out.println("IMPOSSIBLE");
  }
}

Measured memory_bytes: 63636
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

int main() {
	int n;
	std::cin >> n;
	long double ans=1;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	rep(i,n) {
		if(a[i]==0) {
			print(0);
			return 0;
		}
	}
	rep(i,n) {
		ans*=a[i];
		if(ans>1e18) {
			print(-1);
			return 0;
		}
	}
	print((lnt)(ans));
}


Measured memory_bytes: 4052
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	while (in.hasNext()) {
	 double min_v = in.nextDouble();
	 double t = min_v / 9.8;
	 double y = t * t * 4.9;
	 double n2 = (y + 5) / 5;
	 if (n2 % 1.0d != 0.0) n2+=1;
	 System.out.println((int)n2);
	}
 }
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e18;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 105, V = 1e5 + 5;
ll w[N], v[N];
ll dp[V];
int n;

int main(){
    fIO

    memset(dp, -1, sizeof(dp));

    ll maxW;
    ll tot = 0;
    cin >> n >> maxW;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        tot += v[i];
    }

    fill(dp, dp + V, oo);

    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(ll j = tot; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }

    ll ans = 0;
    for(ll j = 0; j <= tot; j++){
        if(dp[j] <= maxW) ans = max(ans, j);
    }

    cout << ans;
}









Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	long long int x, y=100, cnt=0;
	scanf("%lld", &x);
	
	while(y<x){
		y=y+y/100;
		cnt++;
	}
	
	printf("%lld", cnt);
	
return 0;
}

Measured memory_bytes: 1736
using System;

namespace newEx
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] l = Console.ReadLine().Split(' ');
            int p = int.Parse(l[0]);
            int q = int.Parse(l[1]);


            Console.WriteLine(Solve(p, q));
        }

        public static int Solve(int X, int A)
        {
            if (X < A)
            {
                return 0;
            }
            else
            {
                return 10;
            }
        }
    }
}


Measured memory_bytes: 27532
#include <iostream>

using namespace std;

void func(int &points_A, int &points_B, string str1, string str2) {
    int n;
    int isLonger = 0;
    if (str1.length() > str2.length()) {
        n = str2.length();
        isLonger = 1;
    } else if (str1.length() < str2.length()) {
        n = str1.length();
        isLonger = 2;
    } else {
        n = str1.length();
    }
    for (int i = 0; i < n; i++) {
        if ((int) str1[i] > (int) str2[i]) {
            points_A += 3;
            return;
        } else if ((int) str1[i] < (int) str2[i]) {
            points_B += 3;
            return;
        }
    }

    if (isLonger == 1) {
        points_A += 3;
        return;
    } else if (isLonger == 2) {
        points_B += 3;
        return;
    } else if (isLonger == 0) {
        points_A++;
        points_B++;
    }


}

int main() {
    int points_A = 0;
    int points_B = 0;
    int num;
    cin >> num;
    for (int i = 0; i < num; i++) {
        string str1;
        string str2;
        cin >> str1;
        cin >> str2;

        func(points_A, points_B, str1, str2);
    }
    cout << points_A << " " << points_B << "\n";

}

Measured memory_bytes: 3120
import math,itertools,bisect,sys,copy,queue

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

N,M,Q = LI()

train = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    l,r = LI()
    train[l][r] += 1

c = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(1,N+1):
    cnt = 0
    for j in range(1,N+1):
        cnt += train[i][j]
        c[i][j] = c[i-1][j] + cnt

for _ in range(Q):
    l,r = LI()
    print (c[r][r]-c[r][l-1]-c[l-1][r]+c[l-1][l-1])



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

int main()
{
	int N;
	std::cin >> N; std::cin.ignore();

	std::vector<int> numbers(N);
	for (int count = 0; count < N; ++count) {
		std::cin >> numbers[count]; std::cin.ignore();
	}

	std::string output = "APPROVED";
	for (int number : numbers) {
		if (number % 2 != 0) { continue; }
		if (number % 3 != 0 && number % 5 != 0) {
			output = "DENIED";
			break;
		}
	}

	std::cout << output << std::endl;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int MOD = 1e9 + 7;
const int N = 1e5 + 100;

int n, a[N];

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

    cin >> n; forn(i,n) cin >> a[i];

    ll ans = 1;

    int j = 0, start = a[0];
    forn(i,n) {
        while (j < n-1) {
            start = min(start, a[j] - 2*(j-i));
            if (start <= 0) break;
            j++;
        }
        ans = ans * (j+1-i) % MOD;
        start += 2;
    }
    ans %= MOD; if (ans < 0) ans += MOD;
    cout << ans << endl;
        


    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:268435456")
#ifdef _MSC_VER
#	include <intrin.h>
#	define __builtin_popcount(n) __popcnt(n)
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <list>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#define ll long long
#define ull unsigned ll
#define pll pair<ll, ll>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pis pair<int, string>
#define pss pair<string, string>
#define pdd pair<double, double>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define mii map<int, int>
#define mll map<ll, ll>
#define pb push_back
#define PI acos(-1.0L)
#define inf 0x3f3f3f3f
#define inf2 0x3f3f3f3f3f3f3f3f
// [Note1: Use long double]  // %Lf

using namespace std;

inline int gi(){
    char ch=getchar();
    while(!((ch>='0'&&ch<='9')||ch=='-')) ch=getchar();
    int x=0,p=1;
    if(ch=='-') p=-1, ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0', ch=getchar();
    return x*p;
}

int n,m;
ll a,ans[100010];
deque<ll> q1;
mll m1;
mll::iterator it;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
	
	scanf("%d %d", &n, &m);
	q1.push_back(n);
	for(int i=1;i<=m;i++){
		scanf("%lld", &a);
		while(!q1.empty()&&a<q1.back()) q1.pop_back();
		q1.push_back(a);
	}

	m1[q1.back()]=1,q1.pop_back();
	while(!q1.empty()){
		it=m1.upper_bound(q1.back());
		while(it!=m1.end()){
			ll temp=it->first;
			m1[q1.back()]+=temp/q1.back()*it->second;
			m1[temp%q1.back()]+=it->second;
			++it,m1.erase(temp);
		}
		q1.pop_back();
	}
	for(int i=n;i>=1;i--)
		ans[i]+=ans[i+1]+m1[i];
	for(int i=1;i<=n;i++)
		printf("%lld\n", ans[i]);

	//fprintf(stderr, "solved.\n");
	//system("pause");
	return 0;
}

Measured memory_bytes: 8832
# from https://twitter.com/wakuwinmail_C/status/950277218411855872

N, Y = gets.split.map(&:to_i)

x = Y / 10000
y = Y % 10000 / 5000
z = Y % 5000 / 1000

temp=N-(x+y+z)

if temp < 0
  x=y=z=-1
end

if x >= temp % 4
  x -= temp % 4
  y += temp % 4 * 2
  temp -= temp % 4
else
  x=y=z=-1
end

if x >= temp
  x -= temp
  y += temp * 2
  temp = 0
else
  temp -= x / 4 * 4
  y += (x - x % 4) * 2
  x %= 4
end

if y >= temp / 4
  y -= temp / 4
  z += temp / 4 * 5
  temp = 0
else
  x=y=z=-1
end

puts "#{x} #{y} #{z}"


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll x; cin >> x;
  ll flag = x / 11 * 2;
  x -= x/11 * 11;
  if(x > 6) flag += 2;
  else if(x > 0) flag++;
  else flag;
  fin(flag);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll V, T;
string S;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

class imos1D {
public:
    vector<int> data;
    bool is_build = false;
    imos1D(int n) : data(n + 1) {}
    //[l,r)
    void add(int l, int r, int val) {
        if (is_build) {
            fill(data.begin(), data.end(), 0);
            is_build = false;
        }
        data[l] += val;
        data[r] -= val;
    }
    int get(int index) {
        if (!is_build) {
            for (int i = 0; i < N; i++) {
                data[i + 1] += data[i];
            }
            is_build = true;
        }
        return data[index];
    }
};

signed main() {
    cin >> N >> K;
    vector<int> a(N), b(N + 1);
    cin >> a;
    int cnt = 0;
    int k = 0;
    imos1D im(N);
    while (cnt != N && k < K) {
        cnt = 0;
        k++;
        REP(i, N) {
            int l = max(i - a[i], 0);
            int r = min(i + a[i] + 1, int(N));
            im.add(l, r, 1);
        }
        REP(i, N)
        a[i] = im.get(i);
        cnt = count(ALL(im.data), N);
    }
    REP(i, N) {
        cout << a[i] << " ";
    }
}


Measured memory_bytes: 5636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
  	string s;
  	int count=0;
  	int countmax=0;
  	cin >> s;
  	for(int i=0;i<s.size();i++){
    	if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
        	count++;
        }else{
          if(countmax<count){
                countmax = count;
        	}
        	count = 0;
        }
    }
  	if(countmax<count){
    	countmax = count;
    }
  	cout << countmax <<endl;
  	return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> mine(h);
    for(int i = 0; i < h; i++){
        cin >> mine[i];
    }

    vector<vector<int>> ans(h, vector<int>(w,0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mine[i][j] == '#'){
                if(i - 1 >= 0 && j - 1 >= 0){
                    if(mine[i - 1][j - 1] != '#'){
                        ans[i - 1][j - 1]++;
                    }
                }
                if(i - 1 >= 0){
                    if(mine[i - 1][j] != '#'){
                    ans[i - 1][j]++;
                    }
                }
                if(i - 1 >= 0 && j + 1 <= w - 1){
                    if(mine[i - 1][j + 1] != '#'){
                    ans[i - 1][j + 1]++;
                    }
                }
                if(j - 1 >= 0){
                    if(mine[i][j - 1] != '#'){
                    ans[i][j - 1]++;
                    }
                }
                if(j + 1 <= w - 1){
                    if(mine[i][j + 1] != '#'){
                    ans[i][j + 1]++;
                    }
                }
                if(i + 1 <= h - 1 && j - 1 >= 0){
                    if(mine[i + 1][j - 1] != '#'){
                    ans[i + 1][j - 1]++;
                    }
                }
                if(i + 1 <= h - 1){
                    if(mine[i + 1][j] != '#'){
                    ans[i + 1][j]++;
                    }
                }
                if(i + 1 <= h - 1 && j + 1 <= w - 1){
                    if(mine[i + 1][j + 1] != '#'){
                    ans[i + 1][j + 1]++;
                    }
                }
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(ans[i][j] != 0){
                cout << ans[i][j];
            }
            else{
                if(mine[i][j] == '#'){
                    cout << "#";
                }
                else{
                    cout << "0";
                }
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
data = list(map(int, input().strip().split()))



#print(type(value))
#print(data)

#boxA - X
#boxB - Y
#boxC - Z

x = data[0]
y = data[1]
z = data[2]

#print("before x", x)
#print("before y", y)
#boxA = x
#boxB = y
#boxC = z

x, y = y, x
#print("after x", x)
#print("after y", y)

x, z = z, x
#print("after x", x)
#print("after z", z)

boxA = x
boxB = y
boxC = z

print(boxA, boxB, boxC)

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

using namespace std;

int a[100005];

int main() {
	int n;
	scanf("%d", &n);
	
	int res = 0;
	int cur = 0;
	
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	for (int i = n; i >= 0; i--) {
		if (a[i] < a[i + 1]) {
			res = max(res, cur);
			cur = 1;
		}
		else cur++;
	}
	
	printf("%d\n", res - 1);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] + a[j] > a[k]) {
					if (a[i] != a[j] && a[j] != a[k]) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 20

struct point {
  int t;
  int x;
  int y;
};

int comp(const void* a, const void* b) {
  struct point* pa = (struct point*)a;
  struct point* pb = (struct point*)b;
  return pa->t - pb->t;
}

int is_move(struct point* cur, struct point* next) {
  int dist = abs(cur->x - next->x) + abs(cur->y - next->y);
  int time_diff = next->t - cur->t;
  if(time_diff < dist) return 0;
  if((dist&1) == (time_diff&1)) return 1;
  return 0;
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(line, "%d", &num);
  struct point *ps = malloc(sizeof(struct point)*(num+1));
  
  int i;
  ps[0].t = ps[0].x = ps[0].y = 0;
  for(i = 1; i <= num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%d %d %d", &ps[i].t, &ps[i].x, &ps[i].y);
  }
  // already sorted
  // qsort(ps, num+1, sizeof(struct point), comp);

  int flag = 1;
  for(i = 0; i < num; i++) {
    flag &= is_move(&ps[i], &ps[i+1]);
    if(!flag) break;
  }
  printf("%s\n", flag ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 1280
import math
N = int(input())
ans = [0 for _ in range(10050)]
r_n = math.floor(math.sqrt(N))
count = 0
for x in range(1,r_n):
    for y in range(1,r_n):
        for z in range(1,r_n):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n < 10050:
                ans[n]+=1
for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 110
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int a[MAXN];
int main() {
    int k, t;

    cin >> k >> t;

    int ma = 0;
    rep(i, t) {
        cin >> a[i];
        ma = max(ma, a[i]);
    }

    int ans = max(ma-1-(k-ma), 0);
    cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
f = False
count = 0
m = P[0]
for i in range(N):
    m = min(m, P[i])
    if m >= P[i]:
        count += 1


print(count)

    # print(i)
#     for j in reversed(range(0,i)):
#         # print(j)
#         if P[i] > P[j]:
#             f = True
        
#     if f == False:
#         count += 1
#     f = False
# print(count)


Measured memory_bytes: 32328
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse = True)
q = sorted(list(map(int, input().split())), reverse = True)
r = sorted(list(map(int, input().split())), reverse = True)

s = sorted(p[:x] + q[:y] + r, reverse = True)
print(sum(s[:x+y]))

'''
pi = x - 1
qi = y - 1
ri = 0

while ri < c and (p[pi] < r[ri] or q[qi] < r[ri]):
    if p[pi] >= q[qi]:
        q[qi] = r[ri]
        qi -= 1
    else:
        p[pi] = r[ri]
        pi -= 1
    ri += 1

print(sum(p[:x]) + sum(q[:y]))
'''

Measured memory_bytes: 22720
#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 int INF = 1001001001;

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

  int n, x, y; cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n, 0);

  rep(i, n) {
    queue<int> q;
    vector<int> dist(n, INF);

    auto push = [&](int v, int d) {
		 if(dist[v] != INF) return;
		 q.push(v);
		 dist[v] = d;
	       };

    push(i, 0);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];

      if(v-1 >= 0) push(v-1, d+1);
      if(v+1 < n) push(v+1, d+1);
      if(v == x) push(y, d+1);
      if(v == y) push(x, d+1);
    }
    rep(i, n) ++ans[dist[i]];
  }
  rep(i, n) ans[i]/=2;
  rep(i, n-1) {
    cout << ans[i+1] << endl;
  }
}


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

using namespace std;

typedef long long ll;

struct para
{
    ll d, m, nr;
};

bool por(para a, para b)
{
    if (a.m < b.m)
        return true;
    if (a.m > b.m)
        return false;
    if (a.nr < b.nr)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<para> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].d >> a[i].m;
        a[i].nr = i;
    }
    sort(a.begin(), a.end(), por);
    ll s = 0;
    for (int i = 0; i < n; ++i)
    {
        s += a[i].d;
        if (s > a[i].m)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
long long int dp[1001][1001];
int main(void){
	int i,j,n,m,d[1001],c[1001];
	long long int min,M;
	M=9223372036854775800;
	scanf("%d %d",&n,&m);
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++) dp[i][j]=M;
	}
	for(i=0;i<n;i++) scanf("%d",&d[i]);
	for(i=0;i<m;i++) scanf("%d",&c[i]);
	dp[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(dp[i][j]!=M){
				if(dp[i+1][j]>dp[i][j]) dp[i+1][j]=dp[i][j];
				if(dp[i+1][j+1]>dp[i][j]+d[j]*c[i]) dp[i+1][j+1]=dp[i][j]+d[j]*c[i];
			}
		}
	}
//	for(i=0;i<=m;i++){
//		for(j=0;j<=n;j++){
//			printf("%lld ",dp[i][j]);
//		}
//		printf("\n ");
//	}
	min=M;
	for(i=0;i<=m;i++){
		if(min>dp[i][n]) min=dp[i][n];
	}
	printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 8424
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int main(){
    int H,W;
    char mp[55][55];
    int dy[8] = {-1,0,1,-1,1,-1,0,1}, dx[8] = {-1,-1,-1,0,0,1,1,1};
    cin >> H >> W;
    rep1(i,H) rep1(j,W) cin >> mp[i][j];

    rep1(i,H){
        rep1(j,W){
            int ct = 0;
            if(mp[i][j] == '#') cout << '#';
            else{
                rep(k,8) if(mp[i+dy[k]][j+dx[k]] == '#') ct++;
                cout << ct;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int chk(double x1,double y1,
	double x2,double y2,
	double x3,double y3,
	double xp,double yp);

int main(){

	double x1,y1,x2,y2,x3,y3,xp,yp;
	
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
		     &x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
//printf("%.3lf %.3lf %.3lf %.3lf %.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2,x3,y3,xp,yp);

		printf(chk(x1,y1,x2,y2,x3,y3,xp,yp)?"YES\n":"NO\n");
	}

	return 0;
}
int chk(double x1,double y1,
	double x2,double y2,
	double x3,double y3,
	double xp,double yp){

//	p=sa+tb	
//	a.x * s + b.x * t = p.x;
//	a.y * s + b.y * t = p.y;
//	p=(xp-x1,yp-y1);
//	a=(x2-x1,y2-y1);
//	b=(x3-x1,y3-y1);

	double a,b,c,d,e,f;
	double s,t;

	a=x2-x1;
	b=x3-x1;
	c=xp-x1;

	d=y2-y1;
	e=y3-y1;
	f=yp-y1;

	s=(-e*c+b*f)/(-a*e+b*d);
	t=(+d*c-a*f)/(-a*e+b*d);

	//printf("%.3lf,%.3lf",s,t);

	if(s>0 && t>0 && s+t<1 )return 1;
	return 0;

}

Measured memory_bytes: 616
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;

	c = malloc(sizeof(int)*(m+1994));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(n+1));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[2014], y[2014];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 4624
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#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 int             long long int
#define ld              long double
#define F               first
#define S               second
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpi             vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define spi             set <pii>
#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 100005;
int cache[101][N], i, j, n, w;
vpi v;

int dp(int i, int wg)
{
     if (i == n)
          return 0;
     int &ans = cache[i][wg];
     if (ans != -1)
          return ans;

     ans = 0;
     if (wg + v[i].F <= w)
          ans = max(ans, v[i].S + dp(i + 1, wg + v[i].F));
     ans = max(ans, dp(i + 1, wg));
     return ans;
}

void solve()
{
     cin >> n >> w;
     v.resize(n);
     for (i = 0; i < n; i++)
          cin >> v[i].F >> v[i].S;

     memset(cache, -1, sizeof cache);
     cout << dp(0, 0);

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 79232
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int i, n;
    long a;

    n = sc.nextInt();
    a = 1;
    for(i = 0;i < n;i++)a *= (i + 1);
    System.out.println(a);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;
int pnt[11][2] = {
	{1,1}, {1,2}, {1,3}, {2,0},
	{2,1}, {2,2}, {2,3}, {2,4},
	{3,1}, {3,2}, {3,3}
};
int ans = -1;
struct F {
	int p[5][5];
	int cnt;
};
set<string> s;
queue<F> q;

bool cost(int p[5][5], int cnt) {
	int c = cnt;
	REP(i, 5) REP(j, 5) {
		if(p[i][j] > 0) {
			c += abs(i - pnt[p[i][j]-1][0]);
			c += abs(j - pnt[p[i][j]-1][1]);
//			cout << abs(i - pnt[p[i][j]-1][0]) << ' ' << abs(j - pnt[p[i][j]-1][1]) << "  ";
		}
	}
//	cout << c << endl;
	if(c == cnt) ans = cnt;
	return (c > 20) ? true : false;
}

void bfs() {
	while(q.size()) {
		F f = q.front();
		q.pop();
//		cout << cost(f.p, f.cnt) << endl;
		if(cost(f.p, f.cnt)) continue;
		if(ans != -1) break;
		string str = "";
		REP(i, 5) REP(j, 5) str += to_string(f.p[i][j]) + ',';
		if(s.count(str) > 0) continue;
//		cout << str << endl;
		s.insert(str);
		REP(i, 5) REP(j, 5) {
			if(f.p[i][j] == 0) {
				if(j < 4 && f.p[i][j+1] != -1) {
					F f2 = f;
					swap(f2.p[i][j], f2.p[i][j+1]);
					f2.cnt++;
					q.push(f2);
				}
				if(0 < j && f.p[i][j-1] != -1) {
					F f2 = f;
					swap(f2.p[i][j], f2.p[i][j-1]);
					f2.cnt++;
					q.push(f2);
				}
				if(i < 4 && f.p[i+1][j] != -1) {
					F f2 = f;
					swap(f2.p[i][j], f2.p[i+1][j]);
					f2.cnt++;
					q.push(f2);
				}
				if(0 < i && f.p[i-1][j] != -1) {
					F f2 = f;
					swap(f2.p[i][j], f2.p[i-1][j]);
					f2.cnt++;
					q.push(f2);
				}
			}
		}
	}
	return;
}

int main() {
	while(true) {
		q = queue<F>();
		s.clear();
		ans = -1;
		F f;
		int p[5][5] = {
			{-1, -1, 0, -1, -1},
			{-1, 0, 0, 0, -1},
			{0, 0, 0, 0, 0},
			{-1, 0, 0, 0, -1},
			{-1, -1, 0, -1, -1},
		};
		REP(i, 5) REP(j, 5) {
			if(p[i][j] == -1) {
				f.p[i][j] = -1;
				continue;
			}
			else
				cin >> f.p[i][j];
			if(f.p[i][j] == -1) return 0;
		}
		f.cnt = 0;
		q.push(f);
		bfs();
		if(ans < 0) cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4444