akhauriyash/Code-Regression huggingface dataset:
# Partition パーティション


def partition(A, p, r):
    i = p - 1
    x = A[r]
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            t = A[j]
            A[j] = A[i]
            A[i] = t
    A[r] = A[i + 1]
    A[i + 1] = x
    return i + 1


n = int(input())
A = [int(i) for i in input().split()]
par = partition(A, 0, n - 1)
for i in range(0, par):
    print(A[i], end=" ")
print("[", A[par], "]", sep="", end=" ")
for i in range(par + 1, n - 1):
    print(A[i], end=" ")
print(A[n - 1])



Measured memory_bytes: 16368
import math


def read_input():
    n = int(input())
    s = int(input())

    return n, s


def f(b, n):
    if n < b:
        return n
    t = n // b
    m = n % b
    return f(b, t) + m


def submit():
    n, s = read_input()
    sqrtn = math.ceil(math.sqrt(n))

    if n == s:
        print(n + 1)
        return

    for i in range(2, sqrtn + 1):
        if f(i, n) == s:
            print(i)
            return

    for i in range(sqrtn - 1, 0, -1):
        p = i
        q = s - p
        sho,mod = divmod(n - q, p)
        if mod == 0:
            b = sho
        else:
            continue

        if q < b and p < b:
            if f(b, n) == s:
                print(b)
                return

    print(-1)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 42096
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    string ans = (n >= 1000) ? "ABD" : "ABC";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n;
	long long int sum;
	scanf("%d",&n);
	sum=1;
	for(i=2;i<=n;i++) sum=sum*i;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1020
class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  print() {
    console.log(this.x.toFixed(8) + ' ' + this.y.toFixed(8));
  }
}

(function main(){
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
  let p1 = new Point(0, 0);
  let p2 = new Point(100, 0);
  p1.print();
  kock(n, p1, p2);
  p2.print();
})();

