akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 2e5+5;

void solve(){
	int a,b;
	cin>>a>>b;
	if(b==1){
		cout<<0;
	}
	else{
		int ans=1;
		int cur=a;
		while(cur<b){
			int prev=cur;
			for(int i=1;i<=prev && cur<b;++i){
				cur--;
				cur+=a;
				ans++;
			}
		}
		cout<<ans;
	}

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
int n;
void dfs(string s){
  //cout << s << endl;
  if(s.size()>n) return;
  if(s.size()==n){
    cout << s << endl;
    return;
  }
  char mx='a';
  rep(i,s.size()){
    if(s[i]-mx>0) mx=s[i];
  }
  mx++;
  //cout << "mx--> " << mx << endl;
  for(char x='a'; x<=mx; x++){
    string next_s = s + x;
    dfs(next_s);
  }
  return;
}

int main(void) {
  cin >> n;
  dfs("a");
}


Measured memory_bytes: 3560
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N,H,W;
	cin >> N>>H>>W;
	ll A[N],B[N];
	for (ll i = 0; i < N; ++i) cin >> A[i]>>B[i];
 
	// 解法
	ll ans = 0;
	REP(i,N){
		if (A[i]>=H & B[i]>=W) ans++;
	}
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
p = list(map(int, input().split()))

i = 0
if N == 0:
    print(X)
else:
    while True:
        minus_value = X - i
        plus_value = X + i
        if minus_value not in p:
            if plus_value not in p:
                print(minus_value)
                break
            else:
                print(minus_value)
                break
        else:
            if plus_value not in p:
                print(plus_value)
                break
            else:
                i += 1

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

int main() {
  int h,w,n;
  cin >> h >> w >> n;

  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];

  queue<int> que;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) que.push(i);
  }
  vector<vector<int>> ans(h, vector<int> (w));

  int i = 0;
  bool turn = true;
  while(i < h) {
    int j = 0;
    if(!turn) j = w - 1;
    while(true) {
      if(turn && j == w) break;
      if(!turn && j == -1) break;

      int x = que.front();
      que.pop();
      ans[i][j] = x;

      if(turn) j++;
      else j--;
    }
    turn = !turn;
    i++;
  }

  for (int ii = 0; ii < h; ii++) {
    for (int jj = 0; jj < w; jj++) {
      cout << ans[ii][jj] << " ";
    }
    cout << '\n';
  }
}

Measured memory_bytes: 384
import java.util.*;

public class Main {    
    
   public static void main(String[] args){
       
       Scanner sc = new Scanner(System.in);
       
       int N = sc.nextInt();
       int K = sc.nextInt();
       int X = sc.nextInt();
       int Y = sc.nextInt();
       
       if(N <= K){
           System.out.println(X*N);
       }else if(N > K){
           System.out.println(X*K + (N - K)*Y);
       }              
       
   }                                      
}
        
        
        
        
        

Measured memory_bytes: 23892
#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<int,int> 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, x;
	cin >>n >>x;
	VI l(n);
	rep(i, n) cin >>l[i];
	ll c=0, ans =1;
	rep(i, n){
		if(c + l[i] <= x) ans++;
		c +=l[i];
	}
	
	cout << ans <<"\n";

}


Measured memory_bytes: 256
import math

INF = 10 ** 9
A,B,H,M = map(int,input().split())

rad_H = (360*H//12) + (0.5 * M)
rad_M = 360*M//60
diff = abs(rad_H-rad_M)

#if diff > 180:
#	diff = diff - 180

temp = (A ** 2) + (B ** 2) -(2*A*B*math.cos(math.radians(diff))) 
ans = math.sqrt(temp)

print(ans)


Measured memory_bytes: 9444
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		 HashSet<String> hs = new HashSet<>();
		 while(n-->0){
			 String s =scn.next();
			 hs.add(s);
		 }
		 System.out.println(hs.size());

	}

}

