akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    char S[4];
    cin >> S;
    if (S[1] == 'B')
        S[1] = 'R';
    else
        S[1] = 'B';
    cout << S << endl;
    return 0;
}


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

int main() {
  int q;
  cin >> q;
  set<int> st;
  for (int i = 0; i < q; i++) {
    int cmd, x;
    cin >> cmd >> x;
    if (!cmd) {
      st.insert(x);
      cout << st.size() << endl;
    } else {
      cout << st.count(x) << endl;
    }
  }
}



Measured memory_bytes: 12440
#include <stdio.h>

int main(void)
{
	int n;
	int money;
	int i;
	
	scanf("%d", &n);
	
	money = 100000;
	for (i = 0; i < n; i++){
		money += money * 0.05;
		if (money % 1000 > 0){
			money /= 1000;
			money *= 1000;
			money += 1000;
		}
	}
	printf("%d\n", money);
	
	return (0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int H, W, a[1009][1009];
vector<tuple<int, int, int, int>> tup;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (a[i][j] % 2 == 0 || i + j == H + W) continue;
			if (i != H) {
				tup.push_back(make_tuple(i, j, i + 1, j));
				a[i][j]--;
				a[i+1][j]++;
			}
			else {
				tup.push_back(make_tuple(i, j, i, j + 1));
				a[i][j]--;
				a[i][j + 1]++;
			}
		}
	}
	cout << tup.size() << endl;
	for (int i = 0; i < tup.size(); i++) {
		cout << get<0>(tup[i]) << " " << get<1>(tup[i]) << " " << get<2>(tup[i]) << " " << get<3>(tup[i]) << endl;
	}
}


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

int cnt = 0;

void merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;

	int* L = malloc(sizeof(int) * (n1 + 1));
	int* R = malloc(sizeof(int) * (n2 + 1));
	for (i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;

	i = 0;
	j = 0;
	for (k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
	free(L);
	free(R);
}

void mergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int i, n;
	int* S;

	scanf("%d", &n);
	S = (int*)malloc(sizeof(int) * n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}

	mergeSort(S, 0, n);
	for (i = 0; i < n; i++) {
		printf("%d", S[i]);
		if (i != n - 1) {
			printf(" ");
		}
		else {
			printf("\n");
		}
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 5428
#include <stdio.h>

int main(void)
{
  int N, M, K_i, sum[30], A_j, result;
  int i, j;
  
  // 配列・変数の初期化
  scanf("%d %d", &N, &M);
  result = 0;
  for(i = 0; i < 30; i++)
  {
    sum[i] = 0;
  }
  
  // その食べ物が好きだと言われた回数の計上
  for(i = 0; i < N; i++)
  {
    scanf("%d", &K_i);
    for(j = 0; j < K_i; j++){
      scanf("%d", &A_j);
      sum[A_j - 1]++;
    }
  }
  
  // 回数が人数に等しいものが全員が好きな食べ物である
  for(i = 0; i < M; i++)
  {
    if(sum[i] == N) result++;
  }
  
  printf("%d", result);
  
  return 0;
}
    
      

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,x;
    while (cin >> n >> x) {
        VI L(n+1);
        FOR(i,1,n+1)
            cin >> L[i];
        VI D(n+2);
        D[1] = 0;
        FOR(i,2,n+2)
            D[i] = D[i-1]+L[i-1];
        int ans = 0;
        FOR (i,1,n+2) if (D[i] <= x)
            ans ++;
        cout << ans << endl;
    }
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> p(100);
    int ptmp;
    for(int in=0;in<n;in++) {
        cin >> ptmp; ptmp--;
        p.at(ptmp) = 1;
    }

    int ans = x;
    bool flg;
    for(int in=0;in<100;in++) {
        ans = x - in;
        flg = true;
        for(int in=0;in<n;in++) {
            if(1<=ans&&ans<=100) {
                if(p.at(ans-1)==1) {
                    flg = false;
                }
            }
        }
        if(flg) {
            cout << ans << endl;
            return 0;
        }

        ans = x + in;
        flg = true;
        for(int in=0;in<n;in++) {
            if(1<=ans&&ans<=100) {
                if(p.at(ans-1)==1) {
                    flg = false;
                }
            }
        }
        if(flg) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;


int main(){
 double a,b,x ;cin>>a>>b>>x ;
 x= double(x/a) ;
 if(x*2>=a*b){
   double c=a*b-x ;
   double d=double(2*c/a) ;
   double ans= double(atan(double(d/a))*180/pi) ;
   set20 ; 
   cout<<ans<<endl ;
 }
 else{
   double c= double(2*x/b) ;
   double ans= double(atan( double(b/c))*180/pi) ;
   set20 ;
   cout<<ans<<endl ;
 }
 return 0 ; 
}

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

#define int long long

signed main(){
    int n, k;
    cin >> n >> k;


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

    int ans = LLONG_MAX;
    for(int i = 0;i < n;i++){
        int j = i+k-1;
        if(j >= n){
            break;
        }
        ans = min(ans, min(llabs(0-x[i]) + llabs(x[j]-x[i]), llabs(0-x[j]) + llabs(x[j]-x[i])));
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 1024
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n;
        n=sc.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            int v;
            v=sc.nextInt();
            a[v-1]=i+1;
        }
        for(int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 62476
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-09-26 19:47
# @url:
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
## 注意嵌套括号!!!!!!
## 先有思路,再写代码,别着急!!!
## 先有朴素解法,不要有思维定式,试着换思路解决
def main():
    k=int(input())
    print (k*"ACL")
if __name__ == "__main__":
    main()

Measured memory_bytes: 72612
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))



Measured memory_bytes: 25124
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1{
    class Program{
        static void Main(string[] args){
            String input1 = Console.ReadLine();
            String[] input =  input1.Split(' ');
            int h = int.Parse(input[0]);
            int n = int.Parse(input[1]);
            int[,] table = new int[n, 2];
            int[] dp1 = new int[h + 10000];
            int[] dp2 = new int[h + 10000];
            int[] temp = new int[n + 2];
            for (int i = 0; i <= h; i++) {
                dp1[i] = 1000000000;
                dp2[i] = 1000000000;
            }
            dp1[0] = dp2[0] = 0;
            for (int i = 0; i < n; i++){
                String[] input2 = Console.ReadLine().Split(' ');
                int d = int.Parse(input2[0]);
                int c = int.Parse(input2[1]);
                for (int j = 0; j < d; j++) {
                    dp1[j] = Math.Min(dp2[j],c);
                }
                for (int j = d; j <= h; j++)
                {
                    dp1[j] = Math.Min(dp2[j], dp1[j-d] + c);
                }
                temp = dp1;
                dp1 = dp2;
                dp2 = temp;
                //Console.WriteLine(dp2[h]);
            }


            Console.WriteLine(dp2[h]);
        }
    }
}


Measured memory_bytes: 13228
<?php
   $stdin = trim(fgets(STDIN));
   $pieces = explode(" ", $stdin);
   $d = $pieces[0];
   $a = $pieces[1];
   $b = $pieces[2];

   if($a >= $b){
       echo "delicious";
   }else if($b - $a <= $d){
       echo "safe";
   }else{
       echo "dangerous";
   }
?>

Measured memory_bytes: 4984
# coding: utf-8

import sys
input = sys.stdin.readline

def f(n, a):
    dp = [[0] * n for _ in range(n)]
    # dp[i][i] を a[i] で初期化
    for i in range(n):
        dp[i][i] = a[i]
    for i in range(n - 2, -1, -1):
        dpi = dp[i]
        dpi1 = dp[i + 1]
        for j in range(i + 1, n):
            r = a[i] - dpi1[j]
            l = a[j] - dpi[j - 1]
            dp[i][j] = r if r > l else l
            # dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
    return(dp[0][-1])

n = int(input()) # 1 <= n <= 3000
a = list(map(int, input().split()))
print(f(n, a))


Measured memory_bytes: 234168
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

Int d[210];

int main() {
	Int n,k,t,u,v,l;
	cin>>n>>k>>t>>u>>v>>l;
	repn(i,1,n)cin>>d[i];
	d[n+1]=l;
	double res=0;
	Int have=0,f=0;
	repn(i,0,n){
		Int use,dis;
		if(d[i+1]-d[i]<v*t*have+f){
			dis=d[i+1]-d[i];
			use=(dis<=f)?0:(dis-f-1)/(v*t)+1;
			res+=dis/(double)v;
			have-=use;
			f=(v*t-(dis-f)%(v*t))%(v*t);
		}else{
			res+=t*have+f/(double)v+(d[i+1]-d[i]-v*t*have-f)/(double)u;
			have=0;
			f=0;
		}
debug<<i<<" "<<res<<" "<<have<<" "<<f<<endl;
		++have;
		if(have>k){
			f=v*t;
			have=k;
		}
	}
	printf("%.12f\n",res);
	return 0;
}

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

using namespace std;

int main() {
  
  while(1) {
    int card = 0;
    int save = 0;
    for(;;) {
      int add; scanf("%d", &add); if(!add) return 0;
      if(add == 1) {
	save ++;
      }
      else if(10 <= add && add <= 13) card += 10;
      else card += add;
      
      char ch; scanf("%c", &ch);
      if(ch=='\n') break;
    }
    
    card += save;
    
    if(card > 21) {
      card = 0;
    }
    else {
      for(int i=0; i<save; i++) {
	if(card+10 <= 21) card += 10;
	else break;
      }
    }
    
    if(card > 21) card = 0;
    cout << card << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
from collections import Counter
from collections import defaultdict

def li():
    return [int(x) for x in input().split()]

H, W, M = li()
PH = []
PW = []
PF = defaultdict(int)

for i in range(M):
    h, w = li()
    PH.append(h)
    PW.append(w)
    PF[h, w] += 1

frequency_h_list = Counter(PH).most_common()
frequency_w_list = Counter(PW).most_common()
most_common_h_cnt = frequency_h_list[0][1]
most_common_w_cnt = frequency_w_list[0][1]

most_common_h_list = []
for x in frequency_h_list:
    if x[1] < most_common_h_cnt:
        break
    most_common_h_list.append(x[0])

most_common_w_list = []
for x in frequency_w_list:
    if x[1] < most_common_w_cnt:
        break
    most_common_w_list.append(x[0])

add = -1
for h in most_common_h_list:
    for w in most_common_w_list:
        if PF[h, w] == 0:
            add = 0
            break

cnt = most_common_h_cnt + most_common_w_cnt + add

print(cnt)

Measured memory_bytes: 262552
#include<iostream>

using namespace std;

int main()
{
	int W,H,N;
	
	cin >> W >> H >> N;
	
	int l=0,r=W,b=0,t=H;
	int x,y,a;
	
	for(int i=0;i<N;i++){
		cin >> x >> y >> a;
		switch(a){
		case 1:
			if(l < x)l = x;
			break;
		case 2:
			if(r > x)r = x;
			break;
		case 3:
			if(b < y)b = y;
			break;
		case 4:
			if(t > y)t = y;
			break;
		}
	}
	
	int res = (r-l)*(t-b);
	if (r > l && t > b ){
		cout << res << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int s = 0;
    rep(i, n) s ^= a[i];
    rep(i, n) {
        cout << (s^a[i]) << (i+1 == n ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 4044
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divisors = make_divisors(N)

i = 0
res = 0
while True:
    l = divisors[i]
    r = divisors[-(i+1)]
    if r - 1 > l:
        res += r - 1
        i += 1
    else:
        break

print(res)

Measured memory_bytes: 38896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int [] A = new int [N+1];
        for(int i = 1; i<N+1; i++){
            A[i] = scanner.nextInt();
        }
        scanner.close();
        
        int count = 0;
        for(int j = 2; j<N; j++){
            if((A[j-1]<A[j] && A[j]<A[j+1]) || (A[j-1]>A[j] && A[j]>A[j+1])){
            count++;
            }
        }
        
        System.out.println(count);
        
    }
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
#define INF (1 << 30)
using namespace std;

int A[100000];
int dp[100000];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	dp[0] = 0;
	fill(dp + 1, dp + n, INF);
	for(int i = 0; i < n; i++){
		if(i + 1 < n){
			dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i + 1]));
		}
		if(i + 2 < n){
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i] - A[i + 2]));
		}
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include<math.h>
#include<bits/stdc++.h>
#include <map>
#include <algorithm>
#include <cmath>



using namespace std;
const int INF = 1e9+7;
int solve(int h[],int n,int k){
    int dp[n+1];
    for(int i=0;i<n+1;i++)dp[i]=INF;
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
                if(j<n)
            dp[j] = min(dp[j],abs(h[i]-h[j])+dp[i]);
        }
    }
    return dp[n-1];
}

int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    cout<<solve(h,n,k)<<endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s, t;
  cin >>  s >> t;
  cout << t << s << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
l = []
for _ in range(n):
    x, y, h = map(int, input().split())
    if h >= 1:
        l.append([x, y, h])

result = None
for i in range(101):
    for j in range(101):
        judge = True
        x, y, h = l[0]
        highest = abs(i - x) + abs(j - y) + h
        if len(l) == 1:
            result = (x, y, h)
            break
        for x, y, h in l[1:]:
            if abs(i - x) + abs(j - y) + h != highest:
                judge = False
                break
        if judge:
            result = (i, j, highest)
            break
    if result:
        break

print(result[0], result[1], result[2])

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if(x-r<0 || x+r>W){
        cout << "No" <<endl;
    } else if(y-r<0 || y+r>H){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
n = int(input())
num = list(map(int,input().split()))
count = 0
while 1:
    for i in range(n):
        if  num[i] % 2 == 0:
            num[i] = int(num[i] / 2)
        else:
            print(count)
            count = -1
            break
    if count == -1:
        break
    count += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void go(ll A,ll B,ll C,ll D) {
	--C; --D;
	ll maxleftsz;
		ll r=max(
			(A+B)/(B+1),
			(B+A)/(A+1)
			);
	{
		ll imin=0,imax=A+B+1;
		while(imin<imax) {
			ll imid=(imin+imax)>>1;
			ll blocks=(imid-1)/(r+1);
			bool ok=1;
			ll sa=imid-blocks*(r+1);
			ll ta=r*blocks+sa;
			ll tb=blocks;
			ll la=A-ta,lb=B-tb;
			if (r*(la+1) < lb) ok=0;
			if (ok) imin=imid+1;
			else imax=imid;
		}
		maxleftsz=imin-1;
	}
	ll gleftsz=maxleftsz;
	//printf("leftsz:%d\n",gleftsz);
	{
		ll leftsz=gleftsz;
		ll leftblocks=(leftsz-1)/(r+1);
		ll sa=leftsz-leftblocks*(r+1);
		ll rightsz=A+B-leftsz;
		ll rightblocks=rightsz/(r+1);
		ll qb=rightsz-rightblocks*(r+1);
		for (ll _pos=C;_pos<=D;_pos++) {
			ll pos=_pos;
			char c;
			if (pos<leftblocks*(r+1)) {
				pos%=(r+1);
				if (pos==r) c='B'; else c='A';
			}
			else if (pos<leftsz) {
				c='A';
			}
			else if (pos<leftsz+qb) {
				c='B';
			}
			else {
				pos-=leftsz+qb;
				pos%=(r+1);
				if (pos==0) c='A'; else c='B';
			}
			printf("%c",c);
		}
	}
	printf("\n");
}


void solve(long long Q, vector<long long> A, vector<long long> B, vector<long long> C, vector<long long> D){
	for (ll i=0;i<Q;i++) {
		go(A[i],B[i],C[i],D[i]);
	}
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long Q;
	scanf("%lld",&Q);
	vector<long long> D(Q-1+1);
	vector<long long> C(Q-1+1);
	vector<long long> A(Q-1+1);
	vector<long long> B(Q-1+1);
	for(int i = 0 ; i <= Q-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		scanf("%lld",&C[i]);
		scanf("%lld",&D[i]);
	}
	solve(Q, A, B, C, D);
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    ll N;
    cin >> N;

    ll mod = 1e9 + 7;
    cout << factorial(N, mod) << endl;
    return 0;
}


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

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

/*Xを前から見ていって、Sの１個以上の連続箇所があれば、それ以降の部分で
Tが何個連続しているかを見る
各連続箇所で、連続回数の少ない方*2をカウント
*/

int main() {
   int N;
   cin >> N;
   vector<int> a(N+1);
   rep(i,N){
       cin >> a[i+1];
   }
   vector<int> num(N+1);//num[i] = 1ならi番目の箱にボールをいれる
   for(int i = N;i>=N/2 + 1;i--){
       if(a[i] == 1) num[i] = 1;
   }
   for(int i = N/2;i>=1;i--){
       int sum = 0;//iより大きいiの倍数番目の箱のボールの数の和
       for(int j = 2*i;j<=N;j+=i){
           if(num[j] == 1) sum++;
       }
       if(sum%2 == 0 && a[i] == 1) num[i] = 1;
       else if(sum%2 == 0 && a[i] == 0) num[i] = 0;
       else if(sum%2 == 1 && a[i] == 1) num[i] = 0;
       else if(sum%2 == 1 && a[i] == 0) num[i] = 1;
   }
   int ans = 0;
   vector<int> b;
   for(int i = 1;i<=N;i++){
       if(num[i] == 1){
         b.push_back(i);
         ans++;
       }
   }
   cout << ans << endl;
   for(int i = 0;i<b.size();i++){
       cout << b[i] << " " ;
   }
   cout << endl;
  /*rep(i,N+1){
       cout << num[i] << " ";
   }*/
 }

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

int main(){

    int n;
    cin >> n;

    double a[n],b[n];

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        b[n-i-1] = a[i];
    }
    cout << b[0];
    for(int i=1;i<n;i++){
        cout << " " << b[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3252
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    ans=''
    
    while n>0:
        n-=1
        a,b=divmod(n,26)
        n//=26
        ans+=chr(ord('a')+b)
    for i in ans[::-1]:
        print(i,end='')
    print()
        

    
resolve()


Measured memory_bytes: 61940
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

int main()
{
    std::stack<int> S1;
    std::stack<std::pair<int, int> > S2;

    char ch;
    int sum = 0;
    int cur_sum = 0;

    for (int i = 0; std::cin >> ch; i++)
    {
        if(ch == '\\'){
            S1.push(i);
        }else if(ch == '/' && !S1.empty()){
            cur_sum = (i - S1.top());
            sum += cur_sum;
            while(!S2.empty() && S2.top().first > S1.top()){
                cur_sum += S2.top().second;
                S2.pop();
            }
            S2.push(std::make_pair(S1.top(), cur_sum));
            S1.pop();
        }
    }
    std::cout << sum << "\n";

    std::vector<int> ans;

    while(!S2.empty()){
        ans.push_back(S2.top().second);
        S2.pop();
    }

    std::reverse(ans.begin(), ans.end());

    std::cout << ans.size();

    for(int i = 0; i < ans.size(); i++){
        std::cout << " " << ans[i];
    }

    std::cout << "\n";
}


Measured memory_bytes: 3236
S = input()
ans = 0
g_count = 0
for c in S:
    if c == "g":
        if g_count > 0:
            g_count-=1
            ans += 1
        else:
            g_count += 1
    else:
        if g_count > 0:
            g_count-=1

        else:
            g_count += 1
            ans -=1
print(ans)

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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

template <class T>
using P = pair<T, T>;

// 有向閉路が無いので、必ず終点がある？
// だから、終点まで行って、そこから逆にたどればいい
// 再帰でなんとかする

int rec(int v, V<int> &L, VV<int> &G) {
    if (L[v] != -1) return L[v];
    int maxL = 0;
    for (int t : G[v]) {
        maxL = max(maxL, rec(t, L, G) + 1);
    }
    return L[v] = maxL;
}

int main() {
    int N, M;
    cin >> N >> M;
    VV<int> G(N);
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        G[x].push_back(y);
    }
    V<int> L(N, -1);

    int res = 0;
    for (int i = 0; i < N; ++i) {
        res = max(res, rec(i, L, G));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11836
from sys import stdin
import heapq
INF = 1<<21
n = int(stdin.readline())
adj = [[]] * n
for u in range(0, n):
    U = list(map(int, stdin.readline().split()[2:]))
    adj[u] = (e for e in zip(U[0::2], U[1::2]))
def dijkstra():
    d = [0] + [INF] * (n - 1)
    hq = [(0, 0)]
    while hq:
        u = heapq.heappop(hq)[1]
        for v, c in adj[u]:
            alt = d[u] + c
            if d[v] > alt:
                d[v] = alt
                heapq.heappush(hq, (alt, v))
    for i, c in enumerate(d):
        print(i, c)
dijkstra()

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

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	if ((2 * x) == w && (2 * y) == h)
	{
		ld w1 = w;
		cout << fixed << setprecision(9);
		cout << w1 * h / 2 << ' ' << 1 << '\n';
	}
	else
	{
		ld w1 = w;
		// if (2 * x > w)
		// 	x = w - x;
		// if (2 * y > h)
		// 	y = h - y;
		cout << fixed << setprecision(9);
		cout << w1 * h / 2 << ' ' << 0 << '\n';
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
S=(1..13).to_a.map{|n|"S "+n.to_s}
H=(1..13).to_a.map{|n|"H "+n.to_s}
C=(1..13).to_a.map{|n|"C "+n.to_s}
D=(1..13).to_a.map{|n|"D "+n.to_s}
def code_run
  #a,b=$stdin.gets.split.map(&:to_i)
  iN=$stdin.gets.to_i
  iN.times do
    iMark,iNum=$stdin.gets.split
    eval(iMark)[iNum.to_i-1]=nil
  end
  [S,H,C,D].each do |mark|
    puts mark.compact!
  end
end
code_run


Measured memory_bytes: 6896
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>
#include <map>
#include <tuple>
#include <complex>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<string> vs;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> v)
{
    for (auto e : v)
        cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vv)
{
    for (auto v : vv)
    {
        for (auto e : v)
            cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp)
{
    for (auto p : vp)
        cout << p.first << " " << p.second << endl;
}

int main() {
    string S;
    cin >> S;

    const auto size = S.size()-1;
    ll ans = 0;
    for (int bit = 0; bit < (1<<size); ++bit) {
        ll value = 0;
        ll digit = 0;
        for (int j = size; j >= 0; --j) {
            const auto a = S[j] - '0';
            value += a * pow(10, digit);
            if (bit & (1 << (size-j))) digit = 0;
            else ++digit;
        }
        ans += value;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	// your code goes here
	
	int n;
	
	cin >> n;
	
	vector<int> v;
	
	for(int i =0;i<n;i++)
	{
		int x ;
		
		cin >> x;
		
		v.push_back(x);
	}
	
	int c = 0;
	
	for(int i=1;i<n-1;i++)
	{
		if(v[i-1] < v[i] && v[i] < v[i+1])
			c++;
		else if(v[i-1] > v[i] && v[i] > v[i+1])
			c++;
	}
	
	cout << c << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
        int S;
        int h, m, s;
        scanf("%d", &S);
        h = S / 3600;
        m = (S - h * 3600) / 60;
        s = S % 60;
        printf("%d:%d:%d\n", h, m, s);
        return 0;
}

Measured memory_bytes: 592
n=int(input())
s=[list(input().split())+[i] for i in range(n)] 
for i in range(n):
    s[i][1]=int(s[i][1])*-1#第二成分をintにして-1倍

s=sorted(s)

for i in range(len(s)):
    print(s[i][2]+1)

Measured memory_bytes: 3060
import heapq

N, M, s, t = map(int, input().split())
inf = 10 ** 18

def dijkstra(start, G):
    q = [(0, start)]
    heapq.heapify(q)
    cost = [inf] * N
    cost[start] = 0
    while q:
        c, v = heapq.heappop(q)
        if c > cost[v]:
            continue
        for d, u in G[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(q, (tmp, u))
    return cost

# G = [(cost, edge), ...]
Ga = [[] for _ in range(N)]
Gb = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u, v = u - 1, v - 1
    Ga[u].append((a, v))
    Ga[v].append((a, u))
    Gb[u].append((b, v))
    Gb[v].append((b, u))

s2i = dijkstra(s - 1, Ga)
i2t = dijkstra(t - 1, Gb)

c = [0] * N
tmp = 10 ** 18
for i in range(N):
    tmp = min(tmp, s2i[-(i + 1)] + i2t[-(i + 1)])
    c[-(i + 1)] = tmp

for cc in c:
    print(10 ** 15 - cc)


Measured memory_bytes: 114672
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = t * (n / x);
    if (n % x) {
        ans += t;
    }
    cout << ans;
}

/*
*/


Measured memory_bytes: 3668
import Control.Applicative
import Data.List
 
main :: IO ()
main = do
    s <- getLine
    putStrLn $ show (solve (sort s))
    
solve :: String -> Int 
solve s | "ooo" == s = 1000
        | "oox" == s = 900
        | "oxx" == s = 800
        | "xxx" == s = 700

Measured memory_bytes: 380
#include <bits/stdc++.h>
 
using namespace std;
 
int dx[8000];
int dy[8000];
int dpx[8001][16002];
int dpy[8001][16002];
int cx = 0;
int cy = -1;
int x, y;
string s;
 
int main()
{
	cin >> s >> x >> y;
	int t = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'T') {
			t = 1 - t;
			if (t == 0) cx++;
			else cy++;
		}
		else if (t == 0) dx[cx]++;
		else dy[cy]++;
	}
	cx++; cy++;
	dpx[0][8001] = 1;
	dpy[0][8001] = 1;
	for (int i = 0; i < cx; i++) {
		for (int j = 0; j <= 16001; j++) {
			if (dpx[i][j] == 1) {
				dpx[i+1][j+dx[i]] = 1;
				if (i != 0) dpx[i+1][j-dx[i]] = 1;
			}
		}
	}
	for (int i = 0; i < cy; i++) {
		for (int j = 0; j <= 16001; j++) {
			if (dpy[i][j] == 1) {
				dpy[i+1][j+dy[i]] = 1;
				dpy[i+1][j-dy[i]] = 1;
			}
		}
	}
	if (dpx[cx][x + 8001] == 1 && dpy[cy][y + 8001] == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 498048
#include <stdio.h>
#include <math.h>

typedef struct point{
  double x;
  double y;
} P;

double kock(int , P, P);

int main(){
  int n;
  P start={0,0}, end={100, 0};

  scanf("%d", &n);

  printf("%.8f %.8f\n", start.x, start.y);
  kock(n, start, end);
  printf("%.8f %.8f\n", end.x, end.y);

  return 0;
}

double kock(int n, P p1, P p2){
  if(n == 0)return 0.0;
  P s, t, u;
  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * cos(M_PI / 3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
  u.y = (t.x - s.x) * sin(M_PI / 3) + (t.y - s.y) * cos(M_PI / 3) + s.y;
  kock(n - 1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  kock(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  kock(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  kock(n - 1, t, p2);
  return 0.0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

const int MOD = 1000000007;
int H, W;
int a[1001][1001];

int64_t dp[1001][1001];
int64_t f(int i, int j) {
  if (i >= H || j >= W) return 0;
  if (a[i][j] == '#') return 0;
  if (i == H-1 && j == W-1) return 1;
  if (dp[i][j] != -1) return dp[i][j];
  int64_t ans = f(i+1, j) + f(i, j+1);
  if (ans >= MOD) ans -= MOD;
  return dp[i][j] = ans;
}

int main() {
  std::memset(dp, -1, sizeof(dp));
  std::cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    std::string row; std::cin >> row;
    for (int j = 0; j < W; ++j) {
      a[i][j] = row[j];
    }
  }
  std::cout << f(0, 0) << '\n';
}


Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
const int mod = 1e9+7;
using namespace std;
int main()
{
    long long n,ans = 1;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        ans = (ans * i) % mod;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()

int main()
{
    Imposter

    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        //n.x%360 == 0
        for(int i=1;i<=360;i++)
            if(((n*i)%360)==0)
            {
                cout<<i;
                break;
            }


    }

    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
          
  
int main() {
  int N;
  cin >> N;
  vector<int> h(N); 
  rep(i,N) cin >> h[i];
  
  int ans = 0;
  while(true){
    if(*max_element(h.begin(),h.end()) == 0) break;
    
    int i = 0;
    while(i < N){
      if(h[i] == 0) i++;
      else{
        ans++;
        while(i < N && h[i] > 0){
          h[i]--;
          i++;
        }
      }
    }
  }
  
  cout << ans << endl;
}
  

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

int main() {
  int rank;
  cin>>rank;
  if(rank >= 400 && rank < 600){
  cout<<"8"<<endl;
  }
  else if(rank >= 600 && rank < 800){
  cout<<"7"<<endl;
  }
  else if(rank >= 800 && rank < 1000){
  cout<<"6"<<endl;
  }
  else if(rank >= 1000 && rank < 1200){
  cout<<"5"<<endl;
  }
  else if(rank >= 1200 && rank < 1400){
  cout<<"4"<<endl;
  }
  else if(rank >= 1400 && rank < 1600){
  cout<<"3"<<endl;
  }
  else if(rank >= 1600 && rank < 1800){
  cout<<"2"<<endl;
  }
  else if(rank >= 1800 && rank < 2000){
  cout<<"1"<<endl;
  }
	// your code goes here
	return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),M=in();
	vector<pair<int,int>> R(M);
	REP(i,M){
		int u=in(),v=in();
		R[i].first = u;
		R[i].second = v;
	}
	sort(ALL(R),[](pair<int,int>& lhs,pair<int,int>& rhs){return lhs.second<rhs.second;});
	
	int sum = 0;
	int prev = 0;
	for(int i=0;i<M;i++){
		if(R[i].first>prev){
			prev = R[i].second-1;
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
}


Measured memory_bytes: 35756
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll P = 1e9+7;
ll K, N, M;
ll fact[100];

// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

// Modular inverse of x given modulo p, y
// x*y = 1 mod p
// <=> x*y + z*p = 1
ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	return y>=0 ? y : p+(y%p);
}


// Modular factorial of n, also counting p's appearance e
// n! = a * p^e
// return: a % p
// n! = n * (n-1) * ... * (k*p+1) *
//      (k*p) * (k*p-1) * ... ((k-1)*p+1) *
//      ...
//      p * (p-1) * ... * 2 * 1   (k = floor(n/p))
//    = (n%p) * ... * 1 *
//      (k*p) * (p-1) * ... * 1 *
//      p * (p-1) * ... * 1       (mod p, preserving p's multiples)
//    = (n%p)! * p^k * k! * (p-1)^k
//    = (n%p)! * p^k * k! * (p-1)^(k%2)
//
// From the facts:
//   (p-1)! = p-1 (mod p) (c.f. Willson's theorem)
//   (p-2)**2 = 1 (mod p)
ll fact_mod(ll n, ll p, ll &e){
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}


// Modular combination (n, m) given module p
// (n, m) = n!/(n-m)!m!
//        = (a_n * p^(e_n)) / ((a_{n-m} * p^(e_{n-m}) * (a_m * p^e_m))
//        = a_n / (a_{n-m} * a_m) * p^(e_n - e_{n-m} - e_m)
ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
    cin >> N >> M >> K;

    ll c = 1;
    for(int i=1; i<=K-2; i++){
        c *= (N*M-2-i+1);
        c %= P;
        c *= inv_mod(i, P);
        c %= P;
    }

    ll x_sum = 0;
    for(int d=1; d<N; d++){
        ll t = M*M%P;
        t = t*(N-d)%P;
        t = t*d%P;
        // cout << d << " " << t << endl;
        x_sum = (x_sum+t)%P;
    }

    ll y_sum = 0;
    for(int d=1; d<M; d++){
        ll t = N*N%P;
        t = t*(M-d)%P;
        t = t*d%P;
        y_sum = (y_sum+t)%P;
    }

    // cout << c << " " << x_sum << " " << y_sum << endl;
    cout << (x_sum+y_sum)*c%P << endl;

    return 0;
}

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


int main(){
    int N,X,D=0;
    cin >> N >> X;
    int L[N]={0};
    for (int i=0;i<N;++i) cin >> L[i];
    int cnt = 1;
    for (int i=0;i<N;++i){
        if(D + L[i] <= X){
            cnt += 1;
            D += L[i];
        }
        else{
            break;
        }
    }

    cout << cnt << endl;

    }





Measured memory_bytes: 256