akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<climits>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cstring>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>
using namespace std;

#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double>
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if
#define inpv(a,n)   vector<int>a(n);  for(ll i=0;i<n;i++)   cin>>a[i];



ll  efficient_expo(ll a , ll  b , ll mod) {
	ll res = 1 ;
	// a = a % mod;
	// b = b % mod ;
	while (b > 0) {
		if (b & 1) res = (res * a) % mod ;
		a = (a * a) % mod ;
		b = b >> 1 ;
	}
	return res ;
}

// int modd(int a, int b, int c)
// {
// 	if (b == 0) return 1;

// 	if (b % 2 == 0)
// 	{
// 		int x = modd(a, b / 2, c);
// 		return (x * x) % c;
// 	}
// 	else return (a % c * modd(a, b - 1, c)) % c;
// }

// ll recursive_mod(ll a , ll b , ll mod) {
// 	if (b == 0) return 1 ;
// 	if (b & 1) return (a % mod * recursive_mod(a, b - 1, mod)) % mod;
// 	ll x = (recursive_mod(a, b / 2, mod)) ;
// 	return ((x ) * (x )) % mod ;
// }

// ll leading_digit(ll a , ll b , ll k) {
// 	long long double  pro = b * log10(a) ;
// 	long long double deci = pro - floor(pro) ;
// 	int po = pow(10, k - 1);
// 	return (ll)(((long long double)pow(10, deci)) * po) ;
// }

bool check(int num, set<int>ff) {
	while (num) {
		int a = num % 10 ;
		if (ff.count(a)) return false;
		num = num / 10 ;
	}
	return true ;
}



int main() {

	fast ;
	int n; int k;
	cin >> n >> k ;
	set<int> ff;
	for (int i = 0 ; i < k; i++) {
		int aa;
		cin >> aa ;
		ff.insert(aa) ;
	}
	for (int i = n ; i < 1000000; i++) {
		if (check(i, ff)) {
			cout << i ;
			return 0 ;
		}
	}
	return 0 ;


}



Measured memory_bytes: 3612
#include <stdio.h>
#include <string>
#include <iostream>

#define LEN 1000000

using namespace std;

typedef struct Node{
	unsigned int key;
	struct Node *nPrev;
	struct Node *nNext;
} Node;

Node dummy;
unsigned int sum = 0;
void insert(unsigned int n);
void deleteNode(unsigned int n);
void deleteFisrt();
void deleteLast();
void display();

int main() {
	string command;
	int n;
	unsigned input;
	dummy.nPrev = NULL;
	dummy.nNext = NULL;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		cin >> command;
		if (command == "insert") {
			scanf("%u", &input);
			insert(input);
		}
		else if (command == "delete") {
			scanf("%u", &input);
			deleteNode(input);
		}
		else if (command == "deleteFirst") {
			deleteFisrt();
		}
		else if (command == "deleteLast") {
			deleteLast();
		}
		else {
			return -1;
		}
	}
	display();
	return 0;
}

// 先頭に挿入する
void insert(unsigned int n) {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		Node *node = new Node;
		node->key = n;
		node->nPrev = &dummy;
		node->nNext = &dummy;
		dummy.nPrev = node;
		dummy.nNext = node;
		sum++;
	}
	else {
		Node *node = new Node;
		node->key = n;
		node->nPrev = &dummy;
		node->nNext = dummy.nNext;
		node->nNext->nPrev = node;
		dummy.nNext = node;
		sum++;
	}
}

// 任意のキー値を持つノードを削除する
void deleteNode(unsigned int n) {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	// 確認用に宣言
	Node *pNode;
	pNode = &dummy;

	if (sum == 1) {
		if (dummy.nNext->key == n) {
			delete(dummy.nNext);
			dummy.nNext = NULL;
			dummy.nPrev = NULL;
			sum--;
		}
	}
	else {
		for (int i = 0; i < sum; i++) {
			if (pNode->nNext->key == n) {
				// Nodeの削除
				pNode->nNext = pNode->nNext->nNext;
				delete(pNode->nNext->nPrev);			// 前の部分は残っているからそこを使ってdelete()
				pNode->nNext->nPrev = pNode;
				sum--;
				break;
			}
			else {
				// pNodeのnextを次のNodeにする
				pNode = pNode->nNext;
			}
		}
	}
}

