akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <iomanip>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


ll lcm(ll a, ll b){
    ll x = a / gcd(a, b);
    if(LONG_LONG_MAX / x < b){
        return LONG_LONG_MAX;
    }
    else{
        return x * b;
    }
}


int main(){
    ll n, m;    cin >> n >> m;
    vector<ll> a(n); vector<double> p(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i] /= 100;
    }

    double res = 0;
    for(int i = 0; i < (1 << n); i++){
        int count = 0;
        double prob = 1.0;
        ll x = 1;
        for(int j = 0; j < n; j++){
            if((i >> j) % 2 == 0)   continue;
            count++;
            prob *= p[j];
            x = lcm(x, a[j]);
        }
        if(count == 0)  continue;
        else if(count % 2 == 1){
            res += prob * (m / x);
        }
        else{
            res -= prob * (m / x);
        }
    }

    printf("%.12f\n", res);


    return 0;
}



Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int m;
int n;

map<string,int> msi[2][201];

int dfs(string s,int isUsed,int pos){
    if(msi[isUsed][pos].find(s)!=msi[isUsed][pos].end())return msi[isUsed][pos][s];
    int cnt=0;
    for(int i=0;i<s.size();i++)if(s[i]=='B')cnt++;
    if(cnt==s.size()||cnt==0)return msi[isUsed][pos][s]=cnt;
    int res=0;
    {
        int npos=(pos+n-1)%s.size();
        string nstr=s;
        nstr.erase(nstr.begin()+npos);
        res=max(res,dfs(nstr,isUsed,npos));
    }
    if(!isUsed){
        int npos=(pos+n)%s.size();
        string nstr=s;
        nstr.erase(nstr.begin()+npos);
        res=max(res,dfs(nstr,!isUsed,npos));
    }
    return msi[isUsed][pos][s]=res;
}

int main(){

    cin>>m;
    while(m--){
        for(int i=0;i<2;i++)for(int j=0;j<201;j++)msi[i][j].clear();
        string s;
        cin>>n>>s;
        int res=dfs(s,0,0);
        cout<<res<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <iomanip>

struct Vector2
{
    Vector2(double y) : _x(0), _y(y), _length(y) {}
    double _x, _y, _length;

    void Rotate(double rad)
    {
        _y = std::cos(rad) * _length;
        _x = std::sin(rad) * _length;
    }

    void Output()
    {
        std::cout << _x << " : " << _y << std::endl;
    }
};

int main()
{
    double A, B, H, M;
    std::cin >> A >> B >> H >> M;

    Vector2 vecA(A);
    Vector2 vecB(B);

    double radH = ( (H + M / 60.0) / 12.0) * 2 * M_PI;
    double radM = (M / 60.0) * 2 * M_PI;

    vecA.Rotate(radH);
    vecB.Rotate(radM);

    auto diffX = (vecA._x - vecB._x);
    auto diffY = (vecA._y - vecB._y);
    auto distance = sqrt(diffX * diffX + diffY * diffY);
    std::cout << std::fixed << std::setprecision(9) << distance << std::endl;
}


Measured memory_bytes: 4060
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    String[] s = new String[n];
    int[] p = new int[n];
    int[] num = new int[n];

    for(int i = 0; i < n; i++) {
      s[i] = stdIn.next();
      p[i] = stdIn.nextInt();
      num[i] = i+1;
    }

    for(int i = 0; i < n; i++) {
      for(int j = n-1; j >= i+1; j--) {
        if(s[j].compareTo(s[j-1]) < 0) {
          String temp = s[j-1];
          s[j-1] = s[j];
          s[j] = temp;
          int tempi = p[j-1];
          p[j-1] = p[j];
          p[j] = tempi;
          int tempn = num[j-1];
          num[j-1] = num[j];
          num[j] = tempn;
        }else if(s[j].compareTo(s[j-1]) == 0) {
          if(p[j-1] < p[j]) {
            String temp = s[j-1];
            s[j-1] = s[j];
            s[j] = temp;
            int tempi = p[j-1];
            p[j-1] = p[j];
            p[j] = tempi;
            int tempn = num[j-1];
            num[j-1] = num[j];
            num[j] = tempn;
          }
        }
      }
    }


    for(int i = 0; i < n; i++) {
      System.out.println(num[i]);
    }
  }
}

