akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}
	int res = K;
	for (int i = 1; i < N; ++ i) {
		res = min(res, K - (A[i]-A[i-1]));
	}
	res = min(res, A[N-1]-A[0]);
	cout << res << endl;
}


Measured memory_bytes: 1024
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	static long result1 = Long.MAX_VALUE;
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		
		long[] input = new long[n];
		long[] result = new long[n];
		for(int i = 0; i < n; i++) {
			input[i] = sc.nextLong();
		}
		
		counting(input, result, 0, 0, true);
		counting(input, result, 0, 0, false);
		System.out.println(result1);
	}
	
	public static void counting(long[] input, long[] result, long count, int index, boolean sign) {
		if(index > 0) {
			result[index] = result[index-1] + input[index];
		} else {
			result[index] = input[index];
		}
		
		if(sign) {
			if(result[index] <= 0) {
				count += Math.abs(result[index]) + 1;
				result[index] = result[index] + Math.abs(result[index]) + 1;
			} 
			sign = false;
		} else {
			if(result[index] >= 0) {
				count += Math.abs(result[index]) + 1;
				result[index] = result[index] - Math.abs(result[index]) - 1;
			}
			sign = true;
		}
		
		if(index < result.length-1) {
			counting(input, result, count, index+1, sign);
		} else {
			if(result1 > count) {
				result1 = count;
			}
			
		}
	}
}

Measured memory_bytes: 71268
S = str(input())
K = int(input())

# now_s = S[0]
# for i in range(1, len(S)):
#     if now_s == S[i]:
#         cnt += 1
#     now_s = S[i]

