akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-


def main():
    k = int(input())
    n = 50
    p, q = divmod(k, n)
    a = [i + p for i in range(n)]

    for i in range(q):
        for j in range(n):
            if j == i:
                a[j] += 50
            else:
                a[j] -= 1

    print(n)
    print(' '.join(map(str, a)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

template <int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

const int mod = 1e9 + 7;
using mint = ModInt<mod>;

int main() {
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, n) cin >> c[i];

    sort(all(c));

    mint ans = 0;
    rep(i, n) {
        mint add = mint(2).pow(n - 1) * c[i] * (n - i + 1) / 2;
        ans += add;
    }
    ans *= mint(2).pow(n);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef  long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
map <lo,lo> mp1;
map <string,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> n >> m;
    a = n * m;
    if(n == 1 || m == 1){
        cout << 1 ;
        return 0;
    }
    cout << (a % 2== 0?a / 2:a / 2 + 1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	int	n;
  	int	p;
  	int num;
  
  	num = scanf("%d", &n);
  
  	if (n % 2 == 1)
    	p = n / 2 + 1;
  	else
      	p = n / 2;
  
  	printf("%d", p);
  	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, K, A[MAX], dp[MAX];
int main(){
    memset(dp, 0x3f, sizeof(dp));
    scanf("%d %d", &N, &K);
    for(int i = 1; i <= N; i++)
        scanf("%d", A + i);
    dp[1] = 0;
    for(int i = 2; i <= N; i++){
        for(int j = 1; j <= K; j++){
            if(i - j < 1)   break;
            dp[i] = min(dp[i], dp[i - j] + abs(A[i] - A[i - j]));
        }
    }
    printf("%d\n", dp[N]);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>
#include <set>

using namespace std;

void makeSet(const uint32_t n, const uint32_t* A, set<uint32_t>& combSet);
bool check(const uint32_t m, const set<uint32_t>& set);

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

    uint32_t n, a, q, m, bits;
    uint32_t A[30];

    cin >> n;
	for(uint32_t i = 0; i < n; i++){
			cin >> A[i];
	}

	set<uint32_t> combSet;
	makeSet(n, A, combSet);

	cin >> q;
    for(uint32_t i = 0; i < q; i++) {
        cin >> m;
        cout << (check(m, combSet) ? "yes" : "no") << endl;
    }
    return 0;
}

void makeSet(const uint32_t n, const uint32_t* A, set<uint32_t>& combSet) {
    uint32_t sum;

	for(uint32_t i = 1; i < (1 << n); i++) {
		sum = 0;

		for(uint32_t j = 0; j < n; j++) {
			if(i < (1 << j)) {
				break;
			}
			if(i & (1 << j)) {
				sum += A[j];
			}
		}
		combSet.insert(sum);
	}
}

bool check(const uint32_t m, const set<uint32_t>& set) {
	uint32_t sum;

    for(const auto& e : set) {
		if(m == e){
            return true;
        }
    }
    return false;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll inf= 1e9;
void solution(){
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(auto &x: arr)
        cin>>x;
    ll L= arr[0],R=arr[0];
    ll ans = inf;
    for(auto &x: arr){
        L = min(L,x);
        R = max(R,x);
    }
    for(ll i=L;i<=R;++i){
        ll cost=0;
        for(ll j=0;j<n;++j)
            cost += (arr[j]- i)*(arr[j]-i);
        ans = min(cost,ans);
    }
    cout<<ans;

}
int main(){
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cerr.tie(0);
        /*ll t;
        cin>>t;
        while(t--)*/
                solution();
        return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    
    private final static String SPACE = " ";
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                int x = Integer.valueOf(inputs[0]);
                int y = Integer.valueOf(inputs[1]);
                
                if (x < y) {
                    System.out.print(x);
                    System.out.print(SPACE);
                    System.out.print(y);
                    System.out.println();
                } else if (x == 0 && y == 0) {
                    break;
                    // nothing to do
                } else {
                    System.out.print(y);
                    System.out.print(SPACE);
                    System.out.print(x);
                    System.out.println();
                }
            }
            
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

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

int main(void){
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N), B(N);
	for(int i = 0; i < N; ++i){
		cin >> A[i] >> B[i];
	}
	priority_queue<
		pair<ll, ll>,
		vector<pair<ll, ll>>,
		greater<pair<ll, ll>>
		> que;

	for(int i = 0; i < N; ++i){
		que.emplace(A[i], B[i]);
	}
	ll sum = 0;
	ll cnt = 0;
	ll a, b;
	while(true){
		a = que.top().first;
		b = que.top().second;
		que.pop();
		if(cnt + b >= M){
			break;
		}else{
			sum += a * b;
			cnt += b;
		}
	}
	ll ans = sum + (M-cnt) * a;
	cout << ans << endl;
}

Measured memory_bytes: 3956
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.*;

public class Main{
  static int a, b;

  public static void main(String[] args){
    FastScanner sc = new FastScanner();
    a = sc.nextInt(); b = sc.nextInt();

    if((a + b) % 2 == 0){
      System.out.println((a + b) / 2);
    }
    else{
      System.out.println((a + b + 1) / 2);
    }
  }
}

class FastScanner {
  private static final InputStream in = System.in;
  private static final PrintWriter out = new PrintWriter(System.out);
  private final byte[] buffer = new byte[2048];
  private int p = 0;
  private int buflen = 0;

  public FastScanner(){
  }

  private boolean hasNextByte() {
    if(p < buflen){
      return true;
    }
    p = 0;
    try{
      buflen = in.read(buffer);
    }catch (IOException e) {
      e.printStackTrace();
    }
    if(buflen <= 0){
      return false;
    }
    return true;
  }

  public boolean hasNext() {
    while(hasNextByte() && !isPrint(buffer[p])){
      p++;
    }
    return hasNextByte();
  }

  private boolean isPrint(int ch) {
    if(ch >= '!' && ch <= '~'){
      return true;
    }
    return false;
  }

  private int nextByte() {
    if(!hasNextByte()){
      return -1;
    }
    return buffer[p++];
  }

  public String next() {
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = -1;
    while(isPrint((b = nextByte()))){
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }

  public int nextInt() {
    return Integer.parseInt(next());
  }

  public long nextLong() {
    return Long.parseLong(next());
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int n=1;
int dat[2000009];

void update(int i,int x){
  i+=n-1;
  dat[i]=(1<<x);
  while(i>0){
    i=(i-1)/2;
    dat[i]=dat[i*2+1]|dat[i*2+2];
  }
}

int query(int a,int b,int i,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return dat[i];
  else{
    int vl=query(a,b,i*2+1,l,(l+r)/2);
    int vr=query(a,b,i*2+2,(l+r)/2,r);
    return vl|vr;
  }
}

int main(){
  int m,q;
  string s;
  cin>>m>>s;
  while(n<m)n*=2;
  rep(i,n*2-1)dat[i]=0;
  rep(i,m){
    update(i,s[i]-'a');
  }
  cin>>q;
  rep(i,q){
    int com;
    cin>>com;
    if(com==1){
      int x;
      char c;
      cin>>x>>c;
      x--;
      update(x,c-'a');
    }
    else{
      int l,r;
      cin>>l>>r;
      l--;r--;
      int bits=query(l,r+1,0,0,n);
      cout<<__builtin_popcount(bits)<<endl;
    }
  }
  return(0);
}
  


Measured memory_bytes: 7044
main :: IO ()                                                                                                              
main = getLine >>= \s -> getLine >>= \t -> putStrLn $ if t `elem` map (rot s) [0..(length s)] then "Yes" else "No"         
                                                                                                                           
rot :: [a] -> Int -> [a]                                                                                                   
rot xs n = drop n xs ++ take n xs

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
const int mxn=1e6;
vector <int> adj[mxn];
int visited[mxn];
long long dist[mxn];
queue <int> q;
void bfs(int start)
{
    q.push(start);
    visited[start]=1;
    dist[start]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
       // cout<<u<<' ';
        for(int i=0;i<adj[u].size();i++)
        {
           int v= adj[u][i];
           if(!visited[v])
           {
               visited[v]=1;
               q.push(v);
               dist[v]=1+dist[u];
           }
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    int u,v;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
   /*for(auto i:visited)
   {
       cout<<i<<" ";
   }*/

    bfs(1);

        if (dist[n]==2) cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 36408
import org.omg.PortableInterceptor.INACTIVE;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final char[] s = scanner.next().toCharArray();
        final char[] t = scanner.next().toCharArray();

        for (int i = s.length - t.length; i >= 0; i--) {
            if (!check(s, t, i)) {
                continue;
            }

            final StringBuilder builder = new StringBuilder();
            for (int j = 0; j < i; j++) {
                builder.append(s[j] == '?' ? 'a' : s[j]);
            }
            for (int j = i; j < i + t.length; j++) {
                builder.append(t[j - i]);
            }
            for (int j = i + t.length; j < s.length; j++) {
                builder.append(s[j] == '?' ? 'a' : s[j]);
            }
            System.out.println(builder);
            return;
        }
        System.out.println("UNRESTORABLE");
    }

    private static boolean check(final char[] s, final char[] t, final int index) {
        for (int i = index; i < index + t.length; i++) {
            if (s[i] == '?') {
                continue;
            }

            if (s[i] != t[i - index]) {
                return false;
            }
        }
        return true;
    }
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int n , m , a , b;
int h[MAXX];

int main()
{
    _FastIO;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    vector<int> v[n + 5];
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);

    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        bool flag = true;
        for(int j = 0; j < v[i].size(); j++){
            int k = v[i][j];
            if(h[i] <= h[k]){
                flag = false;
                break;
            }
        }
        if(flag)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9164
#include<stdio.h>
#include<stdlib.h>
#define ll long long

typedef struct monster{
	int x,h;
}M;

M m[200010];
ll cum[200010];

int c(const void*p,const void*q){
	if((*(M*)p).x<(*(M*)q).x)return -1;
	return 1;
}


int main(){
	int n,d,a;
	scanf("%d%d%d",&n,&d,&a);
	for(int i=0;i<n;i++)scanf("%d%d",&(m[i].x),&(m[i].h));
	qsort(m,n,sizeof(M),c);

	ll ans=0;
	int r=0;
	for(int i=0;i<n;i++){
		if(i)cum[i]+=cum[i-1];
		if(m[i].h-cum[i]<=0)continue;
		while(r<n&&m[r].x-m[i].x<=2*d)r++;
		int cnt=(m[i].h-cum[i]+(a-1))/a;
		ans+=cnt;
		cum[i]+=a*cnt;
		cum[r]-=a*cnt;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    Deque<Character> stack = new ArrayDeque<>();
    for (char c : s.toCharArray()) {
      if (!stack.isEmpty() && stack.peek() != c) {
        stack.pop();
      } else {
        stack.push(c);
      }
    }
    System.out.println(s.length() - stack.size());
  }
}


Measured memory_bytes: 24532
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;

namespace abc155_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Aarray = Console.ReadLine().Split(" ");
            List<int> EvenArray = new List<int>();

            for (int i = 0;i < N; i++)
            {
                int Ai = int.Parse(Aarray[i]);
                int EvenAi =    Ai % 2;
                if (EvenAi == 0)
                {
                    EvenArray.Add(Ai);
                }
            }

            bool isApproved = true;
            foreach (var b in EvenArray)
            {
                int amari3 = b % 3;
                int amari5 = b % 5;
                if (amari3 == 0 || amari5 == 0)
                {
                    isApproved = true;
                }
                else
                {
                    isApproved = false;
                    break;
                }
            }

            if (isApproved)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
            return;
        }
    }
}


Measured memory_bytes: 27816
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//???

int w,h,field[50][50],ans;

void dfs(int x,int y){
	if(x<0 || x>=w || y<0 || y>=h)return;
	if(field[x][y]==0)return;
	field[x][y]=0;
	dfs(x+1,y);
	dfs(x-1,y);
	dfs(x,y+1);
	dfs(x,y-1);
	dfs(x+1,y+1);
	dfs(x-1,y-1);
	dfs(x-1,y+1);
	dfs(x+1,y-1);
}

int main(void){
	while(1){
		ans=0;
		cin>>w>>h;
		if(w==0 && h==0)break;
		rep(i,h){
			rep(j,w){
				cin>>field[j][i];
			}
		}
		rep(i,h){
			rep(j,w){
				if(field[j][i]==1){
					dfs(j,i);
					ans++;
					// cout<<i<<","<<j<<endl;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>

int main(void){

  int a[3],i,j,dum;

  scanf("%d %d %d",&a[0],&a[1],&a[2]);

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(a[i] < a[j]){
	dum = a[i];
	a[i] = a[j];
	a[j] = dum;
      }
    }
  }

  printf("%d %d %d\n",a[0],a[1],a[2]);
  
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string x;
    while (cin >> x){
        if (x == (string)"0") break;
        long s = 0;
        for (long i = 0; i < x.size(); i++){
            s += x[i] - '0';
        }
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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


Measured memory_bytes: 3636
using System;

public class Hello{
    public static void Main(){
        // Your code here!
        var command = Console.ReadLine().Split(' ');
        var n = int.Parse(command[0]);
        var r = int.Parse(command[1]);
        var rating = r;

        if (n < 10){
            rating = r + (100 * (10 - n));
        }
        Console.WriteLine(rating);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include <iomanip>
#include <limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
    if (n == 0) { return 1; }
    int x = rui(a, n / 2);
    x *= x; x %= p;
    if (n % 2 == 1) { x *= a; x %= p; }
    return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
    for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
    inv_kai = kai;
    rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
    if (n < 0 || r<0 || r>n) { return 0; }
    int a = kai[n] * inv_kai[r]; a %= p;
    a *= inv_kai[n - r]; a %= p;
    return a;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
#define pd pair<int,double>
#define ved vector<double>
int l;
V<string> s;
int ord_2(int n) {
    if (n % 2 == 1) { return 1; }
    return 2 * ord_2(n / 2);
}
int solve(string &now, int st, int to) {
    if (st == to) {
        int ql = l - now.size();
        return ord_2(ql + 1);
    }
    if (s[st] == now) { return 0; }
    now.append(1, '1');
    int mid = lower_bound(s.begin()+st, s.begin()+to, now)-s.begin();
    int ans1 = solve(now, mid, to);
    now.erase(now.end() - 1);
    now.append(1, '0');
    int ans0 = solve(now, st, mid);
    now.erase(now.end() - 1);
    return (ans0 ^ ans1);
}
signed main() {
    int n; cin >> n >> l;
    s = V<string>(n);
    rep(i, n) { cin >> s[i]; }
    sor(s);
    string now = "";
    int ans = solve(now, 0, n);
    //cout << ans << endl;
    if (ans == 0) { cout << "Bob" << endl; return 0; }
    cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 12672
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc132_a.cpp
 * time   : Sat May  2 00:56:07 2020
 * quest  : A - Fifty-Fifty
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  cout << ((s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while(true)
        {
            var s = Console.ReadLine().Trim();
            if (s == "0000") break;
            if (s =="6174") { Console.WriteLine("0"); continue; }
            if (int.Parse(s) % 1111 == 0) { Console.WriteLine("NA"); continue; }
            var count = 1;
            while (true)
            {
                var chk = GetLminusS(s);
                if (chk == "6174") { Console.WriteLine(count); break; }
                else   { count++;   s = chk;  }
            }
        }
    }
    public static string GetLminusS ( string s)
    {
        var lst = new List<int>();
        for (int i = 0; i < 4; i++) lst.Add(int.Parse(s[i].ToString()));
        lst.Sort();
        var L = 1000 * lst[3] + 100 * lst[2] + 10 * lst[1] + lst[0];
        var S = 1000 * lst[0] + 100 * lst[1] + 10 * lst[2] + lst[3];
        var zero = new string('0', 4-(L - S).ToString().Length);
        return zero + (L - S).ToString();
    }
}

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

using namespace std;
static const int INF = (1 << 21);

int E[8][8 ] = { { 0 } };
int N, M;
int c = 0;
int flag[8] = { 0 };

void dfs(int u) {
	int sum = 0;
	for (int i = 0;i < N;i++) {
		sum += flag[i];
	}
	if (sum == N) {
		c++;
	}
	else {
		for (int v = 0;v < N;v++) {
			if (E[u][v] == 1&&flag[v]==0) {
				flag[v] = 1;
				E[v][u] = E[u][v] = 0;
				dfs(v);
				E[v][u] = E[u][v] = 1;
				flag[v] = 0;
			}
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0;i < M;i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		E[u][v] = E[v][u] = 1;
	}
	flag[0] = 1;
	dfs(0);
	cout << c << endl;
}

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

int main()
{
    int N;
    bool judge=false;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    for(int i=1;i<N;i++)
    {
        if(A.at(i-1)==A.at(i))
        {
            judge = true;
            break;
        }
    }

    if(judge==true)
    {
        cout << "NO" << endl;
    }else
    {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 4032
#include<iostream>
#include <iomanip>

#define PI 3.14159265359	

using namespace std;

int main(){
	int h, w;
	while (1){
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++) cout << "#";
			cout << endl;
		}
		cout << endl;
	}

}

Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)4010;
const int MOD = 998244353;
int dp[N][N];
int c1[N];
int c2[N];

void add(int &a, int b){
  a += b;
  if(a >= MOD)
    a -= MOD;
}

int main(){
  fastIO;
  string t;
  cin >> t;
  int n = t.size();
  for(int i = 0; i < n; i ++ ){
    if(t[i]=='1')c1[i]=1,c2[i]=1;
    else if(t[i]=='2')c1[i]=2;
    else c2[i]=2;
    if(i>0) c1[i] += c1[i - 1], c2[i] += c2[i - 1];
  }
  for(int i = n; i < 2 * n; i ++ )
    c1[i] += c1[i - 1], c2[i] += c2[i - 1];
  dp[0][0]=1;
  for(int i = 0; i < 2 * n; i ++ ){
    for(int j = 0 ; j <= i; j ++ ){
      if(dp[i][j]==0)continue;
      if(j<c1[i]){
        add(dp[i + 1][j + 1], dp[i][j]);
      }
      if(i-j<c2[i]){
        add(dp[i + 1][j], dp[i][j]);
      }
    }
  }
  int ans = 0;
  for(int i = 0 ; i <= 2 * n; i ++ )
    add(ans, dp[2 * n][i]);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 60544
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main()
{
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%f", sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2)));
	
	return 0;
}

Measured memory_bytes: 652
#include <stdio.h>

int main(){
  int n, maxv=-999999999, minr;
  int i = 0, j = 0, tmp;
  int r[200000];

  scanf("%d", &n);
  while(i<n){
    scanf("%d", &r[i]);
    i++;
  }
  minr = r[0];
  for(j=1; j<n; j++){
    tmp = r[j]-minr;
    if(maxv < tmp){
      maxv = tmp;
    }
    if(minr>r[j]){
      minr = r[j];
    }
  }
  printf("%d\n", maxv);
}

Measured memory_bytes: 2608
import bisect

N = int(input())
a = list(map(int, input().split()))

a.sort()
a_max = a.pop(-1)
a_half_1 = a[min(bisect.bisect_left(a, a_max // 2), len(a) - 1)]
a_half_2 = a[max(bisect.bisect_left(a, a_max // 2) - 1, 0)]
if abs(a_max / 2 - a_half_1) < abs(a_max / 2 - a_half_2):
    a_half = a_half_1
else:
    a_half = a_half_2

print(a_max, a_half)


Measured memory_bytes: 62704
/*
	  Author : @evenbao
	  Created : 2020 / 07 / 18
*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

#define pii pair<int , int>
#define mp make_pair
#define fi first
#define se second

const int N = 2e5 + 10;
const LL INF = 1e18;

int n , tot , S , T , m , n1 , n2 , n3 , n4;
LL dist[N] , incf[N];
int head[N] , pre[N] , inq[N];
LL ans;

template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void read(T &x) {
    T f = 1; x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    x *= f;
}

struct Edge {
		int to;
		LL w , cst;
		int nxt;
} E[N << 2];

inline void AddEdge(int u , int v , LL w , LL cost) {
		E[++tot] = (Edge) {v , w , cost , head[u]};  head[u] = tot;
		E[++tot] = (Edge) {u , 0 , -cost , head[v]}; head[v] = tot;
}
inline bool argument() {
		queue < int > Q;
		for (int i = 1; i <= m; ++i) {
				dist[i] = incf[i] = -INF;
				inq[i] = false;
		}
		Q.push(S); incf[S] = INF; dist[S] = 0; pre[S] = 0;
		while (!Q.empty()) {
				int u = Q.front(); Q.pop(); inq[u] = false;
				for (int i = head[u]; i; i = E[i].nxt) {
						int v = E[i].to;
						LL w = E[i].w , cst = E[i].cst;
						if (dist[u] + (LL) cst > dist[v] && w > 0) {
								dist[v] = dist[u] + (LL) cst;
								incf[v] = min(incf[u] , (LL) w);
								pre[v] = i;
								if (!inq[v]) {
										inq[v] = true;
										Q.push(v);
								}
						}
				}
		}
		if (dist[T] > -INF) return true;
		else return false;
}
inline void update() {
		int now = T;
		while (now > 0) {
				E[pre[now]].w -= incf[T];
				E[pre[now] ^ 1].w += incf[T];
				now = E[pre[now] ^ 1].to;
		}
		ans += (LL) dist[T] * incf[T];
		return;
}
int main() {
		
		read(n); tot = 1;
		m = 2 * n + 6; S = 2 * n + 1 , T = 2 * n + 2;
		n1 = 2 * n + 3 , n2 = 2 * n + 4 , n3 = 2 * n + 5 , n4 = 2 * n + 6;
		for (int i = 1; i <= n; ++i) {
				int rx , ry , rc;
				read(rx) , read(ry) , read(rc);
				AddEdge(S , i , rc , 0);
				AddEdge(i , n1 , INF , rx + ry);
				AddEdge(i , n2 , INF , -rx + ry);
				AddEdge(i , n3 , INF , rx - ry);
				AddEdge(i , n4 , INF , -rx - ry);
		}
		for (int i = 1; i <= n; ++i) {
				int rx , ry , rc;
				read(rx) , read(ry) , read(rc);
				AddEdge(i + n , T , rc , 0);
				AddEdge(n1 , i + n , INF , -rx - ry);
				AddEdge(n2 , i + n , INF , rx - ry);
				AddEdge(n3 , i + n , INF , -rx + ry);
				AddEdge(n4 , i + n , INF , rx + ry);
		}
		while (argument()) update();
		printf("%lld\n" , ans);		
	  return 0;
}



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

int main(){
    ll k,a,b; cin >> k >> a >> b;
    ll ans = 1;
    ll dif = b-a;
    if(a+2>=b) ans = 1 + k;
    else if(1+k-2<a) ans = 1 + k;
    else{
        ans = a;
        k = k - (a-1);
        if (k%2!=0){
            k--;
            ans ++;
        }
        for(int i=0; i<k/2; i++){
            ans = ans + dif;
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3612
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    val a = readInt()
    val b = readInt()
    val c = readInt()
    val d = readInt()

    print(Math.min(a, b) + Math.min(c, d))
}

Measured memory_bytes: 31608
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
int f[100010],cf[100100],sum[100100];
int abs(int x)
{
	if(x<0)	return -x;
	return x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&f[i]);
		cf[i]=abs(f[i]-f[i-1]);
		sum[i]=sum[i-1]+cf[i];
	}
	for(int i=1; i<n; i++)
		printf("%d\n",sum[n]-cf[i]-cf[i+1]+abs(f[i+1]-f[i-1])+abs(f[n]));
	printf("%d",sum[n-1]+abs(f[n-1]));
}
/*
7 
3 6 2 5 7 9 5 
*/

Measured memory_bytes: 2432
import bisect
import math

N = int(input())
A = [int(i) for i in input().split()]
sa = sum(A)
g = sa/2

S = []
s = 0
for a in A:
    s += a
    S.append(s)


i = bisect.bisect_left(S, g)
print(min(math.ceil(sa-S[i-1]*2), math.ceil(S[i]*2-sa)))


Measured memory_bytes: 25740
a, b, c = map(int, input().split())

if a <= b and b <= c:
    print(a, b, c)
elif a <= c and c <= b:
    print(a, c, b)
elif c <= a and a <= b:
    print(c, a, b)
elif c <= b and b <= a:
    print(c, b, a)
elif b <= a and a <= c:
    print(b, a, c)
else:
    print(b, c, a)


Measured memory_bytes: 5592
n = int(input())
x,answer = [2],1
if n != 1:
	for i in range(2,n+1):
		if all(i%j != 0 for j in x):
			x.append(i)
	for i in x:
		num,num2 = 1,0
		while i**num<=n:
			a = i**num
			num2 += (n-n%a)//a
			num += 1
		answer = answer*(num2+1)%(10**9+7)
print(answer)

Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
#define INFTY 1<<29
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 1005;



// typedef priority_queue<int, greater<int>> RevQ;
lli N, M;
lli a, b;
// vector<int> q[NMAX], p(NMAX), C(NMAX);


// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

int main(){
  cin >> N;
  M = ceil(sqrt(N));
  lli minv;
  REP(i, 1, M+1) {
    a = N/i;
    b = N%i;
    if (i == 1) minv = a + i - 2;
    if (b == 0 && a+i-2 < minv) {
      minv = a + i - 2;
    }
  }
  cout << minv << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{ 

   public static void main(String args[]) {
	 
     Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	int w=s.nextInt();
    	int arr[][]=new int[n+1][3];
    	for(int i=1;i<=n;i++) {
    		for(int j=1;j<=2;j++) {
    		 arr[i][j]=s.nextInt();
    		}
    	}
    	long dp[][]=new long[n+1][w+1];
    	
    	
    	for(int i=1;i<=n;i++) {
    		for(int j=1;j<=w;j++) {
    			dp[i][j]=dp[i-1][j];
    			if(j-arr[i][1]>=0)
    			dp[i][j]=Math.max(arr[i][2] + dp[i-1][j-arr[i][1]],dp[i][j]);
    		   
    		}
    	 }
    	System.out.println(dp[n][w]);
    	
    }

}

Measured memory_bytes: 139752
from collections import Counter

n = int(input())
V = list(map(int,input().split()))

even = V[::2]
odd = V[1::2]

cnt_even = Counter(even).most_common()
cnt_odd = Counter(odd).most_common()

even_num = cnt_even[0][0]
odd_num = cnt_odd[0][0]

if even_num == odd_num:
    if len(cnt_even) == 1 and len(cnt_odd) == 1:
        ans = min(len(even),len(odd))
    elif len(cnt_even) == 1:#oddを変えるしかない
        ans = (len(even)-cnt_even[0][1]) + (len(odd)-cnt_odd[1][1])
    elif len(cnt_odd) == 1:
        ans = (len(even)-cnt_even[1][1]) + (len(odd)-cnt_odd[0][1])
    else:
        ans = min((len(even)-cnt_even[0][1]) + (len(odd)-cnt_odd[1][1]), (len(even)-cnt_even[1][1]) + (len(odd)-cnt_odd[0][1]))
else:
    ans_e = len(even) - cnt_even[0][1]
    ans_o = len(odd) - cnt_odd[0][1]
    ans = ans_e + ans_o

print(ans)

Measured memory_bytes: 91680
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

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

    int a, b;
    cin >> a >> b;

    if(a == 2 or b == 2){
        cout << "No" << endl;  
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		char[] t = nc();

		for (char c : t) {
			if (c == '?') {
				outn('D');
			} else {
				outn(c);
			}
		}

		out("");

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 56384
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 A PICTURE 999.
       01 B PICTURE 999.
       01 H PICTURE 999.
       01 REN PICTURE 99999.
       01 RE PIC Z(5).
       PROCEDURE DIVISION.
       MAIN.
        ACCEPT A.
        ACCEPT B.
        ACCEPT H.
        COMPUTE REN=A+B.
        COMPUTE REN=REN*H/2.
        MOVE REN TO RE.
        DISPLAY RE.
        STOP RUN.


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

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

int main(){
    int a,b,c,k ;
    cin >> a >> b >> c >> k ;
    for (int i = 0; i < k; i++)
    {
        if (a >= b)
        {
            b *= 2 ;
        }else if (b >= c)
        {
            c *= 2 ;
        }
        
        
    }
    if (a < b && b < c)
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}


Measured memory_bytes: 3624
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextInt()
    val c = cin.nextInt()

    val b  = Array<Int>(m, { cin.nextInt() })

    var ans = 0

    for (i in 0..n-1) {
        var value: Long = 0
        for (j in 0..m-1) {
            val a = cin.nextInt()
            value += a*b[j]
        }
        value += c
        if (value > 0) {
            ans += 1
        }
    }
    println(ans)
    
}

Measured memory_bytes: 29860
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	static boolean[][] cant;
	static int a;
	static int b;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			if(a == 0 && b == 0) {
				break;
			}
			cant = new boolean[a + 1][b + 1];
			int n = stdIn.nextInt();
			for (int i = 0; i < n; i++) {
				int x = stdIn.nextInt();
				int y = stdIn.nextInt();
				cant[x][y] = true;
			}
			int ans = dfs(1, 1);
			System.out.println(ans);
		}
	}
	
	public static int dfs(int x, int y) {
		if(x > a || x < 1 || y > b || y < 1 ) {
			return 0;
		}
		if(cant[x][y]) {
			return 0;
		}
		if(a == x && b == y) {
			return 1;
		}
		int c = dfs(x+1,y);
		int d = dfs(x,y+1);
		return c+d;
		
	}
}

Measured memory_bytes: 18916
using System;
using System.Linq;

namespace CPrison
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力 N/M の取得
            var inputsNM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputsNM[0];
            var m = inputsNM[1];

            int maxL = 1, minR = n;
            for (var i = 0; i < m; i++)
            {
                var inputsLR = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var l = inputsLR[0];
                var r = inputsLR[1];
                if (maxL < l) maxL = l;
                if (r < minR) minR = r;
            }

            // 1枚だけで全てのゲートを通過できる ID カードの枚数
            var masterKeys = Math.Max(minR - maxL + 1, 0);

            // 解答の出力
            Console.WriteLine(masterKeys);
        }
    }
}


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

int main(){
	while(true) {
		int n, x;
		scanf("%d%d", &n, &x);
		if(!n && !x) break;
		int ans = 0;
		for(int i = 1; i <= n-2; i++)
			for(int j = i+1; j <= n-1; j++)
				for(int k = j+1; k <= n; k++)
					if(i + j + k == x) ans++;
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 3196
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200100],b[200100];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(a[n-1]==b[i]) printf("%d\n",a[n-2]);
		else printf("%d\n",a[n-1]);
	}
	return 0;
}

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

using namespace std;

// Optimization stuff
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("debug.in", "r", stdin);
    #endif // ONLINE_JUDGE
}

inline void optimizeIt() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
}
// End optimization stuff

inline double ABS(const double &x) {
    return max(x, -x);
}

inline bool isPrime(const int &x) {
    if(x == 1) return false;

    for(int d = 2; d * d <= x; d++) {
        if(x % d == 0) return false;
    }

    return true;
}

typedef long long int ll;

const int NMax = 1e5 + 5;
const int LIM = 1e9;
const int MOD = 1e9 + 7;

int main(){
    //debugMode();
    //optimizeIt();

    int n;
    cin >> n;

    int par = 0;
    int ipar = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        if(x % 2 == 0) {
            par++;
        } else {
            ipar++;
        }
    }

    if(ipar % 2 != 0) {
        cout << "NO";
    } else {
        cout << "YES";
    }

    return 0;

}


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

int main() {
  int P,Q,R;
  int ans=0;
  cin >> P >> Q >> R;
  if (P+R<=Q+P && P+R<=Q+R ){
     ans += P+R;
  }
  else if (Q+R<=P+R && Q+R<=P+Q){
     ans += Q+R;
  }
  else if (P+Q<=Q+R && P+Q<=P+R){
     ans += P+Q;
  }
  cout << ans << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 

ll mod = 1e9 + 7;

#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
// cout<<endl;


int main()
{
	fastio();
	char c;
	cin>>c;
	int a = c+1;
	char k = a;
	cout<<k;
}

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

int main(){
	string s;
	cin >> s;
	
	int i;
	for(i=0; i<s.size(); i++){
		//cout << i << s[i] << endl;
		if(i%2==0){//奇数
			if(s[i]=='L'){
				cout << "No" << endl;
				return 0;
			}
		}
		else{
			if(s[i]=='R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int binary(int l,int r,vector<int> a,int target)
{
    while(l<r)
    {
        int mid=(l+r+1)/2;
        if(a[mid]<target)
            l=mid+1;
        else
            r=mid-1;
    }
    return r;
}
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int count=0;
    for(int i=0;i<a.size()-2;i++)
    {
        for(int j=i+1;j<a.size()-1;j++)
        {
            int target=a[i]+a[j];
            int p=binary(j+1,a.size()-1,a,target);
            if(a[p]>=target)
            {
                p--;
            }
            count+=p-j;
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k,ans=0;cin>>n>>k;
  lvector v(n,0);rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n-k) ans+=v[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
        //Sは秒単位の時間、hは時間、mは分、sは秒を格納
        int S,h,m,s,n;
        //scanfで取得
        scanf("%d",&S);
        
		//Sを60分*60秒で割って時間を出す。
		h = S / (60 * 60);
	
        //Sを60分*60秒で割った余りが1時間未満の秒になる。
        n = S % (60 * 60);
		//秒を分にするため、60で割る。
		m = n / 60;
	
        //1時間未満の秒を1分未満の秒にするため、60で割って余りを出す。
        s = n % 60;
        //結果の出力
        printf("%d:%d:%d\n",h,m,s);
        return 0;
}


Measured memory_bytes: 1968