Measured memory_bytes: 21588
#include <iostream>
using namespace std;
int n, k, a[101010], ans;
int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    if (n <= k)
    {
        cout << "1" << endl;
        return 0;
    }
    else
    {
        n = n - k;
        ans = 1;
        while (n > 0)
        {
            n = n - (k - 1);
            ans += 1;
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 640
s = list(input())
t = list(input())

cnt = 0
tmp = 0

ls = len(s)
lt = len(t)

for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j]==t[j]:
            tmp += 1
    cnt = max(cnt,tmp)
    tmp = 0

print(lt-cnt)

Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector<int> vi;
const int INF=1000000000;
int n;
int par[100005];
int ran[100005];

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

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

void unite(int x, int y)
{
  x=find(x);
  y=find(y);
  if(x==y)return;
  
  if(ran[x]<ran[y])
    {
      par[x]=y;
    }
  else
    {
      par[y]=x;
      if(ran[x]==ran[y]) ran[x]++;
    }
}

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

struct edge{int u,v,cost;};



bool comp(const edge& e1, const edge& e2)
{
  return e1.cost < e2.cost;
}

edge es[200005];
int v,e=0;

int kruskal()
{
  sort(es,es+e,comp);
  init(v);
  int res=0;
  for(int i=0;i<e;i++)
    {
      edge e=es[i];
      if(!same(e.u, e.v))
	{
	  unite(e.u,e.v);
	  res+=e.cost;
	}
    }
  return res;
}

int main()
{
  cin >> n;
  v=n;
  vector< pair<pii,int> > p(n);
  for(int i=0;i<n;i++)
    {
      cin >> p[i].first.first >> p[i].first.second;
      p[i].second=i;
    }
  sort(p.begin(),p.end());
  for(int i=0;i<n-1;i++)
    {
      es[e].u=p[i].second;
      es[e].v=p[i+1].second;
      es[e].cost=min(abs(p[i].first.first-p[i+1].first.first),abs(p[i].first.second-p[i+1].first.second));
      e++;
    }
  for(int i=0;i<n;i++)
    {
      swap(p[i].first.first,p[i].first.second);
    }
  sort(p.begin(),p.end());
  for(int i=0;i<n-1;i++)
    {
      es[e].u=p[i].second;
      es[e].v=p[i+1].second;
      es[e].cost=min(abs(p[i].first.first-p[i+1].first.first),abs(p[i].first.second-p[i+1].first.second));
      e++;
    }
  cout << kruskal() << endl;
  return 0;
}
 


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define fr(i,k,n) for(int i=k;i<n;i++)
#define fl(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
int prime[100001]={};
void sieve()
{
	prime[0]=1;
	prime[1]=1;
	for(int i=0;i*i<100001;i++)
	{
		if(prime[i]==0)
		{
			for(int j=i*i;j<100001;j+=i)
			{
				prime[j]=1;
			}
		}
	}
}
ll binpow(ll a,ll b,ll m)
{
	ll res=1;
	while(b>0)
	{

	if(b&1)
	{
		res=res*a%m;
	}
	a=a*a%m;
	b>>=1;
   }
   return res;
}
void solve()
{
	int n,m;
	cin>>n>>m;
	map<int,vector<int > > adj;
	ll h[n+1];
	for(int i=1;i<=n;i++)
	cin>>h[i];
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);	
	}
	bool vis[n+1]={};
	
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==1)
		continue;
		else
		{
			bool f=1;
			for(int j=0;j<adj[i].size();j++)
			{
				if(h[i]>h[adj[i][j]])
				{
					vis[adj[i][j]]=1;
				}
				else
				f=0;
			}
			if(f)
			ans++;
		}
	}
	cout<<ans<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