function kock(n, p1, p2) {
  const sin60 = Math.sin(60 * Math.PI / 180);
  const cos60 = Math.cos(60 * Math.PI / 180);
  function innerFunc(n, p1, p2) {
    if (!n) return;
    xDiff = p2.x - p1.x;
    yDiff = p2.y - p1.y;
    let s = new Point(p1.x + xDiff / 3, p1.y + yDiff / 3);
    let t = new Point(s.x + xDiff / 3, s.y + yDiff / 3);
    let u = new Point((t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x,
        (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y);
    kock(n-1, p1, s);
    s.print();
    kock(n-1, s, u);
    u.print();
    kock(n-1, u, t);
    t.print();
    kock(n-1, t, p2);
  }
  // kock = innerFunc;
  innerFunc(n, p1, p2);
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n), b(n);
	rep(i, n) cin >>a[i];

	rep(i, n) b[i] = a[i] - i -1;
	sort(all(b));
	ll ct = b[n / 2];
	
	dbg(ct);
	ll ans =0;
	rep(i, n) ans += abs(a[i] - (ct + i +1));
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3328
import math
a,b,h,m = map(int,input().split())

total_minute = 60 * h + m

ax = a * math.cos(math.radians(360-(total_minute/2)+ 90))
ay = a * math.sin(math.radians(360-(total_minute/2)+ 90))
bx = b * math.cos(math.radians(360-(6*m) + 90))
by = b * math.sin(math.radians(360-(6*m) + 90))

kyori = math.sqrt((ax-bx)**2 + (ay-by)**2)

print(kyori)


                

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;cin>>s;
  int cnt1=0;
  rep(i,s.size()){
    if(s[i]=='A')break;
    cnt1++;
  }
  int cnt2=0;
  for(int i=s.size()-1;i>0;i--){
    if(s[i]=='Z')break;
    cnt2++;
  }
  cout<<s.size()-cnt1-cnt2<<endl;
}

Measured memory_bytes: 3752
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

ll n,k;

struct M{
	vector< vector<ll> >t;
	M(){
		t.resize(n,vector<ll>(n,0));
	}
	M operator* (const M &b) const{
		M c=M();
		for(ll i=0;i<n;i++)
		for(ll j=0;j<n;j++)
		for(ll k=0;k<n;k++)
		{
			c.t[i][k]+=( ( t[i][j]%mod * b.t[j][k]%mod )%mod);
			c.t[i][k]%=mod;
		}
		return c;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	M inp=M();
	for(ll i=0;i<n;i++)
	for(ll j=0;j<n;j++)
	{
		cin>>inp.t[i][j];
	}
	M id=M();
	for(ll i=0;i<n;i++)
	{
		id.t[i][i]=1;
	}
	while(k>0)
	{
		if(k&1)
		{
			id=id*inp;
		}
		inp=inp*inp;
		k>>=1;
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			ans+=id.t[i][j];
			ans%=mod;
		}
	}
	cout<< (ans%mod);
    return 0;
}


//252908XL

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int[] abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

    public void Solve()
    {
        Console.WriteLine(abc.Sum() - abc.Max());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
typedef pair<int,int>PAIR;//cost/pos
int main(){
	int N,M;
	while(cin>>N>>M,N){
		int ans=0,cnt=0;
		bool flag[100]={0};
		int load[100][100];
		memset(load,-1,sizeof(load));
		for(int i=0,A,B,C;i<M;i++){
			cin>>A>>B>>C;
			load[A][B]=load[B][A]=C;
		}
		priority_queue<PAIR,vector<PAIR>,greater<PAIR> > Q;
		Q.push(make_pair(0,0));
		for(int now,cost;!Q.empty();){
			cost=Q.top().first;
			now=Q.top().second;
			Q.pop();
			if(flag[now]==0){
				flag[now]=1;
				ans+=cost;
				cnt++;
				for(int i=0;i<N;i++)if(load[now][i]>0&&flag[i]==0)Q.push(make_pair(load[now][i],i));
			}
			if(cnt==N)break;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1248
// AtCoder ABC138: D - Ki
// 2019.8.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

#define MAX 200005
int hi[MAX], *to[MAX], x[MAX]; int N;

void calc(int node, int par, int v) {
	int i, a;
	
	x[node] += v;
	for (i = 0; i < hi[node]; i++) {
		a = to[node][i];
		if (a != par) calc(a, node, x[node]);
	}
}
		
int main()
{
	int i, a, b, N, Q;
	int *memo, sz;
	
	N = in(), Q = in();
	
	memo = malloc(N*sizeof(int)*2);
	sz = 0; for (i = 1; i < N; i++) {
		a = in(), b = in();
		memo[sz++] = a, memo[sz++] = b;
		hi[a]++, hi[b]++;
	}
	
	for (i = 1; i <= N; i++) if (hi[i]) to[i] = malloc(hi[i]*sizeof(int));
	memset(hi, 0, sizeof(hi));
	i = 0; while (i < sz) {
		a = memo[i++], b = memo[i++];
		to[a][hi[a]++] = b, to[b][hi[b]++] = a;
	}
	free(memo);
	
	while (Q--) a = in(), x[a] += in();
	
	calc(1, 0, 0);
	out(x[1]); for (i = 2; i <= N; i++) pc(' '), out(x[i]);
	pc('\n');
	return 0;
}


Measured memory_bytes: 21092
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i=0; i<N; i++) {
            P[i] = sc.nextInt();
        }

        System.out.println(solve(N, P));
    }

    private static int solve(int N, int[] P) {
        int count = 0;

        int min = N+1;
        for (int i=0; i<N; i++) {
            if (P[i] < min) {
                min = P[i];
                count++;
            }
        }

        return count;
    }
}

Measured memory_bytes: 66340
#include<stdio.h>
#include<algorithm>

using namespace std;

long long inp_c, inp_n1, inp_n2, i1, out_n;

long long aa[11];

struct combo {
	
	long long av, bv, cv, dv;
	
};

combo inp_a[51];

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld", temp_func);
	return 0;
};

void checktest() {
	
	long long out_nf = 0;
	
	for (long long i1f = 1; i1f <= inp_c; i1f++) {
		
		if (aa[inp_a[i1f].bv] - aa[inp_a[i1f].av] == inp_a[i1f].cv) {
			
			out_nf += inp_a[i1f].dv;
			
		};
		
	};
	
	out_n = max(out_n, out_nf);
	
};

void emrua(const long long curpos) {
	
	if (curpos == inp_n1 + 1) {
		
		checktest();
		
		return;
		
	};
	
	for (long long i1f = aa[curpos - 1]; i1f <= inp_n2; i1f++) {
		
		aa[curpos] = i1f;
		
		emrua(curpos + 1);
		
	};
	
};

long long caler() {
	
	aa[1] = 1;
	
	emrua(2);
	
	return out_n;
	
};

int main() {
	
	inp_n1 = readNumber();
	
	inp_n2 = readNumber();
	
	inp_c = readNumber();
	
	for (i1 = 1; i1 <= inp_c; i1++) {
		
		inp_a[i1].av = readNumber();
		
		inp_a[i1].bv = readNumber();
		
		inp_a[i1].cv = readNumber();
		
		inp_a[i1].dv = readNumber();
		
	};
	
	printNumber(caler());
	
}

Measured memory_bytes: 1736
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
unsigned int randxor()
{
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int d=365;
vector<int> ans(d);
vector<int> ans1(d);
vector<int> c(26);
vector<vector<int> > s(d);
int score;
int keisan(){
  int cost=0,i,j;
  vector<int> x(26,-1);
  for(i=0;i<d;i++){
    cost+=s[i][ans1[i]];
    x[ans1[i]]=i;
    for(j=0;j<26;j++){
      cost=cost-c[j]*(i-x[j]);
    }
  }
  return cost;
}
void solve(){
  int i;
  for(i=0;i<d;i++){
    ans1[i]=randxor()%26;
  }
  if(score<keisan()){
    for(i=0;i<d;i++){
      ans[i]=ans1[i];
    }
    score=keisan();
  }
}
int main(){
  int i,j;
  int ti=clock();
  cin >> d;
  for(i=0;i<26;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      int a;
      scanf("%d",&a);
      s[i].push_back(a);
    }
  }
  for(i=0;i<d;i++){
    ans1[i]=randxor()%26;
    ans[i]=ans1[i];
  }
  score=keisan();
  while(clock()-ti<197.4*CLOCKS_PER_SEC/100){
    solve();
  }
  for(i=0;i<d;i++){
    printf("%d\n",ans[i]+1);
  }
  return 0;
}

Measured memory_bytes: 3892
from itertools import combinations, count
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
r = next(i for i in count(n, -1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1].issubset(x) for j in x))
print(r)


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>

