akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

constexpr int64_t INF = 9223372036854775807/10;
int32_t N;
int64_t a[555];
int64_t dp[15][15][1 << 15];
int64_t func(int32_t i, int32_t need, int32_t mask, int64_t max) {
	if (need <= 0) { return 0; }
	if (i >= N) { return INF; }
	auto& memo = dp[i][need][mask];
	if (memo !=-1) {
		return memo;
	}
	if (max < a[i]) {
		return memo = func(i + 1, need - 1, mask | (1 << i), a[i]);
	}
	return memo= std::min(func(i + 1, need, mask, max),
		func(i + 1, need - 1, mask|(1<<i), std::max(max + 1, a[i])) + std::max<int64_t>(0, max + 1 - a[i])
		);
}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	fill_all<int64_t>(dp, -1);
	int need;
	in >> N>>need;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> a[i];
	}
	out << func(0, need, 0, 0) << endl;

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
std::string S[10000];
std::string T;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> S[i];
	}
	in >> T;



	return 0;
}
#endif


Measured memory_bytes: 57856
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n<1200){
        cout << "ABC" << endl;
    }else if(1200<= n && n <2800){
        cout << "ARC" << endl;
    }else if(2800<=n){
        cout << "AGC" << endl;
    } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll N; cin>>N;

    set<ll> ans;
    for(ll i=2;i*i<=N;i++){
        if(N%i == 0){
            ans.insert(N/i);
            ans.insert(i);
        }
    }
    ans.insert(N);
    ll sum = 0;

    for(ll x:ans) if(x-1 > 0 && N%(x-1) == N/(x-1)) sum += (x-1);
    

    cout<<sum<<endl; 

}  

signed main(){

   FastRead;    



    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        solve();
    }
}