Measured memory_bytes: 77804
#include<bits/stdc++.h>
using namespace std;
const double pi=atan(1.0)*4;
int main(){
	int n;
	cin>>n;
	int a[n+1]={};
	for(int i=2,x;i<=n;i++) cin>>x,a[x]++;
	for(int i=1;i<=n;i++) printf("%d\n",a[i]);
} 

Measured memory_bytes: 4444
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N,D;
	cin>>N>>D;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	//Aliceの移動をシミュレートする
	vint S;
	S.pb(D);
	for(int i=0;i<N;i++){
		int dist=S.back();
		if(abs(dist-A[i])<dist)
			S.pb(abs(dist-A[i]));
		else
			S.pb(dist);
	}
	//i番目の移動時点でゴールにたどり着けないための最短距離
	vint M(N+1);
	M[N]=1;
	for(int i=N-1;i>=0;i--){
		if(abs(M[i+1]-A[i])<M[i+1])
			M[i]=A[i]+M[i+1];
		else
			M[i]=M[i+1];
	}
	int Q;
	cin>>Q;
	while(Q--){
		int q;
		cin>>q;
		if(S[q-1]<M[q])
			cout<<"NO"<<endl;
		else
			cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 9456
#include<stdio.h>
int main()
{
	char a[55][55];
	int x,y;
	scanf("%d%d",&x,&y);
	for(int i=1;i<=x;i++)
		scanf("%s",&a[i][0]);
	for(int i=1;i<=x;i++)
	{
		for(int j=0;j<y;j++)
		{
			int w=0;
			if(a[i][j]=='#')
				printf("%c",'#');
			else
			{
				if(i-1>=1&&j-1>=0&&a[i-1][j-1]=='#')
					w++;
				if(i-1>=1&&a[i-1][j]=='#')
					w++;
				if(i-1>=1&&j+1<y&&a[i-1][j+1]=='#')
					w++;
				if(j+1<y&&a[i][j+1]=='#')
					w++;
				if(i+1<=x&&j+1<y&&a[i+1][j+1]=='#')
					w++;
				if(i+1<=x&&a[i+1][j]=='#')
					w++;
				if(j-1>=0&&i+1<=x&&a[i+1][j-1]=='#')
					w++;
				if(j-1>=0&&a[i][j-1]=='#')
					w++;	
				printf("%d",w);
			}
					
		
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
from collections import deque


def solve():
    N, M = map(int, input().split())
    to = [[] for _ in range(N)]

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        to[a].append(b)
        to[b].append(a)

    que = deque()
    hint = [0] * N
    seen = [False] * N

    seen[0] = True
    que.appendleft(0)

    # BFS
    while que:
        v = que.popleft()
        for nv in to[v]:
            if seen[nv]:
                continue
            que.append(nv)
            hint[nv] = v + 1
            seen[nv] = True

    print("Yes")
    print(*hint[1:], sep='\n')
    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 100404
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

cnt = {0:1}

ans = 0

for i in range(1, n+1):
    left = i - k
    if left >= 0:
        ldif = (a[left] - left) % k
        if ldif < 0: ldif += k
        cnt[ldif] -= 1
    
    a[i] += a[i-1]
    dif = (a[i] - i) % k
    if dif < 0: dif += k
    if dif not in cnt:
        cnt[dif] = 0
        
    ans += cnt[dif]
    cnt[dif] += 1

print(ans)

Measured memory_bytes: 39656
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;

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

    if (a + b <= n) {
        cout << min(a, b) << " " << 0 << endl;
    } else {
        cout << min(a, b) << " " << (a + b) - n<< endl;
    }
    return 0;
}


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll mi = inf;
    // iまで取る
    FOR(i, 0, N-1){
        ll left = 0;
        ll right = 0;

        FOR(x, 0, i+1){
            left += A[x];
        }
        FOR(x, i+1, N){
            right += A[x];
        }

        ll a = abs(left - right);
        chmin(mi, a);
    }

    p(mi);
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n,m,i=0,j=0,k=0,a,b;
  int B[10];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&a,&b);
      for(j=1;j<=b;j++)
	{
	  scanf("%d",&B[j]);
	}
      k=1;
      for(m=1;m<=n;m++)
	{
	  if(m==B[k] && k<=b)
	    {
	      printf("1");
	      k++;
	    }
	  else
	    {
	      printf("0");
	    }
	  if(m!=n)printf(" ");
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2108
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt(),m=getInt(),R=getInt();
		int[]r=INS(R).sorted().toArray();
		int[][]f=new int[n][n];
		for(int i=0;i<n;++i) {
			Arrays.fill(f[i],114514191);
			f[i][i]=0;
		}
		for(int i=0;i<m;++i) {
			int a=getInt()-1,b=getInt()-1,c=getInt();
			f[a][b]=c;
			f[b][a]=c;
		}

		for(int d=0;d<n;++d) {
			for(int i=0;i<n;++i) {
				for(int j=0;j<n;++j) {
					f[i][j]=Math.min(f[i][j],f[i][d]+f[d][j]);
				}
			}
		}
		//Arrays.stream(f).map(Arrays::toString).forEach(System.out::println);
		int res=Integer.MAX_VALUE;
		do {
			int buf=0;
			for(int i=1;i<R;++i) {
				buf+=f[r[i]-1][r[i-1]-1];
			}
			res=Math.min(res,buf);
		}while((r=nextPermutation(r))!=null);
		System.out.println(res);
	}
	private static int[] nextPermutation(int[] c){
		int first=getFirst(c);
		if(first==-1) return null;
		int toSwap=c.length-1;
		while(c[first]>=c[toSwap])
			--toSwap;
		swap(c,first++,toSwap);
		toSwap=c.length-1;
		while(first<toSwap)
			swap(c,first++,toSwap--);
		return c;
	}
	private static int getFirst(int[] c){
		for(int i=c.length-2;i>=0;--i)
			if(c[i]<c[i+1])
				return i;
		return -1;
	}
	private static void swap(int[] c,int i,int j){
		int tmp=c[i];
		c[i]=c[j];
		c[j]=tmp;
	}
}

Measured memory_bytes: 43140
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int N,i;
	scanf("%d", &N);

	int r=N%8;

	if(r==0){
		for(i=1; i<=N/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=N/2; i++){
			printf("%d ", 3*i);
		}
	}else if(r==2){
		for(i=1; i<=(N+2)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=N/2-1; i++){
			printf("%d ", 3*i);
		}
	}else if(r==4 && N>4){
		for(i=1; i<=(N+4)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=N/2-2; i++){
			printf("%d ", 3*i);
		}
	}else if(r==6){
		for(i=1; i<=(N-2)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=N/2+1; i++){
			printf("%d ", 3*i);
		}
	}else if(r==1){
		for(i=1; i<=(N+3)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=(N-3)/2; i++){
			printf("%d ", 3*i);
		}
	}else if(r==3 && N>3){
		for(i=1; i<=(N+5)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=(N-5)/2; i++){
			printf("%d ", 3*i);
		}
	}else if(r==5){
		for(i=1; i<=(N-1)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=(N+1)/2; i++){
			printf("%d ", 3*i);
		}
	}else if(r==7){
		for(i=1; i<=(N+1)/4; i++){
			printf("%d %d ", 6*i-4, 6*i-2);
		}
		for(i=1; i<=(N-1)/2; i++){
			printf("%d ", 3*i);
		}
	}else if(N==3){
		printf("%d %d %d ", 2, 5, 63);
	}else if(N==4){
		printf("%d %d %d %d ", 2, 5, 20, 63);
	}
	printf("\n");
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
static const int  MAX=1000;

int main(void){
  int A[MAX];
  int N;
  int v;
  cin>>N;

  for(int i=0;i<N;i++)cin>>A[i];

  for(int i=0;i<N;i++){
    v = A[i];
    int j=i -1;

    while(j>=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(int j=0;j<N-1;j++)
      printf("%d ",A[j]);
    cout<<A[N-1]<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 3176
/*
RAone00
Rohit sharma
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef vector < vector < ll > > matrix;
typedef vector < ll > vll;

#define pb push_back
#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int main() {
    fast_io();
    // int s, t;
    // cin >> s >> t;
    // char s1, s2, s3, t1, t2, t3, count = 0;
    // cin >> s1 >> s2 >> s3;
    // cin >> t1 >> t2 >> t3;
    // if (s1 == t1) {
    //     count++;
    // } else if (s2 == t2) {
    //     count++;
    // } else if (s3 == t3) {
    //     count++;
    // }
    // cout << count << "\n";
    string s;
    string t;
    int count = 0;
    cin >> s >> t;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) {
            count ++;
        }
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,m;
    ll r,l;
    std::cin >> n>>m;
    std::cin >> l>>r;
    for (int i = 0; i < m-1; i++) {
        ll tmp_r,tmp_l;
        std::cin >> tmp_l>>tmp_r;
        r = min(r,tmp_r);
        l = max(l,tmp_l);
    }
    
    std::cout << max((ll)0,r-l+1) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[3030][3030][2];
ll a[3030];

ll rec(int x,int y,int idx){
    if(dp[x][y][idx]!=longinf)return dp[x][y][idx];
    if(x==y){
        if(idx)return a[x];
        else return -a[x];
    }
    if(idx)return dp[x][y][idx]=max(a[x]+rec(x+1,y,1-idx),a[y]+rec(x,y-1,1-idx));
    else return dp[x][y][idx]=min(-a[x]+rec(x+1,y,1-idx),-a[y]+rec(x,y-1,1-idx));
}

int main(){
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)rep(j,n)rep(k,2)dp[i][j][k]=longinf;
    cout<<rec(0,n-1,1)<<endl;
    return 0;
}

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

p = []
maxIdx = 0
max = 0
for i in range(n) :
    t = int(input())
    p.append(t)
    if t > max : 
        max = t
        maxIdx = i

sum = 0
for i in range(n) :
    if maxIdx == i :
        sum += p[i]>>1
    else:
        sum += p[i]

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ld long long double
#define ll long long
#define mod 1000000007
#define scl(x) scanf("%lld",&x)
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}

ll power(ll a,ll b) {
    ll res=1LL;
    while(b>0){
        if(b&1) res = mul(res,a);
        b/=2;
        a = mul(a,a);
    }
    return res%mod;
}

int main(){
   ll a,b;
   cin >> a >> b;
   cout << max(0LL, a-(2*b)) << endl; 
}

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

using namespace std;

int idx = 0;
int n;
vector<string> str;

int func(){
	int depth = str[idx].length();
	char ch = str[idx][depth-1];
	if(isdigit(ch)) return atoi(&ch);
	int tmp = 0;
	if(ch == '*') tmp = 1;
	idx++;
	while(idx < n){
		int len = str[idx].length();
		if(len <= depth) break;
		char c = str[idx][len-1];
		if(isdigit(c)){
			if(ch == '+') tmp += (c-'0');
			else tmp *= (c-'0');
			idx++;
		} else{
			if(ch == '+') tmp += func();
			else tmp *= func();
		}
	}
	return tmp;
}


int main(void){
	while(1){
		cin >> n;
		if(!n) break;
		str.clear();
		str.resize(n);
		for(int i=0; i<n; i++){
			cin >> str[i];
		}
		idx = 0;
		cout << func() << endl;
	}
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll N, M;
	cin >> N >> M;
	if(N == 1 || M == 1) cout << abs(max(N-2, M-2));
	else cout << (N-2)*(M-2);

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL W, H, c1, c2, ans;
std::vector<std::pair<LL, LL>>edge;

int main()
{
	in >> W >> H;
	std::vector<LL>p(W), q(H);
	rep(i, W)
	{
		in >> p[i];
		edge.push_back(std::make_pair(p[i], 0));
	}
	rep(i, H)
	{
		in >> q[i];
		edge.push_back(std::make_pair(q[i], 1));
	}
	std::sort(edge.begin(), edge.end());
	c1 = H + 1, c2 = W + 1;
	for (auto e : edge)
	{
		if (e.second == 0)
		{
			ans += e.first*c1;
			--c2;
		}
		else
		{
			ans += e.first*c2;
			--c1;
		}
	}
	out << ans << std::endl;
	return 0;
}


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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    string A, B; cin >> A >> B;
    cout << B << A << endl;

    return 0;
}


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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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


n, m, k = map(int, input().split())


friends = UnionFind(n)
direct_friends = [0] * n
enemies = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    direct_friends[a] += 1
    direct_friends[b] += 1
    friends.union(a, b)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    enemies[c].append(d)
    enemies[d].append(c)

ans = []
for i in range(n):
    num = friends.size(i) - 1 - direct_friends[i]
    for enm in enemies[i]:
        if friends.same(i, enm):
            num -= 1
    ans.append(num)

print(*ans)



Measured memory_bytes: 34740
#include <iostream>
#define MAX 1000000007
using namespace std;

int main(){
  long long int N,M;
  cin >> N >> M;
  if(N-M>1||M-N>1){
    cout << "0" << endl;
    return 0;
  }
  long long int countN =1;
  for(long long int i=1;i<=N;i++){
    countN=(countN*i)%MAX;
  }
  long long int countM=1;
  for(long long int i=1;i<=M;i++){
    countM=(countM*i)%MAX;
  }
  //cout << countN << " " << countM <<endl;
  if(N==M){
    countM=(countM*2)%MAX;
  }
  cout << (countN*countM)%MAX <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a;
  string s,ans;
  cin>>a>>s;
  if(a>=3200)
    ans=s;
  else ans="red";
  ou(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	string t="111";
	rep(i,2,11){
		if(s<=t){
			cout<<t<<endl;
			return 0;
		}
		rep(j,0,3){
			t[j]=char(t[j]+1);
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,t,x,y,k=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t,&x,&y);
		if(x+y>t)
		{
			k=0;
		}
		if((x+y)%2==0&&t%2==1)
        {
            k=0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            k=0;
        }
	}
	if(k==1)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn cumsum<T>(a: T) -> Vec<T::Item>
where
    T: IntoIterator,
    T::Item: std::ops::Add<Output = T::Item> + std::default::Default + std::marker::Copy,
{
    let mut cum = vec![Default::default()];
    cum.extend(a.into_iter().scan(Default::default(), |s, v| {
        *s = v + *s;
        Some(*s)
    }));
    cum
}

fn main() {
    let n = input!(usize);
    let mut a = input!(i64,);
    let lcm = cumsum(a.clone());
    a.reverse();
    let mut rcm = cumsum(a);
    rcm.reverse();

    let mut l = 1;
    let mut r = 3;
    let mut ans = Vec::new();
    for m in 2..n - 1 {
        if r - m == 0 {
            r += 1;
        }
        while r < n - 1 {
            let now = (rcm[m] - 2 * rcm[r]).abs();
            let next = (rcm[m] - 2 * rcm[r + 1]).abs();
            if next < now {
                r += 1;
            } else {
                break;
            }
        }
        while l < m - 1 {
            let now = (lcm[m] - 2 * lcm[l]).abs();
            let next = (lcm[m] - 2 * lcm[l + 1]).abs();
            if next < now {
                l += 1;
            } else {
                break;
            }
        }
        ans.push(calc(&lcm, &rcm, l, m, r));
    }
    println!("{}", ans.iter().min().unwrap());
}

fn calc(lcm: &Vec<i64>, rcm: &Vec<i64>, l: usize, m: usize, r: usize) -> i64 {
    let mut sum: Vec<i64> = Vec::with_capacity(4);
    sum.push(lcm[l]);
    sum.push(lcm[m] - lcm[l]);
    sum.push(rcm[m] - rcm[r]);
    sum.push(rcm[r]);
    sum.iter().max().unwrap() - sum.iter().min().unwrap()
}


Measured memory_bytes: 14064
// finish date: 2018/02/02
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;


int main() {
    int N, W;
    cin >> N >> W;
    vvl DP(N + 1, vl(302, 0));
    int w, v;
    int w1;
    ll ma = 0;
    rep(i, N) {
        cin >> w >> v;
        if (i == 0) w1 = w;
        w -= w1;
        for (int j = i + 1; j >= 0; j--) {
            rep(k, DP[j].size()) {
                if (DP[j][k] > 0 || (j == 0 && k == 0)) {
                    DP[j + 1][k + w] = max(DP[j + 1][k + w], DP[j][k] + v);
                    if ((ll)(j + 1) * w1 + (k + w) <= W) ma = max(ma, DP[j + 1][k + w]);
                }
            }
        }
    }
    cout << ma << endl;

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

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

Measured memory_bytes: 3600
#include <stdio.h>
int main(){
  int n,m,i,j;
  int s_taro[100],s_hanako[100];
  int sum_taro,sum_hanako,sum_exchange,exchange_s_taro,exchange_s_hanako,count,hako_taro,hako_hanako;
  while(1){
    scanf("%d%d",&n,&m);
    if(n==0 && m==0)break;
    sum_taro=0;
    sum_hanako=0;
    sum_exchange=200;
    count=0;
    for(i=0;i<n;i++){
      scanf("%d",&s_taro[i]);
      sum_taro+=s_taro[i];
    }
    hako_taro=sum_taro;
    for(j=0;j<m;j++){
      scanf("%d",&s_hanako[j]);
      sum_hanako+=s_hanako[j];
    }
    hako_hanako=sum_hanako;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	sum_taro-=s_taro[i];
	sum_hanako-=s_hanako[j];
	sum_taro+=s_hanako[j];
	sum_hanako+=s_taro[i];
	if(sum_taro==sum_hanako){
	  count++;
	  if(sum_exchange>=s_taro[i]+s_hanako[j]){
	    sum_exchange=s_taro[i]+s_hanako[j];
	    exchange_s_taro=s_taro[i];
	    exchange_s_hanako=s_hanako[j];
	  }
	}
	sum_taro=hako_taro;sum_hanako=hako_hanako;
      }
    }
    if(count>0)printf("%d %d\n",exchange_s_taro,exchange_s_hanako);
    else if(count==0) printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int queue[2][1000007] = {0};

int main(){
  int h, w;  scanf("%d %d", &h, &w);

  int qsize = 1000007, front = 0, rear = 0;
  int field[1010][1010] = {0};
  for(int i=0; i<h; i++){
    char s[1010];  scanf("%s", s);
    for(int j=0; j<w; j++)
      if(s[j] == '.')
	field[i+1][j+1] = 1;
      else
	queue[0][rear] = i+1, queue[1][rear] = j+1, rear++;
  }

  int ans = 0, table[1010][1010] = {0}, nowh, noww;
  while(front != rear){
    nowh = queue[0][front], noww = queue[1][front], front = (front+1)%qsize;

    ans = max(ans, table[nowh][noww]);
    for(int s=-1; s<=1; s+=2){
      if(field[nowh+s][noww] && !table[nowh+s][noww]){
	queue[0][rear] = nowh+s, queue[1][rear] = noww, rear = (rear+1)%qsize;
	table[nowh+s][noww] = table[nowh][noww] + 1;
      }
      if(field[nowh][noww+s] && !table[nowh][noww+s]){
      	queue[0][rear] = nowh, queue[1][rear] = noww+s, rear = (rear+1)%qsize;
	table[nowh][noww+s] = table[nowh][noww] + 1;
      }      
    }
  }

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

  return 0;
}


Measured memory_bytes: 17464
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int s[101];
int dp[101][10101];
int main(){
    int n,si;
    cin>>n;
    int sum=0;
    rep(i,n){
        cin>>si;
        s[i]=si;
        sum+=si;
    }
    dp[0][0]=0;
    rep(i,n){
        rep(j,n*101){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            dp[i+1][j+s[i]]=max(dp[i+1][j+s[i]],dp[i][j]+s[i]);
        }
    }
    int ans;
    for(int i=n*100;i>=0;--i){
        if(dp[n][i]%10!=0){
        ans=dp[n][i];break;
        }
        if(i==0) ans=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
program main
	implicit none
	integer       :: i, counter_C = 0, counter_Big = 0
	character(10) :: S
	read(*, *) S
	if(S(1:1) /= "A") then
		write(*, *) "WA"
	else
		do i = 3, len_trim(S)-1
			if(S(i:i) == "C") then
				counter_C = counter_C + 1
			end if
		end do
		do i = 1, len_trim(S)
			if(S(i:i) >= "A" .AND. S(i:i) <= "Z") then
				counter_Big = counter_Big + 1
			end if
		end do
		if(counter_C == 1 .AND. counter_Big == 2) then
			write(*, *) "AC"
		else
			write(*, *) "WA"
		end if
	end if
end program main

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int ans = 0;
		for(int i = 0;i <= N; i++) {
			ans += i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21076
from fractions import Fraction
from decimal import *
N,K = map(int,input().split())
list = []
for i in range(1,N+1):
    if i >= K:
        list.append(float(Fraction(N-i+1,N)))
        break
    n = i
    count = 0
    while n < K:
        n *= 2
        count += 1
    list.append(float(Fraction(1,N)*(Fraction(1,2)**count)))

print(Decimal(sum(list)))


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	if (k == 1)cout << 0 << endl;
	else cout << n - k << endl;
}

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

ll ans;
ll N;

void dfs(ll now, int use, ll &ans){
    if(now > N)return;
    if(use == 0b111)ans++;

    dfs(now*10+7, use | 0b001, ans);
    dfs(now*10+5, use | 0b010, ans);
    dfs(now*10+3, use | 0b100, ans);
}

int main() {
    cin >> N;
    dfs(0, 0, ans);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  double all;
  cin >> N >> M;

  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    all = all + A[i];
  }

  sort(A, A+N,std::greater<int>());

  if(A[M-1] < all/(4*M)){
    cout << "No" <<endl;
  }else{
    cout << "Yes" <<endl; 
  }
}

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

int64_t Q=1000000007;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int64_t> p;
  vector<int64_t> dp;
  int A=1;
  while(A*A<=N){
    p.push_back(1);
    A++;
  }
  A--;
  while(A>0){
    if(N/A==A){
      A--;
      continue;
    }
    p.push_back(N/A-N/(A+1));
    A--;
  }
  int M=p.size();
  dp=p;
  vector<int64_t> q(M);
  for(int l=1;l<K;l++){
    q[0]=dp[0];
    for(int i=1;i<M;i++){
      q[i]=q[i-1]+dp[i];
      q[i]%=Q;
    }
    for(int i=0;i<M;i++){
      dp[i]=p[i]*q[M-1-i];
      dp[i]%=Q;
    }
  }
  int64_t Z=0;
  for(int i=0;i<M;i++){
    Z+=dp[i];
    Z%=Q;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define inc(l,i,r) for (int i=l;i<=r;i++)
#define dec(r,i,l) for (int i=r;i>=l;i--)
#define SIZE(V) ((int) V.size())
#define forE(p,u) for (edge *p=head[u];p;p=p->nxt)
#define forV(i,V) for (int i=0;i<SIZE(V);i++)
#define pb push_back
#define In inline
#define fi first
#define se second
#define mp make_pair
#define It iterator
#define ___ putchar(10);
#define cnt(x) __builtin_popcount(x)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N = 100100, P = 998244353;

int main() {
	//freopen("_in.txt","r",stdin);
	int x;
	scanf("%d",&x);
	for (int k=1;k<=360;k++) if (k*x % 360 == 0) {
		printf("%d\n",k);
		break;
	}
}

Measured memory_bytes: 3748
#include<stdio.h>

void call(int);

int main(void) {
        int n;

        scanf("%d", &n);
        call(n);

        return 0;
}

void call(int n){
  int i = 1;
  int x;

 CHECK_NUM:
  x = i;
  if ( x % 3 == 0 ){
        printf(" %d", i);
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
        printf(" %d", i);
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  printf("\n");
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a;
    vector<ll> sum_a;
    sum_a.push_back(0);

    ll sum_tmp = 0;
    rep(i, n){ 
        int tmp; 
        cin >> tmp;
        sum_tmp += tmp;
        sum_a.push_back(sum_tmp);
    }

    map<int, int> amari;
//    rep(i, k) amari.insert(make_pair(i, 0));

    //show(sum_a);
 
    ll ans = 0;
    for (int j = 1; j <= n; j++)
    {
        int itr = (sum_a[j] - (ll)j) % (ll)k;


        int itr_plus = (sum_a[j - 1] - (ll)(j - 1)) % (ll)k;
        if (amari.count(itr_plus) == 0) amari.insert(make_pair(itr_plus, 0));
        amari[itr_plus]++;

        if ((j - k) >= 0) {
            int itr_minus = (sum_a[j - k] - (ll)(j - k)) % (ll)k;   
            if (amari.count(itr_minus) == 0) amari.insert(make_pair(itr_minus, 0));
            amari[itr_minus]--;
        }
        //cout << itr << " "<< amari[itr] << endl;
        if (amari.count(itr) == 0) amari.insert(make_pair(itr, 0));
        ans += amari[itr];

    }
    

    cout << ans << endl;

}

Measured memory_bytes: 11248
def Bfun():
    vals = [int(i) for i in input().split()]
    a = vals[0]
    b = vals[1]
    c = vals[2]
    d = vals[3]
    res2 = a//d + (1 if(a % d > 0) else 0)
    res1 = c//b + (1 if(c % b > 0) else 0)
    res = "Yes" if(res1 <= res2) else "No"
    print(res)
Bfun()

Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int main()
{
   int a, b;
   cin >> a >> b;
   if (a > b)
       cout << "a > b" << endl;
   else if (a < b)
       cout << "a < b" << endl;
   else
       cout << "a == b" << endl;
       
}


Measured memory_bytes: 3104
#include<iostream>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	int n,a[100005]={0},t,m=0;
	cin>>n;
	rep(i,0,n)
	{
		scanf("%d",&t);
		a[t]++;
		a[t-1]++;
		a[t+1]++;
		if(a[t]>m)
		m=a[t];
		if(a[t+1]>m)
		m=a[t+1];
		if(a[t-1]>m)
		m=a[t-1];
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 640
main = putStrLn . format . solve =<< parse

solve :: (Int, Int, Int) -> Bool
solve (5, 5, 7) = True
solve (5, 7, 5) = True
solve (7, 5, 5) = True
solve _ = False

format :: Bool -> String
format True = "YES"
format False = "NO"

parse :: IO (Int, Int, Int)
parse = (\[x, y, z] -> (x, y, z)) . map read . words <$> getLine


Measured memory_bytes: 508
N=int(input())
Vs=str(input())
Cs=str(input())
ListV=Vs.split()
ListC=Cs.split()
for i in range(0,len(ListV),1):
  a=ListV.pop(0)
  ListV.append(int(a))

for i in range(0,len(ListC),1):
  b=ListC.pop(0)
  ListC.append(int(b))

ListI=[]
for i in range(0,len(ListV),1):
  c=ListV[i]-ListC[i]
  ListI.append(c)

Ans=0
for i in range(0,len(ListI),1):
  if ListI[i]>0:
    Ans+=ListI[i]

print(Ans)


Measured memory_bytes: 3064
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    a.sort!"a > b";
    auto g = a.group.array;
    long[] e;
    foreach (x; g)
    {
        if (x[1] >= 4 && e.length == 0)
        {
            e ~= x[0];
            e ~= x[0];
        }
        else if (x[1] >= 2)
        {
            e ~= x[0];
        }

        if (e.length == 2)
        {
            writeln(e[0] * e[1]);
            return;
        }
    }

    0.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 4532
import numpy as np
def main():
    N = int(input())
    ans = 0
    for x in range(50000):
        x += 1
        if np.floor(x * 1.08) == N:
            ans = x
            break
        if x == 50000 and ans == 0:
            ans = ":("
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21648