akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;


int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]);
    lint ans = 1000;
    rep(i, n-1){
        if(a[i+1] > a[i]){
            lint tmp = ans / a[i];
            ans = ans - tmp*a[i] + tmp*a[i+1];
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3812
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BFizzBuzzSum solver = new BFizzBuzzSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class BFizzBuzzSum {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            long n = s.nextLong();
            long ans = 0l;
            for (long i = 1; i <= n; i++) {
                if ((i % 3 != 0) && (i % 5 != 0)) {
                    ans += i;
                }
            }

            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(){
  int64_t X;
  cin >> X;
  int64_t ans=0;
  int a,b;
  a=X/500;
  X%=500;
  b=X/5;
  ans=a*1000+b*5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n,a,d,m;
      cin>>n>>a>>d>>m;
      map<ll,int> dat;
      for(int i=0;i<m;i++){
            int x,y,z;
            cin>>x>>y>>z;
            if(x==0){
                  int yy=dat.count(y)?dat[y]:y;
                  int zz=dat.count(z)?dat[z]:z;
                  dat[y]=zz;
                  dat[z]=yy;
            }else{
                  int zz=dat.count(z)?dat[z]:z;
                  dat[y]=zz;
            }
      }
      int k;
      cin>>k;
      if(dat.count(k)){
            printf("%lld\n",(ll)a+(dat[k]-1)*d);
      }else{
            printf("%lld\n",(ll)a+(k-1)*d);
      }
}

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

using namespace std;

typedef long long ll;

ll prefix[410], dp[410][410];


ll go(int l, int r) {
    if(l == r) {
        return 0;
    }

    if(dp[l][r] != -1) return dp[l][r];

    ll ans = 1LL << 60;

    for(int i = l; i < r; i++) {
        ll cur = go(l, i) + go(i + 1, r);

        cur += prefix[i] - (l > 0 ? prefix[l - 1] : 0);
        cur += prefix[r] - prefix[i];

        ans = min(ans, cur);
    }


    return dp[l][r] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<ll> a(n);

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

        prefix[i] = a[i] + (i > 0 ? prefix[i - 1] : 0);
    }

    memset(dp, -1, sizeof dp);

    cout << go(0, n - 1) << endl;
}

/*
 *
 **/


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define fl long double
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define np next_permutation
#define pi 3.141592653589793238
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define vll vector<ll>
#define vp vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define revpq priority_queue <int, vector<int>, greater<int>>
const ll mod=1000000007;
const ll INF=10000000000;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
ll divisors[10000007];
int main()
{
    fastio
    ll i,j,k,n,m;
    cin>>n;
    memset(divisors,0,sizeof(divisors));
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j+=i)
        {
            ++divisors[j];
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ans=ans+i*(divisors[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81724
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long maxi;
	maxi=max(a*d,a*c);
	maxi=max(maxi,b*c);
	maxi=max(maxi,b*d);
	cout<<maxi;
	return 0; 
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0078
"""
import sys



class MagicSquare():
    def __init__(self, size):
        self.size = size
        self.data = [['@']*self.size for _ in range(self.size)]
        self.fill_data()

    def fill_data(self):
        num = 1
        x = self.size // 2
        y = x + 1
        self.data[y][x] = num

        while num < self.size**2:
            x += 1
            if x >= self.size:
                x = 0
            y += 1
            if y >= self.size:
                y = 0
            if self.data[y][x] == '@':
                num += 1
                self.data[y][x] = num
            else:
                while self.data[y][x] != '@':
                    x -= 1
                    if x < 0:
                        x = self.size - 1
                    y += 1
                    if y >= self.size:
                        y = 0
                num += 1
                self.data[y][x] = num

    def print_data(self):
        for row in self.data:
            temp = ""
            for d in row:
                temp += str(d).rjust(4)
            print(temp)
            temp = ""



def main(args):
    while True:
        size = int(input())
        if size < 3 or size%2 == 0:
            break
        ms = MagicSquare(size)
        ms.print_data()


if __name__ == '__main__':
    main(sys.argv[1:])

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

using P = pair<int, int>;

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

  int max_count{(N - 1) * (N - 2) / 2};
  if (K > max_count) {
    cout << -1 << endl;
    return 0;
  }

  vector<P> ans;
  for (int i{1}; i <= N-1; ++i) {
    ans.push_back(P{i, N});
//    cout << i << ", " << N << endl;
  }
//  cout << endl;

  int add_count{max_count - K};
  vector<P> edge;
  for (int i{1}; i <= N-2; ++i) {
    for (int j{i+1}; j <= N-1; ++j) {
      edge.push_back(P{i, j});
//      cout << i << ", " << j << endl;
    }
  }

  for (int i{}; i < add_count; ++i) {
    ans.push_back(edge[i]);
  }

  cout << ans.size() << endl;
  for (const auto& edge : ans) {
    cout << edge.first << ' ' << edge.second << endl;
  }
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Q1
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int P = int.Parse(strs[0]);
            int Q = int.Parse(strs[1]);
            int R = int.Parse(strs[2]);
            int min = 999;
            if (min > P + Q) min = P + Q;
            if (min > Q + R) min = Q + R;
            if (min > R + P) min = R + P;
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
#define deba(x) cerr << #x << endl; for (auto a : x) cerr << a << " "; cerr << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int MOD = 1000000007;

int main() {
	fastio();
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;i++)
		cin >> h[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	cout << dp[n-1] << "\n";
	return 0;
}



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

int main(){
  int A , B;
  cin >> A >> B;
  if(A != 1 && B != 1)cout << 1 << endl;
  else if(A != 2 && B != 2)cout << 2 << endl;
  else cout << 3 << endl;
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (998244353)
#define asz 300005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll n,k;
    cin>>k>>n;
    vi v(n);
    for(auto &x:v)cin>>x;
    v.push_back(v[0]+k);
    ll ans=0;
    for(int i=0;i<n;i++)ans=max(ans,v[i+1]-v[i]);
    cout<<k-ans<<endl;
}

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

int main(){
    int a, b, c;
    cin >> a >>b >> c;
    if( a == b  || b == c || a == c) {
        if(a == b && b == c){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int sum(int x) {
	int s = 0;
	while (x) {
		s += x % 10;
		x /= 10;
	}
	return s;
}

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

	int ans = 0;
	for (auto i = 1; i <= N; ++i) {
		int s = sum(i);
		if (A <= s && s <= B) {
			ans += i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False

def f(n):
    r = (n - 2)
    m = (4 * (1 - 2 ** r)) // (1 - 2)
    return (3 + m) % MOD


def modinv(a):
    return pow(a, MOD-2, MOD)


def main():
    n, a, b = MI()
    M = 10**5
    # cans = []

    # for i in range(2, M + 1):
    #     g1.append((g1[-1] * i) % MOD)
    #     inverse.append((-inverse[MOD % i] * (MOD//i)) % MOD)
    #     g2.append((g2[-1] * inverse[-1]) % MOD)

    # first = cmb(n, a, MOD)
    # second = cmb(n, b, MOD)

    # for i in range(2, n+1):
    #     ans = 0
    #     red = 0
    #     for j in range(1, i+1):
    #         if j != a and j != b:
    #             ans += cmb(i, j, MOD)
    #         else:
    #             red += cmb(i, j, MOD)
    #         # print('cmb', i, j, cmb(i, j, MOD))
    #     print(i, ans, red, 'f', f(i))
    #     cans.append(ans)
        # print('ans', f(i))

    # for i in range(len(cans) - 1):
    #     print(cans[i+1] - cans[i])

    p = 1
    c = 1
    for i in range(a):
        p *= (n - i)
        c *= (i + 1)
        p = p % MOD
        c = c % MOD
    first = p * modinv(c)

    p = 1
    c = 1
    for i in range(b):
        p *= (n - i)
        c *= (i + 1)
        p = p % MOD
        c = c % MOD
    second = p * modinv(c)
    # print(first, second)

    ans = f(n)
    print((ans - first - second) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 282336
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 705;

int n, m;

int adj[maxn][maxn];

vector<int> G[maxn];

int col[maxn];
int c[maxn], tot;

int dfs(int u, int c){
    if(col[u] != -1){
        return col[u] == c;
    }
    col[u] = c;
    bool flag = true;
    for(auto v : G[u]){
        flag &= dfs(v, c ^ 1); 
    }
    return flag;
}

int dp[maxn][maxn * 2];

int main(){
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u][v] = adj[v][u] = 1;
    }
    for(int i = 1;i <= n;i++){
        for(int j = i + 1;j <= n;j++){
            if(adj[i][j] == 0){
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
    memset(col, -1, sizeof(col));
    int white = 0, black = 0;
    tot = 0;
    for(int i = 1;i <= n;i++){
        if(col[i] == -1){
            bool flag = dfs(i, 0);
            if(!flag){
                cout << -1 << endl;
                return 0;
            }
            int white1 = 0, black1 = 0;
            for(int j = 1;j <= n;j++){
                if(col[j] == 0)
                    white1++;
                if(col[j] == 1)
                    black1++;
            }
            int cw = white1 - white;
            int cb = black1 - black;
            white = white1;
            black = black1;
            c[++tot] = abs(cw - cb);
        }
    }
    dp[0][maxn] = 1;    
    for(int i = 1;i <= tot;i++){
        for(int j = 0;j < maxn * 2;j++){
            if(j + c[i] < maxn * 2){
                dp[i][j] = max(dp[i][j], dp[i - 1][j + c[i]]);
            }
            if(j - c[i] >= 0){
                dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i]]);
            }
        }
    }
    long long ans = 1e18;
    for(int j = maxn - n;j <= maxn + n;j += 2){
        if(dp[tot][j] == 0)
            continue;
        int diff = j - maxn; 
        int a = (diff + n) / 2;
        int b = (n - diff) / 2;
        ans = min(ans, 1LL * a * (a - 1) / 2 + 1LL * b * (b - 1) / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();//辺
		int b = s.nextInt();//辺
		int c = s.nextInt();//間の角
		double S,L,h;//面積，周の長さ，aを底辺としたときの高さ
		S = a * b * Math.sin(Math.toRadians(c)) / 2;
		L = a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(c));
		L = Math.sqrt(L) + a + b;
		h = (S * 2) / a;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 26204
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

int DecreasingArray(vl a) 
{ 
	int n = a.size();
    int sum = 0, dif = 0; 
    priority_queue<int, vector<int>, greater<int> > pq; 
    for (int i = 0; i < n; i++) { 
        if (!pq.empty() && pq.top() < a[i]) { 
            dif = a[i] - pq.top(); 
            sum += dif; 
            pq.pop(); 
            pq.push(a[i]); 
        } 
        pq.push(a[i]); 
    } 
    return sum; 
} 

void check()
{
	ll n, ans = 0;
	cin >> n;
	vl a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	ll maxx = 0;
	for(int i=0;i<n;i++) {
		maxx = max(a[i],maxx);
		ans+=(maxx-a[i]);
	}
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
ll fact[2005];
    ll invfact[2005];
ll ncr(ll n,ll r)
{
    if(n<0)
        return 0;
    if(n<r)
        return 0;
    if(n==r)
        return 1;
    ll ans=fact[n];
    ans*=invfact[r];
    ans%=hell;
    ans*=invfact[n-r];
    ans%=hell;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;

    fact[0]=1;
    invfact[0]=1;
    for(i=1;i<2005;i++)
        fact[i]=(i*fact[i-1])%hell;
    for(i=1;i<2005;i++)
        invfact[i]=power(fact[i],hell-2,hell);
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ans+=ncr(n-2*i-1,i-1);
        ans%=hell;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3684
import sys
input = sys.stdin.readline
s = input().strip()
c = 0
chk = [0]*2019
for i,si in enumerate(s[::-1]):
  c += int(si)*pow(10,i,2019)
  chk[c%2019] += 1
ans = chk[0]
for i in chk:
  ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 9372
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] array=new int[3];
        int i,t,j;
        for(i=0;i<3;i++){
            array[i] = sc.nextInt();
        }
        for(i=0;i<3;i++){
            for(j=i+1;j<3;j++){
                if(array[i]>array[j]){
                    t=array[i];
                    array[i]=array[j];
                    array[j]=t;
                }
            }
        }
 
        System.out.println(array[0]+" "+array[1]+" "+array[2]);
    }
}


Measured memory_bytes: 25932
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(void){
    ll X;
    cin>>X;
    ll i = 1;
    ll sum = 0;
    int ans = 0;
    while(X>sum){
        sum += i;
        i++;
        ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();
    int cnt = 0;
    Y += Z;
    X -= Z;
    while (X >= Y) {
      X -= Y;
      cnt++;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21716
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,p;cin>>n>>p;
    string s;cin>>s;
    if(p==2||p==5){
        ll ans=0;
        for(ll i=n-1;i>=0;i--){
            if((s[i]-'0')%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
    }
    else{
        ll ans=0;
        ll v[200001];
        memset(v, 0, sizeof(v));
        ll now=0;
        ll tenfactor=1;
        v[0]++;
        for(ll i=n-1;i>=0;i--){
            now=now+(s[i]-'0')*tenfactor;
            now%=p;
            tenfactor=(tenfactor*10)%p;
            v[now]++;
        }
        for(ll i=0;i<p;i++){
            ans+=v[i]*(v[i]-1)/2;
        }
        cout<<ans<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int A, B, C, D, k; scanf("%d%d%d%d%d", &A, &B, &C, &D, &k);
	int X = A * 60 + B;
	int Y = C * 60 + D;

	int ans = std::max(0, Y - X - k);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int> >temp;
void find(int k,vector<int>x)
{
   set<int>s;
      for(auto i:x)
      {
         s.insert(i);
      }
   int cnt=s.size();
   for(int i=0;i<=cnt;i++)
   {
      vector<int>xx;
      xx=x;
      xx.push_back(i);
      if(k>1)
         find(k-1,xx);      
      else
         temp.push_back(xx);
   }
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   vector<int>s;
   find(n,s);
   for(auto i:temp)
   {
      for(auto j:i)
      {
         cout<<char(j+97);
      }
      cout<<'\n';
   }

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


Measured memory_bytes: 15152
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int answer = 0;
    int temp = 0;
    String s = sc.next();
    for(int i = 0; i < s.length(); i++){
      if(s.charAt(i) == 'R') {
        temp++;
      } else {
        answer = Math.max(answer, temp);
        temp = 0;
      }
    }
    System.out.println(Math.max(answer, temp));
  }
}

Measured memory_bytes: 35524
#include <iostream>

int main() {
	int s[4] = {}, sum  = 0;
	int min = 0, sec = 0;

	std::cin >> s[0] >> s[1] >> s[2] >> s[3];
	sum = s[0] + s[1] + s[2] + s[3];
	min = sum / 60;
	sec = sum % 60;
	std::cout << min << std::endl << sec << std::endl;

	return 0;
}

Measured memory_bytes: 3080
from collections import Counter

n = int(input())
V = [int(_) for _ in input().split()]

A = V[::2]
B = V[1::2]

resA = Counter(A).most_common()
resB = Counter(B).most_common()

if resA[0][0] == resB[0][0]:

    ans1 = sum([num for x, num in resA[1:]]) + resB[0][1] + sum([num for x, num in resB[2:]])
    ans2 = sum([num for x, num in resB[1:]]) + resA[0][1] + sum([num for x, num in resA[2:]])
    print(min(ans1, ans2))

else:
    if len(resA) == 1 and len(resB) == 1:
        print(0)
    else:
        sumA = sum([num for x, num in resA[1:]])
        sumB = sum([num for x, num in resB[1:]])
        print(sumA + sumB)





Measured memory_bytes: 71172
N, D = map(int, input().split())
X = [[int(j) for j in input().split()] for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        acum = 0.0
        for k in range(D):
            acum += (X[j][k] - X[i][k]) ** 2
        if (acum ** 0.5).is_integer():
            ans += 1
print(ans)


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

int main(){
    int N; cin >> N;
    ll A[100100];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    //処理
    ll sum=0;
    for(int i=0; i<N; i++){
        sum +=A[i];
    }

    ll sumki[100100], sumgu[100100];
    sumki[0]=0;
    sumgu[0]=0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            sumgu[i/2+1] =sumgu[i/2]+A[i];
        }
        else{
            sumki[i/2+1] =sumki[i/2]+A[i];
        }
    }

    //答えを求める
    for(int i=0; i<N; i++){
        if(i%2==0){
            cout << sum - 2*sumgu[i/2] - 2*( sumki[(N-2)/2+1] - sumki[i/2] ) << " ";
        }
        else{
            cout << sum - 2*sumki[i/2] - 2*( sumgu[(N-1)/2+1] - sumgu[i/2+1] ) << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3072
import math
N,K=map(int,input().split())
def parmt(a,b):
    return math.factorial(a)//math.factorial(a-b)

def conbi(a,b):
    return parmt(a,b)//math.factorial(b)

i=1
while i<=K:
    if N-K+1>=i:
        sum=conbi(N-K+1,i)*conbi(K-1,i-1)
        print(sum%(10**9+7))
    else:
        print(0)
    i=i+1

    



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
string s;
int main(){
	cin >> s;
	stack<char> st;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')st.push(s[i]);
		else{
			if(!st.empty()&&st.top()=='S'){
				st.pop();
			}else{
				st.push(s[i]);
			}
		}
	}
	int ans = 0;
	while(!st.empty()){
		ans++;
		st.pop();
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 *1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int CNT[MAX];
int CR[MAX];

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

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

	FOR (i, 0, n)
	{
		CNT[i] = 1;
	}

	CR[0] = 1;

	FOR (i, 0, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;

		CNT[x]--;
		CNT[y]++;

		if (CR[x]) CR[y] = true;
		if (CNT[x] == 0) CR[x] = 0;
	}

	int res = 0;

	FOR (i, 0, n)
	{
		res += CR[i];
	}

	cout<<res<<endl;

}


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

int main(){
  int H, W;
  cin >> H>>W;
  int i;
  string s[52];
  for (int j = 0; j<W+2;j++){
    s[0]+=".";
    s[H+1]+=".";
  }
  for (int j=1; j<H+1;j++){
    cin >> s[j];
    s[j]="."+s[j]+".";
  }
  int j;
  string c[52][52];
  for (int k= 0; k<H+2; k++){
    for (int l =0;l<W+2; l++){
      c[k][l]=s[k].at(l);
    }
  }
  for (int k= 1; k<H+1; k++){
    for (int l =1;l<W+1; l++){
      if (c[k][l]=="#"){
        cout <<"#";
      }
      else{
        int num=0;
        for (int m =k-1;m<=k+1;m++){
          for (int n=l-1;n<=l+1;n++){
            if (c[m][n]=="#"){
              num++;
            }
          }
        }
        cout <<num;
      }
    }
    cout<<""<<endl;
  }
}

/*
int main() {
  int H, W;
  cin >> H>>W;
  string s[50];
  int dy[8]={-1, 0, 1, -1, 1, -1, 0, 1};
  int dx[8]={-1, -1, -1, 0, 0, 1, 1, 1};
  string c[50][50];
  for (int i=0; i<H;i++){
    cin >> s[i];
    for (int j=0;j<W;j++){
      c[i][j]=s[i].at(j);
    }
  }
  
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (c[i][j]=="#"){
        cout <<c[i][j];
      }
      else{
        int num=0;
        for (int k=0;k<8;k++){
          if (i==0){
            if(k==0||k==1||k==2){
              continue;
            }
          }
          if (i==H-1){
            if(k==5||k==6||k==7){
              continue;
            }
          }
          if (j==0){
            if(k==0||k==3||k==5){
              continue;
            }
          }
          if (j==W-1){
            if(k==2||k==4||k==7){
              continue;
            }
          }  
          
          if (c[i+dx[k]][j+dy[k]]=="#"){
            num++;
          }
        }
        cout << num;
      }
    }
    cout <<""<<endl;
  }
}
*/

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    dp = [0 for _ in range(N + 1)]
    for i in range(1, N + 1):
        dp[i] = dp[i - 1] + 1
        n = 6
        while i - n >= 0:
            dp[i] = min(dp[i], dp[i - n] + 1)
            n *= 6
        n = 9
        while i - n >= 0:
            dp[i] = min(dp[i], dp[i - n] + 1)
            n *= 9
    print(dp[N])


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 66796
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, a, b, c;

    ll ans = INF;

    cin >> n >> a >> b >> c;

    vector<ll> l(n);

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

    ll len[3];
    vector<ll> p = {0, 1, 2};

    for (int i = 0; i < (1 << n); i++)
    {
        for (int j = 0; j < (1 << n); j++)
        {
            ll cost = 0;
            len[0] = 0, len[1] = 0, len[2] = 0;

            for (int k = 0; k < n; k++)
            {
                if (i & (1 << k))
                {
                    if (j & (1 << k))
                    {
                        len[0] += l[k];
                        cost += 10;
                    }
                    else
                    {
                        len[1] += l[k];
                        cost += 10;
                    }
                }
                else
                {
                    if (j & (1 << k))
                    {
                        len[2] += l[k];
                        cost += 10;
                    }
                }
            }

            if (len[0] == 0 || len[1] == 0 || len[2] == 0)
            {
                continue;
            }

            do
            {
                ans = min(ans, cost - 30 + abs(a - len[p[0]]) + abs(b - len[p[1]]) + abs(c - len[p[2]]));
            } while (next_permutation(p.begin(), p.end()));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

ll n, cnt;
string s[100001];
map<string, int> m;

int main() {

  cin >> n;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    ++m[s[i]];
  }

  sort(s, s+n);

  rep(i, n) {
    cnt += m[s[i]]-1;
  }

  cout << cnt/2+cnt%2 << endl;

  return 0;
}


Measured memory_bytes: 18176
import sys
sys.setrecursionlimit(100000)
import collections

class UnionFind:

    def __init__(self, N):
        self.raw = [i for i in range(N)]

    def root(self, i):
        if self.raw[i] == i:
            return i
        self.raw[i] = self.root(self.raw[i])
        return self.raw[i]

    def unite(self, a, b):
        a_root = self.root(a)
        b_root = self.root(b)
        self.raw[a_root] = b_root

    def is_same(self, a, b):
        return self.root(a) == self.root(b)


def solve(N, M, K, AB, CD):
    uf = UnionFind(N)
    minus_count = [0 for _ in range(N)]
    for a, b in AB:
        uf.unite(a - 1, b - 1)
        minus_count[a - 1] += 1
        minus_count[b - 1] += 1
    for c, d in CD:
        if uf.is_same(c - 1, d - 1):
            minus_count[c - 1] += 1
            minus_count[d - 1] += 1
    counter = collections.Counter()
    roots = [uf.root(i) for i in range(N)]
    counter.update(roots)

    ans = []
    for i in range(N):
        ans.append(str(counter[uf.root(i)] - minus_count[i] - 1))
    return " ".join(ans)

if __name__ == "__main__":
    N, M, K = tuple(map(int, input().split(" ")))
    AB = []
    for _ in range(M):
        AB.append(tuple(map(int, input().split(" "))))
    CD = []
    for _ in range(K):
        CD.append(tuple(map(int, input().split(" "))))
    print(solve(N, M, K, AB, CD))


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n;
int l,r,mid;
string L,R,M;

string ask(int i) {
	cout<<i<<endl;
	string res;cin>>res;
	return res;
}

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

	cin>>n;
	l=0,r=n-1;
	L=ask(l);
	if(L=="Vacant") return 0;
	R=ask(r);
	if(R=="Vacant") return 0;
	while(M!="Vacant") {
		mid=(r+l)/2;
		M=ask(mid);
		if(((mid-l)%2==0&&M==L)||((mid-l)%2==1&&M!=L)) l=mid,L=M;
		else r=mid,R=M;
		//cout<<"l,r "<<l<<' '<<r<<endl;
	}

	return 0;
}


Measured memory_bytes: 852
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){

    char s1[20],s2[20],s3[20];

    scanf("%[^,]%*c",s1);
    scanf("%[^,]%*c",s2);
    scanf("%s",s3);
    printf("%s %s %s\n",s1,s2,s3);

    return 0;
}


Measured memory_bytes: 128
while 1:
    n,m=map(int,input().split())
    if n==m==0:break
    li=[]
    for i in range(n):
        li.append(int(input()))
    s_li=[li[0]]
    for i in range(1,n):
        s_li.append(s_li[-1]+li[i])
    c_li=[s_li[m-1]]
    for i in range(n-m):
        c_li.append(s_li[i+m]-s_li[i])
    print(max(c_li))


Measured memory_bytes: 15532
#include<stdio.h>
int main()
{
    char c;
    while(scanf("%c",&c)!=EOF) {
        if ('A'<=c&&c<='Z') printf("%c",c-'A'+'a');
        else if ('a'<=c&&c<='z') printf("%c",c-'a'+'A');
        else printf("%c", c);
    }
    return 0;
}


Measured memory_bytes: 2060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9


int main(){
    int n;
    while(cin>>n&&n){
        string ans="";
        if(n>=0){
            for(int i=0;;i++){
                if(i%2==0){
                    ans+='0'+(n%10)%10;
                    n-=(n%10)%10;
                }else{
                    ans+='0'+(10-n%10)%10;
                    n+=(10-n%10)%10;
                }
                n/=10;
                if(n==0)break;
            }
        }else{
            n*=-1;
            for(int i=0;;i++){
                if(i%2==1){
                    ans+='0'+(n%10)%10;
                    n-=(n%10)%10;
                }else{
                    ans+='0'+(10-n%10)%10;
                    n+=(10-n%10)%10;
                }
                n/=10;
                if(n==0)break;
            }
        }
        reverse(all(ans));
        cout<<ans<<endl;
    }
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long x; cin >> x;
    auto p = [&](long long x) {
        long long ret = 1;
        for (int i = 0; i < 5; i++) {
            ret *= x;
        }
        return ret;
    };
    for (long long i = -8e3; i <= 8e3; i++) {
        for (long long j = -8e3; j <= 8e3; j++) {
            if (p(i) - p(j) == x) {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n==1)
        cout<<0<<endl;
    else
    {
        if(n%2==0)
            cout <<n/2-1<< endl;
        else
            cout<<n/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);
$a=explode(" ", rtrim(fgets(STDIN)));
$acp=$a;
sort($acp);
for ($i=0; $i <$n; $i++)
{ 
	if($a[$i]<=$acp[($n/2)-1])
		echo($acp[$n/2] . "\n");
	elseif($a[$i]>=$acp[$n/2])
		echo($acp[($n/2)-1] . "\n");
}

Measured memory_bytes: 33140
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(Graph, N, start):
    q = queue.Queue()
    dist = [-1] * N
    dist[start] = 0
    q.put(start)

    while not q.empty():
        v = q.get()
        if dist[v] >1:
            continue
        for u in G[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v] + 1
            q.put(u)

    return dist
if dfs(G, N, 0)[-1] > 2 or dfs(G, N, 0)[-1] == -1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 42896
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m, x = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(n)]

    res = f_inf
    for pattern in product([0, 1], repeat=n):
        A = [0 for _ in range(m)]
        cost = 0
        for idx, p in enumerate(pattern):
            if p == 1:
                cost += C[idx][0]
                for i in range(m):
                    A[i] += C[idx][i + 1]

        for a in A:
            if a < x:
                break
        else:
            res = min(res, cost)

    if res == f_inf:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9168