akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int oddNum = 0;
		int fourM = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(a[i] % 2 == 1) {
				oddNum++;
			} else if(a[i] % 4 == 0) {
				fourM ++;
			}
		}
		if((oddNum + fourM == n && oddNum <= fourM + 1)
			|| (oddNum + fourM < n && oddNum <= fourM)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 48436
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= n; i++)
            {
                if ( i % 3 != 0 && i % 5 != 0 ) sum += i;
            }
            System.Console.WriteLine(sum);
        }
    }
}



Measured memory_bytes: 27540
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define ll long long
#define endl "\n" 
constexpr int N = 1e5 + 10;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T > inline void out(T s) { cout << s << "\n"; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
int m, d;
int f(int x) {
	int a = x / 10, b = x % 10;
	if (a >= 2 && b >= 2) return a * b;
	return -1;
}
void run() {
	int res = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= d; ++j) {
			if (f(j) == i) ++res;
		}
	}
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> m >> d) run();
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] arugs){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] A = new double[N];
		double ans = 0;
		double sum = 0;
		double result = 0;
		
		for(int i=0; i<N; i++){
			A[i] = sc.nextDouble();
		}
		
		for(int j=0; j<N; j++){
			ans = 1/A[j];
			sum += ans;
			ans = 0;
		}
		
		result = 1/sum;
		
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    L = [0] * M
    R = [0] * M
    for i in range(M):
        L[i], R[i] = map(int, input().split())

    ans = min(R) - max(L) + 1
    print(max(0, ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 75632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS;
	ll n, h , w;
	cin >> n >> h >> w;
	ll cnt = 0;
	REP(i, n){
		ll x, y;
		cin >> x >> y;
		if(x >= h && y >= w)cnt++;
	}
	dump(cnt);
}


Measured memory_bytes: 256
n=int(input())
f=[2-x%2 for x in range(n+1)]
s=5
for c in range(3,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
if n==1:
    print(1)
elif n==2:
    print(5)
else:
    print(s)

Measured memory_bytes: 219216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int h[110];

void mizu(int l) {
  while (h[l] != 0) {
    h[l]--;
    l++;
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) { cin >> h[i]; }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    while (h[i] != 0) {
      mizu(i);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
if __FILE__ == $0
  while line = gets
    data = line.split(',').map{|i| i.to_i}
    rail_length = data[0..-3].inject(:+)
    cross_point = rail_length * (data[-2].to_f / (data[-2] + data[-1]).to_f)
    section = 0
    len_acc = 0
    while true
      if len_acc >= cross_point 
        break
      end
      len_acc += data[section]
      section += 1
    end
    puts section
  end
end

Measured memory_bytes: 6124
n=int(input())
h=list(map(int, input().split()))
ans=1
for i in range(1,n):
    s=False
    for j in range(i):
        if h[i]>=h[j]:
            s=True
        else:
            s=False
            break
    if s==True:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin>>s;
    lli i=0;
    lli ans=0;
    if(s.size()==1){ 
        out(0);
        return 0;
    }
    while (true){ 
        if(i>=s.size()-1){ 
            break;
        }
        if(s[i]!=s[i+1]){ 
            ans+=2;
            if (i+1<s.size()-1) {
                s.erase(i, 2);
                i=0;
            }
            else{ 
                break;
            }


        }
        else{ 
            i++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3696
#include<iostream>
#include<map>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		mp[a] = 1 - mp[a];
	}
	for(auto&& i : mp){
		ans += i.second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
package main

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

const dft = -1

var match = [9]int{2, 5, 5, 4, 5, 6, 3, 7, 6}

type sortRunes []rune

func (s sortRunes) Len() int           { return len(s) }
func (s sortRunes) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortRunes) Less(i, j int) bool { return s[i] > s[j] }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, m)
	for i := range a {
		fmt.Scan(&a[i])
	}

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = dft
	}
	dp[0] = 0

	for i := range dp {
		if dp[i] == dft {
			continue
		}
		for _, v := range a {
			mv := match[v-1]
			if i+mv > n {
				continue
			}
			if dp[i+mv] == dft || dp[i]+1 > dp[i+mv] {
				dp[i+mv] = dp[i] + 1
			}
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	wr := bufio.NewWriter(os.Stdout)
	for i := n; i > 0; {
		for _, v := range a {
			mv := match[v-1]
			if i-mv >= 0 && dp[i-mv] == dp[i]-1 {
				wr.WriteString(strconv.Itoa(v))
				i -= mv
				break
			}
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


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

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

    int sum = x + (x-1);
    int sum2 = y + (y-1);
    int sum3 = x + y;

    cout << max(sum, max(sum2, sum3)) << endl;

    return 0;
}


Measured memory_bytes: 256
INF = float('inf')
class BellmanFord:
    
    def bellmanford(self,s,V,E):
        dist = [INF for _ in range(V)]
        dist[s] = 0
        for i in range(V):
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    if i == V-1 and v == V-1:
                        return -1
        return dist
    

def main():
    N,M = map(int,input().split())
    E = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        E.append((a,b,-c))
    bf = BellmanFord()
    dist = bf.bellmanford(0,N,E)
    if dist == -1:
        print('inf')
    else:
        ans = dist[-1]
        print(-ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	int q; cin >> q;
	ll Y = 0;
	ll L = 0;
	ll R = 0;
	priority_queue<ll> Max;
	priority_queue<ll, vector<ll>, greater<ll>> Min;
	while (q--) {
		int z; cin >> z;
		if (z == 1) {
			ll x, y; cin >> x >> y;
			Y += y;
			if (Max.size() <= Min.size()) {
				Max.push(x);
				L += x;
			}
			else {
				Min.push(x);
				R += x;
			}
			if (!Max.empty() && !Min.empty() && Max.top() > Min.top()) {
				ll tmp = Max.top();  Max.pop();
				ll tmp1 = Min.top(); Min.pop();
				L = L - tmp + tmp1;
				R = R - tmp1 + tmp;
				Min.push(tmp); Max.push(tmp1);
			}
		}
		else {
			ll SSum = Y + (Max.top() * Max.size()) - L + R - (Min.size() * Max.top());
			cout << Max.top() << ' ' << SSum << '\n';
		}
	}
}


Measured memory_bytes: 3828
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n);
    REP(i,n){
        cin >> a[i];
    }
    double x = 0;
    REP(i,n){
        x+=(double)1/(double)a[i];
    }
    x = 1.0/x;
    printf("%.6f\n",x);

    return 0;
}

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

int32_t main()
{
    int n;
    cin>>n;

    int a[n];
    int l[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        l[i] = 0;
    }
    int maxi = 0;
    for(int i=1;i<n;i++){
        if(a[i] <= a[i-1]) l[i] = 1 + l[i-1];
        if(l[i] > maxi) maxi = l[i];
    }
    cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
a = gets.chomp.split(" ").map!{|i| i.to_i}
b = []
n.times do |j|
  if j % 2 == 0
    b.push(a[j])
  else
    b.unshift(a[j])
  end
end
if n % 2 == 0
  puts b.join(" ")
else
  puts b.reverse.join(" ")
end


Measured memory_bytes: 27360
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    string S;
    cin >> S;
    vector<char> v;
    FOR(i, 0, 4)
    v.push_back(S[i]);
    sort(ALL(v));
    Yes(v[0] == v[1] && v[2] == v[3] && v[1] != v[2]);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll dp[101010];
ll MOD = 1e9 + 7;

int main()
{

    int n, k;
    cin >> n;
    cin >> k;
    int p[n];

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

    for (int i = 0; i < k + 1; ++i)
    {
        int lose = 0, cnt = 0;
        for (int j = 0; j < n; ++j)
        {
            if (0 <= i - p[j])
            {
                cnt++;
                if (!dp[i - p[j]])
                    lose++;
            }
        }
        if (cnt == 0)
            dp[i] = 0;
        else if (0 < lose)
            dp[i] = 1;
        else
            dp[i] = 0;
    }
    dp[k] ? (cout << "First" << endl)
          : (cout << "Second" << endl);
}

Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];

	const result = line0.replace(/\?/g, 'D');
	// console.log({
	// 	input: input,
	// 	inputLines: inputLines,
	// 	line0: line0,
	// 	result: result
	// });
	console.log(result);

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];


// P?P
	// PPP PD: 0, D: 0 => 0
	// PDP PD: 1, D: 1 => 1
// P?D
	// PPD PD: 1, D: 1 => 2
	// PDD PD: 1, D: 2 => 3
// D?P
	// DPP PD: 0, D: 1 => 1
	// DDP PD: 0, D: 2 => 2
// D?D
// ??P
// ??D
// P??
// D??
// ???



	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)

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

int rnk[200200];
int par[200200];

void init(int n)
{
    for (int i = 0;i < n;i++)
    {
        rnk[i] = 1;
        par[i] = i;
    }
}

int root(int x)
{
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
}

void unite(int x, int y)
{
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return ;
    if (rnk[rx] < rnk[ry])
    {
        par[rx] = ry;
    }else
    {
        par[ry] = rx;
        if (rnk[rx] == rnk[ry])rnk[rx]++;
    }
}

bool same(int x,int y)
{
    return root(x) == root(y);
}

int main()
{
    int n, m;
    int x[100100], y[100100], z[100100];
    
    cin >> n >> m;
    init(n);
    for (int i = 0;i < m;i++)
    {
        cin >> x[i] >> y[i] >> z[i];
        x[i] --;
        y[i] --;
        unite(x[i], y[i]);
    }

    int cnt = 0;
    bool f[100100];
    for (int i = 0;i < n;i++) f[i] = false;
    for (int i = 0;i < n;i++)
    {
        f[root(i)] = true;
    }

    for (int i = 0;i < n;i++)
    {
        if (f[i]) cnt ++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 2304
H, W, K = map(int, input().split())  # H行W列, K個のいちご

cake = [input() for _ in range(H)]
# for c in cake:
#     print(*c)
cake_row_count = 0
field = 1
tmp = []
ans = [[0]*W for _ in range(H)]
done_y = 0
for i in range(H):
    if "#" not in cake[i]:  # いちごがない場合は処理の対象になる
        tmp.append(cake[i])
    elif cake_row_count == 0:  # 初めてのいちごが見つかった時
        tmp.append(cake[i])
        cake_row_count += 1
    elif cake_row_count == 1:  # 2回目のいちごがみつかったとき処理に入る
        # 処理を始める, 最後にtmpをcake[i]で初期化して終わる
        for j in range(len(tmp)):  # 行に関するループ
            if "#" not in tmp[j]:
                continue
            # いちごがあるtmp[j]にいきついたら処理をしていく

            # いちごが見つかったらグループ分けしていく
            strawberry_counter = tmp[j].count("#")
            separete_strawberry = tmp[j].split("#", strawberry_counter-1)
            for k in range(len(separete_strawberry)-1):
                separete_strawberry[k] += "#"
            # print(separete_strawberry)
            # 横方向への分割の仕方が決まった
            done_x = 0
            for sep in separete_strawberry:
                for y in range(len(tmp)):
                    for x in range(len(sep)):
                        ans[y+done_y][x+done_x] = field
                field += 1
                done_x += len(sep)
            done_y += len(tmp)
        tmp = [cake[i]]

# 最後の1回が実行されないケースがあるから実行する
for j in range(len(tmp)):  # 行に関するループ
    if "#" not in tmp[j]:
        continue
    # いちごがあるtmp[j]にいきついたら処理をしていく

    # いちごが見つかったらグループ分けしていく
    strawberry_counter = tmp[j].count("#")
    separete_strawberry = tmp[j].split("#", strawberry_counter-1)
    for k in range(len(separete_strawberry)-1):
        separete_strawberry[k] += "#"
    # print(separete_strawberry)
    # 横方向への分割の仕方が決まった
    done_x = 0
    for sep in separete_strawberry:
        for y in range(len(tmp)):
            for x in range(len(sep)):
                ans[y+done_y][x+done_x] = field
        field += 1
        done_x += len(sep)
    done_y += len(tmp)
tmp = [cake[i]]
for a in ans:
    print(*a)


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define vl vector<ll> 
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll h,w;
    cin>>h>>w;
    char ch[h][w];
    char a[h][w];
    loop(i,0,h){
        loop(j,0,w){
            cin>>ch[i][j];
            a[i][j]=ch[i][j];
        }
    }

    loop(i,0,h){
        bool y=true;
        for(ll j=0;j<w&& y==true;j++){
            if(ch[i][j]!='.'){
                y=false;
            }
        }
        if(y==true){
            loop(j,0,w){
                a[i][j]='*';
            }
        }
    }
    loop(i,0,w){
        bool y=true;
        for(ll j=0;j<h && y==true;j++){
            if(ch[j][i]!='.'){
                y=false;
            }
        }
        if(y==true){
            loop(j,0,h){
                a[j][i]='*';
            }
        }
    }
    loop(i,0,h){
        bool p=false;
        loop(j,0,w){
            if(a[i][j]!='*'){
                cout<<a[i][j];
                p=true;
            }
        }
        if(p==true) cout<<endl;
    }

}

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n, tmp = 0, sum = 0;
    cin >> n;
    int a[n], ans[n];
    rep(i, n) {
        cin >> a[i];
        if (i % 2 == 0)
            tmp += a[i];
        sum += a[i];
    }
    ans[0] = tmp * 2 - sum;
    rep(i, n) {
        if (i != 0)
            ans[i] = (a[i - 1] - (ans[i - 1] / 2)) * 2;
        printf("%d ", ans[i]);
    }
}

Measured memory_bytes: 2048
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    string s;
    cin >> s;

    s[3] = '8';


    cout << s << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A, B, C;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
  
  	if(A==5 && B==7 && C==5){
      printf("YES");
    }else if(A==7 && B==5 && C==5){
      printf("YES");
    }else if(A==5 && B==5 && C==7)
      {printf("YES");
    }else{
      printf("NO");
    }
    
    return 0;
}

Measured memory_bytes: 128
unittest
{
	assert( [ "4", "abcd" ].parse.expand.solve == 15 );
	assert( [ "3", "baa" ].parse.expand.solve == 5 );
	assert( [ "5", "abcab" ].parse.expand.solve == 17 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	const MOD = 10L ^^ 9 + 7;
	
	// 文字ごとに個数を集計して、文字ごとのケース数（i番目を選ぶor何も選ばない）を掛け算して、全文字選ばない1ケースを除外
	return reduce!( ( a, b ) => a * ( b[ 1 ] + 1 ) % MOD )( 1L, s.sort().group ) - 1;
}


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class ALDS1_12_A
{
    public struct Node
    {
        public int Id;
        public int ParentId;
        public List<int> Children;
        public List<Tuple<int, int>> Adj;
        public bool Checked;
        public Node(int id)
        {
            Id = id;
            ParentId = -2;
            Children = new List<int>();
            Adj = new List<Tuple<int, int>>();
            Checked = false;
        }
    }

    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());

        var nodes = new Node[n];
        for (int i = 0; i < n; i++)
        {
            nodes[i] = new Node(i);
        }

        for (int i = 0; i < n; i++)
        {
            int[] val = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            for (int j = 0; j < n; j++)
            {
                if (val[j] != -1)
                {
                    nodes[i].Adj.Add(new Tuple<int, int>(j, val[j]));
                }
            }
        }

        // root
        nodes[0].ParentId = -1;

        int d = 0;
        while (true)
        {
            var queue = new Queue<int>();
            queue.Enqueue(0);
            for (int i = 0; i < n; i++)
            {
                nodes[i].Checked = false;
            }
            int addD = Bfs(nodes, queue);
            if (addD == -1)
            {
                break;
            }
            d += addD;
        }
        Console.WriteLine(d.ToString());
    }

    public static int Bfs(Node[] nodes, Queue<int> queue)
    {
        int d = -1;
        int parent = -1;
        int target = -1;
        while (queue.Count > 0)
        {
            var i = queue.Dequeue();
            nodes[i].Checked = true;
            for (int j = 0; j < nodes[i].Adj.Count; j++)
            {
                var child = nodes[nodes[i].Adj[j].Item1];
                if (child.Checked)
                {
                    continue;
                }
                if (child.ParentId < 0)
                {
                    if (d == -1 || nodes[i].Adj[j].Item2 < d)
                    {
                        d = nodes[i].Adj[j].Item2;
                        parent = i;
                        target = nodes[i].Adj[j].Item1;
                    }
                }
                else
                {
                    queue.Enqueue(nodes[i].Adj[j].Item1);
                }
                child.Checked = true;
            }
        }
        if (d != -1)
        {
            nodes[target].ParentId = parent;
            nodes[parent].Children.Add(target);
        }
        return d;
    }
}



