akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

class Edge():
    def __init__(self,t,f,r,ca,co):
        self.to = t
        self.fron = f
        self.rev = r
        self.cap = ca
        self.cost = co

class MinCostFlow():
    size = 0
    graph = []

    def __init__(self, s):
        self.size = s
        self.graph = [[] for _ in range(s)]

    def add_edge(self, f, t, ca, co):
        self.graph[f].append(Edge(t, f, len(self.graph[t]), ca, co))
        self.graph[t].append(Edge(f, t, len(self.graph[f])-1, 0, -co))

    def min_path(self, s, t):
        dist = [inf] * self.size
        route = [None] * self.size
        que = collections.deque()
        inq = [False] * self.size
        dist[s] = 0
        que.append(s)
        inq[s] = True
        while que:
            u = que.popleft()
            inq[u] = False
            for e in self.graph[u]:
                if e.cap == 0:
                    continue
                v = e.to
                if dist[v] > dist[u] + e.cost:
                    dist[v] = dist[u] + e.cost
                    route[v] = e
                    if not inq[v]:
                        que.append(v)
                        inq[v] = True

        if dist[t] == inf:
            return inf, 0

        flow = inf
        v = t
        while v != s:
            e = route[v]
            if flow > e.cap:
                flow = e.cap
            v = e.fron

        c = 0
        v = t
        while v != s:
            e = route[v]
            e.cap -= flow
            self.graph[e.to][e.rev].cap += flow
            c += e.cost * flow
            v = e.fron

        return dist[t], flow

    def calc_min_cost_flow(self, s, t, flow):
        total_cost = 0
        while flow > 0:
            c,f = self.min_path(s, t)
            if f == 0:
                return inf
            f = min(flow, f)
            total_cost += c * f
            flow -= f

        return total_cost


def main():
    n,m,f = LI()
    uvcd = [LI() for _ in range(m)]

    mf = MinCostFlow(n)
    for u,v,c,d in uvcd:
        mf.add_edge(u,v,c,d)

    r = mf.calc_min_cost_flow(0, n-1, f)
    if r == inf:
        return -1

    return r

# start = time.time()
print(main())
# pe(time.time() - start)






Measured memory_bytes: 9552
MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)

Measured memory_bytes: 155916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