// 先頭を削除する
void deleteFisrt() {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	Node *ptmpN = dummy.nNext->nNext;
	delete(dummy.nNext);				// 先頭の削除

	// ノードが1つの時と2つ以上の時の条件分岐
	if (&dummy == ptmpN) {
		dummy.nPrev = NULL;
		dummy.nNext = NULL;
	}
	else {
		dummy.nNext = ptmpN;
		ptmpN->nPrev = &dummy;
	}
}

// 末尾を削除する
void deleteLast() {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	Node *ptmpN = dummy.nPrev->nPrev;
	delete(dummy.nPrev);

	// ノードが1つ以上の時と2つ以上の時の条件分岐
	if (&dummy == ptmpN) {
		dummy.nPrev = NULL;
		dummy.nNext = NULL;
	}
	else {
		dummy.nPrev = ptmpN;
		ptmpN->nNext = &dummy;
	}
}

// 出力
void display() {

	Node *node = dummy.nNext;
	while (&dummy != node) {
		printf("%d", node->key);
		node = node->nNext;
		delete(node->nPrev);
		if (node != &dummy) {
			printf(" ");
		}
	}
	printf("\n");
}



Measured memory_bytes: 34540
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, n = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(n)]
inf = float('inf')
dp = [inf] * (h + 1)
dp[0] = 0
for i, (a, b) in enumerate(ab):
    for j in range(h):
        if j + a >= h:
            dp[-1] = min(dp[-1], dp[j] + b)
        else:
            dp[j + a] = min(dp[j + a], dp[j] + b)
print(dp[-1])


Measured memory_bytes: 50268
/* be name khoda */

// #define stream_enable
#define long_enable

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>

// #include <bits/stdc++.h>
// #include <numeric>
// #include <iomanip>
// #include <cmath>
// #include <bitset>
// #include <fstream>

using namespace std;

#ifdef stream_enable
#define cin sss
#endif

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;

const ll MOD = 1000000007;

const long long BIG = 1446803456761533460LL;
const int Big = 336860180;

#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).ff << ", " << (x).ss << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].ff << ", " << (x)[i1_dap].ss << ")" << endl; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll x;
    cin >> x;
    ll l = 0, r = 60000;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (m * 108 / 100 > x) {
            r = m;
        } else {
            l = m;
        }
    }
    if (l * 108 / 100 == x)
        cout << l << '\n';
    else 
        cout << ":(\n";

}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n=sc.nextInt();
        boolean b=true;
        while(n%4!=0){
            n-=7;
            if(n<0){
                b=false;
                break;
            }
        }
        if(b){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }      
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;


int dp[30][100010];

ll mod_pow(ll x, int n, int mod){
	if(n == 0) return 1LL;
	int ret = mod_pow(x*x % mod, n / 2, mod);
	if(n & 1) ret *= x;
	return ret % mod;
}

int main(){
	while(1){
		int n = in.nextInt(), m = in.nextInt(), K = in.nextInt();
		if(n == 0 && m == 0 && K == 0) break;
		for(int i = 0; i < 1e5 + 10; i++) for(int j = 0; j < 30; j++) dp[j][i] = 0;
		dp[0][0] = 1;
		for(int i = 1; i <= n; i++){
			for(int j = 0; j <= m*n; j++){
				for(int k = 1; k<= m; k++){
					dp[i][j+k] += dp[i-1][j];
				}
			}
		}
		double d = mod_pow(m, n, mod);
		//cout<<" "<<d<<endl;
		double ans = 0.0;
		for(int i = 0; i <= 1e5; i++) ans += max(1.0, (double)i-K) * dp[n][i] / d;
		
		printf("%.15lf\n", ans);
	}
}