Measured memory_bytes: 512
#include<cstdio>
    #include<cstring>
    #include<algorithm>
    int n;
    char s[210];
    template<class T>
    inline void read(T&a){
    	char c=getchar();
    	for(a=0;c<'0'||c>'9';c=getchar());
    	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
    }
    int main(){
    	scanf("%s",s+1),n=strlen(s+1);
    	for(int i=(n>>1)-(!(n&1));i;i--){
    		bool f=1;
    		for(int j=1;j<=i;j++)
    			if(s[j]!=s[j+i]){f=0;break;}
    		if(f){printf("%d\n",i<<1);return 0;}
    	}
    	return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long int sum=0;
    cin >> N;
    vector<long long int>a(3*N);
    for(int i=0;i<3*N;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end(),greater<long long int>());
    for(int i=0;i<2*N;i++){
        if(i%2==1){
            sum+=a.at(i);
        }
    }
    cout << sum;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstring>

int n;
int data[101];
long long memo[101][21];

long long res(int k, int sum){
	if (sum < 0 || sum > 20)return 0;
	if (k == n - 1){
		if (sum == data[k])return 1;
		return 0;
	}
	if (memo[k][sum] != -1)return memo[k][sum];

	long long ans = 0;
	ans += res(k + 1, sum + data[k]);
	ans += res(k + 1, sum - data[k]);

	return memo[k][sum] = ans;
}

int main(){

	std::cin >> n;

	memset(memo, -1, sizeof(memo));

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

	std::cout << res(1, data[0]) << std::endl;

	return 0;
}

Measured memory_bytes: 1184
import sys

sys.setrecursionlimit(3100)

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(l):
    def aux(l, i):
        if i == len(l) - 1:
            return l[-1]
        rest = aux(l, i+1)
        return l[i] * rest // gcd(l[i], rest)
    return aux(l, 0)

def modsum(a):
    k = lcm(a) - 1
    return sum(map(lambda x: k % x, a))

if __name__ == '__main__':
    _ = input()
    a = list(map(int, input().split()))
    print(modsum(a))

Measured memory_bytes: 6260
/* 
 * File:   main.cpp
 * Author: shinku
 *
 * Created on August 22, 2018, 8:20 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>

#define MAXN 100

using namespace std;

int n;
long f[MAXN][10];
long p[MAXN][11];

int main(int argc, char** argv) {
    cin >> n;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < 10;j++) 
            cin >> f[i][j];
    for(int i = 0;i < n;i++) 
        for(int j = 0;j <= 10;j++)
            cin >> p[i][j];
    long res = -1000000000;
    for(unsigned i = 1;i < 1024;i++) {
        long pr = 0;
        for(int j = 0;j < n;j++) {
            int c = 0;
            for(int k = 0;k < 10;k++) 
                if(f[j][k] && i & 0b1 << k) c++;
            pr += p[j][c];
        }
        res = max(res,pr);
    }
    cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  double n,k;
  cin >> n >> k;
  long double ans = 0.0;
  for (int x = 1; x <= n; ++x) {
    int m = ceil(log2(k / (double)x));
    chmax(m, 0);
    long double res = pow(2, -m);
    ans += res;
  }
  ans /= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
  	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      double A = sc.nextInt();
      double V = sc.nextInt();
      double B = sc.nextInt();
      double W = sc.nextInt();
      int T = sc.nextInt();
      //System.out.print(A+""+V+""+B+""+W+""T);
      V *= T;
      W *= T;
      if(A<B){
        A += V;
        B += W;
        if(A>=B){
          System.out.print("YES");
        }else{
          System.out.print("NO");
        }
      }else{
        A -= V;
        B -= W;
        if(A<=B){
          System.out.print("YES");
        }else{
          System.out.print("NO");
        }
      }
      
    }
}
      

Measured memory_bytes: 35804
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<char>> v(n + 2, vector<char> (m + 2, '#'));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> v[i + 1][j + 1];
		}
	}
	for (int i = 0; i < n + 2; ++i) {
		for (int j = 0; j < m + 2; ++j) {
			cout << v[i][j];
		}
		cout << endl;
	}
}



















Measured memory_bytes: 256
n, t = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
l.sort(key=lambda x: x[1])
ans = 9999999999
if l[0][1] > t:
    print("TLE")
else:
    for i in range(n):
        if l[i][1] <= t:
            ans = min(ans, l[i][0])
    print(ans)

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

using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> a(4);
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  int k;
  for(int i=0;i<(1<<3);i++){
    int sum=a[0];
    for(int j=0;j<3;j++){
      if(i>>j & 1){
        sum+=a[j+1];
      }
      else{
        sum-=a[j+1];
      }
    }
    if(sum==7){
      k=i;
      break;
    }
  }
  cout << a[0];
  for(int i=0;i<3;i++){
    if(k>>i & 1){
      cout << '+';
    }
    else{
      cout << '-';
    }
    cout << a[i+1];
  }
  cout << "=7" << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class DLuckyPIN {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    string S;
	    in >> N >> S;

	    unordered_set<string> oneChar;
	    unordered_set<string> twoChars;
	    unordered_set<string> threeChars;

	    REP(i,0,N) {
            for (string c : twoChars) {
                threeChars.insert(c + S[i]);
            }
	        for (string c : oneChar) {
	            twoChars.insert(c + S[i]);
	        }
	        oneChar.insert(string(1,S[i]));
	    }
	    out << threeChars.size() << "\n";
	}
};


signed main() {
	DLuckyPIN solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
char check(char tex[]){
	int i;
	for(i=0;i<3;i++){
		if(tex[i*3]!='s' && tex[i*3]==tex[i*3+1] && tex[i*3]==tex[i*3+2])return tex[i*3];
		if(tex[i]!='s' && tex[i]==tex[i+3] && tex[i]==tex[i+6])return tex[i];
	}
	if(tex[0]!='s' && tex[0]==tex[4] && tex[0]==tex[8])return tex[0];
	if(tex[2]!='s' && tex[2]==tex[4] && tex[2]==tex[6])return tex[2];
	return 'd';
}
int main(void){
	char tex[10];
	while(scanf("%s",tex)!=EOF){
		printf("%c\n",check(tex));
	}
	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
int main() {
        int ar[4][4];
        for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                        cin >> ar[i][j];
        for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                        if (ar[i][j] != ar[i][i] + ar[j][j] - ar[j][i]) {
                                cout << "No";
                                return 0;
                        }
        cout << "Yes";
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int k,x,i;
    vector <int> a;
    scanf("%d %d",&k,&x);
    a.push_back(x);
    for(i=1; i<k; i++)
    {
        if(x-i>=-1000000)
            a.push_back(x-i);
        if(x+i<=1000000)
            a.push_back(x+i);
    }
    sort(a.begin(),a.end());
    k=a.size();
    for(i=0; i<k; i++)
        printf("%d ",a[i]);
    return 0;
}


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

namespace ARC069C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(long.Parse);
            var M = ss.Next(long.Parse);
            sw.WriteLine(Math.Min(N, M / 2) + Math.Max(0, M - N * 2) / 4);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t; cin >> s >> t;
    bool ans = true;
    for(int i = 0; i < s.size(); i++){
        if(!(s[i] == t[i])){
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(){
	char str[80];
	char buf[80];
	char n;
	int count = 0;
	
	int i,j,k;
	
	while(scanf("%c",&n) != EOF){
		str[count] = n;
		if(n == '\n'){
			for(i = 0;i < 26;i++){
				strcpy(buf,str);
				for(j = 0;j < count;j++){
					if((int)buf[j] <= 'z'&&(int)buf[j] >= 'a'){
						if((int)buf[j] + i > 'z'){
							buf[j] = (int)buf[j]-'z'+96+i;
						}else{
							buf[j] = (int)buf[j]+i;
						}
					}
				}
				if(strstr(buf,"the") != NULL||strstr(buf,"this") != NULL||strstr(buf,"that") != NULL){
					for(k = 0;k < count;k++){
						printf("%c",buf[k]);
					}
					printf("\n");
				}
			}
			count = 0;
		}else{
			count++;
		}	
	}
	return 0;
}
			

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


def main(args):
    words = []
    words = [x.strip(',.') for x in input().split(' ')]

    result = [x for x in words if 2 < len(x) < 7]
    print(' '.join(result))


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

Measured memory_bytes: 7400
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 2509 /// Still trying to be gray
#define MOD 1000000007
#define rep(i, n) for(ll i = 0; i < (ll)(n); i ++)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); i ++)
#define per(i, n) for(ll i = (ll)(n)-1;i>=0;i--)
#define per1(i, n) for(ll i = (ll)(n);i>=1;i--)
using namespace std;
const int INF = 1000000000;
ll n,m,p;
vector<pii> adj[maxn];
vector<int> dis2[maxn];
void addedge(int a,int b,int c){
    adj[a].push_back({b,c});
}

void dijkstra(int s, vector<int> & d) {
    d.assign(n, INF);

    d[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> q;
    q.push({0, s});
    while (!q.empty()) {
        int v = q.top().second;
        int d_v = q.top().first;
        q.pop();
        if (d_v != d[v])
            continue;

        for (auto edge : adj[v]) {
            int to = edge.first;
            int len = abs(edge.second);

            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                q.push({d[to], to});
            }
        }
    }
}

bool spfa(int s, vector<int>& d) {
    d.assign(n, INF);
    vector<int> cnt(n, 0);
    vector<bool> inqueue(n, false);
    queue<int> q;

    d[s] = 0;
    q.push(s);
    inqueue[s] = true;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        inqueue[v] = false;

        for (auto edge : adj[v]) {
            int to = edge.first;
            int len = edge.second;

            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                if (!inqueue[to] && cnt[to] <= n) {
                    q.push(to);
                    inqueue[to] = true;
                    cnt[to]++;
                    if (cnt[to] >= n && dis2[to][n-1]<INF)
                        return false;  // negative cycle
                }
            }
        }
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>p;
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        addedge(a,b,-1*c+p);
    }
    rep(i,n)dijkstra(i,dis2[i]);
    bool cycn=false;
    vector<int> dis;
    cycn=spfa(0,dis);
    if(!cycn)cout<<"-1\n";
    else cout<<max(-1*dis[n-1],0)<<'\n';
    return 0;   
}           



Measured memory_bytes: 24960
import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb


def erastosthenes(num):
    input_list = [False if i % 2 == 0 else True for i in range(num)]
    input_list[0] = False
    input_list[1] = False
    input_list[2] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            prime_list = [i for i, b in enumerate(input_list) if b]
            return prime_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False


def main():
    Q = int(input())
    l = [0] * (Q + 1)
    r = [0] * (Q + 1)
    for i in range(1, Q + 1):
        l[i], r[i] = map(int, input().split())

    prime_list = set(erastosthenes(10**5))
    count_list = [0] * (10**5 + 1)

    for i in range(1, 10**5 + 1):

        if not i % 2 == 0:
            i2 = (i + 1) / 2
            if i in prime_list and i2 in prime_list:
                count_list[i] = count_list[i - 1] + 1
            else:
                count_list[i] = count_list[i - 1]
        else:
            count_list[i] = count_list[i - 1]

    for q in range(1, Q + 1):
        ans = count_list[r[q]] - count_list[l[q] - 1]
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        final long MOD = 1000000007;
        int big = Math.max(n, m);
        int small = Math.min(n, m);
        long ans = 0L;
        if (big - small > 1) {
            ans = 0L;
        } else if (big == small){
            long tmp = calc(big);
            ans = (tmp * tmp) % MOD;
            ans = (ans * 2) % MOD;
        } else {
            long tmp = calc(small);
            ans = (((tmp * big) % MOD) * tmp) % MOD;
        }
        System.out.println(ans);
    }

    static long calc(int n) {
        long ret = 1L;
        final long MOD = 1000000007;
        for (int i = 2; i <= n; i++) {
            ret = (ret * i) % MOD;
        }
        return ret;
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s, t;

void solve()
{
    cin >> s >> t;
    ll ans=0;
    for (int i=0; i<s.size(); i++) {
        if (s[i]!=t[i]) ans++;
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3732
// https://atcoder.jp/contests/abc087/tasks/abc087_b

#include <iostream>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
  int a, b, c, x, t, cnt = 0;
  cin >> a >> b >> c >> x;

  // 500円玉の枚数ループ
  for (int i = 0; i <= a; i++) {
    if (x >= i * 500) {
      // 100円玉の枚数ループ
      for (int j = 0; j <= b; j++) {
        // 手持ちの50円玉の枚数で合計金額を満たせるか
        t = (x - (i * 500 + j * 100)) / 50;
        if (t >= 0 && t <= c)
          cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}

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

int c[26];
set<char> st;
int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        ++c[s[i]-'a'];
    }
    int n=s.size();
    int mn=1000100010;
    rep(cur,26){
        if(c[cur]==0) continue;
        string ts=s;
    rep(i,n){
        st.clear();
        rep(j,ts.size()) st.insert(ts[j]);
        if(st.size()==1){
            mn=min(mn,i);
            break;
        } 
        string t;
        rep(j,ts.size()-1){
            if(ts[j]-'a'==cur||ts[j+1]-'a'==cur) t+=('a'+cur);
            else t+=ts[j];
        }
        swap(ts,t);
    }
    }
    cout<<mn<<endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int[] num = new int[3];
        num[0] = sc.nextInt();
        num[1] = sc.nextInt();
        num[2] = sc.nextInt();

        int[] num2 = Arrays.stream(num).sorted().toArray();
        System.out.println(num2[0] + num2[1] + num2[2] * 10);
    }
}


Measured memory_bytes: 28628
n,x = map(int,input().split())

a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2 + 3)
  p.append(p[i]*2 + 1)
  
def f(n,x):
  if n == 0:
    return 0 if x <= 0 else 1
  elif x <= 1 + a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1] + 1 + f(n-1, x-2-a[n-1])

print(f(n,x))



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
const int maxn=100005;
int n,m;
int Begin[maxn],Next[maxn<<1],to[maxn<<1],e;
vector<int>ans;
void add_edge(int u,int v){
	to[++e]=v,Next[e]=Begin[u],Begin[u]=e;
}
bool vis[maxn];
void dfs(int u){
	ans.push_back(u);
	for(int i=Begin[u];i;i=Next[i]){
		int v=to[i];
		if(vis[v])continue;
		vis[v]=1,dfs(v);
		break;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int u,v;
	REP(i,1,m){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
	vis[u]=vis[v]=1;
	dfs(u);
	reverse(ans.begin(),ans.end());
	dfs(v);
	printf("%d\n",(int)ans.size());
	REP(i,0,ans.size()-1)
		printf("%d%c",ans[i],i==iend?'\n':' ');
	return 0;
}

Measured memory_bytes: 5624
#include<iostream>
#include<string>
#include<string.h>

using namespace std;

int main(){

	string s, p;
	bool a = false;

	cin >> s >> p;

	s = s + s;

	if (s.find(p) != string::npos)a = true;


	if (a){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(a>=b){
        cout << "delicious" << endl;
    }else if(b-a<=x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin >> n;

	vii m(10, vi(10,0));

	rep(i,1,n+1){
		int a = i%10;
		// int b = i;
		// while(b >= 10) b /= 10;
		int b = to_string(i)[0] - '0';
		m[a][b]++;
	}

	ll tot = 0;
	rep(i,0,10) rep(j,0,10) tot += m[i][j] * m[j][i];
	ret(tot);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll a[1005];
ll b[1005];
ll dp[100005][105];
ll n;
ll rec(ll sum ,ll i)
{
	if(sum<0)
		return INT_MAX;
	if(i==n)
	{
		if(sum==0)
			return 0;
		return INT_MAX;

	}
	ll &res=dp[sum][i];
	if(res!=-1)
		return res ;
	res=min(rec(sum-b[i],i+1)+a[i],rec(sum,i+1));
	return res;
}


 
int main()
{
	ll w;
	cin>>n>>w;

	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	memset(dp,-1,sizeof(dp));
	
	for(int i=100004;i>=0;i--)
		{
			if(rec(i,0)<=w)
			{
				cout<<i;
				return 0;
			}

		}
	
	
	
	
 
	return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

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

    
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int x = a[n-1];

    if(x%2 == 0){
        int m = x/2;
        int y;
        int minv = 1<<29;
        for(int i=0; i<n-1; ++i){
            if(abs(a[i]-m) < minv){
                y = a[i];
                minv = abs(a[i]-m);
            }
        }
        printf("%d %d\n", x, y);
    }
    else{
        int l = x/2;
        int r = l+1;
        int minv = 1<<29;
        int y;
        for(int i=0; i<n-1; ++i){
            if(abs(a[i]-l) < minv || abs(a[i]-r) < minv){
                y = a[i];
                minv = min(abs(a[i]-l), abs(a[i]-r));
            }
        }
        printf("%d %d\n", x, y);
    }


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
      ll n;
      cin>>n;
      ll arr[n],i;
      for(i=0;i<n;i++)
      	cin>>arr[i];
      ll ans=1000,z,y,ans1=1000;
       for(i=0;i<n-1;i++)
       {
       	if(arr[i]<arr[i+1])
       	{
            z=ans/arr[i];
            y=ans%arr[i];
            ans=z*arr[i+1];
            ans+=y;
       	}
       }
       cout<<ans;
    }
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}



Measured memory_bytes: 3648
n=int(input())
a=list(map(int,input().split()))
c2=0
c4=0
for i in range(n):
    if a[i]%4==0:
        c4=c4+2
    elif a[i]%2==0:
        c2=c2+1
    else:
        pass

if c4+c2>=len(a):
    print("Yes")
elif c4+1>=len(a):
    print("Yes")        
else:
    print("No")
        

Measured memory_bytes: 14252
#include <stdio.h>

int main(void) {
	int a;
	int b;
	int c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
input = gets.chomp.split(" ").map(&:to_i)
prices = gets.chomp.split(" ").map(&:to_i).sort.reverse
result = []
result << (prices.shift / 2)
 
(input[1]-1).times do 
  if prices.empty? || prices.first <= result.first
    result << (result.shift / 2)
  else
    result << (prices.shift / 2)
  end
end
sum = 0
prices.each do |e|
  sum += e
end
result.each do |e|
  sum += e
end
puts sum

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
        prime[j] = false;
        }
    }
    return prime;
}

int main()
{
    int x;
    cin>>x;
    auto pt=prime_table(100050);
    for (int i = x; i < 100050; i++)
    {
        if(pt[i]==true)
        {
            cout<<i;
            break;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = int;
  using U = int;
  static T op(const T& a, const T& b) { return a + b; }
  static constexpr T e() { return 0; }
  static void ap(T& a, const U& g, int k) { a += g; }
  static void ap(U& f, const U& g) { f += g; }
  static constexpr U id() { return 0; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  int n;
  V<T> t;
  V<U> u;
  V<> k;

  ST(int n) : n(n) {
    t.assign(2 * n, M::e());
    u.assign(n, M::id());
    k.assign(2 * n, 1);
    for (int i = n - 1; i; i--) k[i] = k[2 * i] + k[2 * i + 1];
  }

  void _ap(int i, const U& f) {
    M::ap(t[i], f, k[i]);
    if (i < n) M::ap(u[i], f);
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    _push(l, r);
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void push() {
    for (int i = 1; i < n; i++) {
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void _push(int l, int r) {
    for (int hl = 8 * sizeof(int) - __builtin_clz(l + n) - 1, hr = 8 * sizeof(int) - __builtin_clz(r - 1 + n) - 1; hr > 0; hl--, hr--) {
      int i = r - 1 + n >> hr;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
      i = l + n >> hl;
      if (i == r - 1 + n >> hr or i >= n) continue;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void set(int l, int r, const U& f) {
    _push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  auto chk = [&](int x) {
    V<> c(n + 1);
    c[0] = n;
    for (int i = 0; i < n; i++) c[i + 1] = c[i] + (a[i] >= x ? 1 : -1);
    lint s = 0;
    ST<M> st(2 * n + 1);
    for (int i = 0; i < n + 1; i++) {
      s += st.get(0, c[i] + 1);
      st.set(c[i], c[i] + 1, 1);
    }
    return 4 * s >= (lint) n * (n + 1);
  };
  V<> b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  b.push_back(2e9);
  auto l = b.begin(), r = --b.end();
  while (r - l > 1) {
    auto m = l + (r - l) / 2;
    if (chk(*m)) l = m;
    else r = m;
  }
  cout << *l << '\n';
}


Measured memory_bytes: 7380
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{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;}
int main()
{
fast;
ll n;
cin>>n;
set<string>s;
for(ll i=0;i<n;i++)
{
    string x;
    cin>>x;
    s.insert(x);
}
cout<<s.size()<<endl;
return 0;
}


Measured memory_bytes: 19248
#include <iostream>

using namespace std;

int main()
{
    int n,res=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0; i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

dummy = list(map(int, input().split(" ")))
K = dummy[0]
N = dummy[1]
A = np.array(list(map(int, input().split(" "))))
Distance = A - np.roll(A, 1)
Distance[0] = K - sum(Distance[1:])
#out = sum(A) - max(A)
#print(A, Distance)
out = K - max(Distance)
print(out)


Measured memory_bytes: 42800
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		vector<int> pile1;
		vector<int> pile2;
		pile2.push_back(0);
		int num[10];
		cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5]>>num[6]>>num[7]>>num[8]>>num[9];
		pile1.push_back(num[0]);
		for(int j=1;j<=9;j++){
			if(pile1[pile1.size()-1]<num[j]) pile1.push_back(num[j]);
			else if(pile2[pile2.size()-1]<num[j]) pile2.push_back(num[j]);
			else{
				cout<<"NO"<<endl;
				break;
			}
			if(j==9) cout<<"YES"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
int n, ans, u, qu[205];
char s[200][205];
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("\n%s", s[i]);
	rep(i,n){
		int de[205] = {}, b = 0, e = 0;
		de[qu[e++] = i] = 1;
		while(b < e){
			int t = qu[b++];
			rep(j,n) if(s[t][j] == '1'){
				if(de[j] == de[t]) return 0*puts("-1");
				if(!de[j]) u = de[qu[e++] = j] = de[t]+1;
			}
		}
		if(ans < u) ans = u;
	}
	printf("%d\n", ans);
}

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

const int N = 305;

int n, m, pm[N][N], dt[N], num[N], now[N];
bool used[N];

int main () {
	scanf("%d%d", &n, &m); int ans = n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) scanf("%d", &pm[i][j]);
		++num[pm[i][now[i] = 1]];
	}
	while (1) {
		int id = -1;
		for (int j = 1; j <= m; ++j) if (!used[j] && (id == -1 || num[j] > id)) id = num[j];
		if (id == -1) break ;
		if (id < ans) ans = id;
		for (int j = 1; j <= m; ++j) if (!used[j] && num[j] == id) used[j] = 1;
		for (int j = 1; j <= n; ++j) if (used[pm[j][now[j]]]) {
			while (used[pm[j][now[j]]]) ++now[j];
			++num[pm[j][now[j]]];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

const int MAXN = 100100;

int t[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, c, k, i;
	int prev = -1, cnt;
	int sol = 0;
	
	cin>>n>>c>>k;
	
	for (i = 0; i < n; ++i)
		cin>>t[i];
	
	sort(t, t + n);
	for (i = 0; i < n; ++i)
	{
		if (t[i] > prev || prev - t[i] > k || cnt == c)
		{
			++sol;
			prev = t[i] + k;
			cnt = 0;
		}
		++cnt;
	}
	cout<<sol<<'\n';
}


Measured memory_bytes: 892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC115_C solver = new ABC115_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC115_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long[] h = new long[n];
            for (int i = 0; i < n; i++) {
                h[i] = in.nextLong();
            }
            Arrays.sort(h);
            Long ans = Long.MAX_VALUE;
            for (int i = 0; i < n - (k - 1); i++) {
                ans = Math.min(ans, h[i + k - 1] - h[i]);
                if (ans == 0) break;
            }

            out.print(ans);


        }

    }
}



Measured memory_bytes: 50224
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
const int N=1005;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
struct mat{
    ll a[2][2];
    mat(){memset(a,0,sizeof a);}
}e;
mat operator *(mat a,mat b){
    mat c;
    for(int i=0;i<2;i++)
        for(int j=0;j<2;j++)
            for(int k=0;k<2;k++)
                c.a[i][j]=(c.a[i][j]+(1ll*a.a[i][k]*b.a[k][j])%mod)%mod;
    return c;
}
mat operator ^(mat a,ll y){
    mat c=e;
    while(y){
        if(y&1)
            c=c*a;
        a=a*a;
        y>>=1;
    }
    return c;
}
ll ksm(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res=(1ll*res*x)%mod;
        x=(1ll*x*x)%mod;
        y>>=1;
    }
    return res;
}
char s[N][N];
int n,m;
ll k;
int main()
{
    scanf("%d%d%lld",&n,&m,&k);
    if(k<=1){
        puts("1");
        return 0;
    }
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    int lr=0,ud=0;
    for(int i=1;i<=n;i++)
        if(s[i][1]=='#'&&s[i][m]=='#')
            lr++;
    for(int j=1;j<=m;j++)
        if(s[1][j]=='#'&&s[n][j]=='#')
            ud++;
    int v=0,ev=0,eh=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            v+=s[i][j]=='#';
            ev+=s[i][j]=='#'&&s[i+1][j]=='#';
            eh+=s[i][j]=='#'&&s[i][j+1]=='#';
        }
    if(lr>0&&ud>0){
        puts("1");
        return 0;
    }
    if(lr==0&&ud==0){
        printf("%lld\n",ksm(v,k-1));
        return 0;
    }
    if(lr>0){
        swap(ud,lr);
        swap(ev,eh);
    }
    mat ans,x;
    for(int i=0;i<2;i++)
            e.a[i][i]=1;
    ans.a[1][0]=1;
    x.a[0][0]=ud,x.a[0][1]=ev;
    x.a[1][0]=0,x.a[1][1]=v;
    x=x^(k-1);
    ans=x*ans;
    printf("%lld\n",(ans.a[1][0]-ans.a[0][0]+mod)%mod);//
}


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

int n, a[100005];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%d", &a[i]);
	vector<int> v;
	for (int i = 1; i <= n; i++) {//
		if (a[i] == i) {
			v.push_back(i);
		}
	}
	int tt = 0;
	int cnt = 0;
	for (int i = 0; i < v.size(); i++) {
		if (i!=0 && v[i] - v[i - 1] == 1)++tt;
		else {
			cnt += (tt + 1) / 2;
			tt = 1;
		}
	}
	if (tt) {
		cnt += (tt + 1) / 2;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
vector<int>primes;
#define MAX 35000
using ll=long long ;
ll flag=0;
#define mod 1000000000000000000
ll ar[100];
ll aarray[100000+10];
int main()
{
    ll n,i,sum=0,l,t=1,zero=0;
    string str,ptr;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>aarray[i];
        if(aarray[i]==0)
            zero++;

    }
    if(zero>0)
    {
        cout<<0<<endl;
        return 0;
    }
    for(i=0;i<n;i++)
    {
        if(aarray[i]<=mod/t)
        t*=aarray[i];
        else
        {
            cout<<-1<<endl;
            return 0;
        }

    }
    cout<<t<<endl;

}


Measured memory_bytes: 4292
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	a := loadint()
	b := loadint()
	result := (a - 1) * (b - 1)
	fmt.Println(result)
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 2005;

P a[N];
int n, memo[N][N];

int dp(int i, int fs, int ls) {
	if (i == n) {
		return 0;
	}
	if (memo[i][fs] != -1) return memo[i][fs];
	int ans = abs(fs - a[i].S) * a[i].F + dp(i + 1, fs + 1, ls);
	ans = max(ans, abs(ls - a[i].S) * a[i].F + dp(i + 1, fs, ls - 1));
	return memo[i][fs] = ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i].F;
		a[i].S = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	memset(memo, -1, sizeof(memo));
	cout << dp(0, 0, n - 1);
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 35208
#include <iostream>

using namespace std;

int main(void){
int n, p, d1, d2;
int ans1,ans2;
while(1){
cin >> n;
if(n == 0){
break;
}
ans1 = -1, ans2 = -1;
for(int i = 0;i < n;i++){
cin >> p >> d1 >> d2;
if(ans2 < d1 + d2){
ans1 = p;
ans2 = d1 + d2;
}
}
cout << ans1 << " " << ans2 << endl;
}
return 0;
}

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

typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int H, A;

int main() {
	cin >> H >> A;
	cout << (H - 1) / A + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
#define MAX 200005
int a[MAX];
int b[MAX];

int main() {
    int n;
    si(n);
    
    for(int i=0;i<n;i++) si(a[i]);
    
    b[n/2]=a[0];
    
    if(n%2==0){
        int lft=(n/2)-1;
        int rht=(n/2)+1;
        
        for(int i=1;i<n;i++){
            if(i%2==1){
                b[lft]=a[i];
                lft--;
            }
            else{
                b[rht]=a[i];
                rht++;
            }
        }
    }
    else{
        int lft=(n/2)-1;
        int rht=(n/2)+1;
        
        for(int i=1;i<n;i++){
            if(i%2==1){
                b[rht]=a[i];
                rht++;
            }
            else{
                b[lft]=a[i];
                lft--;
            }
        }
    }
    
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 3712
number,time = map(int,input().split())
x = [list(map(int,input().split())) for i in range(number)]
a = []

for i in range(number):
    if x[i][1] <= time:
        a.append(x[i][0])
if len(a) > 0:
    print(min(a))
else:
    print("TLE")


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int solve(vi& g,int flg,int cur)
{
	int n=g.size();
	if(flg==(1<<n)-1)
		return 0;
	
	int res=n;
	repi(i,cur,n)
		res=min(res,1+solve(g,flg|g[i],i+1));
	return res;
}

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		vi g(n);
		rep(i,n)
			g[i]=1<<i;
		rep(i,m){
			int s,d; scanf("%d%d",&s,&d);
			g[s]|=1<<d;
			g[d]|=1<<s;
		}
		printf("%d\n",solve(g,0,0));
	}
	
	return 0;
}

Measured memory_bytes: 1188