/*

Graph struct

*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;


struct Graph
{
    struct edge
    {
        int to;
        i64 cost;
    };

    int n;
    vector<vector<edge>> edges;

    Graph(int N)
    {
        n = N;
        edges.resize(n,vector<edge>());
    }

    int size() const
    {
        return n;
    }

    vector<edge>& operator[](int v)
    {
        return edges[v];
    }
    
};


int main()
{
int n;
int k;
int q;
	cin >> n;
	Graph g(n + 1);

	for(int i = 0;i < n - 1;i++)
	{
		int a,b;
		i64 c;
		cin >> a >> b >> c;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}

	cin >> q >> k;

	vector<i64> dist(n + 1,(1LL << 61));

	{
		priority_queue<P> que;
		que.push({0,k});
		dist[k] = 0;
		
		while(!que.empty())
		{
			int v = que.top().second;
			i64 d = que.top().first;
			que.pop();

			if(dist[v] < d) continue;

			for(auto & e : g[v])
			{
				if(dist[e.to] > dist[v]  + e.cost)
				{
					dist[e.to] = dist[v] + e.cost;
					que.push({dist[e.to],e.to});
				}
			}
		}
	}

	for(int i = 0;i < q;i++)
	{
		int x,y;
		cin >> x >> y;
		cout << dist[x] + dist[y] << endl;
	}
	return 0;
}
				








Measured memory_bytes: 11120
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int n, x, ans;
int in[31], in2[31];
bool dp[1000001];
void solve(int a, int sum){
	for (int i = a; i <= n; i++){
		if (sum + in[i] > x&&!in2[i]){
			in[i] /= 10;
			in2[i] = 1;
		}
		if (sum + in[i] <= x){
			if (dp[sum + in[i]])
				continue;
			if (sum + in[i] % 2){
				dp[sum + in[i]] = 1;
			}
			solve(i, sum + in[i]);
		}
	}
}
int main(){
	while (cin >> n >> x&&n&&x){
		ans = 0;
		fill(dp, dp + 1000001, 0);
		for (int i = 1; i <= n; i++){
			cin >> in[i];
			in[i] *= 10;
			in2[i] = 0;
		}
		solve(1, 0);
		for (int i = x; i > 0; i--){
			if (dp[i]){
				for (int j = 5; j <= x; j++){
					if (j == i)
						ans = j;
					if (i % j == 0)
						break;
				}
				if (ans)
					break;
			}
		}
		if (ans)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 5256
function isValid(input, i, j) {
    var dx = [-1, 0, 1, 0];
    var dy = [0, -1, 0, 1];
    var k;
    for (k = 0; k < 4; k++) {
        var xx = i + dx[k];
        var yy = j + dy[k]; 
        if (xx < 0 || yy < 0 || xx >= input.length || yy >= input[i].length) continue;
        if (input[xx][yy] === '#') {
            return true;
        }
    }
    return false;
}

function Main(inp) {
    var input = inp.split('\n').slice(1).map(function(line) {
        return line.split('');
    });
    var i, j;
    for (i = 0; i < input.length; i++) {
        for (j = 0; j < input[i].length; j++) {
            var v = input[i][j];
            if (v !== '#') continue; // # だけ
            if (!isValid(input, i, j)) {
                console.log('No');
                return;
            }
        }
    }
    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort()
ta = 0
tc = 0
for i in range(len(a)):
    tc += min(m, a[i][1])
    ta += min(m, a[i][1]) * a[i][0]
    m -= min(m, a[i][1])
    if m == 0:
        print(ta)
        exit()


Measured memory_bytes: 27880
#include<stdio.h>
int main(){
  int n,i,a[1000000],c=0;
  scanf ("%d",&n);
  for (i=0;i<n;i++)
  {
  scanf("%d",&a[i]);
  //for(i=0;i<n;i++)
    c+=a[i]-1;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll N; cin >> N;
    vector<pair<ll, ll>> fac;
    for(ll p = 2; p * p <= N; p++){
        if(N % p != 0) continue;
        ll cnt = 0;
        while(N % p == 0){
            cnt++;
            N /= p;
        }
        fac.push_back(make_pair(p, cnt));
    }
    if(N != 1) fac.push_back(make_pair(N,1));
    ll ans = 0;
    for(auto x:fac){
        ll e = x.second;
        ll cnt = 0;
        ll tmp = 1;
        while(e >= tmp){    
            e -= tmp;
            tmp++;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << endl;
}

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

#include <math.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;


int main()
{
	
	string str;
	cin >> str;
	int t=0;
	for (int i = 0; i < 3; i++) {
		
		if (str[i] == 'o') t += 100;


		
	
	}


	cout << 700 + t << endl;








}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b){ return a*b/gcd(a,b);}
int main()
{
	ll a,b;
	cin>>a>>b;
	
	if(a>b) swap(a,b);
	cout<<lcm(a,b)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int,input().split())

CAM = list([list(map(int,input().split())) for i in range(N)])
# print(CAM)
minn = 10**18
b = False

for i in range(2 ** N):
  s = 0
  am = []

  for j in range(N):  # このループが一番のポイント
      if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
        am.append(CAM[j])

  j = False
  sss = [0] * (M+1)
  for kk in range(len(am)):
    s += am[kk][0]
    for m in range(0, M):
      sss[m+1] += am[kk][m+1]
  
  if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):
    b = True
    minn = min(s,minn)
  
  # print(sss)
  # if x >= X and y >= X and z >= X:
  #   minn = min(s,minn)
  #   b = True

print(minn if b == True else -1)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int dfs(int x,int y,int index);
int h,w;
int dp[5][110][110];

int main(){
  while(cin >> w >> h && h && w){
    for(int i=0;i<5;i++){
      for(int j=0;j<110;j++){
	for(int k=0;k<110;k++){
	  dp[i][j][k] = -1;
	}
      }
    }
    cout << dfs(0,0,0) << endl;
  }
}

int dfs(int x,int y,int index){
  if(x >= w || y >= h) return 0;
  if(x == w-1 && y == h-1) return 1;
  if(dp[index][x][y] != -1) return dp[index][x][y];
  int ret = 0;
  if(x == 0 && y == 0) ret = dfs(x+1,y,0) + dfs(x,y+1,1);
  else if(index == 0) ret = dfs(x+1,y,0) + dfs(x,y+1,3);
  else if(index == 1) ret = dfs(x+1,y,2) + dfs(x,y+1,1);
  else if(index == 2) ret = dfs(x+1,y,0);
  else if(index == 3) ret = dfs(x,y+1,1);
  
  return dp[index][x][y] = ret % 100000;
}

Measured memory_bytes: 1408
n, s = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
x << s
x.sort_by!{|y| y}
y = []
n.times do |i|
  y << (x[i + 1] - x[i])
end
puts y.inject{|a, b| a.gcd(b)}

Measured memory_bytes: 11648
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/**
 * @author dwij
 */