Measured memory_bytes: 17632
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define repi(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  string a;
  cin >> a;
  
  if(a == "SSS") cout << 0 << endl;
  if(a == "SSR") cout << 1 << endl;
  if(a == "SRS") cout << 1 << endl;
  if(a == "RSS") cout << 1 << endl;
  if(a == "SRR") cout << 2 << endl;
  if(a == "RSR") cout << 1 << endl;
  if(a == "RRS") cout << 2 << endl;
  if(a == "RRR") cout << 3 << endl;
return 0;
}


Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)
        cout<<"Left";
    if(a+b==c+d)
        cout<<"Balanced";
    if(a+b<c+d)
        cout<<"Right";
    cout<<endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	rep(i, n) {
		if (h[i] >= k) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  ans = 1e9
  for x in a:
    tmp = 0
    while x > 1 and x % 2 == 0:
      x //= 2
      tmp += 1
    ans = min(ans, tmp)
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, op1, n, op2) for(int i=a; i op1 (int)(n); op2 ## op2 i)
#define cout(val) cout << (val) << endl

using namespace std;  

int main(){
    int n, y, temp;
    cin >> n >> y;
    y /= 1000;
    rep(i, n + 1){
        rep(j, n-i + 1){
            temp = n + 9 * i + 4 * j;
            if(temp > y) break;
            if(temp == y){
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = int.Parse(ReadLine());

        if (N % 500 <= A) { 
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }

    }
}


Measured memory_bytes: 11092
use std::vec::Vec;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut check_l = vec![false; n]; // '('
    let mut check_r = vec![false; n]; // ')'
    let mut lbrace = 0;
    let mut rbrace = 0;


    for i in 0..n {
      if s[i] == '(' {
        check_l[i] = true;
      } else {
        check_r[i] = true;
      }
    }

    // ペアになっていない '(' の数を数える
    for i in 0..n {
      if s[i] == '(' {
        //println!("check_l = {:?}", check_l);
        //println!("check_r = {:?}", check_r);
        lbrace += 1;
        for j in i..n {
          if check_r[j]  {
            lbrace -= 1;
            check_r[j] = false;
            break
          }
        }
      }
    }

    // ペアになっていない ')' の数を数える
    for i in (0..n).rev() {
      if s[i] == ')' {
        rbrace += 1;
        for j in (0..i).rev() {
          if check_l[j] {
            rbrace -= 1;
            check_l[j] = false;
            break
          }
        }
      }
    }

    //println!("lbrace = {}, rbrace = {}", lbrace, rbrace);
    let mut queu = VecDeque::new();
    for &e in &s {
      queu.push_back(e);
    }

    for _ in 0..rbrace {
      queu.push_front('(');
    }

    for _ in 0..lbrace {
      queu.push_back(')');
    }

    let ans: String = queu.into_iter().collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import math

a,b = map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a_ = prime_factorize(a)
b_ = prime_factorize(b)

for i in a_:
    if i in b_:
        b_.remove(i)

for j in b_:
    a *= j

print(a)

Measured memory_bytes: 3064
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
signed main()
{
    fasino
    ll n,r=0,w=0;
    cin>>n;
    string A;
    cin>>A;
    for(auto i:A) if(i=='R') r++;
    if(r==0 or r==n){
        cout<<0;
        return 0;
    }
    else
    {
        ll res = 0;
        for(int i=0;i<r;i++){
            if(A[i]!='R'){
                res++;
            }
        }
        cout<<res;
    }
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N, K;  cin >> N >> K;
	vector<P> vec(N);
	REP(i, N)
		cin >> vec[i].first >> vec[i].second;

	sort(ALL(vec));
	for(int i = 0 ; i < N ; i++){
		K -= vec[i].second;
		if(K <= 0){
			cout << vec[i].first << endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int give_query(int a, int b) {
    cout << "? " << a << " " << b << endl;
    int d; cin >> d;
    return d;
}

void answer(vector<int> res) {
    cout << "!";
    for(auto e : res) cout << " " << e;
    cout << endl;
    exit(0);
}

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

    int max_dist = 0, side = 0;
    for(int i=1; i<N; i++) {
        int d = give_query(1, i+1);
        if(max_dist < d) {
            max_dist = d;
            side = i;
        }
    }

    vector<int> ans(N);
    ans[0] = side + 1;
    for(int i=0; i<N; i++) {
        if(i == side) continue;
        int d = give_query(side+1, i+1);
        ans[d] = i+1;
    }

    answer(ans);
    return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    cout << 800 * n - (n / 15) * 200 << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    ll A = 0, B = 0, X = 0;
    scanf("%lld%lld", &A, &B);
    for(int i=0; i+2<N; i++) {
        ll x; scanf("%lld", &x);
        X ^= x;
    }
    ll OA = A;

    if((A + B - X) & 1) {
        puts("-1");
        return 0;
    }
    ll AND = (A + B - X) / 2;
    if(AND > A) {
        puts("-1");
        return 0;
    }
    if(AND & X) {
        puts("-1");
        return 0;
    }
    A -= AND;
    for(int i=60; i>=0; i--) {
        if(!(X >> i & 1)) continue;
        if(A >= (1LL << i)) A -= (1LL << i);
    }

    if(A == OA) {
        puts("-1");
    }
    else {
        printf("%lld\n", A);
    }
    return 0;
}


Measured memory_bytes: 3772
#include <cstdio>

int main(void)
{
	int a1count=0,a2count=0,a4count=0;
	int i,N,x;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&x);
		if(x%4==0)
			a4count++;
		else if(x%2==0)
			a2count++;
		else
			a1count++;
	}
	if(a2count>0 && a1count<=a4count)
		printf("Yes\n");
	else if(a2count==0 && a1count<=a4count+1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,a,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a);
		ans+=a;
	}
	if (ans%2==0) printf("YES\n");
	else printf("NO\n");
	return 0;
} 

Measured memory_bytes: 256
import fractions
import numpy as np
import os
import sys

N,L=map(int,input().split())

s=0
ss=[]
for i in range(N):
    s+=i+L
    ss.append(i+L)

S=10000000000000
ans=0
for i in range(N):
    sss=0
    for j in range(N):
        if(i!=j):
            sss+=ss[j]
    if(abs(sss-s)<S):
        S=abs(sss-s)
        ans=sss
        
print(ans)

Measured memory_bytes: 19640
#include <stdio.h>

long int f(int n){
  if(n == 1) return 1;
  return (long int)n * f(n - 1) % 1000000007;
}

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  printf("%ld\n", f(n));
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int A,B,K;
    int i=100;
    cin >> A >> B >> K;
    int cnt=0;
    while(i>0){
      if(A%i==0&&B%i==0){
        cnt++;
        if(cnt==K){
          cout << i;
        }
      }
      i--;
    }
    return 0;
}


Measured memory_bytes: 256
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  cout<<(1000-n%1000)%1000<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main(){
  int A[4][3][10]
    = {{{},{},{}},{{},{},{}},{{},{},{}},{{},{},{}}};
  int n;
  cin >> n;
  for (int i=0; i<n; ++i){
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    A[b-1][f-1][r-1] += v;
  }
  for (int b=0; b<4; ++b){
    for (int f=0; f<3; ++f){
      for (int r=0; r<10; ++r){
	cout << " " << A[b][f][r];
      }
      cout << endl;
    }
    if (b<3) cout << "####################" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
"""
N,Q = map(int,input().split())
S = input()

for i in range(Q):
    lq,rq = map(int,input().split())
    s = S[lq-1:rq]
    count = 0
    while(s.find('A') != -1):
        j = s.find('A')
        if(s[j:j+2] == 'AC'):
            count+=1
            s = s[j+2:]
        else:
            s = s[j+1:]
    print(count)
"""
#愚直なやり方だとTLEになってしまう。
#累積和とよばれるテクニックを使う
#https://qiita.com/drken/items/56a6b68edef8fc605821#問題-3-atcoder-abc-122-c---get-ac

N,Q = map(int,input().split())
S = input()

#区間配列
a = [0] * len(S)
#累積和配列
s = [0] * (len(S) +1)

#左がAである文字Cは何番目にあるか求める
for i in range(len(S)):
    if S[i] == 'C':
        if S[i-1] == 'A':
            a[i] = 1 #i番目に'AC'のCがある (添字が0から始まるため実際にはi-1番目 i番目は'A')

#累積和を計算する
for i in range(1,len(a)+1):
    s[i] = s[i-1] + a[i-1]

#区間内にその文字があるか求める

for i in range(Q):
    lq,rq = map(int,input().split())
    print(s[rq] - s[lq])


Measured memory_bytes: 8436
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;


#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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 digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}



int main() {
	IOS;
	int n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	REP(i, n)cin >> c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll sum = 0;
	REP(i, n) {
		ll x = b[i];
		sum += (lower_bound(ALL(a), x) - a.begin()) * (c.end() - upper_bound(ALL(c), x));
	}
	dump(sum);
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

int a,b;

int main(){
	cin >> a >> b;
	if(b%a== 0)cout << a+b << endl;
	else cout << b-a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[100005], b[100005];
map<int, int>mp;
int main()
{
    int n, x, res= 0, cnt= 0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    scanf("%d", &ara[i]), b[i]= ara[i];
    sort(b+1, b+1+n);
    for(int i=1; i<=n; i++)mp[ b[i] ]= ++cnt;
    for(int i=1; i<=n; i++)ara[i]= mp[ ara[i] ];
    for(int i=1; i<=n; i++)res+= abs(i-ara[i])%2;
    printf("%d\n", res/2);
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    const int INF = 1e9 + 10;
    vector<vector<vector<int>>> dp(K + 1, vector<vector<int>>(N + 1, vector<int>(N + 1, -INF)));
    dp[0][0][N] = 0;

    for (int k = 0; k < K; k++) {
        for (int w = N; w >= 1; w--) {
            for (int i = 0; i + w <= N; i++) {
                int j = i + w;
                chmax(dp[k + 1][i + 1][j], dp[k][i][j] + A[i]);
                chmax(dp[k + 1][i][j - 1], dp[k][i][j] + A[j - 1]);
                if (k + 2 <= K) {
                    chmax(dp[k + 2][i + 1][j], dp[k][i][j]);
                    chmax(dp[k + 2][i][j - 1], dp[k][i][j]);
                }
            }
        }
    }

    int ans = 0;
    for (int k = 0; k <= K; k++) {
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                ans = max(ans, dp[k][i][j]);
            }
        }
    }

    cout << ans << endl;

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 1536
import java.util.*;
import java.util.function.ToDoubleFunction;


public class Main {
    private static final String ex = "3 5\n" +
            "5\n" +
            "1 2 3 6 3";
//    private static final String ex = "2 2\n" +
//            "3\n" +
//            "2 1 1";

    public static void main(String[] args) {
        solve(new Scanner(System.in));
//        solve(new Scanner(ex));
    }

    private static void solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");
        int H = Integer.parseInt(split[0]);
        int W = Integer.parseInt(split[1]);
        int N = Integer.parseInt(scanner.nextLine());
        int[] a = new int[N];
        split = scanner.nextLine().split(" ");
        for (int i = 0; i < N; i ++) {
            a[i] = Integer.parseInt(split[i]);
        }

        int[][] matrix = new int[H][W];
        int row = 0;
        int col = 0;
        int add = 1;
        for (int i = 0; i < N; i ++) {
            for (int  j = 0; j < a[i]; j ++) {
                matrix[row][col] = i + 1;

                col += add;

                if (col == W) {
                    row ++;
                    add = -1;
                    col += add;
                } else if (col == -1) {
                    row ++;
                    add = 1;
                    col += add;
                }
            }
        }

        for (int i = 0; i < H; i ++) {
            for (int j = 0; j < W; j ++) {
                System.out.print(matrix[i][j]);
                if (j == W - 1) System.out.println();
                else System.out.print(" ");
            }
        }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int A,P;

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

  cin >> A >> P;
  P += 3*A;
  cout << P/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  string s, t;
  cin >> s >> t;

  auto result = 1000;
  for (auto i = 0; i < s.length() - t.length() + 1; i++) {
    auto cur = 0;
    for (auto j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) {
        cur++;
      }
    }
    result = min(result, cur);
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 3120