typedef long long ll;
using namespace std;

//class Node{
//public:
//    ll value;
//    Node* parent;
//    Node* leftChild;
//    Node* rightChild;
//    int left;
//    int right;
//    Node(int value,){
//
//    }
//};


bool isPrime(int n){
    if(n < 2){
        return 0;
    }
    if(n%2 == 0){
        return n==2;
    }
    for(int i=3;i*i<=n;i++){
        if(n%i == 0) return 0;
    }
    return 1;
}


int main() {
   string s,t;
   cin>>s>>t;
   int d = 0;
   for(int i=0;i<s.size();i++){
       if(s[i] != t[i])d++;
   }
   cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 105

bool check[SIZE];

int main(){

	int L;
	scanf("%d",&L);

	stack<int> S;

	for(int i = 1; i <= 100; i++){

		check[i] = false;
	}

	int tmp,ans;
	bool FLG = true;

	for(int i = 1; i <= L; i++){

		scanf("%d",&tmp);

		if(!FLG)continue;

		if(tmp < 0){ //猫出

			if(S.empty() == true || S.top() != abs(tmp)){

				FLG = false;
				ans = i;

			}else{

				S.pop();
				check[abs(tmp)] = false;
			}

		}else{ //猫入

			if(check[tmp]){

				FLG = false;
				ans = i;
			}else{

				S.push(tmp);
				check[tmp] = true;
			}
		}
	}

	if(FLG){

		printf("OK\n");

	}else{

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

	return 0;
}



Measured memory_bytes: 3232
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
N = int(input())
As = list(mapint())
query = [0]*W*H

idx = 0
for i in range(N):
    a = As[i]
    for j in range(a):
        query[idx] = i+1
        idx += 1

idx = 0
for h in range(H):
    if h%2==0:
        print(*query[idx:idx+W])
        idx += W
    else:
        print(*query[idx:idx+W][::-1])
        idx += W

Measured memory_bytes: 74440
w,h;
dx[]={0,1,0,-1,1,1,-1,-1};
dy[]={1,0,-1,0,1,-1,1,-1};
char s[55][55];
i,j,r,tx,ty;
main()
{
	scanf("%d%d\n",&h,&w);
	for(i=0;i<h;i++)gets(s[i]);
	for(i=0;i<h;i++)for(j=0;j<w;j++)
	{
		if(s[i][j]!='.')continue;
		s[i][j]='0';
		for(r=0;r<8;r++){
			tx=i+dx[r];ty=j+dy[r];
			if(tx>=0&&ty>=0&&tx<h&&ty<w&&s[tx][ty]=='#')s[i][j]++;
		}
	}
	for(i=0;i<h;i++)puts(s[i]);
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if(discrete) else 10**-8
    if((not left)^f(r)): return r if(left) else r+1
    elif(left^f(l)): return l-1 if(left) else l
    while(r-l>eps):
        h=(l+r)//2 if(discrete) else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if(not discrete) else l if(left) else r

def resolve():
    k = int(input())

    def check(x):
        x = str(x)
        dp = [[0] * 2 for _ in range(10)]
        
        s = int(x[0])
        for i in range(1, s):
            dp[i][1] = 1
        dp[s][0] = 1

        x = x[1:]
        for s in x:
            s = int(s)
            ndp = [[0] * 2 for _ in range(10)]
            for d, lt in product(range(10), range(2)):
                for nd in [d-1, d, d+1]:
                    if not (0 <= nd <= 9):
                        continue
                    if lt == 0 and s < nd:
                        continue
                    nlt = max(lt, s > nd)
                    ndp[nd][nlt] += dp[d][lt]
            for d in range(1, 10):
                ndp[d][1] += 1
            dp = ndp
        return sum(dp[d][lt] for d, lt in product(range(10), range(2))) >= k

    print(bisection(1, 10**18+1, check, left=False))
resolve()

Measured memory_bytes: 43376
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int MAXN = 1005;

int n, m, a, b;
char ans[MAXN][MAXN];

int main(){
	scanf( "%d%d%d%d", &n, &m, &a, &b );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			ans[i][j] = '.';
	if( n&1 )
		for( int j = 1; j < m && a; j += 2, --a ){
			ans[n][j] = '<';
			ans[n][j+1] = '>';
		}
	if( m&1 )
		for( int i = 1; i < n && b; i += 2, --b ){
			ans[i][m] = '^';
			ans[i+1][m] = 'v';
		}
	for( int i = 1; i < n; i += 2 )
		for( int j = 1; j < m; j += 2 ){
			if( a >= 2 ){
				a -= 2;
				ans[i][j] = ans[i+1][j] = '<';
				ans[i][j+1] = ans[i+1][j+1] = '>';
			} else if( b >= 2 ){
				b -= 2;
				ans[i][j] = ans[i][j+1] = '^';
				ans[i+1][j] = ans[i+1][j+1] = 'v';
			} else if( a && b && n&1 && m&1 && i == n-2 && j == m-2 ){
				--a; --b;
				ans[n-2][m-2] = ans[n][m-1] = '<';
				ans[n-2][m-1] = ans[n][m] = '>';
				ans[n-2][m] = ans[n-1][m-2] = '^';
				ans[n-1][m] = ans[n][m-2] = 'v';
			} else if(a){
				--a;
				ans[i][j] = '<';
				ans[i][j+1] = '>';
			} else if(b){
				--b;
				ans[i][j] = '^';
				ans[i+1][j] = 'v';
			} else{
				break;
			}
		}
	if( a || b )
		return puts( "NO" ), 0;
	puts( "YES" );
	for( int i = 1; i <= n; ++i ){
		for( int j = 1; j <= m; ++j )
			printf( "%c", ans[i][j] );
		puts( "" );
	}
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;
import java.math.*;
public class Main {

	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			BigDecimal a=in.nextBigDecimal();
			BigDecimal b=in.nextBigDecimal();
			String ans=a.multiply(b).toString();
			for(int i=0;i<ans.length();i++) {
				if(ans.charAt(i)=='.')break;
				System.out.print(ans.charAt(i));
			}System.out.println();
				
		}
		
		
		in.close();//the end of main
	}
	
	
}

Measured memory_bytes: 37456
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
string a,b,res;
int n,m;
void nhap(){
  cin>>a>>b;
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  n=a.size();
  m=b.size();
  vector<vector<int> > f(n+1,vector<int>(m+1));
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
      if(a[i-1]==b[j-1]) f[i][j]=f[i-1][j-1]+1;
      else f[i][j]=max(f[i-1][j],f[i][j-1]);
    }
  }
  while(n>0 && m>0){
    if(a[n-1]!=b[m-1]){
      if(f[n-1][m]>f[n][m-1]) --n;
      else --m;
    }
    else{
      res+=a[n-1];
      --n;
      --m;
    }
  }
  reverse(res.begin(),res.end());
  cout<<res;
}


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

