akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N; cin >> N;
  vector<string> s;
  rep(_, N){
    string si;
    cin >> si;
    sort(si.begin(), si.end());
    s.push_back(si);
  }
  sort(s.begin(), s.end());

  ll ans = 0, cnt = 0;
  repi(i, 1, N){
    if(s[i-1] == s[i]){
      cnt++;
      ans += cnt;
    }
    else cnt = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
signed main() {
	int n, cnt=0;
	cin >> n;
	if (n % 10 == 2)cnt++;
	n /= 10;
	if (n % 10 == 2)cnt++;
	n /= 10;
	if (n % 10 == 2)cnt++;
	n /= 10;
	if (n % 10 == 2)cnt++;
	cout << cnt << endl;
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int k = cin.NextInt();

        double prob = 0.0;
        for (int i = 1; i <= n; i++)
        {
            long tmp = i;
            double thisProb = 1.0;
            while(tmp < k)
            {
                tmp *= 2;
                thisProb *= 0.5;
            }
            prob += thisProb / n;
        }
        Console.WriteLine(prob);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,d;
cin >> n >> d;
int ans=0;
int count=0;
while(1){
  count+=2*d+1;
  ans++;
  if(count>=n) break;
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
D_list = [int(e) for e in input().split()]
M = int(input())
T_list = [int(e) for e in input().split()]
D_counted = collections.Counter(D_list)
T_counted = collections.Counter(T_list)

for difficult,count in T_counted.items():
    if difficult in D_counted and D_counted[difficult] >= count:
        pass
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 57144
#include<iostream>
#include<stack>
using namespace std;
int n, x[300000];
int main() {
	cin >> n;
	stack<int>S; int sum = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (sum < x[i]) {
			S.push(x[i] - sum); cnt++;
			sum = x[i];
		}
		else {
			while (sum > x[i]) {
				sum -= S.top();
				S.pop();
			}
			if (sum < x[i]) {
				S.push(x[i] - sum);
				sum = x[i]; cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2588
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll DIV = 998244353;

int main(void) {
   ll N;
   cin>>N;
   map<ll,ll> A;
   ll a;
   rep(i,0,N) {
      cin>>a;
      if (A.count(a)) A[a]++;
      else A[a] = 1;
   }
   // for(auto el: A) cout<<el.first<<" "<<el.second<<endl;

   for (auto& el: A) {
      if (el.second>=3) el.second = el.second%2?1:2;
   }
   // for(auto el: A) cout<<el.first<<" "<<el.second<<endl;
   ll Num[2] = {0,0};
   ll ans =0;
   for(auto el: A) Num[el.second-1]++;
   if (Num[1]%2 == 1) ans = Num[0]+Num[1]-1;
   else ans = Num[0]+Num[1];
   cout<<ans<<endl;


   return 0;
}



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

int main(){
  int n,y;
  cin >> n >> y;
  int tth=n,fth=0,th=0;
  bool ok=false;
  for(int i=0;i<=n;i++){
    tth=i;
    for(int j=0;j<=n-i;j++){
      fth=j;
      th=n-i-j;
      if(tth*10000+fth*5000+th*1000==y){
        ok=true;
        break;
      }
    }
    if(ok)
      break;
  }
  if(ok)
    cout << tth << " " << fth << " " << th << endl;
  else
    cout << "-1 -1 -1\n";
  return 0;
}

Measured memory_bytes: 3624
N=int(input())
A=list(map(int, input().split()))
B=[A[i]-i-1 for i in range(N)]
B=sorted(B)

center=B[N//2] if N%2==1 else round((B[(N-1)//2]+B[(N+1)//2])/2)
ans=0
for i in B:
    ans+=abs(i-center)
print(ans)

Measured memory_bytes: 101332
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

bool ans = false;
int length,e_loc[501],e_index = 0;
int memo[500][500];

char buf[501];

bool recursive(int left,int right){
    if(ans)return true;
    if(buf[left] != 'm' || buf[right] != 'w')return false;

    bool FLG = false;
    for(int i = 0; i < e_index; i++){
        if(left < e_loc[i] && right > e_loc[i]){
            FLG = true;
            if(((e_loc[i] == left+1) || memo[left+1][e_loc[i]-1] == 1 || (memo[left+1][e_loc[i]-1] != 99 && recursive(left+1,e_loc[i]-1) == true)) &&
             ((e_loc[i] == right-1) || memo[e_loc[i]+1][right-1] == 1 || (memo[e_loc[i]+1][right-1] != 99 &&recursive(e_loc[i]+1,right-1)) == true)){
                if(left == 0 && right == length-1){
                	ans = true;
                }
                memo[left][right] = 1;
                return true;
            }
        }
    }
    memo[left][right] = 99;
    return false;
}


int main(){

    scanf("%s",buf);

    for(length = 0;buf[length] != '\0';length++){
        if(buf[length] == 'e'){
            e_loc[e_index++] = length;
        }
    }

    for(int i = 0; i < length; i++){
    	for(int k = 0; k < length; k++)memo[i][k] = -1;
    }

    recursive(0,length-1);
    if(ans){
        printf("Cat\n");
    }else{
        printf("Rabbit\n");
    }

    return 0;
}

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

int main() {
  string N;
  cin>>N;
  for(int i=0;i<N.size();i++){
    if(N.at(i)=='1')N.at(i)='9';
    else N.at(i)='1';
  }
  cout<<N<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

bool check(vector<pair<int,int>> &branch)
{
    string s; cin >> s;
    int n = s.length();
    int nodeindex = 0;
    int lastparent = 0;
    int lastnum = 0;
    if( s[n - 1] == '1' ) return false;
    rep(i, n / 2  )
    {
        if( s[i] != s[ n - 2 - i ] ) return false;
        if( i == 0 )
        {
            if( s[i] != '1' ) return false;
            lastparent = nodeindex++;
            lastnum = i;
        }
        else
        {
            if( s[i] == '1' )
            {
                branch.emplace_back(lastparent, nodeindex);
                lastparent = nodeindex;
                nodeindex++;

                while( i > lastnum + 1 )
                {
                    branch.emplace_back(lastparent, nodeindex++);
                    lastnum++;
                }
                lastnum = i;
            }
        }
    }

    int tsize = nodeindex;
    int t1top = lastparent;
    int branchsize = branch.size();
    int t2top = lastparent + tsize;
    rep(j, branchsize)
    {
         branch.emplace_back( branch[j].first + tsize, branch[j].second + tsize );
    }
    nodeindex += nodeindex;

    branch.emplace_back(t1top, t2top);
    while(nodeindex < n)
    {
        branch.emplace_back(t2top, nodeindex++);
    }

    return true;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); 
    vector<pair<int,int>> branch;
    if( check(branch) )
    {
        vecrep(itr, branch)
        {
            cout << itr->first + 1 << " " << itr->second + 1 << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 4428
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans = 0
t_dif = 999
t_dif1 = 0
for i in range(n):
    t_dif1 = abs(a - (t - h[i]*0.006))
    if t_dif1 < t_dif:
        ans = i+1
        t_dif = t_dif1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;

const int INF = 1000000;

int n;
vector<vector<int>> graph;

vector<int> bfs(int start){
    vector<int> dFrom(n+1,INF);
    queue<int> que;
    que.push(start);
    dFrom[start] = 0;

    while(que.size()){
        int tmpPoint = que.front();
        que.pop();

        for(int i=0; i<graph[tmpPoint].size(); i++){
            int nextPoint = graph[tmpPoint].at(i);

            if(dFrom[nextPoint] == INF){
                que.push(nextPoint);
                dFrom[nextPoint] = dFrom[tmpPoint] + 1;
            }
        }
    }
    return dFrom;
}

int main() {
    cin >> n;
    graph.resize(n+1);

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

    vector<int> dFrom1 = bfs(1);
    vector<int> dFromN = bfs(n);

    int black=0, white=0;
    for(int i=1; i<=n; i++){
       dFromN[i] >= dFrom1[i] ? black++ : white++;
    }

    white >= black ? printf("Snuke\n") : printf("Fennec\n");
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s, k = "keyence";
    cin >> s;
    int N = s.size();
    bool isok = false;
    rep(i, 8) {
        string t = s.substr(0, i) + s.substr(N - 7 + i, 7 - i);
        // cout << s.substr(0, i) << " " << s.substr(N - 7 + i, 7 - i) << endl;
        if (t == k) {
            isok = true;
            break;
        }
    }
    cout << (isok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
by_sweets = {}
for _ in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        by_sweets.setdefault(a, 0)
        by_sweets[a] += 1


print(n - len(by_sweets))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

typedef struct {
  string name;
  int score;
  int id;
} restaurant;

int main() {
  int N; cin >> N;
  vector<restaurant> rs(N);
  rep(i, N) { cin >> rs[i].name >> rs[i].score; rs[i].id = i+1; }
  bool sorted = false;
  while(!sorted) {
    sorted = true;
    for(int i=0; i<rs.size()-1; ++i) {
      if(rs[i].name > rs[i+1].name) {
        sorted = false;
        restaurant tmp = rs[i];
        rs[i] = rs[i+1];
        rs[i+1] = tmp;
      } else if(rs[i].name == rs[i+1].name) {
        if(rs[i].score < rs[i+1].score) {
          sorted = false;
          restaurant tmp = rs[i];
          rs[i] = rs[i+1];
          rs[i+1] = tmp;
        }
      }
    }
  }
  for(auto r:rs) cout << r.id << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

type point struct {
	x, y int
}

type container struct {
	data []point
}

func (c *container) isEmpty() bool {
	return len(c.data) == 0
}
func (c *container) queue(v point) {
	c.data = append(c.data, v)
}
func (c *container) dequeue(v *point) bool {
	if !c.isEmpty() {
		*v = c.data[0]
		c.data = c.data[1:]
		return true
	}
	return false
}

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	maze := make([]string, H)
	for i := range maze {
		fmt.Scan(&maze[i])
	}
	var dx = [4]int{1, -1, 0, 0}
	var dy = [4]int{0, 0, -1, 1}

	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if maze[i][j] == '#' { // スタート地点にできない
				continue
			}
			// (i,j)を開始地点としてBFSする
			maxd := 0
			d := make([][]int, H)
			for k := 0; k < H; k++ {
				d[k] = make([]int, W)
				for l := 0; l < W; l++ {
					d[k][l] = -1
				}
			}
			var q container
			d[i][j] = 0
			q.queue(point{j, i})
			for !q.isEmpty() {
				var p point
				q.dequeue(&p)
				for k := 0; k < 4; k++ {
					nx := p.x + dx[k]
					ny := p.y + dy[k]
					if 0 <= nx && nx < W && 0 <= ny && ny < H && d[ny][nx] == -1 && maze[ny][nx] == '.' {
						d[ny][nx] = d[p.y][p.x] + 1
						maxd = max(maxd, d[ny][nx])
						q.queue(point{nx, ny})
					}
				}
			}
			// fmt.Printf("s(%d,%d) -> maxd %d\n", j, i, maxd)
			ans = max(ans, maxd)
		}
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5376
N,T = map(int, input().split())
C = [list(map(int,input().split())) for i in range(N)]
X = sorted(C, key = lambda x:x[1])

i = 0
ans = 1001
while X[i][1] <= T:
  ans = min(ans, X[i][0])
  if i + 1 == N:
    break
  i += 1

if ans <= 1000:
  print(ans)
else:
  print("TLE")



Measured memory_bytes: 38736
#include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<unordered_set<int>> edges(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].insert(b);
    edges[b].insert(a);
  }
  bool ret = false;
  for (int i = 1; i + 1 < N; ++i) {
    if (edges[i].count(0) && edges[i].count(N - 1)) {
      ret = true;
      break;
    }
  }

  if (ret)
    cout << "POSSIBLE";
  else
    cout << "IMPOSSIBLE";
  cout << endl;
}

Measured memory_bytes: 31944
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n;
  cin >> n;
  if(n==0){co(1);}else{co(0);}
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    bitset<32> bs1(a), bs2(b);
    cout << (bs1 & bs2) << "\n" << (bs1 | bs2) << "\n" << (bs1 ^ bs2) << "\n";
    return 0;
}




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

int main() {
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  
  if(u == s) a--;
  if(u == t) b--;
  
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL X, Y;

int main()
{
	in >> X >> Y;
	out << X + Y / 2 << std::endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll p;
typedef vector<ll> poly;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

poly mul(const poly& x, ll k){
	poly res(p+1, 0);
	REP(i, p+1){
		if(i == 0) continue;
		res[i] = (x[i-1]-k*x[i]);
		res[i] %= p;
		res[i] += p;
		res[i] %= p;
	}
	res[0] = -k*x[0];
	res[0] %= p;
	res[0] += p;
	res[0] %= p;
	return res;
}

poly div(const poly& x, ll k){
	poly res(p+1, 0);
	for(int i=p-1;i>=0;i--){
		res[i] = (x[i+1] + k*res[i+1])%p;
	}
	return res;
}

vector<ll> rinv(5000);

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

    
    cin >> p;
    vector<ll> a(p);
    REP(i, p) cin >> a[i];
    REP(i, 5000) if(i>0) rinv[i] = modinv(i, p); 

    poly total(p+1, 0);
    total[0] = 1;
    REP(i, p){
    	total = mul(total, i);
    }
    //cout << total << endl;

    poly res(p+1, 0);
    REP(i, p){
    	auto tmp = div(total, i);
    	ll bai = a[i];
    	REP(j, p){
    		if(j==i) continue;
    		//bai *= modinv(((i-j)%p+p)%p, p);
    		bai *= rinv[((i-j)%p+p)%p];
    		bai %= p;
    	}
    	REP(j, p+1) res[j] += (tmp[j] * bai)%p, res[j] %= p;
    }

    REP(i, p) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int c = 0;
	string s;
	cin >> s;
	
	for(int i = 1; i < s.size(); i++){
		for(int j = 0; j < i; j++){
			if(s[i] == s[j]){
				c = 1;
				break;
			}
		}
		if(c == 1){
			cout<< "no" << endl;
			break;
		} 
	}
	if(c == 0)
		cout << "yes" << endl;
	
 	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;


class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main(void)
{
	ll n, m;
	cin >> n >> m;
	Divisor d(m);
	ll sum = 1;
	for (auto p : d.pfac()) {
		Factorial f(p.second + n - 1);
		sum *= f.cmb(p.second + n - 1, p.second);
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, max, ans = infi;
int dat[20];

int main(){
	while (std::cin >> n, n){
		ans = infi;
		rep(i, n)std::cin >> dat[i];

		max = (1 << n);
		rep(i, max){
			int sumA = 0, sumB = 0;
			rep(j, n){
				if ((i >> j) & 1)sumA += dat[j];
				else sumB += dat[j];
			}
			ans = std::min(ans, std::abs(sumA - sumB));
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N=int(input())
b=input().split()
c=[]
for i in range(N):
  c.append(int(b[i]))
ans='APPROVED'
for j in c:
  if j%2==0:
    if not(j%3==0 or j%5==0):
    	ans='DENIED'
    	break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
using namespace std;

int main () {
  int max = 100000;
  int prime[max + 1];
  int pp[max + 1];
  for (int i = 0; i <= max; i++) {
    prime[i] = 0;  
  }
  for (int i = 2; i <= max; i++) {
    bool ok = true;
    for (int j = 2; j <= (int) sqrt(i); j++) {
      if (i % j == 0) {
        ok = false;  
      }  
    }  
    if (ok) {
      prime[i]++;  
    }
  }  
  int sum[max + 1];
  for (int i = 0; i <= max; i++) {
    sum[i] = 0;  
    pp[i] = 0;
  }
  for (int i = 0; i <= max; i++) {
    if (prime[i] == 1 && prime[(i + 1) / 2] == 1) {
      pp[i] = 1;  
    }  
  }
  for (int i = 2; i <= max; i++) {
    sum[i] = sum[i - 1] + pp[i];    
  }
  int q;
  cin >> q;
  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  for (int i = 0; i < q; i++) {
    cout << sum[r[i]] - sum[l[i] - 1] << endl;  
  }
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i=1;i<n;i++)
    {
        ll x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;i++) cout<<a[i]<<"\n";
    return 0;
}

Measured memory_bytes: 4784
#include <stdio.h>
int main(void)
{
  int N, A, B, train, taxi;
  scanf("%d %d %d",&N, &A, &B);
  train = A * N;
  taxi = B;

  if(train < taxi)
    printf("%d\n", train);
  else
    printf("%d\n", taxi);

  return 0;
}



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

from collections import deque

ans = deque()

if N%2 == 0:
    for i in range(N):
        if i%2 == 0:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])
else:
    for i in range(N):
        if i%2 == 0:
            ans.appendleft(a[i])
        else:
            ans.append(a[i])

for i in range(N):
    print(ans[i],end=" ")

Measured memory_bytes: 26180
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    a,b=pin()
    t=(a+b)
    if t%2==0:print(t//2);return
    print("IMPOSSIBLE")
#%%submit!
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 0) : 1; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 0) : 1; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vii a(n); fore(i, 0, n) {
        cin >> a[i].fi;
        a[i].se = i + 1;
    }
    sort(a.begin(), a.end());
    fore(i, 0, n) cout << a[i].se << ' ';
    return 0;
}


Measured memory_bytes: 1664
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=deque([])
for i in range(n):
    a=int(input())
    ind=bisect.bisect_right(l,a-1)
    if ind==0:
        l.appendleft(a)
    else:
        l[ind-1]=a
print(len(l))

Measured memory_bytes: 9024
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;
pair<int,ii>a[N];

int main()
{
    int n; scanf("%d",&n);
    for(int i=1 ; i<=n ; i++){
        scanf("%d%d%d",&a[i].F,&a[i].S.F,&a[i].S.S);
    }

    sort(a+1,a+n+1);

    for(int i=0 ; i<n ; i++){
        int d=abs(a[i].S.F-a[i+1].S.F)+abs(a[i].S.S-a[i+1].S.S);
        int t=a[i+1].F-a[i].F;

        if(d > t){
            printf("No");
            return 0;
        }

        if(d&1){
            if(!(t&1)){
                printf("No");
                return 0;
            }
        }

        else{
            if(t&1){
                printf("No");
                return 0;
            }
        }
    }


    printf("Yes");

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#define pf printf
#define sc scanf
#define sf(xx) scanf("%lld",&xx)
#define INF (1<<30)-1+(1<<30)
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

// a new data structure defined. Please refer below
// GNU link : https://goo.gl/WVDL6g
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast()    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<class T1> void deb(T1 e1)
{
	cout << e1 << endl;
}
template<class T1, class T2> void deb(T1 e1, T2 e2)
{
	cout << e1 << " " << e2 << endl;
}
template<class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3)
{
	cout << e1 << " " << e2 << " " << e3 << endl;
}
#define bug(x) cerr<<#x<<" is "<<x<<endl
#define all(x) (x).begin(), (x).end()
#define unik(v) (v).erase(unique(all(v)), v.end())
#define sz(x) ((ll) (x).size())
const ll MOD = 1000000007;
int main()
{
	ll t, n, m, x, y, b, sum = 0, x1 = 0, c = 0, x2 = 0, mx = 0, u = 1, mn = 1e9;
	cin >> n;
	while (n--)
		{
			cin >> x;
			c = __gcd(x, c);
		}
	deb(c);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int x[5];
	rep(i, 5) {
		cin >> x[i];
	}
	rep(i, 5) {
		if (i + 1 != x[i]) {
			cout << i + 1;
			break;
		}
	}
	
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c){
        cout << "Yes" << endl;
    }
    else if (c + b == a){
        cout << "Yes" << endl;
    }
    else if (a + c == b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

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

int main(void)
{
	int n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	vector<int> left, right;
	for(int i=0;i<n;i+=(c+1)) {
		while(s[i]=='x') i++;
		right.pb(i);
		if(right.size() == k) break;
	}
	for(int i=n-1;i>=0;i-=(c+1)) {
		while(s[i]=='x') i--;
		left.pb(i);
		if(left.size() == k) break;
	}
	if(right.size() < k || left.size() < k) return 0;
	reverse(left.begin(), left.end());
	for(int i=0;i<k;i++) {
		if(left[i] == right[i]) {
			cout << left[i] + 1 << endl;
		}
	}


	return 0;
}


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

int main() {
  string s;
  cin >> s;


  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	ll X, Y;	cin >> X >> Y;
	ll num = X;
	int ans = 1;
	while (true) {
		if (num * 2 <= Y) {
			++ans;
			num *= 2;
		}
		else break;
	}
	cout << ans << endl;
	cin >> X;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double sum = 0;
    double min = 100;
    int a[] = new int[n];
    for(int i = 0 ; i < n ; ++i){
      a[i] = sc.nextInt();
      sum += a[i];
    }
    double ave = sum/n;

    int num = 0;
    for(int i = 0 ; i < n ; ++i){
      if(Math.abs((double)a[i]-ave) < min){
        min =Math.min(Math.abs((double)a[i]-ave),min);
        num = i;
      }
    }
    
    
    System.out.println(num);
    
  }
}

Measured memory_bytes: 35984
#include <iostream>
using namespace std;
typedef long double ld;
typedef unsigned long long ull;
const ld inf=1e18;
int main()
{
    int n;cin>>n;
    ld x,ans=1;//cin>>n;
    int flag=1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;ans*=x;
        if(ans>inf){flag=0;ans=1;}
        //if(ans>inf){flag=0;ans=1;}
    }
    if(!flag&&(int)ans)cout<<-1<<endl;
    else cout<<(ull)(ans+0.5)<<endl;
    return 0;
}

Measured memory_bytes: 3788
#include "iostream"
#include "vector"
#include "algorithm"
using namespace std;

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

    int ans = 0;
    int mini = 1 << 30;
    vector<int> s(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> s[i];
        ans += s[i];
        if(s[i] % 10 != 0){
            mini = min(mini, s[i]);
        }
    }

    if(ans % 10 == 0){
        ans = max(ans - mini, 0);
    }

    cout << ans << endl;

    return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int N;	cin >> N;
	vector<int> p(N);
	REP(i,N){
	    cin >> p[i];
	}
	int count = 0;
	REP(i,N){
	    if (p[i] != i+1) count++;
	}

	if (count <= 2) puts("YES");
	else puts("NO");

    return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;


int main()
{
    FAST_IO;

    //string s, t; cin >> s >> t;
    //cout << t << s << endl;

    ll a, b, k; cin >> a >> b >> k;
    ll t = a;
    a -= min(a, k);
    k -= min(t, k);
    b -= min(b,k);
    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll A, B, V, W, T;
	std::cin >> A >> V >> B >> W >> T;
	if (V > W&&((abs(A-B)/(V-W)<T)||(abs(A-B)%(V-W)==0&& abs(A - B) / (V - W) == T))){
		std::cout << "YES" << endl;
	}
	else {
		std::cout << "NO" << endl;
	}


	return 0;
}


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

using namespace std;
//using namespace std::chrono;

#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>

typedef long long ll;
typedef double ld;

struct Pt {
    ld x, y;
};

vector< pair<Pt, char> > v;
int n;

ld getArea(ld t){
    vector<Pt> modified(n);
    for(int i = 0; i<n; i++){
        if(v[i].second == 'D') {
            Pt newP; newP.x = v[i].first.x; newP.y = v[i].first.y-t;
            modified[i] = newP;
        }
        if(v[i].second == 'U') {
            Pt newP; newP.x = v[i].first.x; newP.y = v[i].first.y+t;
            modified[i] = newP;
        }
        if(v[i].second == 'L') {
            Pt newP; newP.x = v[i].first.x-t; newP.y = v[i].first.y;
            modified[i] = newP;
        }
        if(v[i].second == 'R') {
            Pt newP; newP.x = v[i].first.x+t; newP.y = v[i].first.y;
            modified[i] = newP;
        }
    }

    ld maxY = INT_MIN, minX = INT_MAX, maxX = INT_MIN, minY = INT_MAX;
    for(int i = 0; i<n; i++){
        if(modified[i].x > maxX) maxX = modified[i].x;
        if(modified[i].x < minX) minX = modified[i].x;
        if(modified[i].y > maxY) maxY = modified[i].y;
        if(modified[i].y < minY) minY = modified[i].y;
    }
    return (maxX-minX) * (maxY-minY);
}

ld getAns(){
    ld lo = 0, hi = 1000000000;
    for(int i = 0; i<2000; i++){
        ld t1 = lo + (hi-lo)/3;
        ld t2 = hi - (hi-lo)/3;

        if (getArea(t1) < getArea(t2))
            hi = t2;
        else
            lo = t1;
    }
    ld t = (lo+hi)/2;
    return getArea(t);
}

void print(vi v){
    cout<<"Contents of vector:\n";
    for(auto x : v) cout<<x<<" ";
    cout<<endl<<endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
    //ifstream cin("input.txt"); ofstream cout("output.txt");///cia failai

    //int T; cin>>T;
    int T = 1;

    for(int i = 1; i<=T; i++){
        cin>>n;

        for(int i = 0; i<n; i++) {
            Pt p; char c;
            cin>>p.x>>p.y>>c;
            v.push_back({p, c});
        }

        ld X = getAns();

        cout<<fixed<<setprecision(15)<<X<<endl;

    }


}


Measured memory_bytes: 7260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll h, w; cin >> h >> w;
    vector<string> maze(h);
    rep(i, h) cin >> maze[i];
    ll ans = -1;
    // スタート地点を全探索
    rep(sh, h){
        rep(sw, w){
            if(maze[sh][sw] == '#') continue;
            // 未訪問 -1 に初期化
            vector<vector<ll>> seen(h, vector<ll>(w, -1));
            seen[sh][sw] = 0;
            queue<pll> q;
            q.push(pll(sh, sw));
            while(!q.empty()){
                pll now = q.front(); q.pop();
                rep(i, 4){
                    ll nh = now.first + dy[i], nw = now.second + dx[i];
                    // 訪問済みなら訪れない
                    if(0 <= nh && nh < h && 0 <= nw && nw < w && maze[nh][nw] == '.' && seen[nh][nw] == -1) seen[nh][nw] = seen[now.first][now.second] + 1, q.push(pll(nh, nw));
                }
            }
            ll cnt = -1;
            // 終点を全探索
            rep(hi, h) rep(wi, w) chmax(cnt, seen[hi][wi]);
            // 最大値の最大化
            chmax(ans, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
data = []
until (st = $<.gets.chomp) == "0,0"
  data << st.split(",").map(&:to_i)
end
data.sort! {|a, b| b[1] <=> a[1]}
x = data.first.last
h = {}
l = 1
data.each do |d|
  l += 1 unless x == d.last
  x = d.last
  h[d.first] = l
end

puts $<.readlines.map(&:to_i).map {|i| h[i]}


Measured memory_bytes: 6852
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#define N 1009
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;

int fun(int n)
{
    int f[N];
    memset(f, 0, sizeof(f));
    long long ans = 1;
    for(int i = 2; i <= n; i++)
    {
        int k = i;
        for(int j = 2; j <= k; j++)
        {
            while(k % j == 0)
            {
                f[j]++;
                k /= j;
            }
        }
        if(k) f[k]++;
    }
    for(int i = 2; i <= n; i++) if(f[i]) ans = ans * (f[i] + 1) % mod;
    return ans % mod;
}

int main()
{
    int n;
    scanf("%d", &n);
    cout << fun(n) << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::cmp;
//use std::cmp::Ordering;
//use std::collections::HashSet;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let mut ans = INF;
    for _i in 0..n {
        let mut a: i32 = sc.read();
        let mut t = 0;
        while a % 2 == 0 {
            t += 1;
            a /= 2;
        }
        ans = cmp::min(ans, t);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352