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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;




int main() {
	
	int n;
	cin >> n;
	VI t(n);
	REP(i, n) cin >> t[i];

	int sum = 0;
	REP(i, n)sum += t[i];

	int ans = sum;

	int cur = 0;
	REP(i, n) {
		cur += t[i];
		int di = sum - cur;
		ans = min(ans, abs(cur - di));
	}

	cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
struct node {
	int x;
	ll c[2];
	node() {
        x = c[0] = c[1] = 0;
	}
	bool operator < (node a) const {
        return a.c[1]*c[0] < a.c[0]*c[1];
	}
};
int n;
int par[maxn];
node p[maxn];
int head[maxn];
priority_queue<node> heap;
int findhead(int x) {
	if(head[x]==x) return x;
	return head[x] = findhead(head[x]);
}
int main() {
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d",&par[i]);
	for(int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		p[i].x = i;
		p[i].c[x] = 1;
	}
	long long ans = 0;
	for(int i=1;i<=n;i++) head[i] = i;
	for(int i=2;i<=n;i++) heap.push(p[i]);
	while(!heap.empty()) {
		node t = heap.top(); heap.pop();
		int x = t.x;
		if(p[x].c[0]!=t.c[0] || p[x].c[1]!=t.c[1]) continue;
		int y = findhead(par[x]);
//		printf("merge %d with %d\n",x,y);
		ans += p[y].c[1] * p[x].c[0];
		p[y].c[0] += p[x].c[0];
		p[y].c[1] += p[x].c[1];
		if(y!=1) heap.push(p[y]);
		head[x] = y;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 14704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
	cin>>a>>b;
	cout<<a*b; 
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)

#define PI 3.14159265358479

int main(){
	int n;
	cin >> n;
	FOR(i,1,n+1){
		if (i % 3 == 0)cout << " " << i;
		long long int k = i;
		REP(j, 4){
			if (i % 3 == 0)break;
			if (k % 10 == 3){
				cout << " " << i;
				break;
			}
			k = k / 10;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <math.h>
#include <iostream>

int main() {
	int n;
	std::cin >> n;

	int loan = 100000;
	for (int i = 0; i < n; i++) {
		loan *= 1.05;
		if (int tmp = loan % 1000)
			loan += 1000 - tmp;
	}
	std::cout << loan << std::endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

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

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	for (int i = 2; i >= 0; i--) {
		if (a[i] % 2 == 0) {
			puts("0");
			return 0;
		}
	}
	cout << a[0] * a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
function bomb(x,y,t){
   if(obj.hasOwnProperty(x+","+y)==true && obj[x+","+y]>=t)return;
   obj[x+","+y]=t;
   if(t==0)return;
   var dx=[0,1,1,0,-1,-1];
   var dy=[1,1,0,-1,-1,0];
   for(var i=0;i<6;i++){
      if(xy[x+dx[i]][y+dy[i]]==0)bomb(x+dx[i],y+dy[i],t-1);
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var tn=arr.shift();
   if(tn=="0 0")break;
   tn=tn.split(" ").map(Number);
   var xy=[];
   for(var x=0;x<200;x++){
      xy[x]=[];
      for(var y=0;y<200;y++){
         xy[x][y]=0;
      }
   }
   while(tn[1]--){
      var wall=arr.shift().split(" ").map(Number);
      var x=wall[0]+100;
      var y=wall[1]+100;
      xy[x][y]=1;
   }
   var start=arr.shift().split(" ").map(Number);
   var obj={};
   bomb(start[0]+100,start[1]+100,tn[0]);
   console.log(Object.keys(obj).length);
}

Measured memory_bytes: 60540
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}



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

int main()
{
  string s;
  int k;
  cin >> s;
  cin >> k;

  vector<string> ans;
  for (int len = 1; len <= 5; len++) {
    for (int i = 0; i + len <= int(s.length()); i++) {
      ans.push_back(s.substr(i, len));
    }
  }
  sort(begin(ans), end(ans));
  unique(begin(ans), end(ans));
  cout << ans[k - 1] << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>


int main()
{
	ll i,j,k,n;
	cin>>n;
	ll arr[n+1];
	ll ans[n+1]={0};
	for(i=0;i<n-1;i++)
	{
		cin>>arr[i];
		ans[arr[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;

}

Measured memory_bytes: 6748
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	string t;
	for (char i = 'z'; i >= 'a'; i--) {
		t.push_back(i);
	}
	if (s == t) {
		cout << -1 << endl;
		return 0;
	}
	if (s.size() == 26) {
		t = s;
		next_permutation(s.begin(), s.end());
		for (int i = 0; i < 26; i++) {
			cout << s[i];
			if (s[i] != t[i]) {
				break;
			}
		}
		return 0;
	}
	for (int i = min(26, (int)s.size()); i >= 1; i--) {
		vector<int>v(300);
		for (int j = 0; j < i; j++) {
			v[s[j]]++;
		}
		for (int j = 'a'; j <= 'z'; j++) {
			if (!v[j]) {
				for (int k = 0; k < i; k++) {
					cout << s[k];
				}
				cout << char(j) << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    bubbleSort(A, N)

def bubbleSort(A, N):
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
                i += 1

    print(' '.join(map(str, A)))
    print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 500
using namespace std;
char Map[MAXN+5][MAXN+5];
char red[MAXN+5][MAXN+5],blue[MAXN+5][MAXN+5];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",Map[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=2;j<m;j++)
			if(i%2==1)
				red[i][j]='#';
			else
				blue[i][j]='#';
	for(int i=1;i<=n;i++)
		red[i][1]='#',blue[i][m]='#';
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(Map[i][j]=='#')
			{
				if(red[i][j]=='#')
					blue[i][j]='#';
				else
					red[i][j]='#';
			}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(red[i][j]==0)
				red[i][j]='.';
			if(blue[i][j]==0)
				blue[i][j]='.';
		}
	for(int i=1;i<=n;i++)
		printf("%s\n",red[i]+1);
	printf("\n");
	for(int i=1;i<=n;i++)
		printf("%s\n",blue[i]+1);
	return 0;
}

Measured memory_bytes: 1408
let solve n w d =
  let v0 = Array.make (w + 1) 0 in
  let v1 = Array.make (w + 1) 0 in
  let rec doit = function
    | (i, _) when i > n -> v1.(w)
    | (i, x) when x > w ->
      Array.iteri (fun i e -> v0.(i) <- e) v1;
      doit (i + 1, 1)
    | (i, x) ->
      let (vi, wi) = d.(i-1) in
      v1.(x) <- if wi <= x && v0.(x-wi) + vi > v0.(x) then v0.(x-wi) + vi else v0.(x);
      doit (i, x + 1) in
  doit (1, 1)

let read () = Scanf.scanf "%d %d\n" (fun x y -> (x, y))

let () =
  let (n, w) = read () in
  let d = Array.init n (fun _ -> read ()) in
  Printf.printf "%d\n" (solve n w d)

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

long long cnt;
vector<int> G;

void insertionSort(vector<int>& A, int g) {
    for (auto i = g; i < A.size(); i++) {
        int v = A[i];
        int j = i-g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j-g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int>& A) {
    cnt = 0;

    int i = 1;
    while (i <= A.size()) {
        G.push_back(i);
        i = 3*i + 1;
    }
    for (int i = G.size()-1; i >= 0; i--) {
        insertionSort(A, G[i]);
    }
}


int main(void) {
    int n;
    cin >> n;

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

    shellSort(ary);
    cout << G.size() << endl;
    for (auto i = G.size()-1; i >= 1; i--) {
        cout << G[i] << " ";
    }
    cout << G[0] << endl;
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << ary[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4888
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>

int main()
{

    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int s;
    cin>>s;


    cout<<arr[s-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int A,B;
  
  scanf("%d\n",&A);
  scanf("%d\n",&B);
  
  if(A>=13&&A<=100){
    
    printf("%d",B);
  }
  else if(A<13&&A>5){
    printf("%d",B/2);
  }
  else if(A<=5&&A>=0){
    printf("%d",0);
  }
        
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    if (N[0] == '9' || N[1] == '9') {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,m;
  cin>>n>>m;
  int nums[n];
  bool red[n];
  REP(i,n){
    nums[i]=1;
    red[i]=false;
  }
  red[0]=true;
  int x,y;
  REP(i,m){
    cin>>x>>y;
    x--;y--;
    nums[x]--;
    nums[y]++;
    if(red[x]){
      red[y] = true;
      if(nums[x]==0){
        red[x] = false;
      }
    }
  }
  int ans=0;
  REP(i,n){
    if(red[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 768
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n, x;
    readf("%d %d\n", &n, &x);

    int[] a;
    foreach(i; 0..n) a ~= readint();
    writeln(n + (x - a.sum) / a.reduce!min);

    string _ = readln;
}

Measured memory_bytes: 256
from itertools import combinations

N = int(input())
A = [int(num) for num in input().split()]

combs = combinations(A, 2)

ret = 0
for comb in combs:
    if abs(comb[0] - comb[1]) > ret:
        ret = abs(comb[0] - comb[1])

print(ret)


Measured memory_bytes: 3060
h, w = map(int, input().split())
li = [['x']*(w+2)]
li += [list('x' + input() + 'x') for _ in range(h)]
li += [['x']*(w+2)]

x = 1
y = 1

flag = 1
while flag:
    li[y][x] = 'o'

    if li[y][x+1] == '#':
        x += 1
    elif li[y+1][x] == '#':
        y += 1
    else:
        break

for i in range(h+2):
    for j in range(w+2):
        if li[i][j] == '#':
            print('Impossible')
            break
    else:
        continue
    break
else:
    print('Possible')

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
#define tc int t;cin>>t;while(t--)
#define get cin>>
#define geta ll a[n];for (int i = 0; i < n; ++i){cin>>a[i];}
#define puta for (int i = 0; i < n; ++i){cout<<a[i];}
#define put cout<<
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
//shaaar
int main() 
{
	
 	int n,m;cin>>n>>m;
 	double a[n];int c=0;double s=0;
 	for (int i = 0; i < n; ++i)
 	{
 		cin>>a[i];
 		s+=a[i];
 	}
 	for (int i = 0; i < n; ++i)
 	{
 		if (a[i]>=(double)(s/(4*m)))
 		{
 			++c;
 		}
 	}
 	if (c>=m)
 	{
 		cout<<"Yes";
 	}
 	else
 	{
 		cout<<"No";
 	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int LOG = 35;
int main(){
  long long N;
  int X, M;
  cin >> N >> X >> M;
  vector<vector<int>> next(35, vector<int>(M));
  for (int i = 0; i < M; i++){
    next[0][i] = (long long) i * i % M;
  }
  for (int i = 1; i < LOG; i++){
    for (int j = 0; j < M; j++){
      next[i][j] = next[i - 1][next[i - 1][j]];
    }
  }
  vector<vector<long long>> sum(35, vector<long long>(M));
  for (int i = 0; i < M; i++){
    sum[0][i] = i;
  }
  for (int i = 1; i < LOG; i++){
    for (int j = 0; j < M; j++){
      sum[i][j] = sum[i - 1][j] + sum[i - 1][next[i - 1][j]];
    }
  }
  long long ans = 0;
  for (int i = 0; i < LOG; i++){
    if (N >> i & 1){
      ans += sum[i][X];
      X = next[i][X];
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 45104
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;
int a, p;
int main() {
	cin >> a >> p;
	int num = (a * 3 + p)/2;
	cout << num;
	return 0;
}


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

using namespace std;

int main()
{
	int R;
  	cin >> R;
  	if(R < 1200) cout << "ABC" << endl;
  	else if(R < 2800) cout << "ARC" << endl;
  	else cout << "AGC" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [i for i in map(int, input().split())]

cnt = 0
for i in range(N):
    if A[i] < 0:
        A[i] = -A[i]
        cnt += 1
if cnt%2 == 0:
    print(sum(A))
else:
    a = min(A)
    print(sum(A)-2*a)

Measured memory_bytes: 14256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	while(cin>>n){
		int count = 0;
		REP(i, 10)
			REP(j, 10)
			REP(k, 10)
			REP(l, 10)
			if (i + j + k + l == n)count++;
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();
		Set<Integer> sSet = new HashSet<Integer>();

		while(!sSet.contains(s)) {
			sSet.add(s);

			if(s % 2 == 0) {
				s = s/2;
			} else {
				s = 3*s + 1;
			}
		}

		System.out.println(sSet.size() + 1);

	}

}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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

    reverse(a.begin(), a.end());

    int max = 0;
    int ans = 0;
    priority_queue<int> q;
    rep(i, a.size()) {
        if (q.empty()) {
            q.push(a[i]);
            continue;
        }

        int d = q.top() - a[i];
        q.push(a[i]);
        if (d > max) {
            max = d;
            ans = 1;
        } else if (d == max) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1276
import sys
import math

sys.setrecursionlimit(1000000)


def solve(H1, M1, H2, M2, K):
    S = H1 * 60 + M1
    E = H2 * 60 + M2
    return max(0, E-S-K)


if __name__ == "__main__":
    H1, M1, H2, M2, K = tuple(map(int, input().split(" ")))
    print(solve(H1, M1, H2, M2, K))

Measured memory_bytes: 9128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x = scanner.nextLong();

        for (long a = 0; a < 10000; a++) {
            for (long b = -10000; b < 10000; b++) {
                if (((long)Math.pow(a, 5)) - ((long)Math.pow(b, 5)) == x) {
                    System.out.println(a + " " + b);
                    System.exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 39040
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

const int maxN=1e6+5;

int main()
{
    int k,l,n,m;
    ll ans=1e18,a[3];
    cin>>n>>m;
    if(n%3==0 || m%3==0)
    {
    	cout<<0<<endl;
    	return 0;
    }
    l=m/2;
    for(k=1;k<=n;k++)
    {
    	a[0]=(ll)k*l;
    	a[1]=(ll)k*(m-l);
    	a[2]=(ll)(n-k)*m;
    	sort(a,a+3);
    	ans=min(ans,a[2]-a[0]);
    }
    l=n/2;
    for(k=1;k<=m;k++)
    {
    	a[0]=(ll)k*l;
    	a[1]=(ll)k*(n-l);
    	a[2]=(ll)(m-k)*n;
    	sort(a,a+3);
    	ans=min(ans,a[2]-a[0]);
    }
    ans=min((ll)min(n,m),ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;

bool cmp(const pair<int, int> &a, const pair<int, int> &b){
	if (a.second == b.second)
		return a.first < b.first;
	return a.second < b.second;
}

int main() {
	IO
	int n, m;
	cin >> n >> m;
	ll x;
	priority_queue <ll> pq;
	while (n--){
		cin >> x;
		pq.push(x);
	}
	while (m--){
		x = pq.top();
		pq.pop();
		x /= 2;
		pq.push(x);
	}
	ll sum = 0;
	while (pq.size()){
		sum += pq.top();
		pq.pop();
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1400
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	int data[10001] = {};
	data[0] = 1;
	for (size_t i = 1; i < 10001; i++)
	{
		data[i] = data[i - 1] + i;
	}
	int n;
	while (cin >> n)
	{
		cout << data[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
fun main(args: Array<String>) {
    val (N, K) = listOfLong()
    var n0 = N % K
    val n1 = K - n0
    val ans = Math.min(n0, n1)
    println(ans)
}


fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }





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

int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    for(int i=0;i<2*n;i++){
        if(i%2==0) cout << s[i/2];
        if(i%2==1) cout << t[i/2];
    }
    cout << endl;
    return 0;
}

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




const int MAXN = 2e5+7;

int bap[MAXN];
int sz[MAXN];

int parent(int u) {
    if (bap[u] == u) return u;
    return bap[u] = parent(bap[u]);
}

void unite(int u, int v) {
    u = parent(u);
    v = parent(v);
    if (u==v) return;
    if (sz[u] < sz[v]) swap(u, v);
    bap[v] = u;
    sz[u] += sz[v];
}

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

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        bap[i] = i;
        sz[i] = 1;
    }

    while (m--) {
        int u, v;
        cin >> u >> v;
        unite(u, v);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (parent(i)==i) {
            ans = max(ans, sz[i]);
        }
    }

    cout << ans << "\n";










    return 0;
}


Measured memory_bytes: 5224
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

void solve()
{
  int r, c;
  cin >> r >> c;
  vector<vector<char>> board(r, vector<char>(c, '.'));
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      cin >> board[i][j];
 
  vector<vector<int>> dp(r, vector<int>(c, 0));
  dp[0][0] = (board[0][0] != '#');
  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      if (i == 0 && j == 0)
        dp[i][j] = (board[0][0] != '#');
      else if ((i == 0 || j == 0) && board[i][j] != '#')
        dp[i][j] = (i >= 1 ? dp[i - 1][j] : dp[i][j - 1]);
      else if (i != 0 && j != 0)
      {
        if (r - 1 >= 0 && board[i - 1][j] != '#')
          dp[i][j] = (dp[i][j]%MOD + dp[i - 1][j]%MOD)%MOD;
        if (c - 1 >= 0 && board[i][j - 1] != '#')
          dp[i][j] = (dp[i][j]%MOD + dp[i][j - 1]%MOD)%MOD;
      }
    }
  }
  cout << (dp[r - 1][c - 1]) << endl;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	int n;
	std::cin >> n;

	std::vector<int> d;

	int temp;
	int i = 1;
	while (std::cin >> temp) {
		d.push_back(temp);
		i++;
		if (i > n)
			break;
	}

	std::sort(d.begin(), d.end());

	std::cout << d[d.size()/2] - d[(d.size() / 2) -1] << std::endl;
		
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int h;cin>>h;
  int w;cin>>w;
  
  vector<string> a(h);
  
  for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
  vector<bool> tate(h);
  vector<bool> yoko(w);
  
  rep(i,h) {
    rep(j,w) {
      if (a.at(i).at(j) == '#'){
        tate.at(i) = true;
        yoko.at(j) = true;
      }
    }
  }
  
  rep(i,h){
    if(tate.at(i)){
      rep(j,w) {
        if (yoko.at(j)){
          cout << a.at(i).at(j) ;
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    K, N = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(x) for x in stdin.readline().rstrip().split()]
    As1 = sorted(As)
    result = As1[-1] - As1[0]
    for i in range(1, len(As1)):
        x = (As1[-1] - As1[i]) + (K - As1[-1]) + As1[i - 1]
        result = min(result, x)

    As2 = [K - a for a in As]
    As2 = sorted(As2)
    result = min(result, As2[-1] - As2[0])
    for i in range(1, len(As2)):
        x = (As2[-1] - As2[i]) + (K - As2[-1]) + As2[i - 1]
        result = min(result, x)

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26444
#include<iostream>
#include<bitset>
using namespace std;
int sum,n;
bitset<1<<22>b;
int main(){
    ios::sync_with_stdio(0);
    b[0]=1;
    cin>>n;
    for(int i=1,p;i<=n;++i){
        cin>>p;
        b|=b<<p;
        sum+=p;
    }
    for(sum=sum+1>>1;!b[sum];++sum);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, m;
bool f1[maxn], f2[maxn];

bool read()
{
	if (scanf("%d %d", &n, &m) != 2)
		return false;

	forn (i, m)
	{
		int a, b;
		scanf("%d %d", &a, &b);

		if (a == 1 && b != n)
			f1[b] = true;

		if (a != 1 && b == n)
			f2[a] = true;
	}

	return true;
}

void solve()
{
	bool g = false;

	forn (i, n)
		g |= f1[i] && f2[i];

	if (g)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


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

int main() {
    int n;
    cin >> n;

    auto sum = 0LL;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0)
            continue;
        if (i % 5 == 0)
            continue;
        sum += i;
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
import sys

def generate_frog_positions(x, y):
    positions = []
    positions.append((x - 1, y - 2))
    positions.append((x, y - 2))
    positions.append((x + 1, y - 2))
    positions.append((x + 2, y - 1))
    positions.append((x + 2, y))
    positions.append((x + 2, y + 1))
    positions.append((x - 1, y + 2))
    positions.append((x, y + 2))
    positions.append((x + 1, y + 2))
    positions.append((x - 2, y - 1))
    positions.append((x - 2, y))
    positions.append((x - 2, y + 1))
    return [(a, b) for (a, b) in positions if 0 <= a <= 9 and 0 <= b <= 9]

def is_near_sprinkler(frog, sprinkler):
    dx = frog[0] - sprinkler[0]
    dy = frog[1] - sprinkler[1]
    return -1 <= dx <= 1 and -1 <= dy <= 1

while True:
    frog_pos = tuple([int(i) for i in sys.stdin.readline().split()])
    if frog_pos == (0, 0):
        break
    num_sprinklers = int(sys.stdin.readline())
    tmp = [int(i) for i in sys.stdin.readline().split()]
    sprinklers = zip(tmp[::2], tmp[1::2])

    positions = [frog_pos]
    for sprinkler in sprinklers:
        next_positions = []
        for pos in positions:
            next_positions += generate_frog_positions(pos[0], pos[1])
            next_positions = [pos for pos in next_positions if is_near_sprinkler(pos, sprinkler)]
        positions = next_positions
    if positions:
        print("OK")
    else:
        print("NA")

Measured memory_bytes: 6788
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
print('R'*x+'U'*y+'L'*x+'D'*(y+1)+'R'*(x+1)+'U'*(y+1)+'L'+'U'+'L'*(x+1)+'D'*(y+1)+'R')


Measured memory_bytes: 9168
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	X, Y := getInt(), getInt()

	out(X + Y/2)
}


Measured memory_bytes: 640
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_l = list(map(int, input().split()))
    p_x_l = [ x-i for i in p_l ]
    for i in range(101):
        if i not in p_x_l:
            print(x-i)
            break
        if -i not in p_x_l:
            print(x+i)
            break

Measured memory_bytes: 9016
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    int a_min = 1000, a_max = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a_min = min(a_min, a);
        a_max = max(a_max, a);
    }

    cout << a_max - a_min << endl;
}


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

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    int cnt = 0;
    rep(i, n) {
        if (x[i] * x[i] + y[i] * y[i] <= d * d) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6420
N,T = map(int,input().split())
t = list(map(int,input().split()))
sum_time = 0
for i in range(1,N):
    if T <= t[i] - t[i-1]:
        sum_time += T
    elif T > t[i] - t[i-1]:
        sum_time += t[i] - t[i-1]
sum_time += T
print(sum_time)

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int k;
    vector<int> v;
    for (int i = 0; i < 3; i++)
    {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    cin >> k;

    sort(v.begin(), v.end(), greater<int>());

    for (int i = 1; i <= k; i++)
        v[0] *= 2;

    int sum = v[0] + v[1] + v[2];
    cout << sum << endl;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
ll dp[81][81][2*80*80+1];
int main()
{
   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    READV(H);
    READV(W);
    ll A[H][W];
    ll B[H][W];
    FORI(i,0,H)
    {
        FORI(j,0,W)
        {
            READ(A[i][j]);
        }
    }
    FORI(i,0,H)
    {
        FORI(j,0,W)
        {
            READ(B[i][j]);
        }
    }
    dp[0][0][0]=1;
    dp[0][1][0]=1;
    dp[0][0][1]=1;
    FORI(i,1,H+1)
    {
        FORI(j,1,W+1)
        {
            ll z=A[i-1][j-1]-B[i-1][j-1];
            FORI(k,0,2*80*80+1)
            {
                if (dp[i-1][j][k])
                {
                    if (abs(k-z)<=2*80*80)
                    {
                        dp[i][j][abs(k-z)]=1;
                    }
                    if (abs(k+z)<=2*80*80)
                    {
                        dp[i][j][abs(k+z)]=1;
                    }
                }
                if (dp[i][j-1][k])
                {
                    if (abs(k-z)<=2*80*80)
                    {
                        dp[i][j][abs(k-z)]=1;
                    }
                    if (abs(k+z)<=2*80*80)
                    {
                        dp[i][j][abs(k+z)]=1;
                    }
                }
            }
        }
    }
    ll ans=inf;
    FORI(i,0,2*80*80+1)
    {
        if (dp[H][W][i])
        {
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
	int n, k;
	cin >> n >> k;
	priority_queue<ll> m;

	for (int i=0; i<n; i++) {
		ll h; cin >> h;
		m.push(h);		
	}

	ll ret = 0;
	for (int i=0; i<n; i++) {
		if (i >= k) ret += m.top();
		m.pop();
	}
	
	cout << ret << endl;
	return 0;
}

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

int main(){

  string b;

  cin >> b;

  if(b=="A"){
    cout << "T" <<endl;
  }

  if(b=="T"){
    cout << "A" <<endl;
  }

  if(b=="G"){
    cout << "C" <<endl;
  }

  if(b=="C"){
    cout << "G" <<endl;
  }

}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Map<BigInteger, Integer> memo;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        BigInteger a = sc.nextBigInteger();
        BigDecimal b =sc.nextBigDecimal();

        System.out.println(b.multiply(new BigDecimal(a)).toBigInteger());

    }


    static int lowerBound(int[] arr, int element) {

        int low = 0, high = arr.length - 1, ans = 0;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (arr[mid] <= element) {
                low = mid + 1;
                ans = mid;
            } else
                high = mid - 1;

        }

        return high;
    }

    static boolean isPalindrome(String word) {
        int i = 0, j = word.length() - 1;

        while (i <= j) {
            if (word.charAt(i++) != word.charAt(j--))
                return false;
        }

        return true;
    }

    static String longestPalindrome(String[] words, String word, int i) {
        if (i >= words.length) {
            if (isPalindrome(word))
                return word;

            return "";
        }

        if (word.length() > 0 && isPalindrome(word))
            return word;
        String left = longestPalindrome(words, word + words[i], i + 1);
        String right = longestPalindrome(words, word, i + 1);

        if (left.length() > 0)
            return left;
        return right;
    }


    static int solve(int[] arr, int i, int j, int k) {
        if (i == j && arr[i] <= k)
            return 1;

        int left = 0, right = 0;
        if (arr[i] <= k)
            left = solve(arr, i + 1, j, k) + 1;

        else if (arr[j] <= k)
            right = solve(arr, i, j - 1, k) + 1;

        return left + right;
    }

    static int minMove(BigInteger bg, int count) {
        if (bg.equals(BigInteger.ONE))
            return count;

        int first = Integer.MAX_VALUE, sec = Integer.MAX_VALUE, last = Integer.MAX_VALUE;
        if (bg.mod(BigInteger.valueOf(2)).compareTo(BigInteger.ZERO) == 0)
            first = minMove(bg.divide(BigInteger.valueOf(2)), count + 1);

        else if (bg.mod(BigInteger.valueOf(3)).compareTo(BigInteger.ZERO) == 0)
            sec = minMove(bg.multiply(BigInteger.valueOf(2)).divide(BigInteger.valueOf(3)), count + 1);

        else if (bg.mod(BigInteger.valueOf(5)).compareTo(BigInteger.ZERO) == 0)
            last = minMove(bg.multiply(BigInteger.valueOf(4)).divide(BigInteger.valueOf(5)), count + 1);

        if (memo.containsKey(bg))
            return memo.get(bg);

        memo.put(bg, Math.min(first, Math.min(sec, last)));

        return Math.min(first, Math.min(sec, last));
    }
}


Measured memory_bytes: 37652
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int n, q, i; 
int* D;

void initValue(void);
int min(int a, int b);
void initRMQ( int n_);
void update(int k, int a);
int findMin(int a, int b);
int query(int a , int b, int k, int l, int r);


int main(int argc, char* argv[]){

    initValue();
	
	initRMQ(n);


	int a, b;
	int com, ans;
	
    while(q > 0){
		
        scanf("%d %d %d",&com, &a, &b);
		
        if(com){
			ans = findMin(a,b);
			printf("%d\n",ans);
		}else{
			update(a,b);
		}	
		q--;
	}

	return 0;
}

int min(int a, int b){
	if(a > b){
	return b;
	}else{
	return a;
	}
}

void initValue(void){

	scanf("%d %d", &n, &q);
	return;
}

void initRMQ(int n_){
	
	n = 1;
	while(n < n_){
		n *= 2;
	}
	
	D = malloc(sizeof(int)* (2 * n - 1));
	
    if(D == NULL){
		printf("Init Array Failed, no memory or size is wrong\n");
		return;
	}

	for(i = 0; i< 2*n-1 ; i++){
		D[i] = INT_MAX;
	}
	return;
}


void update(int k , int a){
	k += n - 1;
	D[k] = a;
	
    while (k > 0){
		k = (k-1)/2;
		D[k] = min(D[k*2+1], D[k*2+2]);
	}
}

int findMin(int a, int b){
	
	return query( a, b+1, 0, 0, n);
}

int query(int a, int b, int k , int l , int r){
	
	if(r <= a || b <= l){
		return INT_MAX;
	}
	if(a <= l && r <= b){
		return D[k];
	}
	
	int vl = query(a, b, k * 2 + 1, l , (l + r) / 2);
	
	int vr = query(a, b, k * 2 + 2, (l + r)/2, r);
	return min(vl, vr);
}




Measured memory_bytes: 2824
#include <stdio.h>
#define COLOR_NUM 6

/* パネル配置 */
typedef struct panel{
	int h;
	int w;
	int p[8][8];
} Panel;

/* 変更履歴 */
typedef struct change_log{
	int x[8*8];
	int y[8*8];
	int n;
	int c;
} Log;

Panel p;
int c;
Log l[6];
int step;

/* パネルを表示する (デバッグ用) */
void show(){
	int i, j;
	for (i = 0; i < p.h; i++){
		for (j = 0; j < p.w; j++){
			printf("%d ", p.p[i][j]);
		}
		printf("\n");
	}
	printf("\n");
}

/* 指定した座標のパネルを指定された色 from から to に変える (再帰) */
int fillr(int x, int y, int from, int to){
	int r;
	if (x < 0 || x >= p.w || y < 0 || y >= p.h || p.p[y][x] != from) return 0;
	/* 変更を記録する */
	l[step].x[l[step].n] = x;
	l[step].y[l[step].n] = y;
	l[step].n++;

	p.p[y][x] = to;
	r = 1;

	/* 周囲の升も塗りつぶす */
	r += fillr(x    , y - 1, from, to);
	r += fillr(x    , y + 1, from, to);
	r += fillr(x - 1, y    , from, to);
	r += fillr(x + 1, y    , from, to);

	return r;
}
/* 指定した座標のパネルを指定された色で塗りつぶし、塗りつぶしたパネルの数を返す */
int fill(int x, int y, int c){
	int r;
	l[step].n = 0;
	l[step].c = p.p[y][x];
	r = fillr(x, y, p.p[y][x], c);
	step++;
	return r;
}

/* 色の変更を戻す */
void re(){
	int i;
	step--;
	for (i = 0; i < l[step].n; i++){
		p.p[l[step].y[i]][l[step].x[i]] = l[step].c;
	}
}

/* 指定した座標のパネルの大きさを返す */
int size(int x, int y){
	int r = fill(x, y, 0);
	re();
	return r;
}

/* パネルの色の変え方を探索し得られる最も大きなパネルの大きさを返す */
int search(int n){
	int max = 0, m;
	int i;

	/* 5 回目 */
	if (n == 4){
		fill(0, 0, c);
		m = size(0, 0);  /* 左上のパネルの大きさを調べる */
		re();  /* 元に戻す */
		return m;
	}

	/* 色の変え方を全通り試す */
	for (i = 1; i <= COLOR_NUM; i++){
		if (p.p[0][0] == i) continue;  /* 今の色と同じ色に変えても無意味なので試行しない */
		if (n == 3 && i == c) continue;  /* 5 回目で目標色に必ず変えるので、4 回目では目標色を試行しない */

		fill(0, 0, i);  /* 色を変える */
		m = search(n + 1);
		if (m > max) max = m;
		re();  /* 元に戻す */
	}

	return max;
}

int main(void){
	int i, j;

	while (scanf("%d%d%d", &p.h, &p.w, &c) == 3 && p.h > 0 && p.h <= 8 && p.w > 0 && p.w <= 8 && c > 0 && c <= COLOR_NUM){
		/* 入力 */
		for (i = 0; i < p.h; i++) for (j = 0; j < p.w; j++) scanf("%d", &(p.p[i][j]));
		/* 初期化 */
		step = 0;

		printf("%d\n", search(0));
	}

    return 0;
}

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

double K, R, L;
double P, E, T;

double solve(double l, double r, double p, int k) {
  if (r < T-E || T+E < l) return 0.0;
  if (T-E <= l && r <= T+E) return p;
  double mid = (l+r)/2;
  if (k == 0) {
    if (T-E <= mid && mid <= T+E) return p;
    return 0.0;
  }

  double ret = 0;
  if (mid >= T) {
    ret += solve(l, mid, p*(1-P), k-1);
    ret += solve(mid, r, p*P, k-1);
  } else {
    ret += solve(l, mid, p*P, k-1);
    ret += solve(mid, r, p*(1-P), k-1);
  }
  return ret;
}

int main() {
  scanf("%lf%lf%lf", &K, &R, &L);
  scanf("%lf%lf%lf", &P, &E, &T);
  printf("%f\n", solve(R, L, 1.0, K));
}

Measured memory_bytes: 3224
#include <stdio.h>
#define NUM 100010

int gcd(int a, int b){
    if(b == 0){
        return a;
    }
    if(a == 0){
        return b;
    }
    if(a < b){
        return gcd(a, b%a);
    }else{
        return gcd(b, a%b);
    }
}

int main(void){
    int N;
    int A[NUM];
    int L[NUM];
    int R[NUM];
    int L_R[NUM];

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    L[0] = A[0];
    for(int i = 1; i < N; i++){
        L[i] = gcd(L[i-1], A[i]);
    }

    R[N-1] = A[N-1];
    for(int i = N - 2; i >= 0; i--){
        R[i] = gcd(A[i], R[i+1]);
    }
    
    L_R[0] = R[1];
    L_R[N-1] = L[N-2];
    for(int i = 1; i < N - 1; i++){
        L_R[i] = gcd(L[i-1], R[i+1]);
    }

    int m = L_R[0];
    for(int i = 0; i < N; i++){
        m = m < L_R[i] ? L_R[i]:m;
    }

    printf("%d\n", m);
}


Measured memory_bytes: 1792