#include <bits/stdc++.h>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>

using namespace std;

//******* Debugging Class Template *******/
#define sim template <class c
#define ris return *this
#define dor > deb& operator<<
#define eni(x) \
    sim > typename enable_if<sizeof dud<c>(0) x 1, deb&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct deb {
#ifdef LOCAL
    ~deb() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define log(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// End of weird debugging stuff.

typedef long long ll;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define endl "\n"

void solution() {
    // deb() << log();
    int n;
    cin >> n;
    vll arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    sort(arr.rbegin(), arr.rend());

    deb() << log(arr);

    ll ans = arr[0];
    for (int i = 1; i < n / 2; i++) {
        ans += arr[i] * 2LL;
        deb() << log(ans);
    }

    if (n % 2 != 0) {
        ans += arr[n / 2];
    }

    cout << ans << endl;
}

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

    int T = 1;
    // cin >> T;
    // cin.ignore(); must be there when using getline(cin, s)
    for (int tt = 1; tt <= T; tt++) {
        // cout << "Case #" << tt << ": ";
        solution();
    }

    return 0;
}


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

#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define f80 double
#define LOCAL 0
#define endl '\n'

typedef long long int ll;
#define int long long int

const int mod = 1e9 + 7;
const int N = 100005;
const int inf = 2e9;

signed main(){
    IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
    }
    int n;
    cin >> n;
    int s = 0, x;
    forn(i, 1, n){
        cin >> x;
        s += (x - 1);
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "bitset"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int time = 60 * (H2 - H1) + (M2 - M1);
    cout << time - K << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,M;cin >> N >> M;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];
    map<LL,LL> m;
    vector<LL> rui(N+1);
    rui[0] = 0;
    rep(i,N){
        rui[i+1] = rui[i] + A[i];
    }

    rep(i,N+1){
        LL tmp = rui[i] % M;
        m[tmp]++;
    }

    LL ans = 0;
    for(auto a : m){
        ans += (a.S)*(a.S-1)/2;
    }
    cout << ans << endl;
}

// ABC105 D - Candy Distribution

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	int n, m; cin >> n >> m;
	int a[n][m];
	FOR (i, 0, n-1) FOR (j, 0, m-1) cin >> a[i][j];

	vi take(m+1, 1);
	int ans = n;
	// int st = 1, en = n;
	// while (st < en) {
		// bool can = 0;
		// int mid = (st + en) >> 1;
		while (1) {
			vi p(m+1);
			FOR (i, 0, n - 1) {
				FOR (j, 0, m - 1) {
					if (take[a[i][j]]) {
						p[a[i][j]]++;
						break;
					}
				}	
			}
			auto it = max_element(all(p));
			if (*it == 0) break;
			ans = min(ans, *it);
			take[it-p.begin()] = 0;
		}
		// if (can) en = mid;
		// else st = mid+1;
	// }
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, t = map(int, readline().split())

    print(max(X - t, 0))

    return


if __name__ == '__main__':
    main()


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

int main(){
int k,a,b;
cin>>k;
cin>>a;
cin>>b;
 int x=b/k;
 int y=x*k;
 if(y>=a && y<=b)
    cout<<"OK";
 else
    cout<<"NG";

    return 0;
}


Measured memory_bytes: 3632
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    int N, M, p;
    readf("%d %d %d\n", &N, &M, &p);
    int[] d = new int[M];
    foreach(i; 0..M) d[i] = readln.chomp.to!int;
    d = d.map!(a=>(a-p+N)%N).array.sort;
    (iota(-1, M).map!(i => [i<0?0:d[i], i+1>=M?0:N-d[i+1]]).map!(a => min(a[0]*2+a[1], a[0]+a[1]*2)).reduce!min*100).writeln;
}