using namespace std;

int main()
{
    int k,a,b,i,ans=0;
    cin >> k >> a >> b;
    for(i=a;i<=b;i++)
    {
        if(i%k == 0)
        {
            ans = 1;
            break;
        }
    }
    if(ans==1)
    {
        cout << "OK";
    }else
    {
        cout << "NG";
    }
    return 0;
}



Measured memory_bytes: 3608
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const ll inf=0x3f3f3f3f;
const ll N=1005;
ll read(){
	ll s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
char Ans[N][40];
ll n,m,a[N],flag[2];
struct Node{ll x,y;}P[N];
void Solve(ll d){
	a[++m]=d;
	for(ll i=1;i<=n;i++){
		if(abs(P[i].x)>abs(P[i].y)){
			Ans[i][m]=(P[i].x<0?'L':'R');
			P[i].x=(P[i].x<0?P[i].x+d:P[i].x-d);
		}
		else{
			Ans[i][m]=(P[i].y<0?'D':'U');
			P[i].y=(P[i].y<0?P[i].y+d:P[i].y-d);
		}
	}
}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();
	for(ll i=1;i<=n;i++){
		P[i].x=read();P[i].y=read();
		flag[(abs(P[i].x)+abs(P[i].y))&1]=1;
	}
	if(flag[0]&&flag[1]){puts("-1");return 0;}
	for(ll i=30;i>=0;i--)Solve(1<<i);
	if(flag[0])Solve(1);
	printf("%lld\n",m);
	for(ll i=1;i<=m;i++)printf("%lld ",a[i]);puts("");
	for(ll i=1;i<=n;i++)printf("%s\n",Ans[i]+1);
	return 0;
}