if len(S) == 1:
    print(K//2)
    exit()


cnt = 0
ruisekiwa = [1]
now_s = S[0]
for i in range(1, len(S)):
    if now_s == S[i]:
        ruisekiwa[-1] += 1
    else:
        ruisekiwa.append(1)
    now_s = S[i]

if len(ruisekiwa) == 1:
    if ruisekiwa[0] % 2 == 0:
        print(ruisekiwa[0]//2*K)
        exit()

    # 文字数が奇数
    if K % 2 == 0:
        cnt += (ruisekiwa[0]//2 + 1) * (K//2)
        cnt += (ruisekiwa[0]//2) * (K//2)
    else:
        cnt += (ruisekiwa[0]//2) * (K//2 + 1)
        cnt += (ruisekiwa[0]//2 + 1) * (K//2)
    print(cnt)
    exit()



cnt = 0
for i in range(len(ruisekiwa)):
    cnt += ruisekiwa[i]//2

# 先頭と末尾が違うなら問題ない
if S[0] != S[-1]:
    print(cnt*K)
    exit()




# 先頭と末尾が同じ場合を考える

# 先頭が偶数, 末尾も偶数回数
if ruisekiwa[0] % 2 == 0 and ruisekiwa[-1] % 2 == 0:
    print(cnt * K)
    exit()
# 先頭が偶数, 末尾が奇数
if ruisekiwa[0] % 2 == 0 and ruisekiwa[-1] % 2 == 1:
    print(cnt * K)
    exit()
# 末尾が偶数なら末尾を変えれるから嬉しい
# 先頭が奇数, 末尾が偶数
if ruisekiwa[0] % 2 == 1 and ruisekiwa[-1] % 2 == 0:
    print(cnt * K)
    exit()

# 偶は先頭を変える必要があるから、嬉しい

# 先頭が奇数回数続いていて, 末尾も奇数回数
if ruisekiwa[0] % 2 == 1 and ruisekiwa[-1] % 2 == 1:
    # if K % 2 == 1:
    #     print(cnt * (K//2+1) + (cnt+1) * (K//2))
    # else:
    #     print(cnt * (K//2) + (cnt+1) * (K//2))
    # exit()
    print((cnt+1) * K -1)
    exit()
    # ここを直した, waが減った


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	int A, B, C;

	cin >> A >> B >> C;
	for (int i = 1; i <= B; i++) {

		if ((i * A) % B == C) {

			cout << "YES";

			return 0;
		}
	}
	
		cout << "NO";
	
}

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

int main(){
    string s;
    cin >> s;
    if(s.size()%2==0){
        if(s[0]==s[s.size()-1]) cout << "First" << endl;
        else cout << "Second" << endl;
    }else{
        if(s[0]==s[s.size()-1]) cout << "Second" << endl;
        else cout << "First" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        """[l, r)
        """
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret

    def __getitem__(self, key):
        return self.__tree[key + self.__size]
@mt
def slv(N, A, Q):
    st = SegmentTree(A, add, 0)
    ans = []
    for q in Q:
        if q[0] == 0:
            _, p, x = q
            st.update(p, st[p]+x)
        else:
            _, l, r = q
            ans.append(st.query(l, r))

    return ans


def main():
    N, Q = read_int_n()
    A = read_int_n()
    Q = [read_int_n() for _ in range(Q)]
    print(*slv(N, A, Q), sep='\n')


if __name__ == '__main__':
    main()


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

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

    if(a>0) cout << "Positive" << endl;
    else if(a==0) cout << "Zero" << endl;
    else if(b >= 0) cout << "Zero" << endl;
    else if((b-a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

ll a, b;

void solve() {
  ll ans = 0;
  a--;
  for (ll i=0;(1LL<<i)<=b;i++) {
    ll base = 1LL << (i + 1);
    ll cntB = (b / base) * (base / 2) + max(b % base - base / 2 + 1, 0LL);
    ll cntA = (a / base) * (base / 2) + max(a % base - base / 2 + 1, 0LL);
    if ((cntB - cntA) & 1) {
      ans += (1LL << i);
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> a >> b;
  solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	long long ans = 1;
	
	for (int i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		
		if (a == 0) {
			ans = 0;
			break;
		} else if (a == 1000000000000000000) {
			ans = -1;
		}
		
		auto b = ans;
		if (ans != -1)
			ans *= a;
		
		if (ans > 1000000000000000000 || ans < b)
			ans = -1;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = "";
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == '1') {
				t += "9";
			}
			if (c == '9') {
				t += "1";
			}
		}
		System.out.println(t);
	}
}

Measured memory_bytes: 22608
#include<stdio.h>
int main(void){
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<=a){
        printf("%d",k);
        return 0;
    }
    if(k>a&&k<=a+b){
        printf("%d",a);
        return 0;
    }
    if(a+b<k&&k<=a+b+c){
        printf("%d",2*a+b-k);
        return 0;
    }
    
}

Measured memory_bytes: 1720
#include<stdio.h>

int main(void) {
	unsigned int	iNumber;
	char			cCondition = 0;
	//正の整数を入力
	scanf("%d", &iNumber);
	//入力された数に応じた"本"の読み方を出力
	switch (iNumber % 10)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;		
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 3:
		printf("bon\n");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Dice
{
private:
	int tmp;
public:
	int lab[6];
	void rE(){
		tmp = lab[0];
		lab[0] = lab[3];
		lab[3] = lab[5];
		lab[5] = lab[2];
		lab[2] = tmp;
	}
	void rN(){
		tmp = lab[0];
		lab[0] = lab[1];
		lab[1] = lab[5];
		lab[5] = lab[4];
		lab[4] = tmp;
	}
	void rS() {
		tmp = lab[0];
		lab[0] = lab[4];
		lab[4] = lab[5];
		lab[5] = lab[1];
		lab[1] = tmp;
	}
	void rW() {
		tmp = lab[0];
		lab[0] = lab[2];
		lab[2] = lab[5];
		lab[5] = lab[3];
		lab[3] = tmp;
	}
	void rR() {
		tmp = lab[1];
		lab[1] = lab[2];
		lab[2] = lab[4];
		lab[4] = lab[3];
		lab[3] = tmp;
	}
	int get3(int top, int front) {
		int i;
		if (top != lab[0]) {
			rep(i,3) {
				rN();
				if (top == lab[0]) break;
				rW();
				if (top == lab[0]) break;
			}
		}
		rep(i,3) {
			if (front == lab[1]) break;
			rR();
		}
		return lab[2];
	}
	bool check(Dice &D) {
		int i;
		rep(i,6) {
			if (lab[i] != D.lab[i]) return false;
		}
		return true;
	}
	bool equal(Dice &D) {
		int i;
		rep(i,3) {
			rN();
			if (lab[0] == D.lab[0]) break;
			rW();
			if (lab[0] == D.lab[0]) break;
		}
		rep(i,4) {
			if (check(D)) return true;
			rR();
		}
		return false;
	}
};


int main() {
	Dice dice1, dice2;
	int i;
	rep(i,6) cin >> dice1.lab[i];
	rep(i,6) cin >> dice2.lab[i];

	//process
	cout << (dice1.equal(dice2) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1160
class node():
    def __init__(self, key, parent, left, right):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

root = None

def insert(z):
    global root

    y = None
    x = root

    while x != None:
        y = x

        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(key):
    
    x = root
    answer = "no"

    while x != None:

        if key == x.key:
            answer = "yes"
            break

        if key < x.key:
            x = x.left
        else:
            x = x.right
    
    return answer

def Inorder_TreeWalk(node):
    if node is None:
        return

    Inorder_TreeWalk(node.left)
    print(" " + str(node.key), end="")
    Inorder_TreeWalk(node.right)

def Preorder_TreeWalk(node):
    if node is None:
            return
            
    print(" " + str(node.key), end="")
    Preorder_TreeWalk(node.left)
    Preorder_TreeWalk(node.right)

def Main():
    
    n = int(input())
    global root

    for i in range(n):
        inp = input().split()
        ope = inp[0]

        if ope == "insert":
            insert(node(int(inp[1]), None, None, None))
        
        elif ope == "find":
            print(find(int(inp[1])))

        elif ope == "print":
            Inorder_TreeWalk(root)
            print()
            Preorder_TreeWalk(root)
            print()
        else:
            pass
Main()


Measured memory_bytes: 85264
#include<stdio.h>
int main(void){
int a,b;
int d,r;
double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#define  ll long long
using namespace std;
ll dp[105][100005];
int main(){
int n,wt;
cin>>n>>wt;
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
	int w,v;
	cin>>w>>v;
	for(int j=0;j<=wt;j++){
		if(j-w>=0)
		dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v);
		else
		dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][wt];

return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        if(ans>k) ans+=k;
        else ans*=2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll factorial[201000];
ll invfactorial[201000];

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

ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD; 
	return ret;
}
int main(void){
    ll n;
    cin >> n;
    vector<ll> c(n);

    factorial[0] = 1;

    for (int i = 1; i < 201000; i++){
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    for (int i = 0; i < 201000; i++){
        ll x, y;
        ll g = extGCD(factorial[i], MOD, x, y);
        while (x < 0) x += MOD;
        x %= MOD;
        invfactorial[i] = x;
    }

    ll ans = 0;
    for(int i = 0; i < n; i++) cin >> c[i];

    sort(all(c));

    for(int i = 0; i < n; i++){
        ll tmpans = modpow(2LL, n - 1 - i);
        tmpans += modpow(2LL, n - i - 2) * (n - 1 - i);
        tmpans %= MOD;
        tmpans *= modpow(2LL, i);
        tmpans %= MOD;
        tmpans *= c[i];
        tmpans %= MOD;
        ans += tmpans;
        ans %= MOD;
    }

    cout << ans * modpow(2LL, n) % MOD << endl;

}   

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    rep(i,n) {
        cin >> a[i];
        if(a[i]%2 == 0) cnt++;
    }
    int ans = pow(3,n);
    ans -= pow(2,cnt);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype> //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646> //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal> //信号机制支持
#include <csetjmp> //异常处理支持
#include <cstdarg> //不定参数列表支持
#include <cstddef> //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale> //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory> //STL通过分配器进行的内存分配
#include<new> //动态内存分配
#include <numeric> //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator> //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo> //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray> //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;
 
const int maxn = 1e3 + 20;
int vis[maxn],n;
double x[maxn],y[maxn],r[maxn],dist[maxn],mp[maxn][maxn];
 
void SPFA(int s)
{
    queue<int>q;
    for(int i = 1;i <= n;i++) dist[i] = 1e10;
    memset(vis,0,sizeof(vis));
    while(!q.empty()) q.pop();
    dist[s] = 0;
    vis[s] = 1;
    q.push(s);
 
    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        vis[v] = 0;
        for(int i = 1;i <= n;i++)
        {
            if(dist[i] > dist[v] + mp[v][i])
            {
                dist[i] = dist[v] + mp[v][i];
                if(!vis[i])
                {
                    vis[i] = 1;
                    q.push(i);
                }
            }
        }
    }
}
 
int main()
{
    while(scanf("%lf%lf%lf%lf",&x[1],&y[1],&x[2],&y[2]) != EOF)
    {
        scanf("%d",&n);
        n += 2;
        r[1] = r[2] = 0;
        mp[1][2] = mp[2][1] = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2]));
        for(int i = 3;i <= n;i++)
        {
            scanf("%lf%lf%lf",&x[i],&y[i],&r[i]);
        }
        for(int i = 1;i <= n;i++)
        {
            for(int j = 1;j <= n;j++)
            {
                mp[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
                mp[i][j] -= r[i] + r[j];
                if(mp[i][j] < 0)
                {
                    mp[i][j] = 0;
                }
            }
        }
        SPFA(1);
        printf("%.10f\n",dist[2]);
    }
    return 0;
}


Measured memory_bytes: 11836
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
st = input().split()
s = st[0]
t = st[1]

ans = ''
for i in range(n):
    ans += s[i] + t[i]

print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    string S;
    int o;
    cin>>S;
    string str[3]={"Sunny","Cloudy","Rainy"};
    rep(i,3){
        if(S==str[i]){
        cout<<str[(i+1)%3]<<endl;
        return 0;
        }
    }
    return 0;
}

//a=97,z=122

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

int main()
{
    ios::sync_with_stdio();cin.tie(0);cout.tie(0);
    #define pb push_back
    #define mk make_pair
    //#define int long long int
    float r;
    cin>>r;
    cout<<setprecision(20)<<fixed<<2*r*3.141592653589793238<<endl;



    return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main() {
	int a,b,c;
	int cal = 0;
	cin >> a >> b >> c;
	for (; a <= b; a++) {
		if (c%a == 0)
			cal++;
	}
	cout << cal << endl;
}

Measured memory_bytes: 1160
def solve(input)
  a = 0
  input.split("\n").each do |s|
    is_palindrome = true
    i1 = 0
    i2 = s.size - 1
    while i1 <= i2
      unless s[i1] == s[i2]
        is_palindrome = false
        break
      end
      i1 += 1
      i2 -= 1
    end
    if is_palindrome
      a += 1
    end
  end
  a
end

puts solve(gets(nil))

Measured memory_bytes: 6096
/**
*    author:  yuya1234
*    created: 26.06.2020 16:07:37
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n;
    ll a[100010];

    cin>>n;
    REP(i,n)cin>>a[i];

    ll cnt=1;
    int status=0,tmp=a[0];

    REP(i,n)
    {
        if(status==0)
        {
            if(tmp<a[i])status=1;
            else if(tmp>a[i])status=-1;
        }
        else if(status==1)
        {
            if(tmp>a[i])
            {
                status=0;
                cnt++;
            }
        }
        else
        {
            if(tmp<a[i])
            {
                status=0;
                cnt++;
            }
        }
            tmp=a[i];
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 4396
import sys

N=int(sys.stdin.readline())

A=[int(i) for i in sys.stdin.readline().split()]

Q=int(sys.stdin.readline())

ans=sum(A)

arr=[0]*(pow(10,5)+1)

for g in range(N):
	arr[A[g]]+=1

for q in range(Q):
	[B,C]=[int(x) for x in sys.stdin.readline().split()]
	ans=ans+arr[B]*(-B+C)
	arr[C]+=arr[B]
	arr[B]=0
	print(ans)


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

public class Test
{
	public static void Main()
	{
		var cards = new[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1 }
			.Select((v, s) => new Card { Value = v, Strength = s });
		var AB = Console.ReadLine().Split().Select(int.Parse);
		int A = AB.First(), B = AB.Last();
		int strength_A = cards.Where(item => item.Value == A).First().Strength;
		int strength_B = cards.Where(item => item.Value == B).First().Strength;
		if (strength_A > strength_B)
		{
			Console.WriteLine("Alice");
		}
		else if (strength_A == strength_B)
		{
			Console.WriteLine("Draw");
		}
		else
		{
			Console.WriteLine("Bob");
		}
	}
}

public class Card
{
	public int Value { get; set; }
	public int Strength { get; set; }
}

Measured memory_bytes: 13524
def main():

    n,x=list(map(int,input().split()))
    point=list(map(int,input().split()))

    jump=[0]
    sum=0
    for i in range(n):
        sum+=point[i]
        jump.append(sum)

    count=0
    for k in range(n+1):
        if jump[k]<=x:
            count+=1
    print(count)

    
if __name__=="__main__":
    main()

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

int main() {
        int m, f, b;
        int r;

        cin >> m >> f >> b;

        r = b - m;

        if (r > f) {
                cout << "NA" << endl;
        }
        else {
                cout << max(0, r) << endl;
        }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int n;
  cin>>n;
  //vector<int> a(n);
  int ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if((i+1)%2==1 && a%2==1)ans++;
  }
  cout<<ans<<"\n";

  
  
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(N), B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  vector<int64_t> C(N + 1, 0), D(M + 1, 0);
  for (int i = 0; i < N; i++) {
    C[i + 1] += C[i] + A[i];
  }
  for (int i = 0; i < M; i++) {
    D[i + 1] += D[i] + B[i];
  }
  int res = 0;
  for (int i = 0; i < N + 1; i++) {
    if (K - C[i] < 0) break;
    int j = upper_bound(D.begin(), D.end(), K - C[i]) - D.begin();
    res = max(res, i + j - 1);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 7944
import queue

n = int(input())
links = [set() for _ in [0] * n]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    links[u].add((v, w))
    links[v].add((u, w))
ans = [-1] * n
q = queue.Queue()
q.put((0, 0, -1))
while not q.empty():
    v, d, p = q.get()
    if d % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u, w in links[v]:
        if u == p:
            continue
        q.put((u, d + w, v))
for i in ans:
    print(i)


Measured memory_bytes: 51348
#include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define all(x) (x).begin(), (x).end()
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int MOD = 1e9 + 7;
int a, b, n;
vector <int> v;
string ans;

int main()
{
    cin >> a >> b;
    if(a <= b)
    {
        cout << "Impossible" << endl;
        fflush(stdout);
        exit(0);
    }

    v.pb(0);
    n = a + b;
 	rep(i, 1, n - 1)
    {
        if(v.empty()) {v.pb(i); continue;}
        cout << "? " << v.back() << " " << i << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == 'N') v.pop_back();
        else v.pb(i);
    }

    ans = "!";

 	rep(i, 0, n - 1)
    {
        cout << "? " << v.back() << " " << i << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == 'N') ans += '0';
        else ans += '1';
    }
    cout << ans << endl;
    fflush(stdout);
}


Measured memory_bytes: 820
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int n;

int gcd(int m, int n) {
  return n == 0 ? m : gcd(n, m % n);
}

int solve(vector<int>& a) {
  int ret = a.front();
  for (int i = 1; i < n; i++) {
    ret = gcd(ret, a[i]);
  }
  return ret;
}

int main() {
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  cout << solve(a) << endl;
}


Measured memory_bytes: 640
import sys
a, b, c=map(int, input().split())
k=int(input())
while(k>=1 and a>=b):
    b=b*2
    k=k-1
if a>=b:
    print("No")
    sys.exit()
while(k>=1 and b>=c):
    c=c*2
    k=k-1
if b>=c:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 61648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    long gcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }

    public void solve() throws IOException {
        int t = nextInt();
        for (int tt = 0; tt < t; tt++) {
            long a = nextLong(), b = nextLong(), c = nextLong(), d = nextLong();
            if (a < b) {
                out.println("No");
            } else if (a % b > c) {
                out.println("No");
            } else if (d < b) {
                out.println("No");
            } else if(c >= b){
                out.println("Yes");
            } else if(d % b == 0){
                out.println("Yes");
            }else{
                a %= b;
                d %= b;
                long gcd = gcd(d, b);
                if(b - c > d){
                    out.println("No");
                }else if(b - c > gcd){
                    out.println("No");
                }else if((a + gcd - 1)/gcd*gcd - a < b - c && (a + gcd - 1)/gcd*gcd - a != 0){
                    out.println("No");
                }else{
                    out.println("Yes");
                }
            }

        }
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    public void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k;
    cin >> n >> k;
    map<ll,ll> mp;
    rep(i,k){
        ll d;
        cin >> d;
        rep(j,d){
            ll a;
            cin >> a;
            mp[a]++;
        }

    }

    cout << n - mp.size() << endl;

}

Measured memory_bytes: 3636
n = gets.to_i
n.times do
  xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f)
  d = Math.sqrt( (xa - xb) ** 2 + (ya - yb) ** 2 )
  if ra > rb + d then
    puts 2
  elsif rb > ra + d then
    puts -2
  elsif d <= ra + rb then
    puts 1
  else
    puts 0
  end
end

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

int main() {
	string n; cin >> n;
	bool b = false;
	for (char& c : n) {
		if (c == '7') {
			b = true;
			break;
		}
	}
	cout << (b ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3628
n = gets.to_i
v = gets.chomp.split(" ").map(&:to_i)
v.sort!
(n-2).times{
  avg = (v[0]+v[1])/2.0
  v.delete_at(0);v.delete_at(0)
  v.push(avg)
  v.sort!
}
print (v[0]+v[1])/2.0

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll M,N;
  cin >> N >> M;
  string S[55],T[55];
  rep(i,N){
    cin >> S[i];
  }
  rep(i,M){
    cin >> T[i];
  }
  rep(i,N-M+1){
    rep(j,N-M+1){
      ll X=0;
      Rep(k,i,i+M){
        Rep(l,j,j+M){
          if(S[k][l]!=T[k-i][l-j]){
            X=1;
          }
        }
      }
      if(X==0){
        cYes;
        return 0;
      }
    }
  }
  cNo;
}

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

int main() {
  ll n, m, ans;
  cin >> n >> m;
  if (n == 1 && m == 1)
    ans = 1;
  else if (n == 1)
    ans = m - 2;
  else if (m == 1)
    ans = n - 2;
  else
    ans = (n - 2) * (m - 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

maxn = 100000

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

par = [0] * n
rank = [0] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
    elif rank[rx] > rank[ry]:
        par[ry] = rx
    else:
        par[ry] = x
        rank[rx] += 1

a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
ans = 0
for i in range(m):
    for j in range(n):
        par[j] = j
        rank[j] = 0
        
    for j in range(m):
        if i == j:
            continue
        unite(a[j],b[j])
        
    l = [find(k) for k in range(n)]
    fl = 1
    
    for j in range(n-1):
        if l[j] != l[j+1]:
            fl = 0
            
    if fl == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 42992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	string ans = "OK";
	for(int i= a; i <= b; i++) {
		if(i%k == 0) {
		cout << ans << endl;
		return 0;
		}
	}
	ans = "NG";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<utility>
#include<vector>

#define MOD   998244353
#define F_MAX 333333
long long mod_div(long long a, long long b)
{
	if(a % b == 0)
	{
		return a / b;
	}
	/*
	p is prime,(b,p)=1   ⇒   b^(p-1)≡1     (mod p)
	                     ⇒   a*b^(p-1)≡a   (mod p)
	                     ⇒   a*b^(p-2)≡a/b (mod p)
	*/
	long long index = MOD - 2, power = 1;
	while(index > 0)
	{
		if(index & 1)
		{
			power *= b;
			power %= MOD;
		}
		b *= b;
		b %= MOD;
		index >>= 1;
	}
	return a * power % MOD;
}
long long combination(long long n, long long r)
{
	if(n < r || n < 0 || r < 0)
	{
		return -1;
	}
	static std::vector<long long>factorial_mod(F_MAX);
	if(factorial_mod[0] != 1)
	{
		factorial_mod[0] = 1;
		for(long long i = 1; i < F_MAX; i++)
		{
			factorial_mod[i] = (factorial_mod[i - 1] * i) % MOD;
		}
	}
	long long numerator = factorial_mod[n];
	long long denominator = (factorial_mod[r] * factorial_mod[n - r]) % MOD;
	return mod_div(numerator, denominator);
}

signed main()
{
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for(long long x = 0; x <= n; x++)
	{
		if((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if(0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for(auto i : pairs)
	{
		ans += combination(n, i.first) * combination(n, i.second) % MOD;
		ans %= MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7168
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] numList = new char[9];
		for(int i = 0; i < 3 ; i++){
			String tmp = sc.next();
			char a = tmp.charAt(i);
			numList[i] = a;
		}
		System.out.println(String.valueOf(numList[0]) + String.valueOf(numList[1]) + String.valueOf(numList[2]));
		
	}
}

Measured memory_bytes: 22484
d,n=map(int,input().split())
# # nは1<=n<=100

s=1
if d==1:
    s=100
elif d==2:
    s=10000

if s==1:
    ans=[i for i in range(1,100)]
    ans.append(101)
elif s==100:
    ans=[100*i for i in range(1,100)]
    ans.append(10100)

else:
    ans=[10000*i for i in range(1,100)]
    ans.append(1010000)

print(ans[n-1])

Measured memory_bytes: 9076
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int a=0;

		Array.Sort(s,ca);

		for(int i=1;i<s.Length;i++){
			a+=s[i]-s[i-1];
		}

		Console.WriteLine(a);
	}
	static int ca(int a,int b){
		if(a>b){return 1;}
		else if(a<b){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 13268
n = int(input())
R = [0]*n
for i in range(n):
    R[i] = int(input())

sub = R[1] - R[0]
minimum = R[0]

for j in range(1,n):
    sub = max(sub, R[j] - minimum)
    minimum = min(minimum,R[j])
    
print(str(sub))


Measured memory_bytes: 13376
s = input()
x, y = map(int,input().split())

s = s.split("T")
s = [len(e) for e in s]
a = []
b = []
for i, s in enumerate(s):
    if i % 2 == 0:
        a.append(s)
    else:
        b.append(s)

x -= a.pop(0)
ans = True

dpx = [[False] * (2*abs(x) + 1) for _ in range(len(a) + 1)]
dpx[0][abs(x)] = True

for i in range(1,len(a)+1):
    for j in range(2*abs(x) + 1):
        if j + a[i-1] < 2*abs(x) + 1:
            dpx[i][j] |= dpx[i-1][j+a[i-1]]
        if j - a[i-1] >= 0:
            dpx[i][j] |= dpx[i-1][j-a[i-1]]

ans &= dpx[len(a)][x+abs(x)]

dpy = [[False] * (2*abs(y) + 1) for _ in range(len(b) + 1)]
dpy[0][abs(y)] = True

for i in range(1, len(b) + 1):
    for j in range(2*abs(y) + 1):
        if j + b[i-1] < 2*abs(y) + 1:
            dpy[i][j] |= dpy[i-1][j+b[i-1]]
        if j - b[i-1] >= 0:
            dpy[i][j] |= dpy[i-1][j-b[i-1]]

ans &= dpy[len(b)][y+abs(y)]

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 318216
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4;
  h*=2;
  int p=min(min(q,h),s);
  int ans=0;
  if(p*2>d){
    ans+=n/2*d;
    if(n%2) ans+=p;
  }else ans=n*p;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var s,t string
	Fscan(in, &s,&t)
	if strings.HasPrefix(t,s) {
		Fprintln(out, "Yes")
	} else {
		Fprintln(out, "No")
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1824
#include <stdio.h>

#define N 100

int main(){
  int n,u,k,i,j,v,a[N+1][N+1]={0};
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }
  for(i=1; i<=n; i++){
    for(j=1; j<=n-1; j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][j]);
  }
  return 0;
}



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

int main()
{
    int H, W;
    string s[100];
    cin >> H >> W;
    for(int i = 0; i < H; i++) cin >> s[i];

    bool h[100], w[100];
    for(int j = 0; j < W; j++) w[j] = false;
    for(int i = 0; i < H; i++){
        h[i] = (s[i].find('#') != -1 ? true : false);
        
        for(int j = 0; j < W; j++){
            if(s[i][j] == '#') w[j] = true;
        }
    }
    
    for(int i = 0; i < H; i++){
        if(!h[i]) continue;
        for(int j = 0; j < W; j++){
            if(!w[j]) continue;
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int main(int argc, char** argv)
{
        int n;
        long long t[1000] = {}, a[1000] = {};
        scanf("%d", &n);
        for(int i = 0; i < n; i++){
            scanf("%lld%lld", &t[i], &a[i]);
        }

        long long tCnt = t[0], aCnt = a[0];

        for(int i = 1; i < n; i++){
            long long lo = 1ll;
            long long hi = (1000000000000000000ll + max(t[i], a[i]) - 1) / max(t[i], a[i]);

            while(lo != hi){
                long long mi = (lo + hi) / 2;

                if(mi * t[i] >= tCnt && mi * a[i] >= aCnt) hi = mi;
                else lo = mi + 1;

            }
            tCnt = t[i] * lo;
            aCnt = a[i] * lo;
        }

        printf("%lld", tCnt + aCnt);

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  double a[100];

  cin>>n;
  rep(i,0,n) cin>>a[i];
  double cnt=0;

  rep(i,0,n) cnt+=(1/a[i]);

  cout<<1/cnt<<endl;
}

Measured memory_bytes: 256
from collections import deque

def bfs(maze, sy, sx):
    gy, gx = H - 1, W - 1
    q = deque([[sy, sx]])
    visited[sy][sx] = 1
    #print(sy, sx, gy, gx)
    now = 0
    while q:
      y, x = q.popleft()
      if (y, x) == (gy, gx):
        return visited[y][x]
      for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        new_y, new_x = y + j, x + k #改行して条件文を続けるときにバックスラッシュ
        if (0 <= new_y <= H - 1) and (0 <= new_x <= W - 1):
          if maze[new_y][new_x] == "." and visited[new_y][new_x] > 10 ** 5:#まだ来たことない点だったという条件
            visited[new_y][new_x] = visited[y][x] + 1
            q.append([new_y, new_x])
    return 0

          
if __name__ == "__main__":
    H, W = map(int, input().split())
    maze = [[0] * W for i in range(H)]
    count = 0
    for i in range(H):
      s = str(input())
      for j in range(W):
        maze[i][j] = s[j]
        if s[j] == ".":
          count += 1
    visited = [[float("inf")] * W for j in range(H)]
    ans = bfs(maze, 0, 0)
    if ans == 0:
      print(-1)
    else:
      print(count - ans)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 1000010
#define INF int(2e9 + 9)
#define BIG_INF ll(1e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")


ll n, a[SIZE];

bool used[SIZE];

int cnt[SIZE];

int A, B, C, D;

ll pref[SIZE];


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;


    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i]) {cout << "No\n"; return 0;}
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3596