solve();
}

return 0;
}




Measured memory_bytes: 15132
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  long long x,y;
  cin>>x>>y;
  if(abs(x-y)>1){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Brown"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

int n,m,q;
int a[50],b[50],c[50],d[50];
int A[50];
int dfs(int idx){
  if(idx == n){
    int sum = 0;
    rep(i,q){
      if(A[b[i]-1] - A[a[i]-1] == c[i])sum += d[i];
    }
    return sum;
  }
  
  int start = (idx == 0)? 1 : A[idx-1];
  int sum = 0;
  for(int i = start;i <= m;++i){
    A[idx] = i;
    chmax(sum,dfs(idx+1));
  }
  return sum;
}

// TODO: write
int main() {
  cin>>n>>m>>q;
  rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
  print(dfs(0));
  return 0; 
}


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

struct Edge{
	  int s,t,w;
	  Edge(int si, int ti, int wi){
			s = si; t = ti; w = wi;
	  }
	  bool operator < (const Edge& e) const {
			return w < e.w;
	  }
	  bool operator > (const Edge& e) const {
			return w > e.w;
	  }
	  void print(){
			cout << s << "->" << t << ":" << w << endl;
	  }
};

typedef vector<vector<Edge> > Graph;

int prim(Graph& G){

	  priority_queue<Edge, vector<Edge>, greater<Edge> > q;
	  vector<int> used(G.size(),0);
	  int num_used=0, ans=0;
	  
	  for(Edge e : G[0])	q.push(e);
	  used[0] = 1; num_used++;
	  
	  while(q.size()){
			Edge e = q.top(); q.pop();
			if(used[e.t] == 1) continue;
			used[e.t] = 1; num_used++; ans += e.w;
			if(num_used == G.size()) break;
			for(Edge ne : G[e.t])
				  if(used[ne.t] != 1)
						q.push(ne);
	  }
	  return ans;
}


int main(){

	  int V,E; cin >> V >> E;
	  Graph G(V);
	  for(int i=0; i<E; i++){
			int s,t,w; cin >> s >> t >> w;
			G[s].push_back( Edge(s,t,w) );
			G[t].push_back( Edge(t,s,w) );
	  }
	  cout << prim(G) << endl;
	  
}

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

#include<stdlib.h>
#include<iostream>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;

int main()
{
IOS;
int t;
cin>>t;
cout<<pow(t,3);



return 0;
}

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

public class Main {
    static int pos = 0;
    static ArrayList<Integer> pre = new ArrayList<>();
    static ArrayList<Integer> in = new ArrayList<>();
    static ArrayList<Integer> post = new ArrayList<>();
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for(int i = 0; i < n; i++) {
            pre.add(input.nextInt());
        }
        for(int i = 0; i < n; i++) {
            in.add(input.nextInt());
        }
        rec(0, pre.size()); // 用 in 的下标 left 和 right 表示 Preorder 当前访问的子树的范围（不包含 r）
        for(int i = 0; i < post.size(); i++) {
            System.out.print(post.get(i));
            if (i != post.size() - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }

    public static void rec(int left, int right) {
        if(left >= right) {
            return;
        }
        int root = pre.get(pos++);
        int middle = getIndex(in, root);

        rec(left, middle);
        rec(middle+1, right);

        post.add(root); // 左-右-根，此时访问的顺序相当于后序遍历
    }

    public static int getIndex(ArrayList<Integer> arr, int value) {
        for (int i = 0; i < arr.size(); i++) {
            if(arr.get(i) == value) {
                return i;
            }
        }
        return -1;
    }
}


Measured memory_bytes: 26236
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
int main() {
   long long a;
   cin>>a;
   cout<<a*(a-1)/2<<endl;
}



Measured memory_bytes: 256
st=True
while True:
    n=int(input())
    if n==0:
        break
    if st==False:
        print()

    team={}
    for _ in range(n):
        data=input().split(" ")
        team[data[0]]=3*int(data[1])+int(data[3])
    team=team.items()
    team=sorted(team,key=lambda w:w[1],reverse=True)
    for t in team:
        print("{0},{1}".format(*t))
    st=False



Measured memory_bytes: 5596
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] == 2:
    print(1)
    sys.exit()

tmp = A[0]-1
for i in range(N):
    if A[tmp] == 2:
        print(i+2)
        sys.exit()
    else:
        tmp = A[tmp]-1

print(-1)

Measured memory_bytes: 80344
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    int N;
    string s,t;
    cin>>N>>s>>t;
    REP(i,N){
        int f=true;
        FOR(j,i,N)
            if(s[j]!=t[j-i])
                f=false;
        if(f){
            cout<<N+i<<endl;
            return 0;
        }
    }
    cout<<2*N<<endl;
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define ll long long
#define MOD (ll)1e9+7
#define REP(i,b,e) for(int (i)=b;(i)<e;(i)++)
const ll INF= 1LL << 60;

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


//入力
ll N;
vector<ll> A;
vector<ll> B;
int main(){
  cin >> N;
  REP(i,0,N){
    ll a,b;
    cin >> a>>b;
    A.push_back(a);
    B.push_back(b);
  }
  ll ans=0;
  bool flag=true;
  ll min=(ll)1e9+10;
  REP(i,0,N){
    if(A[i]!=B[i]){
      flag=false;
    }
    ans+=A[i];
    if(A[i]>B[i]){
      chmin(min,B[i]);
    }
  }
  ans-=min;
  
  if(flag){
    cout<<0<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 768
t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i!=n-1:
            if a[i-1]=="D" and a[i+1]=="?":
                a[i]="P"
            elif a[i-1]=="P" and a[i+1]=="?":
                a[i]="D"
            elif a[i-1]=="D" and a[i+1]=="D":
                a[i]="P"
            else:
                a[i]="D"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)


Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

void dfs(int i, const std::vector<std::vector<int>>& edges, std::vector<bool>& memo, std::vector<int>& ans) {
    memo[i] = true;
    for(auto v: edges[i]) {
        if(!memo[v]) dfs(v, edges, memo, ans);
    }
    ans.push_back(i);
}

int main() {
    int V, E;
    std::cin >> V >> E;
    std::vector<std::vector<int>> edges(V);
    while(E--) {
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
    }

    std::vector<int> ans;
    ans.reserve(V);
    std::vector<bool> memo(V, false);
    for(int i = 0; i < V; ++i) {
        if(!memo[i]) dfs(i, edges, memo, ans);
    }

    std::reverse(begin(ans), end(ans));

    for(auto val: ans)
        std::cout << val << "\n";
    std::cout << std::flush;

    return 0;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll big = 1000000007;
const ll big2 = 1000000009;

ll n,m,k,T,q;

vl A;

int main() {

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> k;
    for(ll c1 = 0; c1 < k; c1++){
        cin >> a;
        A.push_back(a);
    }

    ll x = 2;
    ll y = 2;
    bool fail = 0;

    if(2%A[k-1] != 0)fail = 1;

    for(ll c1 = k-1; c1 >= 1; c1--){
        y += A[c1]-1;
        y -= (y%A[c1-1]);
        a = x%A[c1-1];
        if(a != 0)x += (A[c1-1]-a);
        if(x > y)fail = 1;
        //cout << x << " " << y << "\n";
    }

    if(fail){
        cout << "-1\n";
    }
    else{

        cout << x << " " << y + A[0]-1 << "\n";

    }

    return 0;
}


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

int main(){
  int N;
  double p[3000];
  std::cin>>N;
  for(int i=0;i<N;++i){
    std::cin>>p[i];
  }
  double dp[3001][3001]; // dp[i][j] = i個のコインを振って、j個の表が出る確率。
  for(int i=0;i<=3000;++i){
    for(int j=0;j<=3000;++j){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      dp[i+1][j+1]+=dp[i][j]*p[i];
      dp[i+1][j]+=dp[i][j]*(1-p[i]);
    }
  }
  double ans=0;
  for(int i= N/2+1;i<=N;++i){
    ans+=dp[N][i];
  }
  printf("%.20f\n",ans);
  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;



int main() {
	int a, b; cin >> a >> b;
	if (a > b) swap(a, b);
	for (int i = 0; i < b; i++) cout << a; cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static boolean bElapsed = false;
	StringBuilder sb = new StringBuilder();
	List<String> list = new ArrayList<>();
	Set<String> set = new HashSet<>();
	Map<String,String> map = new HashMap<>();

	void solve(BufferedReader br) throws Exception {
		String line = br.readLine();
		for (int i=0; i<line.length(); i++) {
			char ch = line.charAt(i);
			switch (ch) {
			case '0':
				sb.append(ch);
				break;
			case '1':
				sb.append(ch);
				break;
			case 'B':
				if (sb.length() > 0) {
					sb.deleteCharAt(sb.length()-1);
				}
				break;
			}
		}
		pln(sb.toString());
	}

	void p(char c) {
		System.out.print(c);
	}
	void pln(char c) {
		System.out.println(c);
	}
	void p(long l) {
		System.out.print(l);
	}
	void pln(long l) {
		System.out.println(l);
	}
	void p(String s) {
		System.out.print(s);
	}
	void pln(String s) {
		System.out.println(s);
	}
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.out.println((end-start) + "ms");
		}
	}
}


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

int main(){
  long long x;
  cin >> x;
  for(int i=1;i<=1000;i++){
    if(x-i*100 >= 0 && x-i*100 <= i*5){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			map.merge(a[i], 1, (v1, v2) -> v1 + v2);
			map.merge(a[i] - 1, 1, (v1, v2) -> v1 + v2);
			map.merge(a[i] + 1, 1, (v1, v2) -> v1 + v2);
		}
		int max = 0;
		for(int k : map.keySet()) {
			if(max < map.get(k)) {
				max = map.get(k);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 58704
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  sort(s,s+n);
  rep(i,n) cout << s[i];ln;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, ans = 0, Nstep;
  cin >> N;
  Nstep = N;
  vector<ll> A(N);
  for(ll i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ans = A.at(0);
  for(ll i = 1; i < N - 1; i++) {
    ans += A.at((i + 1) / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4824
I=lambda:[int(i)for i in input().split()]
F=1<<65
r=range
n,m=I()
X=set([0,F,-F])
Y=set(X)
R=[((-F,F),F),((-F,F),-F)]
H=[(F,(-F,F)),(-F,(-F,F))]
for i in r(n):a,b,c=I();R.append(((a,b),c));Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H.append((a,(b,c)));X.add(a);Y.add(b);Y.add(c)

xdc=dict(enumerate(sorted(X)))
nx=len(xdc)
ydc=dict(enumerate(sorted(Y)))
ny=len(ydc)
 
h=dict(zip(xdc.values(),xdc.keys()))
w=dict(zip(ydc.values(),ydc.keys()))
 
V=[[0]*(nx+1+1)for i in r(ny+1+1)]
U=[i[:]for i in V]

for (a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(ny+1):
 for j in r(nx):
  U[i][j+1]+=U[i][j]
        
for d,(e,f) in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(nx+1):
 for i in r(ny):
  V[i+1][j]+=V[i][j]

v=[[0]*(nx+1) for i in r(ny+1)]
q=[(h[0],w[0])]
v[w[0]][h[0]]=1

a=0
while q:
    cx,cy=q.pop()
    a+=(xdc[cx]-xdc[cx+1])*(ydc[cy]-ydc[cy+1])
    for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
        k=0
        nbx=cx+dx
        nby=cy+dy
        if (0>nbx>=nx)or(0>nby>=ny)or v[nby][nbx]==1:
            continue
        if dy!=0:
            k=U[-~dy//2+cy][cx]==0
        else:
            if V[cy][-~dx//2+cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
        if k:q.append((nbx,nby));v[nby][nbx]=1

if a>=F:a='INF'
print(a)


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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char ans1, ans2, ans3;
  ans1 = a[0]-'a'+'A';
  ans2 = b[0]-'a'+'A';
  ans3 = c[0]-'a'+'A';
  cout << ans1 << ans2 << ans3 << endl;
  return 0;
}


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

using namespace std;

vector<int> a(1);
char d[8002][16111];

int main()
{
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	for (auto c : s) {
		if (c == 'T')
			a.push_back(0);
		else a.back()++;
	}
	d[0][8000] = 1;
	d[1][a[0] + 8000] = 1;
	for (int i = 1; i < a.size(); i++)
		for (int j = 0; j < 16001; j++)
			d[i + 1][j] = j >= a[i] && d[i - 1][j - a[i]] || j + a[i] <= 16000 && d[i - 1][j + a[i]];
	int p = a.size(), q = p - 1;
	if (q % 2) swap(p, q);
	cout << (d[p][x + 8000] && d[q][y + 8000] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 125184
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<ll>> a(4, vector<ll>(n + 2));
    a[0][0] = 0;
    a[0][1] = 0;
    a[1][0] = 0;
    a[1][1] = 1;
    a[2][0] = 1;
    a[2][1] = 0;
    a[3][0] = 1;
    a[3][1] = 1;
    for (ll j = 0; j < 4; j++)
    {
        for (ll i = 1; i <= n; i++)
        {
            if (a[j][i] == 0)
            {
                if (s[i % n] == 'o')
                {
                    a[j][i + 1] = a[j][i - 1];
                }
                else
                {
                    a[j][i + 1] = (a[j][i - 1] + 1) % 2;
                }
            }
            if (a[j][i] == 1)
            {
                if (s[i % n] == 'o')
                {
                    a[j][i + 1] = (a[j][i - 1] + 1) % 2;
                }
                else
                {
                    a[j][i + 1] = a[j][i - 1];
                }
            }
        }
    }
    for (ll j = 0; j < 4; j++)
    {
        if (a[j][n] == a[j][0] && a[j][n + 1] == a[j][1])
        {
            for (ll i = 0; i < n; i++)
            {
                if (a[j][i] == 0)
                {
                    cout << "S";
                }
                else
                {
                    cout << "W";
                }
            }
            cout << endl;
            break;
        }
        if (j == 3)
        {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 7348
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int k;
    cin >> k;
    vector<ll> a;
    repi(i, 10, 1)
    {
        a.push_back(i);
    }
    while (1)
    {
        if (k <= a.size())
        {
            cout << a[k - 1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old, a); //vectorの中身を入れ替え
        for (ll x : old)
        {
            for (int i = -1; i <= 1; ++i)
            {
                int d = x % 10 + i;
                if (d < 0 || d > 9)
                    continue; //1のときと9のときの例外処理
                ll nx = x * 10 + d;
                a.push_back(nx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>

using namespace std;

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

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

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

	for (int i = 1; i< N; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
			A[j + 1] = v;
		}
		for (int j = 0; j < N; j++) {
			if (j != N - 1) cout << A[j] <<" ";
			else cout << A[j] << endl;
		}
	}

}


Measured memory_bytes: 3096
'use strict'

const main = (input) => {
    input = input.split('\n')
    const nums = input[0].split(' ').map(i => parseInt(i))
    const K = parseInt(input[1])

    nums.sort((a, b) => a - b)
    let n = nums.pop()
    n = n * Math.pow(2, K)
    nums.push(n)
    console.log(nums.reduce((p, c) => p + c))
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

int main() {
  int N;
  cin>>N;
  vector<long> l(N+1);
  if(N==0){
    cout<<2<<endl;
    return 0;
  }
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  l[0]=2;
  l[1]=1;
  for(int i=0;i<=N-2;i++){
    l[i+2] = l[i+1]+l[i];
  }
  cout<<l[N]<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector <int> a(n);
  vector <int> b(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++){
    cin >> b.at(i);
  }
  int ans = 0;
  int value = 0;
  for (int i = 0; i < n; i++){
    value = a.at(i) - b.at(i);
    if (value > 0){
      ans += value;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n, w;
    cin >> n >> w;
    vector<ll> v[4];
    int w0;

    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (i == 0) w0 = a;
        v[a - w0].push_back(b);
    }

    rep(i, 4) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
    }

    ll ans = 0;

    rep(i, v[0].size() + 1) rep(j, v[1].size() + 1) rep(k, v[2].size() + 1) rep(l, v[3].size() + 1) {
        if (w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l > w) continue;
        ll sum = 0;
        rep(s, i) sum += v[0][s];
        rep(s, j) sum += v[1][s];
        rep(s, k) sum += v[2][s];
        rep(s, l) sum += v[3][s];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

Q,d=gets.chomp.split(' ').map{|n| n.to_i}

1.upto(Q){|d|
	a,b=gets.chomp.split(' ').map{|n| n.to_i}
	if(a==b)
		puts 2*a-2
	else
		ab = a*b
		sqrtab = Math.sqrt(ab)
		c = sqrtab.to_i
		c = sqrtab.to_i == sqrtab ? c-1 : c
		if(c*(c+1) < ab)
			puts 2*c-1
		else
			puts 2*c-2
		end
	end
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
#define MAX(A,B) (A)>(B)?(A):(B)
#define MIN(A,B) (A)<(B)?(A):(B)
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;
#define int long long
int arr[2010];
int counter[2020];
int32_t main()
{
	usecppio
	int n;
	cin >> n;
	for (int i = 1; i<=n; i++)
	{
		cin >> arr[i];
		counter[arr[i]]++;
	}
	for (int i = 1; i<=2000; i++)
	{
		counter[i] += counter[i-1];
	}
	int ans = 0;
	for (int i = 1; i<n; i++)
	{
		for (int j = i+1; j<=n; j++)
		{
			int u = arr[i]+arr[j];
			int k = max(arr[i], arr[j]) - min(arr[i],arr[j]);
			int ways = max(0LL, counter[u-1]-counter[k]-(k<arr[i])-(k<arr[j]));
			ans += ways;
		}
	}
	cout << ans/3;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int X,Y;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		X = nextInt();
		Y = nextInt();

		int a = 0,b = 0;
		if(X == 3)a = 100000;
		else if(X == 2) a = 200000;
		else if(X == 1) a = 300000;

		if(Y == 3)b = 100000;
		else if(Y == 2) b = 200000;
		else if(Y == 1) b = 300000;

		int sum = a + b;
		if(X == 1 && Y == 1)sum += 400000;

		out.println(sum);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e5 + 5;

vi adj[N];
int dp[N];

int sol(int nd) {
    int &ret = dp[nd];
    if(ret != -1) return ret;

    ret = 0;
    for(auto ch : adj[nd]) {
        ret = max(ret, 1 + sol(ch));
    }
    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(dp, -1, sizeof(dp));
    int n, m;
    cin >> n >> m;

    int x, y;
    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        x--; y--;

        adj[x].pb(y);
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(dp[i] == -1) {
            ans = max(ans, sol(i));
        }
    }

    cout << ans << "\n";
}








Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

int dignum(int n){
int res = 0;
while(n > 0){
  res ++;
  n /= 10;
}
return res;
}

int main (){
    ll n;   cin >> n;
    ll cnt=0;
    for(int i=1;i<=n;i++){
        if(dignum(i) % 2 == 1)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll a[2001];
vector<ll> b[2001];
int main(){
  int n;
  ll x;
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (b[i].empty()) {
        b[i].push_back(a[i]);
        continue;
      }
      int t = i - j + n;
      if (t > n) t -= n;
      b[i].push_back(min(b[i][b[i].size() - 1], a[t]));
    }
  }
  ll ans = 1e18;
  for (int i = 0; i < n; i++) {
    ll tmp = 0;
    for (int j = 1; j <= n; j++) {
      tmp += b[j][i];
    }
    ans = min(ans, i * x + tmp);
  }
  cout << ans << endl;
  return 0;
}


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

int n, m, t[200000];
vector<int> d;
bool flag = true;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		d.push_back(a);
	}
	sort(d.begin(), d.end());

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
		vector<int>::iterator itr;
		if ((itr = lower_bound(d.begin() , d.end(), t[i])) != d.end() && *itr == t[i]) {
			//cout << *itr << endl;
			d.erase(itr);
		}
		else {
			flag = false;
		}
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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


int main(void) {
    vector<int> antena(5);
    for(int i = 0; i < 5; i++) {
        cin >> antena[i];
    }
    int k;
    cin >> k;
    int judge = 1;
    
    if(abs(antena[0] - antena[4]) > k) judge = 0;
    
    if(judge) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()

c = []
f = []

for i, si in enumerate(S):
    if si == 'C':
        c.append(i)
    elif si == 'F':
        f.append(i)

if len(c) == 0 or len(f) == 0:
    print('No')
elif min(c) < max(f):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
//greaterで必要
#include <functional>
//重複チェック
#include <set>


using namespace std;
typedef long long ll;
ll N;
ll M;
ll r;
ll INF = 1<<28;


int main() {
    //頂点数
    int A;
    int B;
    int C;
    cin >> A >> B >> C;

    if(A == B && B == C && C == A){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }


    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int mod = 1e9 + 7;

const int N = 1e6 + 5;
ll fac[N+3], reFac[N+3];
ll power8[N+3];

ll power(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1){
            (res *= a) %= mod;
        }
        (a *= a) %= mod;
        b >>= 1;
    }
    return res;
}

void calc() {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = (fac[i-1] * i) % mod;

    reFac[N] = power(fac[N], mod-2);
    for (int i = N; i > 0; --i){
        reFac[i-1] = (reFac[i] * i) % mod;
    }
}

ll modMul(ll a, ll b) {
    return (a  * b) % mod;
}

ll nCr(ll a, ll b) {
    return modMul(fac[a], modMul(reFac[b], reFac[a - b]));
}

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

    calc();

    ll n; cin >> n;
    if (n <= 1) {
        cout << 0;
        return 0;
    }
    power8[0] = 1;
    for (int i = 1; i <= n; ++i) {
        power8[i] = modMul(power8[i-1], 8);
    }

    ll ans = (power(10, n) - power(8, n) + mod) % mod;
    ll exclude = 0;
    for (int i = 1; i <= n; ++i) {
        exclude += modMul(nCr(n, i), power8[n - i]);
        exclude %= mod;
    }

    ans = (ans - (2 * exclude) % mod + mod) % mod;
    cout << ans;


    return 0;
}

/*
 * ans = total possible ways to form any sequence of (0..9) - # ways of invalid sequence;
 * total possible  to form any sequence of (0..9) => power(10, n);
 * invalid cases => power(8, n) + 2*(nC1 * power(8, n-1)  +  nC2 * power(8, n-2) ... nCn * power(8, 0));
 * invalid means = those sequences have no 0's and 9's together.

*/

Measured memory_bytes: 26988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

vector<vector<int>> G1,G2;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    G1.resize(n);
    G2.resize(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.merge(a,b);
        G1[a].push_back(b);
        G1[b].push_back(a);
    }
    rep(i,k){
        int c,d;
        cin>>c>>d;
        c--,d--;
        G2[c].push_back(d);
        G2[d].push_back(c);
    }

    rep(i,n){
        int ans=uf.size(i)-1-G1[i].size();
        for(auto v : G2[i]){
            if(uf.issame(v,i)) ans--;
        }

        cout<<ans<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 14660