Measured memory_bytes: 3812
require 'set'

def main
  loop do
    n,h = gets.chomp.split(' ').map(&:to_i)
    break if (n|h) == 0
    puts get_non_hole_cubes_num(n, h)
  end
end
 
def get_non_hole_cubes_num n, h
  hole_cubes = Set.new
 
  h.times do
    c,a,b = gets.chomp.split(' ')
    case c
    when 'xy'
      1.upto(n) do |idx|
        hole_cubes << "#{a.to_i} #{b.to_i} #{idx}"
      end
    when 'xz'
      1.upto(n) do |idx|
        hole_cubes << "#{a.to_i} #{idx} #{b.to_i}"
      end
    when 'yz'
      1.upto(n) do |idx|
        hole_cubes << "#{idx} #{a.to_i} #{b.to_i}"
      end
    end
  end
  n ** 3 - hole_cubes.size
end

main

Measured memory_bytes: 12868
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
string s;
deque<char> a;
int q, t;
char c;
bool r;

int main() {
  cin >> s;
  for (char x : s) a.push_back(x);
  cin >> q;
  while (q--) {
    cin >> t;
    if (t == 1) {
      r ^= 1;
    } else {
      cin >> t >> c;
      if (t == 1) {
        if (r) {
          a.push_back(c);
        } else {
          a.push_front(c);
        }
      } else {
        if (!r) {
          a.push_back(c);
        } else {
          a.push_front(c);
        }
      }
    }
  }
  if (r) {
    reverse(ALL(a));
  }
  for (char x : a) cout << x;
  cout << '\n';
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


Measured memory_bytes: 976
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int a, b;
    cin >> a >> b;

    if( a % 2 == 0 || b % 2 == 0 )
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
    
    return 0;
}

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