Measured memory_bytes: 14864
#include<iostream>
using namespace std;
int a[60],b[60],c[60];
int main(){
	int n;
	cin>>n;
	a[0]=-999;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	cin>>b[i];
	for(int i=1;i<n;i++)
	cin>>c[i];
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=b[a[i]];
		if(a[i]==a[i-1]+1) ans+=c[a[i-1]];	
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    if(n%2):
        print(0)
        return
    A.sort()
    print(A[n//2]-A[n//2-1])
resolve()

Measured memory_bytes: 52684
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	// adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	// adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	// if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;

	public Graph() {
		totalVertex = 0;
	}

	public int getTotalVertex() {
		return totalVertex;
	}

	// load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for (i = 0; i < totalVertex; i++) {
			ifSettled[i] = false;
			for (j = 0; j < totalVertex; j++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for (i = 0; i < totalVertex; i++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for (j = 0; j < degree; j++) {
				v = in.nextInt();
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}
		}
		in.close();
	}

	// return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}

	// return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if (adjMatrix[u][v] == 1)
				tmp.add(v);
		}
		return tmp;
	}

	// return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for (int v = 0; v < totalVertex; v++) {
			if ((adjMatrix[u][v] == 1) && (ifSettled[v] == false))
				tmp.add(v);
		}
		return tmp;
	}

	// return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for (v = 0; v < totalVertex; v++) {
			if ((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}

	// implement the following
	public int[] Dijkstra(int x) {
		int[] map = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++) {
			map[i] = Integer.MAX_VALUE;
		}

		map[x] = 0;
		ifSettled[x] = true;

		int set = x;
		boolean cow = true;
		LinkedList<Integer> neighbors;

		while (cow) {
			neighbors = getUnsettledNeighbors(set);
			for (int i : neighbors) {
				if (map[i] > map[set] + getWeight(set, i)) {
					map[i] = map[set] + getWeight(set, i);
				}
			}
			set = getUnsettledNearest(map);
			ifSettled[set] = true;
			cow = false;
			for (int i = 0; i < totalVertex; i++) {
				if (ifSettled[i] == false) {
					cow = true;
				}
			}
		}
		return map;
	}
}