Measured memory_bytes: 2828
import java.util.*;class Main{public static void main(String[]_){Scanner S=new Scanner(System.in);double o=1e4,a,b,c,n[]=new double[6],l[];for(int i,m=S.nextInt();m-->0;System.out.printf("%.3f %.3f %.3f\n",n[3],n[4],n[5])){l=n.clone();for(i=0;i<6;)n[i++]=S.nextDouble();for(i=0;(i+=2)<5;l[i+1]=2*(n[i+1]-n[1]))l[i]=2*(n[i]-n[0]);l[0]=n[0]*n[0]+n[1]*n[1]-n[2]*n[2]-n[3]*n[3];l[1]=n[0]*n[0]+n[1]*n[1]-n[4]*n[4]-n[5]*n[5];n[3]=(l[3]*l[1]-l[5]*l[0])/(l[2]*l[5]-l[4]*l[3])*o;n[4]=(l[0]*l[4]-l[1]*l[2])/(l[2]*l[5]-l[4]*l[3])*o;n[5]=Math.hypot(n[3]/o-n[0],n[4]/o-n[1])*o;for(i=2;++i<6;n[i]/=o)n[i]+=n[i]%10<5?-n[i]%10:10-n[i]%10;}}}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t;cin>>t;while(t--)
#define f(i,n) for (int i=0;i<n;i++)
#define fa(i,a,b) for (int i=a;i<b;i++)
#define b(i,a,b) for (int i=a;i>=b;i--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define fi first    
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<">"<<#x<<" = "<<x<<endl;
// #define MOD 1000000007
#define ce cout<<"\n"