int main(){
  int n;
  cin>>n;
  int card[4][13]={};
  for(int i=0;i<n;i++){
  string suit;
  int num;
  cin>>suit>>num;


  if(suit == "S") card[0][num-1] = 1;
  if(suit == "H") card[1][num-1] = 1;
  if(suit == "C") card[2][num-1] = 1;
  if(suit == "D") card[3][num-1] = 1;
 }

 string str[4] = {"S","H","C","D"};
 for(int i=0;i<4;i++){
  for(int j=0;j<13;j++){
   if(card[i][j] == 1) continue;
   cout<<str[i]<<" "<<j+1<<endl;
  }
 }


  return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b, c, x, y;
	int sum = 0;
	int sa = 0;

	cin >> a >> b >> c >> x >> y;

	int minn, maxn;
	minn = min(x, y);
	maxn = max(x, y);
	int dai;
	if (maxn == x) {
		dai = a;
	}
	else {
		dai = b;
	}

	sa = maxn - minn;


	//for (; ;) {
		if (c * 2 < a + b) {
			sum = c * minn * 2;

			if (c * 2 < dai) {
				sum = sum + c * 2 * sa;
				cout  << sum << endl;

				getchar();
				getchar();
				return 0;
			}
			else {
				sum = sum + dai * sa;

				cout  << sum << endl;

				getchar();
				getchar();
				return 0;
			}

		}
		else {
			sum = sum + (a * x);
			sum = sum + (b * y);

			cout << sum << endl;

			getchar();
			getchar();
			return 0;
		}




	//}





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main(){
  for(;;){
    int n;
    string s;
    cin >> n;
    if(n == 0) break;
    cin >> s;
    string s1 = "";
    for(int i = 1; i <= n; i++){
      for(int j = 0; j < s.length(); j++){
	char ch = s[j];
	int cnt = 1;
	char buf[1000];
	while(s[j] == s[j + 1]){
	  cnt++;
	  j++;
	}
	//itoa(cnt, buf, 10);
	sprintf(buf, "%d", cnt);
	s1 += buf;
	s1 += ch;
      }
      s = s1;
      s1.clear();
    }
    cout << s << endl;
  }
  return 0;
}

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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  int A,B,C,D,E,F,G,H,I,J;
  A=b-a;
  B=c-a;
  C=d-a;
  D=e-a;
  E=c-b;
  F=d-b;
  G=e-b;
  H=d-c;
  I=e-c;
  J=e-d;
  int x=max({A,B,C,D,E,F,G,H,I,J});
  if(x<=k){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())

aaa = [[0 for i in range(10)] for j in range(10)]

for i in range(1, n+1):
  aaa[int(str(i)[0])][i%10] += 1

ans = 0
for i in range(1, 10):
  for j in range(1, 10):
    ans += aaa[i][j]*aaa[j][i]
print(ans)

Measured memory_bytes: 3064
ans=0
    ps=true
    p45=false
    (gets.chomp+'0').chars{|c|
      d=c.to_i
      if d>=5 && p45
        ps=false
        ans+=1
      end
      if d>5||d==5&&!ps
        ans+=10-d+(ps ? 1 : -1)
        p45=false
        ps=false
      else
        ans+=d
        p45=d==5||d==4&&!ps
        ps=true
      end
    }
    puts ans

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

vector<double> put_in (vector<double> v) {
  int n = v.size();
  sort (v.begin(), v.end());
  double x = (v[0] + v[1]) / 2;
  vector<double> u (n-1);
  for (int i = 0; i < n-1; i++) {
    if (i == 0)
      u[0] = x;
    else
      u[i] = v[i+1];
  }
  return u;
}

int main () {
  int n;
  cin >> n;
  vector<double> v (n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  
  //できるだけ価値の小さい具材から鍋に入れたほうが良い
  for (int i = 0; i < n-1; i++) {
    v = put_in (v);
  }
  cout << fixed << setprecision(5);
  cout << v[0] << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn parse_line() -> u64 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let buf = buf.trim();
    u64::from_str(buf).unwrap()
}

fn parse() -> (u64, u64) {
    let n = parse_line();
    let min = (0..5).map(|_| parse_line()).min().unwrap();
    (n, min)
}

fn calc(n: u64, min: u64) -> u64 {
    if n % min == 0 {
        n / min + 4
    } else {
        n / min + 5
    }
}

fn main() {
    let (n, min) = parse();
    println!("{}", calc(n, min));
}

#[test]
fn test_calc() {
    assert_eq!(calc(1,1), 5);
    assert_eq!(calc(2,2), 5);
    assert_eq!(calc(4,2), 6);
    assert_eq!(calc(5, 2), 7);
    assert_eq!(calc(10, 123), 5);
    assert_eq!(calc(10000000007, 2), 5000000008);
}


Measured memory_bytes: 4352
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,41301):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 300-(298*k/41300)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 88460
#include <stdio.h>

int main(){
  int n, i, j;
  long long int x, left_s=0, left_p=0, ans=0, s[70], p[70];
  scanf("%d %lld", &n, &x);

  s[0]=1;
  p[0]=1;
  for(i=1; i<=n; i++){
    s[i]=2*s[i-1]+3;
    p[i]=2*p[i-1]+1;
  }

  for(i=n; i>=0; i--){
    if(x==left_s+1){
      ans=left_p;
      break;
    }
    else if(left_s+1 < x && x < left_s+1+s[i]/2){
      left_s++;
    }
    else if(x==left_s+1+s[i]/2){
      ans=left_p+1+p[i]/2;
      break;
    }
    else if(left_s+1+s[i]/2 < x && x < left_s+s[i]){
      left_s=left_s+1+s[i]/2;
      left_p=left_p+1+p[i]/2;
    }
    else{
      ans=left_p+p[i];
      break;
    }
  }
  if(i==0) ans++;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define SIZE 200005
#define read(a,n) for(i=0;i<n;i++)cin>>a[i];
#define pii pair<int,int>
#define pb push_back
using namespace std;
typedef	long long ll;
ll n, m, i, j, k, h, t, maxn, ttt, t1, t2, sig = 0;
int main() 
{
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e >> k;
	int ss[5] = { a,b,c,d,e };
	int maxx = 0;
	for (i = 0; i < 5; i++) {
		for (j = i + 1; j < 5; j++) {
			int tmp = abs(ss[i] - ss[j]);
			maxx = max(maxx, tmp);
		}
	}
	if (maxx <= k)cout << "Yay!";
	else cout << ":(";
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln.split;
	auto N = tokens[0].to!long;
	auto a = my_readln.split.to!(ulong[]);

	ulong ans;
	foreach (e; a) ans += e - 1;
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 2428
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

#define INF 999999999

double dp[22][150002];

int main(void){
  int n;
  int t[22];

  while(scanf("%d",&n) != EOF){
    rep(i,n){
      scanf("%d",&t[i]);
    }

    rep(i,22) rep(j,150002) dp[i][j] = INF;
    REP(i,1,150002) dp[0][i] = (double)(abs(t[0] - i)) / t[0];
    rep(i,n-1){
      rep(j,150002){
        if(dp[i][j] == INF) continue;
        for(int k=j;k<150002;k+=j){
          dp[i+1][k] = min(dp[i+1][k],max(dp[i][j],(double)(abs(t[i+1]-k))/t[i+1]));
        }
      }
    }

    double ans = INF;
    rep(i,150002){
      if(dp[n-1][i] == -1) continue;
      ans = min(ans,dp[n-1][i]);
    }
    printf("%.10f\n",ans);
  }
}

Measured memory_bytes: 26000
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int h, w; cin >> w >> h;
	std::vector<std::string> s(h);
	std::vector<std::string> A, B;
	std::map<std::string, int> X, Y;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			char a; cin >> a;
			s[i] += a;
		}
		A.push_back(s[i]);
		X[s[i]] += 1;
	}
	for(int i = 0; i < w; i++) {
		std::string t = "";
		for(int j = 0; j < h; j++) t += s[j][i];
		B.push_back(t);
		Y[t] += 1;
	}
	sort(begin(A), end(A)); A.erase(unique(begin(A), end(A)), end(A));
	sort(begin(B), end(B)); B.erase(unique(begin(B), end(B)), end(B));
	
	bool f = true;
	if(A.size() != 2) f = false;
	else if(std::abs(X[A[0]] - X[A[1]]) > 1) f = false;
	if(B.size() != 2) f = false;
	else if(std::abs(Y[B[0]] - Y[B[1]]) > 1) f = false;
	
	if(f) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}