public class Main {
	public static void main(String[] args) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for (int i = 0; i < g.getTotalVertex(); i++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40392
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{
    

    class Program
    {

        static void Main(string[] args)
        {
            var NC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            
            var N = NC[0];
            var C = NC[1];

            var RightOnly = new long[N+1];
            var RightOnlyRepeat = new long[N + 1];
            var LeftOnly = new long[N + 1];
            var LeftOnlyRepeat = new long[N + 1];
            var CumValueRight = new long[N + 1];
            var LeftX = new long[N];
            var LeftV = new long[N];

            for (int i = 1; i <= N; i++)
            {
                var XV = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var X = XV[0];
                var V = XV[1];
                CumValueRight[i] = CumValueRight[i-1] + V; 
                //右回りでのみi個まで取得を許した場合の価値の最大値
                RightOnly[i] = Max(RightOnly[i - 1],CumValueRight[i] - X);
                //右回りで往復を考慮した時のi個まで取得可能とした場合の最大値
                RightOnlyRepeat[i] = Max(RightOnlyRepeat[i-1], CumValueRight[i] - 2*X);
                //左回り用の配列を用意
                LeftX[N - i] = X;
                LeftV[N - i] = V;
            }

            var CumValueLeft = new long[N + 1];
            for (int i = 1; i <= N; i++)
            {
                var X = C-LeftX[i-1];
                var V = LeftV[i-1];
                CumValueLeft[i] = CumValueLeft[i - 1]+V;
                //左回りでのみi個まで取得を許した場合の価値の最大値
                LeftOnly[i] = Max(LeftOnly[i - 1], CumValueLeft[i] - X);
                //左回りで往復を考慮したときのi個まで取得可能とした場合の最大値
                LeftOnlyRepeat[i] = Max(LeftOnlyRepeat[i-1],CumValueLeft[i]-2*X);
            }

            var ans = Max(RightOnly.Max(), LeftOnly.Max());

            //右回りから左回りに移行する場合
            for (int i = 1; i <= N; i++)
            {
                ans = Max(ans, RightOnlyRepeat[i] + LeftOnly[N - i]);
            }

            //左回りから右回りに移行する場合
            for (int i = 1; i <= N; i++)
            {
                ans = Max(ans, LeftOnlyRepeat[i] + RightOnly[N - i]);
            }

            Console.WriteLine(ans);
        }


    }
}


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


int main() {
    int N,T,A;
    cin>>N>>T>>A;
    vector<pair<double,double>>p(N);
    rep(i,N){
        int H;
        cin>>H;
        double B= abs(A-T+H*0.006);
        p[i]=make_pair(B,i+1);
    }
    double mn =1000000;
    for(auto a:p){
        mn =min(mn,a.first);
    }
    for(auto a:p){
        if(a.first!=mn)continue;
        cout<<a.second<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;

int n;
vector<int> adj[MaxN + 1];

int f[MaxN + 1][2];

void dfs(int u, int fa)
{
	f[u][0] = 0;
	f[u][1] = 1;

	for (int v : adj[u])
		if (v != fa)
		{
			dfs(v, u);
			f[u][0] += f[v][1];
			f[u][1] += min(f[v][0], f[v][1]);
		}
}

int main()
{
	while (cin >> n)
	{
		for (int u = 1; u <= n; ++u)
			adj[u].clear();
		for (int i = 1; i < n; ++i)
		{
			int u = getint(), v = getint();
			adj[u].push_back(v);
			adj[v].push_back(u);
		}

		dfs(1, 0);

		int n_matches = min(f[1][0], f[1][1]);
		if (n_matches * 2 == n)
			puts("Second");
		else
			puts("First");
	}

	return 0;
}

Measured memory_bytes: 6656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  
#include <vector>
#include <stack>
#include <cmath>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=1e5+5;
using namespace std;
int x,y,z;
int t,n,m;
int maxn=INF,minn;
int v[N]={0};
int sum=0;
int main(){
	cin>>v[0]>>v[1]>>v[2];
	sort(v,v+3);
	v[0]=v[2]-v[0];
	v[1]=v[2]-v[1];
	if(v[0]%2&&v[1]%2){
		v[1]-=v[0];
		sum+=v[0];
		sum+=v[1]/2;
	}else if(v[0]%2||v[1]%2){
		v[0]++;
		v[1]++;
		if(v[0]%2){
			v[0]--;
		}else{
			v[1]--;
		}
		sum++;
		sum+=(v[0]+v[1])/2;
	}else{
		sum=(v[0]+v[1])/2;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if(a<9&&b<9) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c; cin >> a >> b >> c;
  int k; cin >> k;
  int i = 0;
  int max_num = max(max(a,b),c);
  if(max_num == a){
    while(i < k){
      a *=2;
      i++;
    }
  }
  else if(max_num == b){
    while(i < k){
      b *=2;
      i++;
    }
  }
  else {
    while(i < k){
      c *=2;
      i++;
    }
  }
  cout << a + b +c;
}
  

Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<Integer> A = new ArrayList<Integer>();

        while (true) {
            String str = sc.next();
            if (str.equals("0")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            else {
                int a = 0;
                for (int i=0; i<str.length(); i++) {
                    a += Integer.valueOf(str.substring(i, i+1));
                }
                A.add(a);
            }
        }
    }
}


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

typedef long long ll;

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0;
    cin >> n;
    vector<int> v(n, 0);

    vector<int> cnt(1e5 + 5, 0);

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

    
    ll ans = 1;
    if(n % 2 == 0) {
        int found = 0;
        int count = 0;
        for(int i = 0; i < cnt.size(); i++) {
            if(cnt[i] == 2) count++;

            if(cnt[i] != 2 && cnt[i] != 0) {
                found = 1;
            }
        }

        if(!found) {
            while(count--) {
                ans = (ans * 2) % ll(1e9 + 7);
            }
            ans = ans % ll(1e9 + 7);
        }
        else {
            ans = 0;
        }
    }
    else {
        int found = 0;
        int count_t = 0;
        int index_m = 0;
        int count_o = 0;

        for(int i = 0; i < cnt.size(); i++) {
            if(cnt[i] == 1) count_o++;
            else if(cnt[i] == 2) count_t++;
            else if(cnt[i] != 0)found = 1;
        }

        if(!found && count_o == 1 && cnt[0] == 1) {
            while(count_t--) {
                ans = (ans * 2) % ll(1e9 + 7);
            }
            ans = ans % ll(1e9 + 7);
        }
        else {
            ans = 0;
        }

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

vector<long long> a;
vector<long long> aSum;
long long dp[400][400];

long long section(int l, int r){

    long long temp = dp[l][r];
    if(temp != -1){
        return temp;
    }

    if(l == r){
        return 0;
    }

    long long ret = (1LL << 60);
    for(int i = l; i < r; i++){
        long long sum = section(l, i) + section(i + 1, r);
        sum += aSum[i + 1] - aSum[l];
        sum += aSum[r + 1] - aSum[i + 1];
        ret = min(ret, sum);
    }

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

int main(){

    int N;
    cin >> N;
    a.resize(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    aSum.resize(N + 1);
    aSum[0] = 0;
    for(int i = 1; i < N + 1; i++){
        aSum[i] = aSum[i - 1] + a[i - 1];
    }

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

    long long ans = section(0, N - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main(){
	int n;
	cin >> n;
	vector<int> foo;
	REP(i, n) {
		int a;
		cin >> a;
		foo.push_back(a);
	}
	sort(foo.begin(), foo.end());
	int ans = 0;
	REP(i, n - 1) {
		ans += foo[i];
	}
	ans += foo[n - 1] / 2;
	cout << ans << endl;
	return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 998244353

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

ll      MPl(ll x, ll y) {
        return ((x+y)%MOD+MOD)%MOD;
}

ll      MMi(ll x, ll y) {
        return ((x-y)%MOD+MOD)%MOD;
}

ll      MMul(ll x, ll y) {
        return ((x*y)%MOD+MOD)%MOD;
}

int     main() {
        ll A, B, C, D;
        cin >>A >>B >>C >>D;
        vector<vector<ll>> DP(C+1, vector<ll> (D+1, 0));
        DP.at(A).at(B)=1;
        for(auto i=A; i<=C; i++)
                for(auto j=B; j<=D; j++) {
                        if ((i==A)&&(j==B))
                                DP.at(i).at(j)=1;
                        else {
                                DP.at(i).at(j)=MMul(DP.at(i-1).at(j), j);
                                DP.at(i).at(j)=MPl(DP.at(i).at(j), MMul(DP.at(i).at(j-1), i));
                                DP.at(i).at(j)=MMi(DP.at(i).at(j), MMul(MMul(DP.at(i-1).at(j-1), i-1), j-1));
                        }
                }
        cout <<DP.at(C).at(D) <<endl;
        return 0;
}

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

int main() {
    int x;
    cin >> x;

    if ( x < 100 )
    {
        cout << '0';
        return 0;
    }

    // m = num1 + num2 + ... num;
    int num = x/100;
    int m = x%100;

    rep(i, num){
        if ( m>=5)
            m-=5;
        else if (m>=4)
            m-=4;
        else if (m>=3)
            m-=3;
        else if (m>=2)
            m-=2;
        else if (m>=1)
            m-=1;
    }
    
    if (m==0)
        cout << '1';
    else
        cout << '0';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 100;

// 入力
int N, A, B, C, X;
int Y[MAX_N];

void solve() {
	int real = 0;
	int r = X;
	if (r == Y[real]) {
		real++;
		if (real == N) {
			cout << 0 << endl;
			return;
		}
	}
	for (int frame = 1; frame <= 10000; frame++) {
		r = (A * r + B) % C;
		if (r == Y[real]) {
			real++;
			if (real == N) {
				cout << frame << endl;
				return;
			}
		}
	}
	cout << -1 << endl;
	
	return;
}

int main() {
	while (true) {
		cin >> N >> A >> B >> C >> X;
		if (N == 0) {
			break;
		}
		for (int i = 0; i < N; i++) {
			cin >> Y[i];
		}
		solve();
	}
	
	return 0;
}

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

int main(){
    int csize[3], n, t;
    bool f;
    while(1){
        f = false;
        for(int i = 0;i < 3;++i){
            cin >> csize[i];
            f = f || csize[i] != 0;
        }
        if(!f) break;
        cin >> n;
        for(int k = 0;k < n;++k){
            cin >> t;
            f = false;
            for(int i = 0;i < 3 && !f;++i){
                for(int j = i + 1;j < 3 && !f;++j){
                    f = f || csize[i] * csize[i] + csize[j] * csize[j] < 4 * t * t;
                }
            }
            if(f) cout << "OK" << endl;
            else cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long int
#define li long int
#define ld long double
#define pb push_back
using namespace std;

vector<int> lis[200001];
bool vis[200001];

void dfs(int node,int&curr)
{
    vis[node]=true;
    curr++;
    for(int x:lis[node])
    {
        if(!vis[x])
        {
            dfs(x,curr);
        }
    }
}

int main()
{
    int n,m,a,b;
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        lis[a].pb(b);
        lis[b].pb(a);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            int curr=0;
            dfs(i,curr);
            ans=max(ans,curr);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 24096
from heapq import *
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Dice:
    def __init__(self,top,bot,lef,rig,fro,bac):
        self.top = top
        self.bot = bot
        self.lef = lef
        self.rig = rig
        self.fro = fro
        self.bac = bac

    def up(self):
        top, bac, bot, fro = self.fro, self.top, self.bac, self.bot
        return Dice(top,bot,self.lef,self.rig,fro,bac)

    def down(self):
        top, bac, bot, fro = self.bac, self.bot, self.fro, self.top
        return Dice(top,bot,self.lef,self.rig,fro,bac)

    def right(self):
        top, rig, bot, lef = self.lef, self.top, self.rig, self.bot
        return Dice(top,bot,lef,rig,self.fro,self.bac)

    def left(self):
        top, rig, bot, lef = self.rig, self.bot, self.lef, self.top
        return Dice(top,bot,lef,rig,self.fro,self.bac)

    def state(self):
        return (self.top, self.rig, self.bot, self.lef, self.fro, self.bac)

def main():
    h, w = MI()
    ss = [[0 if c == "#" else int(c) for c in SI()] for _ in range(h)]
    stack=[(0,0,Dice(1,6,4,3,2,5))]
    fin=[[set() for _ in range(w)] for _ in range(h)]
    fin[0][0].add(Dice(1,6,4,3,2,5).state())
    while stack:
        i,j,d=stack.pop()
        if i==h-1 and j==w-1:
            print("YES")
            exit()
        ni,nj=i-1,j
        if i-1>=0:
            nd=d.up()
            if nd.bot==ss[ni][nj] and nd.state() not in fin[ni][nj]:
                fin[ni][nj].add(nd.state())
                stack.append((i-1,j,nd))
        ni,nj=i+1,j
        if i+1<h:
            nd=d.down()
            if nd.bot==ss[ni][nj] and nd.state() not in fin[ni][nj]:
                fin[ni][nj].add(nd.state())
                stack.append((i+1,j,nd))
        ni,nj=i,j-1
        if j-1>=0:
            nd=d.left()
            if nd.bot==ss[ni][nj] and nd.state() not in fin[ni][nj]:
                fin[ni][nj].add(nd.state())
                stack.append((i,j-1,nd))
        ni,nj=i,j+1
        if j+1<w:
            nd=d.right()
            if nd.bot==ss[ni][nj] and nd.state() not in fin[ni][nj]:
                fin[ni][nj].add(nd.state())
                stack.append((i,j+1,nd))
    print("NO")

main()



Measured memory_bytes: 9508
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int M,D; cin >> M >> D; int ans=0;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            int a=j/10,b=j%10;
            if(a*b==i && a>=2 && b>=2) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
result = 0
prev = 0

for i in range(N):
    pointer = int(A[i])
    result += int(B[pointer-1])
    if i != 0 and pointer - prev == 1:
        result += int(C[prev-1])
    prev = pointer

print(result)


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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for (int i=0; i<n; i++) cin >> m[i];
    int min_m = *min_element(m.begin(), m.end());
    int ans = n + (x - accumulate(m.begin(), m.end(), 0))/min_m;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n, a;
	cin >> n >> a;
	if(a >= n % 500) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=998244353;
const int maxn = 1e6+7;


int main(){

    LL a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;

    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>

int main(void)
{
    int x, a, b, lentha, lenthb;
    scanf("%d%d%d", &x, &a, &b);
    lentha = a - x;
    lenthb = b - x;

    if(lentha < 0) lentha = lentha * -1;
    if(lenthb < 0) lenthb = lenthb * -1;

    if(lentha > lenthb) printf("B");
    if(lentha < lenthb) printf("A");

    return (0);
}


Measured memory_bytes: 128
double p[333][333][333];
n;c[4];i,j,k;
main(a){
	for(;~scanf("%d",&a);)!n?n=a:c[a]++;
	//for(;k<=n;k++)for(j=-1;j++<n;)for(i=-1;i++<n;)
	//for(;k<=n;k++)for(i=j=0;i>n?i=0,j++<n:1;i++)
	for(;i>n?i=0,j++<n?:(j=0,k++<n):1;i++)
	//for(k=0;k<=n;k++)for(j=0;j<=n;j++)for(i=0;i<=n;i++)
	{
		p[i][j][k]=i+j+k?(i*p[i?i-1:i][j][k]+j*p[i+1][j?j-1:j][k]+k*p[i][j+1][k?k-1:k]+n)/(i+j+k):0;
	}
	printf("%.9f",p[c[1]][c[2]][c[3]]);
}
//#define r(i)for(i=-1;i++<n;);r(k)r(j)r(i)


Measured memory_bytes: 262144
#include<iostream>
using namespace std;
int mem[10],cnt,bit;
int main(){for(string s;cin>>s;cout<<endl)for(int i=0;i<s.size();i++,cout<<"."){int pos=(s[i]-33)/10;while(pos!=bit)if(pos>bit)bit++,cout<<">";	else
 bit--,cout<<"<";while(mem[pos]!=s[i])if(mem[pos]-s[i]>0)mem[pos]--,cout<<"-";else mem[pos]++,cout<<"+";}}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int a[100005];

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

    long long cnt = 0;
	if(a[0]>x) {
		cnt = a[0] - x;
		a[0] = x;
	}
    for(int i=1;i<n;++i) {
        if(a[i-1] + a[i] > x) {
            cnt += a[i-1]+a[i]-x;
            a[i] -= a[i-1]+a[i]-x;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
S= list(map(int,list(input())))
cntOD0=0
cntOD1=0
for i in range(len(S)):
  if i%2==0 and S[i]==1:
    cntOD0+=1
  elif i%2==1 and S[i]==0:
    cntOD0+=1
  elif i%2==0 and S[i]==0:
    cntOD1+=1
  elif i%2==1 and S[i]==1:
    cntOD1+=1
print(min(cntOD0,cntOD1))

Measured memory_bytes: 4652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll a,b,q;
  cin>>a>>b>>q;
  vector<ll>s(a,0);
  vector<ll>t(b,0);
  vector<ll>x(q,0);
  map<ll,ll> ms;
  map<ll,ll> mt;
  for(ll i=0;i<a;i++){
    cin>>s[i];
    ms[s[i]]=i;
  }
  for(ll i=0;i<b;i++){
    cin>>t[i];
    mt[t[i]]=i;
  }
  for(ll i=0;i<q;i++){
    cin>>x[i];
  }
  for(ll i=0;i<q;i++){
    ll ans=9999999999999;
    auto itrs = ms.lower_bound(x[i]);
    if( itrs != ms.end() ) {
      ll k=abs((itrs->first)-x[i]);
      auto itrt = mt.lower_bound(itrs->first);
      if( itrt != mt.end() ) {
        ll kk=abs((itrt->first)-(itrs->first));
        ans=min(ans,k+kk);
      }
      if( itrt != mt.begin() ) {
        itrt--;
        ll kk=abs((itrt->first)-(itrs->first));
        ans=min(ans,k+kk);
      }
    }
    if( itrs != ms.begin() ) {
      itrs--;
      ll k=abs((itrs->first)-x[i]);
      auto itrt = mt.lower_bound(itrs->first);
      if( itrt != mt.end() ) {
        ll kk=abs((itrt->first)-(itrs->first));
        ans=min(ans,k+kk);
      }
      if( itrt != mt.begin() ) {
        itrt--;
        ll kk=abs((itrt->first)-(itrs->first));
        ans=min(ans,k+kk);
      }
    }


    auto itrtt = mt.lower_bound(x[i]);
    if( itrtt != mt.end() ) {
      ll k=abs((itrtt->first)-x[i]);
      auto itrss = ms.lower_bound(itrtt->first);
      if( itrss != ms.end() ) {
        ll kk=abs((itrss->first)-(itrtt->first));
        ans=min(ans,k+kk);
      }
      if( itrss != ms.begin() ) {
        itrss--;
        ll kk=abs((itrss->first)-(itrtt->first));
        ans=min(ans,k+kk);
      }
    }
    if( itrtt != mt.begin() ) {
      itrtt--;
      ll k=abs((itrtt->first)-x[i]);
      auto itrss = ms.lower_bound(itrtt->first);
      if( itrss != ms.end() ) {
        ll kk=abs((itrss->first)-(itrtt->first));
        ans=min(ans,k+kk);
      }
      if( itrss != ms.begin() ) {
        itrss--;
        ll kk=abs((itrss->first)-(itrtt->first));
        ans=min(ans,k+kk);
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 17664
h,w=map(int,input().split())
mod=10**9+7
T=[]
for i in range(h):
  T.append(input())
DP=[[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if i==0:
      if j==0:
        DP[i][j]=1
      elif T[i][j]=="#":
        DP[i][j]=0
      else:
        DP[i][j]=DP[i][j-1]
    else:
      if j==0:
        if T[i][j]=="#":
          DP[i][j]=0
        else:
          DP[i][j]=DP[i-1][j]
      else:
        if T[i][j]=="#":
          DP[i][j]=0
        else:
          DP[i][j]=(DP[i-1][j]+DP[i][j-1])%mod
print(DP[h-1][w-1])

Measured memory_bytes: 43604
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   int c = sc.nextInt();
   int d = sc.nextInt();
   
   if(a*b>c*d)System.out.println(a*b);
   else System.out.println(c*d);
 }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m,l;
  cin>>n>>m>>l;
  int d[310][310]={};
  rep(i,n){
    rep(j,n){
      if(i!=j) d[i][j]=INF;
    }
  }

  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    d[a][b]=c;
    d[b][a]=c;
  }

  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(i==j||j==k||k==i) continue;
        if(d[i][k]==INF||d[k][j]==INF) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }

  int d1[310][310]={};
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      d1[i][j]=inf;
    }
  }

  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      if(d[i][j]<=l) d1[i][j]=1;
    }
  }

  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(i==j||j==k||k==i) continue;
        d1[i][j]=min(d1[i][j],d1[i][k]+d1[k][j]);
      }
    }
  }

  int q;
  cin>>q;
  while(q--){
    int s,t;
    cin>>s>>t;
    s--;t--;
    cout<<(d1[s][t]==inf?-1:d1[s][t]-1)<<endl;
  }




}

Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n, k; cin >> n >> k;
	double p = 0;
	rep(i, 1, n+1) {
		int d = i;
		int cnt = 0;
		while (d < k) {
			cnt++; d *= 2;
		}
		p += (double)1.0 / n * pow(0.5, cnt);
	}
	printf("%.12f", p);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define f first
#define s second
const int N = 2e5 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
vector <int> g[N];
deque <ii> dp[N];
vector <ii> tmp[N];
int pref[N], post[N];
ii get(vector <ii> &a) {
    pref[0] = 1;
    for (int i = 0; i < (int)a.size(); ++i) {
        pref[i + 1] = mod(pref[i] * a[i].s);
    }   
    post[a.size()] = 1;
    for (int i = (int)a.size() - 1; i >= 0; --i) {
        post[i] = mod(post[i + 1] * a[i].s);
    }   
    int all = 1;
    for (auto e : a) all = mod(all * (e.f + e.s));
    int t = 0;
    for (int i = 0; i < (int)a.size(); ++i) {
        t = mod(t + mod(a[i].f * mod(pref[i] * post[i + 1])));
    }   
    return {t, mod(all - t)};
}   
int cnt[N];
void dfs(int u, int h) {
    ++cnt[h];
    int mx = -1;
    for (int v : g[u]) {
        dfs(v, h + 1);
        if (mx == -1 || dp[mx].size() < dp[v].size()) mx = v;
    }   
    if (mx == -1) {
        dp[u].push_back({1, 1});
        return;
    }
    swap(dp[mx], dp[u]);
    dp[u].push_front({1, 1});
    for (int v : g[u]) {
        if (v == mx) continue;
        for (int i = 0; i < (int)dp[v].size(); ++i) {
            tmp[i + 1].push_back(dp[v][i]);
        }   
    }   
    for (int i = 1; ; ++i) {
        if (tmp[i].empty()) break;
        tmp[i].push_back(dp[u][i]);
        dp[u][i] = get(tmp[i]);
    }   
    for (int v : g[u]) {
        if (v == mx) continue;
        for (int i = 1; i <= (int)dp[v].size(); ++i) tmp[i].clear();
    }   
}   
int pw[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    pw[0] = 1;
    for (int i = 1; i < N; ++i) pw[i] = mod(pw[i - 1] << 1);

    int n;
    cin >> n; ++n;
    for (int i = 1; i < n; ++i) {
        int p; cin >> p;
        g[p].push_back(i);
    }   
    dfs(0, 0);
    int ans = 0;
    for (int i = 0; i < (int)dp[0].size(); ++i) {
        ans = mod(ans + mod(dp[0][i].f * pw[n - cnt[i]]));
    }   
    cout << ans << '\n';
}   

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    double ans=0;
    rep(i,0,n){
        ans+=1.0/a[i];
    }
    printf("%.12f",1.0/ans);
    return 0;
}

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

int main(){

  int N, cnt=0;
  string S;

  cin >> S;

  N = S.size() / 2;

  for (int i=0; i<N; i++){
    if (!(S.at(i)==S.at(S.size()-i-1))){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define SZ(c) int(c.size())
#define pb push_back
#define loop(i,start,n)  for(int i=start;i<n;i++)
#define rloop(i,start,n)  for(int i=start;i>n;i--)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
const ll inf = 2e9+3;

void solve(){
    int tc=1 ;
    //cin >> tc;
    while(tc--) {
        ll n,m,k,res=0;
        cin >> n >> m >> k;
        vll va(n+1) , vb(m+1);
        ll A=0, B=0;
        loop(i,1,n+1) { cin >> va[i]; va[i] = va[i]+va[i-1]; }
        loop(i,1,m+1) { cin >> vb[i]; vb[i] = vb[i]+vb[i-1]; }
        ll b = m , a = n;
        loop(i,1,n+1) if(va[i]<=k) a = i;
        loop(i,1,m+1) if(vb[i]<=k) b = i;
        loop(i,0,a+1){
            if(vb[b]+va[i] <= k) res = max(res,i+b);
            else b--;
            /*loop(j,0,b+1) {
                if (va[i] + vb[j] <= k) res = max(res,(ll)(i+j));
            }*/
        }
        cout << res;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 6304