int main()
{
    int n, i, j=0, fact[10] = {0};
    fact[0]=1;
    cin>>n;
    int x[n], y[n];
    for(i=0; i<n; i++){
        cin>>x[i]>>y[i];
        fact[i+1] = fact[i]*(i+1);
    }

    vector<int> v;
    for(i=0; i<n; i++)
        v.pb(i);
    ld ans = 0, p = fact[n];
    do{
        for(i=0; i<n-1; i++)
        {
            ld x1 = pow(x[v[i]] - x[v[i+1]], 2);
            ld y1 = pow(y[v[i]] - y[v[i+1]], 2);
            ld a = sqrt(x1+y1);
            ans+=a;
        }
    }while(next_permutation(v.begin(), v.end()));
    ans = ans/p;
    cout<<setprecision(18)<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
int main(){
    int n,k; cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    int dp[k+1];
    dp[0]=0;
    for(int i=1;i<=k;i++){
        dp[i]=0;
        int temp=1;
        for(int j=0;j<n && i>=A[j];j++){
            if(dp[i-A[j]]==0) temp=0;
        }
        if(temp==0) dp[i]=1;
    }
    //for(auto it:dp) cout<<it<<" ";
    string s=(dp[k]==1) ? "First" : "Second" ;
    cout<<s;
}//

Measured memory_bytes: 4012
n,p=map(int,input().split())

def fctr1(n): #[[素因数,数]]を出力
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f
a=fctr1(p)
ans=1
for i in range(len(a)):
    ans=ans*(a[i][0]**(a[i][1]//n))
print(ans)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int count = 0;
        for (int i = Integer.parseInt(a); i <= Integer.parseInt(b); i++) {
            List<String> iList = Arrays.asList(String.valueOf(i).split(""));
            List<String> reverseList = new ArrayList<>();
            for (int j = iList.size() - 1; j >= 0; j--) {
                reverseList.add(String.valueOf(iList.get(j)));
            }
            for (int j = 0; j < iList.size(); j++) {
                if (!iList.get(j).equals(reverseList.get(j))) {
                    break;
                }
                if (j == iList.size() - 1) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 65112
/*     If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

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

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b){a+=b; a%=MOD;if(a<0) a+=MOD;return a;}
//doesn't work for neg numbers

ll mult(ll a, ll b){if(a>MOD) a%=MOD;if(b>MOD) b%=MOD;ll ans=(a*b)%MOD;if(ans<0) ans+=MOD;return ans;}
//doesn't work for neg numbers

ll pw(ull a, ull b){ll r=1;while(b){if(b&1) r=mult(r,a);a=mult(a,a);b>>=1;}return r;}
//doesn't work for neg numbers

ll a[1000001];

void solve(){
	ll n;
    cin>>n;
    int i;
    if(n%2==0){cout<<-1<<endl;return;}a[1] = 7%n;
    if(a[1]==0){cout<<1<<endl;return;}
    for(i=2;i<=n;i++){a[i] = (a[i-1]*10 + 7) % n;if(a[i]==0){cout<<i<<endl;return;}}
    cout<<-1<<endl;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;        
        //cout<<"Case "<<k<<": ";
        solve();
    }
}


Measured memory_bytes: 11416
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

ll gcd(ll a, ll b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto m = b % a;
        if (m == 0)
            return a;
        b = a;
        a = m;
    }
}

int main()
{
    using namespace std;

    string s;
    cin >> s;

    auto w = count(s.cbegin(), s.cend(), 'o');

    if (w + (15 - s.size()) >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_macros)]

macro_rules! line {
    () => {{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf
    }};
}
macro_rules! line_as_vec {
    ( $t:ty ) => {
        line!()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    };
}
macro_rules! input {
    { $( $i:ident : $t:ty ),* } => {
        let ( $( $i ),* ) = match &line!().split_whitespace().collect::<Vec<_>>()[..] {
            &[ $( $i ),* ] => ( $( $i.parse::<$t>().unwrap() ),* ),
            _ => panic!(),
        };
    };
}

fn main() {
    input!(h1: f64, a1: f64, h2: f64, a2: f64);
    println!(
        "{}",
        if (h2 / a1).ceil() <= (h1 / a2).ceil() {
            "Yes"
        } else {
            "No"
        }
    )
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		char[] x = new char[N];
		for (int i = 0; i < N; i++) {
			if (i == K - 1) {
				char a = S.charAt(i);
				x[i] = Character.toLowerCase(a);
			} else {
				x[i] = S.charAt(i);
			}
		}

		for (int i = 0; i < x.length; i++) {
			System.out.print(x[i]);
		}
	}

}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
bool dp[100005];
ll a[105];

int32_t main(){
    IOS;
    ll i,j,k,n,m,p,q;
    cin >> n >> k;
    fori2(n) cin >> a[i];
    dp[0] = 1;
    for(i = 1 ; i <= k ; i++){
        dp[i] = 1;
        for(j = 1 ; j <= n ; j++){
            if(a[j] <= i && dp[i-a[j]] == 1){
                dp[i] = 0;
                break;
            }
        }
    }
    if(!dp[k]) cout <<"First\n";
    else cout <<"Second\n";


} 

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
const int mx = 100020;
pair<int, int> a[mx];
int main()
{
    int n;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i)
    {
        cout << a[i].second << " ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<iostream>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    char ban[10][10]={{},{'.',',','!','?',' ','#'},{'a','b','c','#'},{'d','e','f','#'},{'g','h','i','#'},{'j','k','l','#'},{'m','n','o','#'},{'p','q','r','s','#'},{'t','u','v','#'},{'w','x','y','z','#'}};
    char in[1025]={};
    /*
    REP(i,10)
    {
        REP(j,10)printf("%c ",ban[i][j]);
        printf("\n");
    }
    */
    int a;
    scanf("%d\n",&a);
    while(a-->0)
    {
        REP(i,1025)in[i]='\0';
        scanf("%s\n",in);
        if(in[0]=='\0')return 0;
        char *a=&in[0];
        int num=0;
        int row=0;
        while(*a!='\0')
        {
            if(*a=='0')
            {
                if(ban[row][num]!='\0')printf("%c",ban[row][num]);
                row=0;
                num=0;
            }
            else if(row==*a-'0')
            {
                num++;
                if(ban[row][num]=='#')num=0;
            }
            else if(row!=*a-'0')
            {
                row=*a-'0';
                num=0;
            }
            a++;
        }
        if(ban[row][num]!='\0')printf("%c",ban[row][num]);
        printf("\n");
    }
    return 0;
}


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

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

int main() {
int n,k;
  cin >> n>>k;
  cout << (n % k == 0 ? 0:1) << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
while(true) {
	$n = trim(fgets(STDIN));
	if ($n == 0) {
		break;
	}
	$sum = 0;
	for ($i = 0; $i < $n; $i++) {
		list($x, $y, $h, $w) = explode(' ', trim(fgets(STDIN)));
		$s = $x + $y + $h;
		$p1 = 0;
		$p2 = 0;
		if ($s <= 60) {
			$p1 = 600;
		} elseif ($s <= 80) {
			$p1 = 800;
		} elseif ($s <= 100) {
			$p1 = 1000;
		} elseif ($s <= 120) {
			$p1 = 1200;
		} elseif ($s <= 140) {
			$p1 = 1400;
		} elseif ($s <= 160) {
			$p1 = 1600;
		}
		if ($w <= 2) {
			$p2 = 600;
		} elseif ($w <= 5) {
			$p2 = 800;
		} elseif ($w <= 10) {
			$p2 = 1000;
		} elseif ($w <= 15) {
			$p2 = 1200;
		} elseif ($w <= 20) {
			$p2 = 1400;
		} elseif ($w <= 25) {
			$p2 = 1600;
		}
		if ($p1 > 0 && $p2 > 0) {
			$sum += max($p1, $p2);
		}
	}
	echo "$sum\n";
}

Measured memory_bytes: 6624
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		char[] stone = sc.next().toCharArray();
		
		int count = 0;
		int ans = Integer.MAX_VALUE;
		for(int i=0;i<N;i++){
			if(stone[i]=='.')count++;
		}
		ans = Math.min(ans,count);
		for(int i=0;i<N;i++){
			if(stone[i]=='.'){
				count--;
			}else{
				count++;
			}
			ans = Math.min(ans,count);
		}

		System.out.println(ans);
		
		sc.close();
	}
	
}


Measured memory_bytes: 27424
#include<iostream>
using namespace std;
//一点更新区間取得
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn;
	function<T(T,T)>updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b,int i=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query(a,b,i*2+1,l,(l+r)/2),
				query(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
};

main()
{
	int n,q;cin>>n>>q;
	segtree<int>rmq(n);
	for(int i=0;i<q;i++)
	{
		int c,x,y;cin>>c>>x>>y;
		if(c)cout<<rmq.query(x,y+1)<<endl;
		else rmq.update(x,y);
	}
}



Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
cin>>n;
ll prev, ans=0;
cin >> prev;
for(ll i = 1; i < n; i++)
{
  ll a;
  cin>>a;
  if (a==prev&&prev!=1234567890987654321)
ans++, prev=1234567890987654321;
else prev=a;
}
cout << ans;
}

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

int main(){
    string s ;
    cin >> s ;
    if (s.size() % 2 != 0)
    {
        cout << "No" << endl ;
        return 0 ;
    }
    
    for (size_t i = 0; i < s.size()/2; i++)
    {
        if (s.at(i*2) != 'h' || s.at(i*2+1) != 'i')
        {
            cout << "No" << endl ;
            return 0 ;
        }
        
    }
    cout << "Yes" << endl ;
}

Measured memory_bytes: 256
/**
 * 幅優先でトポロジカルソート
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()

    Main.display()
}

class Main {

    companion object {

        // 連結リスト
        private val graphMatrix = arrayListOf<ArrayList<Int>>()

        private val nodeList = arrayListOf<Node>()
        private val out = arrayListOf<Int>()

        private val Q = Queue(arrayListOf())

        fun init() {
            val (nodeNum, lineNum) = readLine()!!.split(" ")

            for (index in 1..nodeNum.toInt()) {
                graphMatrix.add(arrayListOf())
                nodeList.add(Node())
            }

            for (index in 1..lineNum.toInt()) {
                val (from, to) = readLine()!!.split(" ")
                // 連結リストに保存
                graphMatrix[from.toInt()].add(to.toInt())
                // 入次数を記録
                nodeList[to.toInt()].indeg++
            }
        }

        fun execute() {
            for (index in 0 until graphMatrix.size) {
                // 入次数が0の場合は、計算できる
                if (nodeList[index].color == Node.COLOR.WHITE && nodeList[index].indeg == 0) {
                    nodeList[index].color = Node.COLOR.GRAY
                    Q.enqueue(index)
                    bfs()
                }
            }
        }

        fun bfs() {
            while(!Q.isEmpty()) {
                val dequedIndex = Q.dequeue()!!

                out.add(dequedIndex)

                graphMatrix[dequedIndex].forEach {
                    // つながりを切る
                    nodeList[it].indeg--

                    // 入次数が0の場合は、計算できる
                    if (nodeList[it].color == Node.COLOR.WHITE && nodeList[it].indeg == 0) {
                        // 計算済みとする
                        nodeList[it].color = Node.COLOR.GRAY
                        // 計算候補に追加
                        Q.enqueue(it)
                    }
                }
            }
        }

        fun display() {
            println(out.joinToString("\n"))
        }

    }
}

class Node {
    /**
     * GRAYは計算完了済。
     */
    enum class COLOR {
        WHITE,
        GRAY
    }

    var indeg: Int = 0

    var color: COLOR = COLOR.WHITE
}

class Queue(list: MutableList<Int>) {

    var items: MutableList<Int> = list

    fun isEmpty(): Boolean = items.isEmpty()


    fun contains(i: Int): Boolean = items.contains(i)

    fun size(): Int = items.count()

    override fun toString() = items.toString()

    fun enqueue(element: Int) {
        items.add(element)
    }

    fun dequeue(): Int? {
        if (this.isEmpty()) {
            return null
        } else {
            return items.removeAt(0)
        }
    }

    fun peek(): Int? {
        return items[0]
    }
}


Measured memory_bytes: 66900
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    // Let's think we want to decrement all h with the process.

    // while all h is not zero

    var answer = 0

    // Find a window which doesn't contains 0 in a row
    while (true) {
        var index = 0
        // find start index
        while (index < N && h[index] == 0) {
            index++
        }
        val startIndex = index // inclusive
        if (startIndex == N) {
            break
        }

        while (index < N && h[index] != 0) {
            index++
        }
        val endIndex = index // exclusive

        answer++
        (startIndex..(endIndex-1)).forEach {
            h[it]--
        }
    }

    println(answer)
}