Measured memory_bytes: 6180
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	int tmp,ans;
	int minimum = BIG_NUM;

	for(int i = 1; i <= N; i++){

		scanf("%d",&tmp);
		if(tmp < minimum){
			minimum = tmp;
			ans = i;
		}
	}

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

	return 0;
}



Measured memory_bytes: 3216
import sys
from collections import Counter
from itertools import combinations

MARCH = set('MARCH')

n = int(sys.stdin.readline().rstrip())
s = [x[0] for x in sys.stdin.read().split() if x[0] in MARCH]

def main():
    c = Counter(s)
    ways = 0
    for comb in combinations('MARCH', 3):
        res = 1
        for i in comb:
            res *= c.get(i, 0)
        ways += res
    
    return ways

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 11596
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.next());
        int Q = Integer.parseInt(s.next());
        int[] ar = new int[N];
        TreeSet<Integer> set = new TreeSet<Integer>();
        int max_val = 0;
        for(int i = 0; i < N; i++){
            int c = Integer.parseInt(s.next());
            ar[i] = c;
            set.add(c);
            max_val = Math.max(max_val, c);
        }
        for(int i = 0; i < Q; i++){
            int q = Integer.parseInt(s.next());
            int ans = 0;
            if(q < 100){
                for(int j = 0; j < N; j++){
                    ans = Math.max(ans, ar[j] % q);
                }
            }else{
                for(int j = q; j <= max_val; j += q){
                    Integer v = set.lower(j);
                    if(v == null) continue;
                    ans = Math.max(ans, (int)(v) % q);
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 124288
#include<stdio.h>
signed main(){


	int n ,k ;
	scanf("%d %d",&n ,&k);

	if(k <= n && 1 <= k && 1 <= n && k <= 50 && n <= 50)
	{
	printf("%d\n",n + 1 - k);
	}

return(0);
}
	
	

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];

    int ans = 0;
    bool flg = true;
    while(flg){
        flg = false;
        rep(i,n){
            if(a[i]){
                flg = true;
                ans++;
                Rep(j,i,n){
                    if(a[j] == 0) break;
                    a[j]--;
                }
                break;
            }
        }
    } 

    cout << ans << endl;
}

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

using namespace std;

const int mod = 1000000007;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

const int max_f = 100111;

int f[max_f], rf[max_f];

void get_all_f() {
    f[0] = rf[0] = 1;
    for (int i = 1; i < max_f; ++i) {
        f[i] = mul(i, f[i - 1]);
    }
    rf[max_f - 1] = inv(f[max_f - 1]);
    for (int i = max_f - 2; i > 0; --i) {
        rf[i] = mul(i + 1, rf[i + 1]);
    }
}

int get_c(int n, int k) {
    if (n < k) {
        return 0;
    }
    return mul(f[n], mul(rf[k], rf[n - k]));
}

int n, a[max_f];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_f();
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    int ans = 0, sum = 0;
    for (int i = 0; i + 1 < n; ++i) {
        sum += mul(f[n - 1], inv(i + 1));
        sum %= mod;
        ans += mul(sum, a[i + 1] - a[i]);
        ans %= mod;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		boolean judge = true;

		char[] inputChar = input.toCharArray();
		Integer[] alphabet = new Integer[26];
		for (int i = 0; i < alphabet.length; i++) {
			alphabet[i] = 0;
		}
		for (int i = 0; i < inputChar.length; i++) {
			alphabet[(int) inputChar[i] - 97] += 1;
		}
		for (int i : alphabet) {
			if (i % 2 == 1) {
				judge = false;
			}
		}
		if (judge) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A >= K) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S, T);
  ll n = 0;
  map<char, char> mp;
  rep(i, 0, (int)S.length()) {
    if (!mp[S[i]]) {
      mp[S[i]] = n + 65;
      n++;
    }
    S[i] = mp[S[i]];
  }
  n = 0;
  mp.clear();
  rep(i, 0, (int)T.length()) {
    if (!mp[T[i]]) {
      mp[T[i]] = n + 65;
      n++;
    }
    T[i] = mp[T[i]];
  }
  print(S == T ? "Yes" : "No");
}


