akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}


int main() {
  GI2(H, W);
  vector<string> mp(H);
  FOR(i, H) cin >> mp[i];
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};
  ll ans = 0;
  vector<vector<bool>> visited(H ,vector<bool>(W));
  FOR(i, H) {
    FOR(j, W) {
      if (!visited[i][j]) {
		  int thisans=0;
        stack<int> s;
        s.push(i * W + j);
		visited[i][j]=1;
		int cnt=0;
        while (!s.empty()) {
          int v = s.top();
          s.pop();
          int x = v % W, y = v / W;
          if (mp[y][x] == '.')
            thisans++;
			else cnt++;
          FOR(c, 4) {
            int nx = x + dx[c], ny = y + dy[c];
            if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                !visited[ny][nx] && mp[y][x] != mp[ny][nx]) {
              s.push(ny * W + nx);
              visited[ny][nx] = 1;
            }
          }
        }
		ans+=(ll)thisans*cnt;
	  }
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main ()
{
    int a,b,c,d,z=0,m=0;
    cin>>a>>b>>c>>d;
    z=a*b;
    m=c*d;
    if(z>m)
    cout<<z;
    else
    cout<<m;
    return 0;
    
}

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

#define     MX        100005
#define     mod       1000000007
#define     ll        long long
#define     ld        long double
#define     mem(a,b)  memset(a,b,sizeof(a))
#define     fast()    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     F         first
#define     S         second
//#define     mp        make_pair
#define     inf       2e18
#define     PI        acos(-1)

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

int n;
int p[250005];
int dp[505][505];
int ok[505][505];
//int mark[505][505][4];
int ans=0;
int cur;

int getMin(int ro,int col){
    int res= n;
    res =min(res,dp[ro-1][col] + ok[ro-1][col]);
    res= min(res,dp[ro+1][col] + ok[ro+1][col]);
    res= min(res,dp[ro][col-1] + ok[ro][col-1]);
    res= min(res,dp[ro][col+1] + ok[ro][col+1]);
    return res;
}
void process(int ro,int col);

void tryToUpdate(int ro,int col,int val){
    if(dp[ro][col]<=val) return;
   // cout<<"updated "<<ro<<" "<<col<<" "<<" val "<<val<<endl;

    dp[ro][col]=val;
    process(ro,col);

}

void process(int ro,int col){
    //cout<<"process "<<ro<<" "<<col<<endl;
    int need= getMin(ro,col)+ok[ro][col];

    if(ro>1) tryToUpdate(ro-1,col,need);
    if(ro<n) tryToUpdate(ro+1,col,need);
    if(col>1) tryToUpdate(ro,col-1,need);
    if(col<n) tryToUpdate(ro,col+1,need);
}


int main(){
    fast();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>p[i];
    for(int i=1;i<=n*n;i++){
        int ro=p[i]/n;
        int col= p[i]%n;
        if(col) ro++;
        else col= n;

        dp[ro][col]= min(min(ro-1,n-ro),min(col-1,n-col));
        ok[ro][col]=1;
    }

    for(int i=1;i<=n*n;i++){
        int ro=p[i]/n;
        int col= p[i]%n;
        if(col) ro++;
        else col= n;
        ans+= dp[ro][col];
        ok[ro][col]=0;
        process(ro,col);
        /*
        cout<<p[i]<<" "<<ro<< " "<<col<<endl;
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++) cout<<dp[j][k]<<" ";
            cout<<endl;
        }
        cout<<endl;
        */
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14044
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define mod 7778777
using namespace std;
const int N=2000,M=4*1e5+100;
int n,d1,d2,p[N],cnt[5][5],vi[M][2];
vector <pair<int,int> > f[2];
void check(int d,int kind)
{
	for (int i=0;i<=1000;i++)
	{
		if (p[i]>d) continue;
		int pos=lower_bound(p,p+1001,d-p[i])-p;
		if (p[pos]+p[i]==d)
		{
			f[kind].push_back(m_k(pos,i));
			f[kind].push_back(m_k(pos,-i));
			f[kind].push_back(m_k(-pos,i));
			f[kind].push_back(m_k(-pos,-i));
		}
	}
}
bool judge(int x,int y)
{
	if (x<0 || y<0 || x>=2*n || y>=2*n) return 0;
	return 1;
}
int id(int x,int y){return x*2*n+y+1;}
void dfs(int x,int y,int kind)
{
	for (int i=0;i<(int)f[kind].size();i++)
	{
		int nx=x+f[kind][i].first,ny=y+f[kind][i].second;
		if (!judge(nx,ny)) continue;
		if (vi[id(nx,ny)][kind]) continue;
		vi[id(nx,ny)][kind]=3-vi[id(x,y)][kind];
		dfs(nx,ny,kind);
	}
}
signed main()
{
//	freopen("1.out","w",stdout);
	scanf("%d%d%d",&n,&d1,&d2);
	for (int i=0;i<=1000;i++) p[i]=i*i;
	check(d1,0);check(d2,1);
	for (int i=0;i<2*n;i++)
	{
		for (int j=0;j<2*n;j++)
		{
			if (!vi[id(i,j)][0]) vi[id(i,j)][0]=1,dfs(i,j,0);
			if (!vi[id(i,j)][1]) vi[id(i,j)][1]=1,dfs(i,j,1);
		}
	}
	for (int i=0;i<2*n;i++)
	{
		for (int j=0;j<2*n;j++)
		  cnt[vi[id(i,j)][0]][vi[id(i,j)][1]]++;
	}
	int MAX=0;
	for (int i=1;i<3;i++) for (int j=1;j<3;j++) MAX=max(MAX,cnt[i][j]);
	for (int i=1;i<3;i++)
	{
		for (int j=1;j<3;j++)
		{
			if (MAX!=cnt[i][j]) continue;
			int cnt=0;
			for (int p=0;p<2*n;p++)
			{
				for (int q=0;q<2*n;q++)
				{
					if (cnt==n*n) continue;
					if (vi[id(p,q)][0]==i && vi[id(p,q)][1]==j)
					{
						printf("%d %d\n",p,q);
						cnt++;
					}
				}
			}
			return 0;
		}
	}
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int as[n] = {};
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        as[a] = 1;
    }

    int mod = 1e9+7;
    int dp[n+1] = {};
    dp[0] = 1;
    if (as[1] != 1) {
        dp[1] = 1;
    }
    for (int i = 2; i <= n; i++) {
        if (as[i] != 1) {
            dp[i] = (dp[i-1] + dp[i-2]) % mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        int N = Integer.parseInt(in.readLine());
        String[] s = in.readLine().split(" ");
        int[] a = new int[N];
        int max = 0;
        for (int i = 0; i < N; i++) {
            max = Math.max(max, (a[i] = Integer.parseInt(s[i])));
        }

        int half = max / 2;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int now = Math.min(a[i], max - a[i]);
            int temp = Math.min(ans, max - ans);
            if (temp < now && now <= half) {
                ans = a[i];
            }
        }

        out.println(max + " " + ans);
    }
}


Measured memory_bytes: 47988
# Problem B - ATCoder

# input
S = list(input())

# initialization
max_count = 0
atgc_list = ['A', 'T', 'G', 'C']

# count
tmp = 0
for i in range(len(S)):
    if S[i] in atgc_list:
        tmp += 1
    else:
        max_count = max(max_count, tmp)
        tmp = 0
max_count = max(max_count, tmp)
# output
print(max_count)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
    string s; cin >> s;

    int g=0;
    for(int i=0; i<n-1; ++i){
        if(s[i]!=s[i+1]) ++g;
    }
    int cnt=n-1-g;
    
    int ans=cnt+2*min({k,g/2});
    if(k-g/2>0 && g%2==1) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 512
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int d=0,l=a[0],k=0;
		for(int i=1;i<s[0];i++){
			if(d<a[i]-l){d=a[i]-l;k=1;}
			else if(d==a[i]-l){k++;}
			l=Math.Min(l,a[i]);
		}
		Console.WriteLine("{0}",k);
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	pair<int,int> max_a = make_pair(0,0);
	rep(i,n) {
		cin >> a[i];
		if (max_a.second <= a[i]) {
			max_a.first = i;
			max_a.second = a[i];
		}
	}
	sort(a.begin(), a.end());
	rep(i,n) {
		if (i == max_a.first) {
			cout << a[n-2] << endl;
		}
		else {
			cout << max_a.second << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2432
n = int(input())

def plus(s):
  m = max(s)
  ret = []
  for i in range(ord(m)-97+2):
    ret.append(s+chr(i+97))
  return ret

s = 'a'
ws = [[] for i in range(10+1)]
ws[0].append(s)
for i in range(1,10+1):  
  for s in ws[i-1]:
    ws[i].extend(plus(s))     
    
for s in ws[n-1]:
  print(s)

Measured memory_bytes: 62924
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
def search(pros,tgt,g,d):
    tmp = 0
    cnt = 0
    rest = []
    for i in range(d):
        if tgt % 2 == 1:
            tmp += 100 * (i+1) * pros[i][0] + pros[i][1]
            cnt += pros[i][0]
        else:
            rest.append((i+1,pros[i][0]-1))
        tgt //= 2
    # print(tmp)
    if tmp >= g:
        return cnt
    for ap, ac in rest[::-1]:
        if tmp + 100 * ap * ac >= g:
            cnt += math.ceil((g - tmp)/(100 * ap))
            return cnt
        else:
            cnt += ac
            tmp += 100 * ac * ap

    return INF

def main():

    n = getN()
    x = 800 * n
    y = 200 * (n // 15)
    print(x-y)

 
if __name__ == "__main__":
    main()
   

Measured memory_bytes: 65708
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int> > A(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
		}
	}
	vector<vector<vector<int> > > dp(H * W, vector<vector<int> >(H, vector<int>(W, 1000000000)));
	dp[0][0][0] = 0;
	int ans = 1000000000;
	for (int i = 1; i < H * W; ++i) {
		for (int j = 0; j < H; ++j) {
			for (int k = 0; k < W; ++k) {
				for (int l = 0; l < 4; ++l) {
					int nx = j + dx[l], ny = k + dy[l];
					if (0 <= nx && nx < H && 0 <= ny && ny < W) {
						dp[i][j][k] = min(dp[i][j][k], dp[i - 1][nx][ny] + A[j][k] * (2 * i - 1));
					}
				}
			}
		}
		ans = min(ans, dp[i][H - 1][W - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7188
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

struct light_t {
  int k;
  std::vector<int> ss;
};

static int solve(int n, const std::vector<light_t>& ls,
                 const std::vector<int> ps) {
  int ret = 0;
  int const nn = 1 << n;
  int const m = ls.size();
  for (int i = 0; i < nn; ++i) {
    std::bitset<10> bits(i);
    int j;
    for (j = 0; j < m; ++j) {
      auto const l = ls[j];
      int onCount = 0;
      for (int k = 0; k < l.k; ++k) {
        if (bits.test(l.ss[k])) {
          onCount++;
        }
      }
      if (onCount % 2 != ps[j]) {
        break;
      }
    }
    if (j >= m) {
      ret++;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  int m;
  std::cin >> n >> m;
  std::vector<light_t> ls(m);
  for (int i = 0; i < m; ++i) {
    int k;
    std::cin >> k;
    ls[i].k = k;
    for (int j = 0; j < k; ++j) {
      int s;
      std::cin >> s;
      ls[i].ss.emplace_back(s - 1);
    }
  }
  std::vector<int> ps(m);
  for (int i = 0; i < m; ++i) {
    std::cin >> ps[i];
  }
  std::cout << solve(n, ls, ps) << std::endl;
  // Failed to predict input format
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

int maxl = -1, minr = 1001001001;

class Range {
public:
  int l, r;
  Range() {}
  Range(int l, int r) : l(l), r(r) {}
};

bool cmp(const Range &a, const Range &b)
{
  int l = a.r;
  int r = b.r;
  if (l == r) return a.l > b.l;
  return l < r;
}

vector<Range> ranges;

int lmax[100010];
int rmin[100010];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    ++r;
    ranges.emplace_back(l, r);
  }
  sort(ranges.begin(), ranges.end(), cmp);
  int p, q;
  for (int i = 0; i < n; ++i) {
    Range &range = ranges[i];
    if (maxl < range.l) { 
      p = i;
      maxl = range.l;
    }
    if (minr > range.r) {
      q = i;
      minr = range.r;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i == p || i == q) continue;
    Range &range = ranges[i];
    ans = max(ans, range.r-range.l);
  }
  ans += max(minr-maxl, 0);

  lmax[0] = ranges[0].l;
  rmin[n-1] = ranges[n-1].r;
  for (int i = 1; i < n; ++i) {
    lmax[i] = max(lmax[i-1], ranges[i].l);
    rmin[n-i-1] = min(rmin[n-i], ranges[n-i-1].r);
  }
  for (int i = 0; i < n-1; ++i) {
    ans = max(ans, max(rmin[i+1]-maxl,0)+max(minr-lmax[i],0));
  }
  cout << ans << endl;
}

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

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

    vi primes;
    for (int i = 2; i <= 55555; i++) {

        bool ok = true;
        for (int j = 2; j <= sqrt(i); j++) {
            if (i % j == 0) {
                ok = false;
                break;
            }
        }

        if (ok) {
            if (i % 5 == 1) {
                primes.push_back(i);
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cout << primes[i];
        if (i != N - 1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int c;
    cin >> c;
    vector<int> v(c);
    for(int i = 0; i < c; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < c-2;i++) {
        for (int j = i+1; j < c - 1; j++) {
            for (int z = j + 1; z < c; z++) {
                if(v[i]!=v[j] && v[j] != v[z] && v[i] + v[j] > v[z]) {
                    sum++;
                }
            }
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N;
    cin >> N;
    ll ma = 0;
    ll prev = 0;
    cin >> prev;
    ll cur = 0;
    for (int i = 1; i < N; i++) {
        ll H;
        cin >> H;
        if (prev >= H) {
            cur++;
        } else {
            ma = max(ma, cur);
            cur = 0;
        }
        prev = H;
    }
    ma = max(ma, cur);
    cout << ma << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define endl "\n"
using namespace std;
int n  , m, x  , c , k ;
const int N = 1000000;
int z ;
int inf = 1e14;
int dp[N][5];
int a[N];

int r , g , b;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> r >> g >> b >> n ;
    dp[r][1] = 1;
    dp[g][2] = 1;
    dp[b][3] = 1;
    int k[5];
    for (int i=1;i<=n;i++){
        k[3] = dp[i][1] + dp[i][2] + dp[i][3];
        k[2] = dp[i][1] + dp[i][2];
        k[1] = dp[i][1];
        dp[i+b][3] += k[3];
        dp[i+g][2] += k[2];
        dp[i+r][1] += k[1];
    }

    cout << dp[n][1] + dp[n][2] + dp[n][3] << endl;
    return 0;
}


Measured memory_bytes: 2304
n, a = map(int, input().split())
x = list(map(int, input().split()))

dp = [[[0] * 3000 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(2500):
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]
            dp[i + 1][j][k] += dp[i][j][k]

ans = 0
for i in range(1, n + 1):
    ans += dp[n][i][i * a]

print(ans)

Measured memory_bytes: 102620
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val m = sc.nextLong()

  val list = mutableListOf<Long>()
  list.add(0)


  val last = m - n * 2
  if (last >= 0) {
    var tmp = n
    tmp += (last - (last % 4)) / 4
    list.add(tmp) 
  } else {
    var tmp = m / 2

    list.add(tmp)
  }


  println(list.max())

}

Measured memory_bytes: 37296
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			decimal n = decimal.Parse(Console.ReadLine());

			decimal par = 0;

			if (n % 2 == 1)
			{
				par = ((int)(n / 2) + 1) / n;
				Console.WriteLine(par);

			}
			else
			{
				Console.WriteLine(0.5);
			}

		}


	}

}


Measured memory_bytes: 11220
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


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

ans = 0
for i in range(n):
    ans += 2 * min(x[i]-0, abs(x[i]-k))
print(ans)


Measured memory_bytes: 8688
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string odd;
    string even;
    cin >> odd;
    cin >> even;

    string password;
    for (int i = 0, j = 0; (i + j) < odd.size() + even.size();) {
        if ((i + j) % 2 == 0) {
            password += odd[i];
            ++i;
        } else {
            password += even[j];
            ++j;
        }
    }
    cout << password << endl;
    return 0;
}


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

int main(){

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

    int n = s.length();
    int m = t.length();
    
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    string result = "";

    for (int i = 1 ; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (s[i-1] == t[j-1]){
                // result += s[i-1];
                dp[i][j] = dp[i-1][j-1] + 1; 
            } else{
                dp[i][j] =  max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int res = dp[n][m];

    int i = n, j = m;

    while (i > 0 and j > 0){
        if (s[i-1] == t[j-1]){
            result = s[i-1] + result;
            i--;j--;
        } else if (dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    cout << result << endl;
}

Measured memory_bytes: 35456
const Main = input => {
    const inp = input.split(/\n/);
    const k = parseInt(inp[0], 10);
    const s = inp[1];

    if(s.length <= k) {
        console.log(s);
    } else {
        const result = s.slice(0, k);
        console.log(`${result}...`);
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
vector<long long> factors;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
vector<int> a;
pll dp[450][450];

pll count(int l, int r)
{
	if (dp[l][r].first != 0)
	{
		return dp[l][r];
	} else
	{
		pll mn = {LL_INF,LL_INF};
		if (l == r)
		{
			dp[l][r].first = a[l];
			dp[l][r].second = 0;
		} else
		{
			for (int i = l; i < r; ++i)
			{
				pll temp1 = count(l, i);
				pll temp2 = count(i + 1, r);
				if (mn.second > temp1.second + temp2.second + temp1.first + temp2.first)
				{
					mn.first = temp1.first + temp2.first;
					mn.second = temp1.second + temp2.second + mn.first;
				}
			}
			dp[l][r] = mn;
		}
	}
	return dp[l][r];
}

int main()
{
	IOS

	int n;
	cin >> n;
	a.resize(n + 1);
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	cout << count(1, n).second;

	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


struct C{
	P p;
	double r;
};

vector<P> isCC(const C &c1, const C &c2) {
	double d = abs(c1.p - c2.p);
	if (c1.r + c2.r - d < -EPS || fabs(c1.r - c2.r) - d > EPS) return vector<P>();
	double x = (d*d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
	double y = sqrt(c1.r * c1.r - x * x);
	P diff = (c2.p - c1.p) / d;
	vector<P> res;
	res.pb(c1.p + diff * P(x, y));
	if (y != 0) res.pb(c1.p + diff * P(x, -y));
	return res;
}

int main(){
	int n; cin >> n;
	while (n--) {
		double xa, ya, ra, xb, yb, rb; cin >> xa >> ya >> ra >> xb >> yb >> rb;
		P pa = P(xa, ya), pb = P(xb, yb);
		C ca = (C){pa, ra}, cb = (C){pb, rb};
		int ans;
		if (isCC(ca, cb).size()){
			ans = 1;
		}
		else {
			if (ra + rb - abs(pa - pb) < -EPS) ans = 0;
			else ans = ra > rb ? 2 : -2;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    int n, k;

    cin >> n >> k;
    set<int> s;
    for (int i = 1; i <= 1e5; i++){
      n = n % k;
      s.insert(n);
      n = abs(n - k);
    }
    cout << *s.begin() << endl;
}



Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

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;}

#define endl "\n"

typedef long long lint;

using namespace std;
int main(){
	char c[3];
	rep(i,3)cin>>c[i];
	cout<<(stoi(c)%4==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc060.contest.atcoder.jp/tasks/arc060_a>
問題文============================================================
 高橋君は、N 枚のカードを持っています。 i (1≤i≤N) 番目のカードには、整数 xi が書かれています。
 高橋君は、これらのカードの中から 1 枚以上を選び、
 選んだカードに書かれた整数の平均をちょうど A にしたいと考えています。
 そのようなカードの選び方が何通りあるか求めてください。
=================================================================

解説=============================================================

================================================================
*/
ll dp[55][55][50*50+1];
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,A; cin >>N >> A;
    vector<ll> x(N);
    for(auto& in:x) cin >> in;
    dp[0][0][0] = 1;
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= i; j++){
            for(int k = 0; k <= N*50; k++){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N;i++){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53504
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	if (s == "KIHBR")cout << "YES\n";
	else if (s == "KIHBRA")cout << "YES\n";
	else if (s == "KIHBAR")cout << "YES\n";
	else if (s == "KIHBARA")cout << "YES\n";
	else if (s == "KIHABR")cout << "YES\n";
	else if (s == "KIHABRA")cout << "YES\n";
	else if (s == "KIHABAR")cout << "YES\n";
	else if (s == "KIHABARA")cout << "YES\n";
	else if (s == "AKIHBR")cout << "YES\n";
	else if (s == "AKIHBRA")cout << "YES\n";
	else if (s == "AKIHBAR")cout << "YES\n";
	else if (s == "AKIHBARA")cout << "YES\n";
	else if (s == "AKIHABR")cout << "YES\n";
	else if (s == "AKIHABRA")cout << "YES\n";
	else if (s == "AKIHABAR")cout << "YES\n";
	else if (s == "AKIHABARA")cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;

	int n, k; cin >> n >> k;
	mk(arr, n, int);
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	int state[k + 1] = {};

	for (int i = k - 1; i >= 0; i--) {
		int curr_state = 1;
		for (int j = 0; j < n; j++) {
			if (i + arr[j] <= k)
				curr_state &= state[i + arr[j]];
			else
				break;
		}

		state[i] = !curr_state;
	}

	if (state[0])
		cout << "First" << endl;
	else
		cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 4432
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		num_E = num_W = 0;
	}
	int num_E,num_W;
};


int main(){

	int N,M,total_W = 0,total_E = 0;
	scanf("%d %d",&N,&M);

	Info info[N+1];
	char buf[N+1];

	for(int loop = 0; loop < M; loop++){
		scanf("%s",buf);
		for(int i = 0; i < N; i++){
			if(buf[i] == 'W'){
				info[i+1].num_W++;
				total_W++;
			}else{
				info[i+1].num_E++;
				total_E++;
			}
		}
	}

	if(total_W == 0){
		printf("0 1\n");
		return 0;
	}else if(total_E == 0){
		printf("%d %d\n",N,N+1);
		return 0;
	}

	int calc_E = 0,calc_W = 0,left = 0,div_min = total_W,tmp_div;

	for(int i = 1; i <= N; i++){
		calc_E += info[i].num_E;
		calc_W += info[i].num_W;
		tmp_div = calc_E + total_W - calc_W;
		if(div_min > tmp_div){
			div_min = tmp_div;
			left = i;
		}
	}

	printf("%d %d\n",left,left+1);

	return 0;
}

Measured memory_bytes: 2856
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	fo(i,1,n)
	if(ar[i]%5!=0 && ar[i]%3!=0 && ar[i]%2==0)
		return cout<<"DENIED",0;

	cout<<"APPROVED";

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 384
def heron(a,b,c):
    s = 0.5*(a+b+c)
    return (s*(s-a)*(s-b)*(s-c))**0.5

def gaishin(a,b,c,z1,z2,z3,s):
    p = (a**2*(b**2 + c**2 - a**2)*z1 + \
         b**2*(c**2 + a**2 - b**2)*z2 + \
         c**2*(a**2 + b**2 - c**2)*z3)/(16*s**2)
    return p

n = input()

for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float, raw_input().split(' '))
    l1 = ((x2-x3)**2+(y2-y3)**2)**0.5
    l2 = ((x3-x1)**2+(y3-y1)**2)**0.5
    l3 = ((x1-x2)**2+(y1-y2)**2)**0.5
    s = heron(l1,l2,l3)
    px = gaishin(l1,l2,l3,x1,x2,x3,s)
    py = gaishin(l1,l2,l3,y1,y2,y3,s)
    r = ((px-x1)**2+(py-y1)**2)**0.5
    print '%.3f %.3f %.3f' % (px,py,r)

Measured memory_bytes: 4368
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 1e9;
static const int SIZE = 100001;
struct edge
{
	int to;
	int cost;
};

vector<edge> G[SIZE];
int d[SIZE];

void solve()
{
	int V, E, start;
	cin >> V >> E >> start;
	for (int i = 0; i < E; ++i)
	{
		int from, to, cost;
		cin >> from >> to >> cost;
		edge e;
		e.to = to;
		e.cost = cost;
		G[from].push_back(e);
	}
	for (int i = 0; i < SIZE; ++i)
	{
		d[i] = INF;
	}
	d[start] = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, start));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				pque.push(P(d[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < V; ++i)
	{
		if (d[i] == INF)
		{
			cout << "INF" << endl;
		}
		else
		{
			cout << d[i] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 11308
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

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;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,ans=0,y;
  double m;
  cin >> n;
  m=n;
  m=sqrt(m);
  y=m;
  FOR(i,1,y+1){
    if(n%i==0&&n!=(i+1)*i&&n!=i*i)ans+=n/i-1;
  }
  printf("%lld",ans);
}

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;

int main() {
    ll a,b, c;
    cin >> a >> b >> c;
    ll d = a+b-c;
    if ((d*d > 4*a*b && d < 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<stdio.h>
using namespace std;
int main()
{
	int N,countR=0,countB=0;
	char s[100];
	scanf("%d%s",&N,&s);
	for(int i=0;i<N;i++)
	{
		if(s[i]=='R')
		countR++;
		else if(s[i]=='B')
		countB++;
	}
	if(countR>countB)
	printf("Yes");
	else
	printf("No");
} 

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))

ans = 10**10
for i in range(N-K+1):
    if(a[i] < 0 and a[i+K-1] > 0):
        ans = min(ans, abs(a[i])*2+a[i+K-1], abs(a[i+K-1])*2+abs(a[i]))
    else:
        if(a[i] < 0):
            ans = min(ans, abs(a[i]))
        else:
            ans = min(ans, abs(a[i+K-1]))

if(N > 1):        
    print(ans)
else:
    print(a[0])

Measured memory_bytes: 14844
import sys

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

def score(tt):
    ans=0
    for i,t in enumerate(tt):
        t-=1
        ans += ss[i][t]
        p = i - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
        last[t] = i + 1
    for t in range(26):
        p = d - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
    return ans

inf=10**16
d = II()
cc = LI()
ss = LLI(d)
ans = 0
last = [0] * 26
tt=list(range(1,27))*(d//26+1)
tt=tt[:d]
for _ in range(10):
    for i in range(d):
        mx=-inf
        best=0
        for j in range(1,27):
            tt[i]=j
            cur=score(tt)
            if cur>mx:
                mx=cur
                best=j
        tt[i]=best
#print(score(tt))
print(*tt,sep="\n")


Measured memory_bytes: 69148
from fractions import gcd
a,b = map(int,input().split())
n = int(max(a,b)**(0.5))
m = min(a,b)
ans = 1
for i in range(2,min(m,n)+1):
    if a%i == 0 and b%i == 0:
        while a % i == 0 and b % i == 0:
            a //= i
            b //= i
        ans += 1
if gcd(a,b) != 1:
    ans += 1
print(ans)

Measured memory_bytes: 6452
n, t = map(int, input().split())
a = list(map(int, input().split()))

profit = [0] * n
buy_mn = a[0]
for i, e in enumerate(a[1:], 1):
    profit[i] = e - buy_mn
    buy_mn = min(buy_mn, e)

profit_mx = max(profit)
ans = profit.count(profit_mx)
print(ans)


Measured memory_bytes: 14244
#include <iostream>
using namespace std;
int main () {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0) 
        cout << "Yes\n";
    else 
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3096
#include <array>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::string S;
  std::cin >> N >> S;

  std::vector<std::array<uint32_t, 10>> follow(N);
  follow.back().fill(N);

  for (size_t i = N - 1; i > 0; i--) {
    follow[i - 1] = follow[i];
    uint32_t value = S[i] - '0';
    follow[i - 1][value] = i;
  }

  std::array<uint32_t, 10> initial(follow.front());
  initial[S[0] - '0'] = 0;

  uint32_t count = 0;
  for (size_t i = 0; i < initial.size(); i++) {
    if (initial[i] == N) continue;
    uint32_t idx_1st = initial[i];
    for (size_t j = 0; j < follow[idx_1st].size(); j++) {
      if (follow[idx_1st][j] == N) continue;
      uint32_t idx_2nd = follow[idx_1st][j];
      for (size_t k = 0; k < follow[idx_2nd].size(); k++) {
        if (follow[idx_2nd][k] == N) continue;
        count++;
      }
    }
  }
  std::cout << count << std::endl;

  return 0;
}

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

nums = list(map(int,input().split()))

i = 0

while 1 != 0:
    new = [(num/2) for num in nums if (num%2) == 0]

    if len(new) != N:
        print(i)
        exit()
    else:
        i += 1
        nums = new


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll h,w,A,B,ans,jc[500010],ny[500010];
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
int main(){
	ll i,xlh;
	jc[0]=ny[0]=1;
	for(i=1;i<=200000;i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2);
	scanf("%lld%lld%lld%lld",&h,&w,&A,&B);
	ans=C(h-1+w-1,h-1);
	for(i=1;i<=B;i++){
		xlh=C(h-A-1+i-1,i-1)*C(A-1+w-i,A-1)%p;
		ans=(ans-xlh+p)%p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5888
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << "NO", 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 200;
const long long MNN = 3e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e13;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k;
double b[MXN], dp[MXN], ans;

void add(llong& a, llong b){
    a += b;
    while(a < 0) a += MOD;
    a %= MOD;
}

int main () {
    ios;
    cin >> n;
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        for(int j = i; j >= 0; j--){
            dp[j] = (j == 0 ? 0 : dp[j - 1] * b[i]) + (dp[j] * (1 - b[i]));
        }
    }
    for(int i = 1; i <= n; i++){
        if(i > n - i){
            ans += dp[i];
        }
    }
    cout << fixed << setprecision(9) << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    ll n = SZ(s)+1;
    vll x(n, 0);
    ll c = 0;
    rep(i, n-1){
        if(s[i] == '<'){
            c++;
            chmax(x[i+1], c);
        }else{
            c = 0;
        }
    }
    c = 0;
    repb(i, n-1){
        if(s[i] == '>'){
            c++;
            chmax(x[i], c);
        }else{
            c = 0;
        }
    }
    dump(x);
    cout << accumulate(ALL(x), 0ll) << endl;
    return 0;
}

Measured memory_bytes: 4764
n,k=map(int,input().split())
T = [int(input()) for i in range(n)]

def check(P):
    global k, T, n

    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if (i == n):
                return n
	
    return i
def find():
    
    left = 0
    right = 100000 * 10000

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if (v >= n):
            right = mid
        else:
            left = mid

    return right


print(find())



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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] dp = new int[100005];
            int n = in.nextInt();
            dp[0] = 0;
            for (int i = 1; i <= n; ++i) {
                dp[i] = dp[i - 1] + 1;
                for (int j = 6; j <= i; j *= 6) {
                    dp[i] = Math.min(dp[i], dp[i - j] + 1);
                }
                for (int j = 9; j <= i; j *= 9) {
                    dp[i] = Math.min(dp[i], dp[i - j] + 1);
                }
            }
            out.print(dp[n]);
        }

    }
}



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

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

    int64_t t = N % K;
    int64_t s = K - t;
    cout << min(t, s) << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    for (int i = 0; i <= N / 4; ++i) {
        int M = N - i * 4;
        if (M % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main()
{
    int n, count = 1;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i-1]) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256