Measured memory_bytes: 37932
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6+100;
ll n;
ll ans ;
ll cnt;
ll prime[N] = {0},num_prime = 0;      
bool isNotPrime[N] = {1, 1};
ll sieve(ll n)
{
	for(ll i = 2 ; i < n ; i ++)         
    {              
    if(! isNotPrime[i])            
        prime[num_prime ++]=i;
	for(ll j = 0 ; j < num_prime && i * prime[j]<  N ; j ++)  
        {                 
        	isNotPrime[i * prime[j]] = 1;
            if( !(i % prime[j] ) )  
	            break;             
        }          
    }    
    
    return num_prime;
}

vector<pair<ll, ll> > prime_divide(ll x)
{
	vector<pair<ll, ll> > res;
	for(ll i=0;i<num_prime;i++)
	{
		ll nowprime = prime[i];
		if(nowprime*nowprime > x)	break;
		if(x%nowprime)	continue;
		res.emplace_back(nowprime,0);
		cnt++;
		do
		{
			
			res.back().second++;
		}while((x /= nowprime)%nowprime == 0);
	}
	if(x!=1)	cnt++,res.emplace_back(x,1);
	return res;
 }


int main()
{
	cin >> n;
	sieve(1e6);
	ans ++;
	for(ll i=2;i<n;i++)
	{
		ll sum = 1;
		cnt = 0;
		vector<pair<ll, ll> > now  = prime_divide(i);
		for(ll j=0;j<cnt;j++)
		{
			sum *= (now[j].second+1);
		}
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <string>
#include <map>
using namespace std;

typedef pair<int,int> P;
string m  = ">^<v",s;
char mas[21][21];
int w,h,muki,sx,sy,len;
int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int shoot(int i,int j){
    if((!(i >= 0 && i < h && j >= 0 && j < w)) || (mas[i][j] == '#')) return 1;
    if(mas[i][j] == '*'){
        mas[i][j] = '.';
        return 1;
    }
    return shoot(i+dy[muki],j+dx[muki]);
}

P search(){
    int i = sy,j = sx;
    for(int k=0;k<len;k++){
        if(s[k] == 'R'){
            muki = 0;
            if(i >= 0 && i < h && j+1 >= 0 && j+1 < w && mas[i][j+1] == '.') j++;
        }
        if(s[k] == 'U'){
            muki = 1;
            if(i-1 >= 0 && i-1 < h && j >= 0 && j < w && mas[i-1][j] == '.') i--;
        }
        if(s[k] == 'L'){
            muki = 2;
            if(i >= 0 && i < h && j-1 >= 0 && j-1 < w && mas[i][j-1] == '.') j--;
        }
        if(s[k] == 'D'){
            muki = 3;
            if(i+1 >= 0 && i+1 < h && j >= 0 && j < w && mas[i+1][j] == '.') i++;
        }
        if(s[k] == 'S'){
            shoot(i,j);
        }
    }
    P p = P(i,j);
    return p;
}

int main(){
    int t;
    bool judge = false;
    cin >> t;
    while(t--){
        if(judge) cout << endl;
        judge = true;
        cin >> h >> w;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> mas[i][j];
                if(mas[i][j] == '>'){
                    muki = 0; mas[i][j] = '.';
                    sx = j; sy = i;
                }
                if(mas[i][j] == '^'){
                    muki = 1; mas[i][j] = '.';
                    sx = j; sy = i;
                }
                if(mas[i][j] == '<'){
                    muki = 2; mas[i][j] = '.';
                    sx = j; sy = i;
                }
                if(mas[i][j] == 'v'){
                    muki = 3; mas[i][j] = '.';
                    sx = j; sy = i;
                }
            }
        }
        cin >> len >> s;
        P p = search();
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i == p.first && j == p.second) cout << m[muki];
                else cout << mas[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1208
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int main(){
  int c = 6;
  int a, b;
  fastScan(a);
  fastScan(b);
  c -= a;
  c -= b;
  printf("%d\n", c);
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define IO                       \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define mem(a, x) memset(a, x, sizeof(a))
#define per(x, a, b) for (int x = a; x <= b; x++)
#define rep(x, a, b) for (int x = a; x >= b; x--)

using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-8;

int n;
LL a[maxn];
vector<int> s1, s2, s3;
bool solve() {
    // cout << s1.size() << " " << s2.size() << " " << s3.size() << endl;
    int nm = 0;
    if (s2.size() == 0)
        nm = s1.size() + 1;
    else {
        nm = s1.size();
    }
    if ((int)s3.size() > nm)
        return false;
    return true;
}

int main() {
#ifdef LOCAL_IM0QIANQIAN
    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#else
    IO;
#endif // LOCAL_IM0QIANQIAN

    while (cin >> n) {
        s1.clear();
        s2.clear();
        s3.clear();
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] % 4 == 0)
                s1.push_back(a[i]);
            else if (a[i] % 2 == 0)
                s2.push_back(a[i]);
            else {
                s3.push_back(a[i]);
            }
        }
        if (solve()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1788
from collections import deque
N,H = map(int,input().split())
A=[]
B=[]
d=deque()
max_axe = 0
max_throw = 0
ans=0
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)
    
for i in B:
    if i>=A[0]:
        H-=i
        ans+=1
        if H<=0:break
    else:
        break

if H>0:ans+=int(-(-H//A[0]))

print(ans)

Measured memory_bytes: 11580
import itertools
from collections import defaultdict
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
dd = defaultdict(int)
for xy1, xy2 in itertools.combinations(xy, 2):
    x1, y1 = xy1
    x2, y2 = xy2
    unit_vect = (x1-x2, y1-y2)
    dd[unit_vect] += 1
    unit_vect = (x2-x1, y2-y1)
    dd[unit_vect] += 1

if n == 1:
    ans = 1
else:
    ans = n-max(dd.values())
print(ans)

Measured memory_bytes: 3828
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main()
    {
        var st = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        // var t = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Test(st, n);
    }

    static void Test(string s, int n)
    {
        List<string> ans = new List<string>();

        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 1; j <= s.Length - i&& j <= n; j++)
            {
                var sub = s.Substring(i, j);
                if (sub != string.Empty)
                {
                    ans.Add(sub);
                    
                }


            }
           // ans.Sort();
            //if (ans.Count>n)
            //    break;
        }
         ans.Sort();
        var r=ans.Distinct().ToList();
        Console.Write(r[n - 1]);
    }



}



Measured memory_bytes: 15200
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

a = 0
b = 0
for i, r in enumerate(permutations(range(n), n)):
    flagp = 1
    flagq = 1
    for j in range(n):
        if p[j]-1 != r[j]:
            flagp = 0
        if q[j]-1 != r[j]:
            flagq = 0
    if flagp:
        a = i
    if flagq:
        b = i

print(abs(a-b))


Measured memory_bytes: 42736
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
q=[0,0,0]
for i in p:
  if(i<=a):q[0]+=1
  elif(i<=b):q[1]+=1
  else:q[2]+=1
print(min(q))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
using namespace std;
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
int n,m;

int main(){
	n=R();
	m=R();
	printf("%d",max(n+m,max(n-m,n*m))); 
	return 0;
}



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

int main() {
  string vowel = "aeiou";
  char c;
  cin >> c;
  for (int i = 0; i < 5; i++) {
    if (c == vowel.at(i)) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)



int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int ans[110] = {0,};
    int num = 1;
    for (int i = 100; i >= 1; i--) {
        if (a%i==0 && b%i==0) {
            ans[num] = i;
            num++;
            
        }
    }
    
    cout << ans[k] << endl;
    return 0;
}


Measured memory_bytes: 256