Measured memory_bytes: 916
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main() {
    long double H,W,result;
    cin >> H >> W;

    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    result = ceil(H*W/2);

    cout << (ll)result << endl;

    return 0;

}


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

int main()
{
  uint64_t n, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    if (i % 3 != 0 && i % 5 != 0)
    {
      sum += i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<int> >;
#define INF 1000000007
typedef long long ll;


vector<int> color;
bool dfs(const Graph &G,int v,int c = 0){
    color[v] = c;
    for(auto e : G[v]){

        /* 
        if(color[e] != -1){
            if(color[e] == c)return false;
            else continue;
        }
        if(!dfs(G,e, 1-c) )return false;*/

    if(color[e] == c){
            return false;
        }
        if(color[e] == -1 && !dfs(G,e, 1-c) ){
            return false;
        }

    }
    return true;
}

int main(){
    ll N,M;cin >> N >> M;
    Graph G(N);
    color.assign(N,-1);
    ll res = 0;
    ll w = 0,b = 0;
    for(int i = 0 ; i < M ; i++){
        int u,v;cin>>u>>v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(G, v)) is_bipartite = false;
    }

    if(is_bipartite){
         for(int i=0; i<N; i++){
            if(color[i] == 1){
                b++;
            }else if(color[i] == 0){
                w++;
            }
        }
        cout << b*w-M << endl;
    }else{
        cout << ((N*(N-1))/2)-M << endl;//完全グラフ
    }
    return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll M = 1000000007;
ll inv[1005], fac[1005], fiv[1005];
ll dp[1005][1005]; // i人をj人以下のグループに分ける時の場合の数

ll comb(int n, int k) {
    return fac[n] * fiv[k] % M * fiv[n-k] % M;
}

ll pow_mod(ll num, ll pow) {
    ll prod = 1;
    num %= M;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % M;
        num = num * num % M;
        pow >>= 1;
    }
    return prod;
}

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < 1005; i++) {
        fac[i] = fac[i - 1] * i % M; // n!
        inv[i] = inv[M % i] * (M - M / i) % M; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % M; // (n!)^-1
    }

    dp[0][A-1] = 1;
    for (int i = 0; i <= N; i++) {
        for (int j = A-1; j < B; j++) {
            (dp[i][j + 1] += dp[i][j]) %= M;

            for (int k = C; k <= D; k++) {
                // dp[i][j] -> i人をj人以下のグループに
                // dp[i+k*(j+1)][j+1] -> ↑に加え、j+1人グループをk個作る
                int people = k * (j+1);
                if (i + people > N) break;
                ll tmp = fac[people] * comb(N - i, people) % M * fiv[k] % M * pow_mod(fiv[j+1], k) % M;
                (dp[i + people][j + 1] += dp[i][j] * tmp % M) %= M;
            }
        }
    }

    cout << dp[N][B] << "\n";
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    static const long double pi = 3.141592653589793;
    using namespace std;

    int main() {

    ll int a,b,c,s,n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll int sum = 0;
    for(int i = 0;i<k;i++){
        sum += v[i];
    }
    cout<<sum<<endl;
        return 0;
    }


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cfloat>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
double p[3005];
double dp[3005][3005];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }

    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j > 0) {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
            }
            else {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            }
        }
    }

    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dp[n][i];
    }

    printf("%.*lf\n", DBL_DIG, ans);

    return 0;
}


Measured memory_bytes: 70656